SourceXtractorPlusPlus
0.16
Please provide a description of the project.
SEUtils
SEUtils
HilbertCurve.h
Go to the documentation of this file.
1
18
#ifndef _SEUTILS_HILBERTCURVE_H_
19
#define _SEUTILS_HILBERTCURVE_H_
20
21
#include <vector>
22
23
#include "
SEUtils/Misc.h
"
24
#include "
SEUtils/PixelCoordinate.h
"
25
26
namespace
SourceXtractor
{
27
28
class
HilbertCurve
{
29
public
:
30
explicit
HilbertCurve
(
unsigned
int
size) {
31
m_size
=
nextPowerOfTwo
(size);
32
}
33
34
std::vector<PixelCoordinate>
getCurve
()
const
{
35
std::vector<PixelCoordinate>
hilbert_curve;
36
for
(
unsigned
int
i = 0; i <
m_size
*
m_size
; i++) {
37
hilbert_curve.
emplace_back
(
get2DCoordinate
(i));
38
}
39
return
hilbert_curve;
40
}
41
42
PixelCoordinate
get2DCoordinate
(
unsigned
int
index)
const
{
43
unsigned
int
x
= 0;
44
unsigned
int
y
= 0;
45
for
(
unsigned
int
s
=1;
s
<
m_size
;
s
*=2) {
46
unsigned
int
rx = 1 & (index >> 1);
47
unsigned
int
ry = 1 & (index ^ rx);
48
49
if
(ry == 0) {
50
if
(rx == 1) {
51
x
=
s
-1 -
x
;
52
y
=
s
-1 -
y
;
53
}
54
55
std::swap
(
x
,
y
);
56
}
57
58
x
+=
s
* rx;
59
y
+=
s
* ry;
60
index >>= 2;
61
}
62
63
return
{(int)
x
, (
int
)
y
};
64
}
65
66
private
:
67
unsigned
int
m_size
;
68
};
69
70
}
71
72
#endif
/* _SEUTILS_HILBERTCURVE_H_ */
Misc.h
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
PixelCoordinate.h
SourceXtractor::HilbertCurve
Definition:
HilbertCurve.h:28
SourceXtractor::HilbertCurve::HilbertCurve
HilbertCurve(unsigned int size)
Definition:
HilbertCurve.h:30
SourceXtractor::HilbertCurve::getCurve
std::vector< PixelCoordinate > getCurve() const
Definition:
HilbertCurve.h:34
SourceXtractor::HilbertCurve::m_size
unsigned int m_size
Definition:
HilbertCurve.h:67
SourceXtractor::HilbertCurve::get2DCoordinate
PixelCoordinate get2DCoordinate(unsigned int index) const
Definition:
HilbertCurve.h:42
std::vector::emplace_back
T emplace_back(T... args)
s
constexpr double s
SourceXtractor
Definition:
Aperture.h:30
SourceXtractor::nextPowerOfTwo
T nextPowerOfTwo(T v)
Definition:
Misc.h:26
SourceXtractor::PixelCoordinate
A pixel coordinate made of two integers m_x and m_y.
Definition:
PixelCoordinate.h:37
std::swap
T swap(T... args)
std::vector
Generated by
1.9.1