SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEUtils
SEUtils
PixelCoordinate.h
Go to the documentation of this file.
1
23
#ifndef _SEUTILS_PIXELCOORDINATE_H
24
#define _SEUTILS_PIXELCOORDINATE_H
25
26
#include <functional>
27
#include <boost/functional/hash.hpp>
28
29
namespace
SourceXtractor
{
30
37
struct
PixelCoordinate
{
38
int
m_x
,
m_y
;
39
40
PixelCoordinate
() :
m_x
(0),
m_y
(0) {}
41
42
PixelCoordinate
(
int
x
,
int
y
) :
m_x
(
x
),
m_y
(
y
) {}
43
44
bool
operator==
(
const
PixelCoordinate
&
other
)
const
{
45
return
m_x
==
other
.m_x &&
m_y
==
other
.m_y;
46
}
47
48
bool
operator!=
(
const
PixelCoordinate
&
other
)
const
{
49
return
!(*
this
==
other
);
50
}
51
52
PixelCoordinate
operator*
(
double
scalar
)
const
{
53
return
PixelCoordinate
(
static_cast<
int
>
(
m_x
*
scalar
),
54
static_cast<
int
>
(
m_y
*
scalar
));
55
}
56
57
PixelCoordinate
operator+
(
const
PixelCoordinate
&
other
)
const
{
58
return
PixelCoordinate
(
m_x
+
other
.m_x,
m_y
+
other
.m_y);
59
}
60
61
PixelCoordinate
&
operator+=
(
const
PixelCoordinate
&
other
) {
62
m_x
+=
other
.m_x;
63
m_y
+=
other
.m_y;
64
return
*
this
;
65
}
66
67
PixelCoordinate
operator-
(
const
PixelCoordinate
&
other
)
const
{
68
return
PixelCoordinate
(
m_x
-
other
.m_x,
m_y
-
other
.m_y);
69
}
70
71
PixelCoordinate
&
operator-=
(
const
PixelCoordinate
&
other
) {
72
m_x
-=
other
.m_x;
73
m_y
-=
other
.m_y;
74
return
*
this
;
75
}
76
77
bool
operator>=
(
const
PixelCoordinate
&
other
)
const
{
78
return
m_x
>=
other
.m_x &&
m_y
>=
other
.m_y;
79
}
80
81
bool
operator<=
(
const
PixelCoordinate
&
other
)
const
{
82
return
m_x
<=
other
.m_x &&
m_y
<=
other
.m_y;
83
}
84
90
bool
clip
(
int
w
,
int
h
) {
91
int
ox
=
m_x
,
oy
=
m_y
;
92
m_x
=
std::min
(
std::max
(0,
m_x
),
w
- 1);
93
m_y
=
std::min
(
std::max
(0,
m_y
),
h
- 1);
94
return
ox
!=
m_x
||
oy
!=
m_y
;
95
}
96
};
97
98
99
}
/* namespace SourceXtractor */
100
101
102
namespace
std
{
103
104
template
<>
105
struct
hash
<
SourceXtractor
::PixelCoordinate>
106
{
107
std::size_t
operator()
(
const
SourceXtractor::PixelCoordinate
& coord)
const
{
108
std::size_t
local_hash
= 0;
109
boost::hash_combine(
local_hash
, coord.
m_x
);
110
boost::hash_combine(
local_hash
, coord.
m_y
);
111
return
local_hash
;
112
}
113
};
114
115
}
// namespace std
116
117
118
#endif
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition
MoffatModelFittingTask.cpp:94
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition
MoffatModelFittingTask.cpp:94
std::function
std::hash
std::max
T max(T... args)
std::min
T min(T... args)
SourceXtractor
Definition
Aperture.h:30
std
STL namespace.
std::size_t
SourceXtractor::PixelCoordinate
A pixel coordinate made of two integers m_x and m_y.
Definition
PixelCoordinate.h:37
SourceXtractor::PixelCoordinate::m_y
int m_y
Definition
PixelCoordinate.h:38
SourceXtractor::PixelCoordinate::operator+
PixelCoordinate operator+(const PixelCoordinate &other) const
Definition
PixelCoordinate.h:57
SourceXtractor::PixelCoordinate::PixelCoordinate
PixelCoordinate(int x, int y)
Definition
PixelCoordinate.h:42
SourceXtractor::PixelCoordinate::clip
bool clip(int w, int h)
Definition
PixelCoordinate.h:90
SourceXtractor::PixelCoordinate::operator>=
bool operator>=(const PixelCoordinate &other) const
Definition
PixelCoordinate.h:77
SourceXtractor::PixelCoordinate::operator!=
bool operator!=(const PixelCoordinate &other) const
Definition
PixelCoordinate.h:48
SourceXtractor::PixelCoordinate::operator<=
bool operator<=(const PixelCoordinate &other) const
Definition
PixelCoordinate.h:81
SourceXtractor::PixelCoordinate::m_x
int m_x
Definition
PixelCoordinate.h:38
SourceXtractor::PixelCoordinate::PixelCoordinate
PixelCoordinate()
Definition
PixelCoordinate.h:40
SourceXtractor::PixelCoordinate::operator==
bool operator==(const PixelCoordinate &other) const
Definition
PixelCoordinate.h:44
SourceXtractor::PixelCoordinate::operator+=
PixelCoordinate & operator+=(const PixelCoordinate &other)
Definition
PixelCoordinate.h:61
SourceXtractor::PixelCoordinate::operator*
PixelCoordinate operator*(double scalar) const
Definition
PixelCoordinate.h:52
SourceXtractor::PixelCoordinate::operator-=
PixelCoordinate & operator-=(const PixelCoordinate &other)
Definition
PixelCoordinate.h:71
SourceXtractor::PixelCoordinate::operator-
PixelCoordinate operator-(const PixelCoordinate &other) const
Definition
PixelCoordinate.h:67
std::hash< SourceXtractor::PixelCoordinate >::operator()
std::size_t operator()(const SourceXtractor::PixelCoordinate &coord) const
Definition
PixelCoordinate.h:107
Generated by
1.10.0