forked from kvtsang/Supera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WireRange3D.h
159 lines (123 loc) · 3.88 KB
/
WireRange3D.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
* \file WireRange3D.h
*
* \ingroup MeatSlicer
*
* \brief Class def header for a class WireRange3D
*
* @author kazuhiro
*/
/** \addtogroup MeatSlicer
@{*/
#ifndef WIRERANGE3D_H
#define WIRERANGE3D_H
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <limits>
namespace supera {
class GridPoint3D {
public:
GridPoint3D(int xval = std::numeric_limits<int>::max(),
int yval = std::numeric_limits<int>::max(),
int zval = std::numeric_limits<int>::max())
: x(xval)
, y(yval)
, z(zval)
{}
~GridPoint3D(){}
GridPoint3D(const GridPoint3D& rhs)
: x(rhs.x)
, y(rhs.y)
, z(rhs.z)
{}
inline bool operator < (const GridPoint3D& pt) const {
if( x < pt.x ) return true;
if( x > pt.x ) return false;
if( y < pt.y ) return true;
if( y > pt.y ) return false;
if( z < pt.z ) return true;
if( z > pt.z ) return false;
return false;
}
inline bool operator == (const GridPoint3D& pt) const
{ return ( x == pt.x && y == pt.y && z == pt.z ); }
inline bool operator != (const GridPoint3D& pt) const
{ return !( (*this) == pt ); }
inline bool operator > (const GridPoint3D& pt) const
{
if( (*this) == pt ) return false;
return !( (*this) < pt);
}
inline bool Valid() const
{
return (x != std::numeric_limits<int>::max() &&
y != std::numeric_limits<int>::max() &&
z != std::numeric_limits<int>::max());
}
int x, y, z;
};
/**
\class WireRange3D
User defined class WireRange3D ... these comments are used to generate
doxygen documentation!
*/
class WireRange3D{
public:
/// Default constructor
WireRange3D()
: _verbosity(2)
, _width()
, _min_bound()
, _max_bound()
, _min_fiducial()
, _max_fiducial()
, _padding(0,0,0)
, _grid_size_x(0)
, _grid_size_y(0)
, _grid_size_z(0)
{}
/// Default destructor
~WireRange3D(){}
inline void Clear() { _constraint_v.clear(); }
void AddConstraint(double x, double y, double z);
void SetWidth(double x, double y, double z);
void SetMin(double x, double y, double z);
void SetMax(double x, double y, double z);
void SetPadding(double x, double y, double z);
inline void Verbosity(unsigned int v=2) { _verbosity = v; }
inline void SetGridSize(double x, double y, double z)
{ _grid_size_x = x; _grid_size_y = y; _grid_size_z = z; }
inline const std::vector<supera::GridPoint3D> GetConstraints() const
{ return _constraint_v; }
supera::GridPoint3D GridPoint3D(double x, double y, double z) const;
inline double GridSizeX() const { return _grid_size_x; }
inline double GridSizeY() const { return _grid_size_y; }
inline double GridSizeZ() const { return _grid_size_z; }
bool Valid() const;
void DeriveRange(const std::vector<supera::GridPoint3D>& points,
supera::GridPoint3D& min_pt,
supera::GridPoint3D& max_pt) const;
inline const supera::GridPoint3D& EffectiveMin() const
{ return _min_bound; }
inline const supera::GridPoint3D& EffectiveMax() const
{ return _max_bound; }
inline unsigned int Verbosity() const { return _verbosity; }
std::string PrintConfig() const;
private:
unsigned int _verbosity;
supera::GridPoint3D _width;
supera::GridPoint3D _min_bound, _max_bound;
supera::GridPoint3D _min_fiducial, _max_fiducial;
supera::GridPoint3D _padding;
double _grid_size_x, _grid_size_y, _grid_size_z;
std::vector<supera::GridPoint3D> _constraint_v; /// A list of 3D grid point that must be included
void RederiveBounds();
void Randomize(int& min_val, int& max_val,
const int min_bound, const int max_bound,
const int width, const int padding) const;
};
}
#endif
/** @} */ // end of doxygen group