Class representing axis-aligned bounding box. More...
#include <AxisBox.hpp>
Public Member Functions | |
AxisBox () | |
AxisBox (const double *min, const double *max) | |
AxisBox (const double *point) | |
AxisBox & | operator&= (const AxisBox &other) |
AxisBox & | operator|= (const AxisBox &other) |
AxisBox & | operator|= (const double *point) |
const double * | minimum () const |
const double * | maximum () const |
double * | minimum () |
double * | maximum () |
void | center (double *center_out) const |
void | diagonal (double *diagonal_out) const |
bool | intersects (const AxisBox &other, double tolerance) const |
Check if two boxes intersect. More... | |
bool | intersects (const double *point, double tolerance) const |
Check if box contains point. More... | |
bool | valid () const |
Check that box is valid. More... | |
void | closest_position_within_box (const double *input_position, double *output_position) const |
Find closest position on/within box to input position. More... | |
Static Public Member Functions | |
static ErrorCode | get_tag (Tag &tag_handle_out, Interface *interface, const char *tag_name=0) |
static ErrorCode | calculate (AxisBox &box_out, EntityHandle set, Interface *interface) |
static ErrorCode | calculate (AxisBox &box_out, const Range &elements, Interface *interface) |
Private Attributes | |
double | minVect [3] |
double | maxVect [3] |
Class representing axis-aligned bounding box.
Definition at line 30 of file AxisBox.hpp.
|
inline |
Definition at line 134 of file AxisBox.hpp.
135 {
136 minVect[0] = minVect[1] = minVect[2] = std::numeric_limits< double >::max();
137 maxVect[0] = maxVect[1] = maxVect[2] = -std::numeric_limits< double >::max();
138 }
References maxVect, and minVect.
Referenced by calculate().
|
inline |
Definition at line 140 of file AxisBox.hpp.
141 {
142 minVect[0] = min[0];
143 minVect[1] = min[1];
144 minVect[2] = min[2];
145 maxVect[0] = max[0];
146 maxVect[1] = max[1];
147 maxVect[2] = max[2];
148 }
|
inline |
Definition at line 150 of file AxisBox.hpp.
151 { 152 minVect[0] = maxVect[0] = point[0]; 153 minVect[1] = maxVect[1] = point[1]; 154 minVect[2] = maxVect[2] = point[2]; 155 }
|
static |
Calculate a box bounding the vertices/elements in the passed Range
Definition at line 50 of file AxisBox.cpp.
51 {
52 ErrorCode rval;
53 Range vertices;
54 Range elements;
55
56 elements.merge( entities.upper_bound( MBVERTEX ), entities.lower_bound( MBENTITYSET ) );
57 rval = interface->get_adjacencies( elements, 0, false, vertices );
58 if( MB_SUCCESS != rval ) return rval;
59
60 vertices.merge( entities.begin(), entities.upper_bound( MBVERTEX ) );
61
62 std::vector< double > coords( 3 * vertices.size() );
63 rval = interface->get_coords( vertices, &coords[0] );
64 if( MB_SUCCESS != rval ) return rval;
65
66 box = AxisBox();
67 std::vector< double >::const_iterator i = coords.begin();
68 for( ; i != coords.end(); i += 3 )
69 box |= &*i;
70
71 return MB_SUCCESS;
72 }
References AxisBox(), entities, ErrorCode, moab::Interface::get_adjacencies(), moab::Interface::get_coords(), MB_SUCCESS, MBENTITYSET, MBVERTEX, moab::Range::merge(), and moab::Range::size().
|
static |
Calculate a box bounding the entities contained in the passed set
Definition at line 41 of file AxisBox.cpp.
42 {
43 Range range;
44 ErrorCode rval = interface->get_entities_by_handle( set, range );
45 if( MB_SUCCESS != rval ) return rval;
46
47 return calculate( box, range, interface );
48 }
References ErrorCode, moab::Interface::get_entities_by_handle(), and MB_SUCCESS.
|
inline |
Definition at line 187 of file AxisBox.hpp.
188 { 189 center_out[0] = 0.5 * ( minVect[0] + maxVect[0] ); 190 center_out[1] = 0.5 * ( minVect[1] + maxVect[1] ); 191 center_out[2] = 0.5 * ( minVect[2] + maxVect[2] ); 192 }
|
inline |
Find closest position on/within box to input position.
Find the closest position in the solid box to the input position. If the input position is on or within the box, then the output position will be the same as the input position. If the input position is outside the box, the outside position will be the closest point on the box boundary to the input position.
Definition at line 220 of file AxisBox.hpp.
221 {
222 for( int i = 0; i < 3; ++i )
223 {
224 if( input_position[i] < minVect[i] )
225 output_position[i] = minVect[i];
226 else if( input_position[i] > maxVect[i] )
227 output_position[i] = maxVect[i];
228 else
229 output_position[i] = input_position[i];
230 }
231 }
|
inline |
Definition at line 194 of file AxisBox.hpp.
195 { 196 diagonal_out[0] = maxVect[0] - minVect[0]; 197 diagonal_out[1] = maxVect[1] - minVect[1]; 198 diagonal_out[2] = maxVect[2] - minVect[2]; 199 }
|
static |
Definition at line 31 of file AxisBox.cpp.
32 {
33 assert( sizeof( AxisBox ) == 6 * sizeof( double ) );
34
35 if( !tagname ) tagname = AXIS_BOX_TAG_NAME;
36
37 return interface->tag_get_handle( tagname, sizeof( AxisBox ), MB_TYPE_DOUBLE, tag_out,
38 MB_TAG_DENSE | MB_TAG_CREAT | MB_TAG_BYTES );
39 }
References moab::AXIS_BOX_TAG_NAME, MB_TAG_BYTES, MB_TAG_CREAT, MB_TAG_DENSE, MB_TYPE_DOUBLE, and moab::Interface::tag_get_handle().
|
inline |
Check if two boxes intersect.
Check if two boxes are within the specified tolerance of each other. If tolerance is less than zero, then boxes must overlap by at least the magnitude of the tolerance to be considered intersecting.
Definition at line 201 of file AxisBox.hpp.
202 {
203 return minVect[0] - other.maxVect[0] <= tolerance && minVect[1] - other.maxVect[1] <= tolerance &&
204 minVect[2] - other.maxVect[2] <= tolerance && other.minVect[0] - maxVect[0] <= tolerance &&
205 other.minVect[1] - maxVect[1] <= tolerance && other.minVect[2] - maxVect[2] <= tolerance;
206 }
References maxVect, minVect, and moab::tolerance.
|
inline |
Check if box contains point.
Check if a position is in or on the box, within the specified tolerance
Definition at line 208 of file AxisBox.hpp.
209 {
210 return minVect[0] - point[0] <= tolerance && minVect[1] - point[1] <= tolerance &&
211 minVect[2] - point[2] <= tolerance && maxVect[0] - point[0] <= tolerance &&
212 maxVect[1] - point[1] <= tolerance && maxVect[2] - point[2] <= tolerance;
213 }
References maxVect, minVect, and moab::tolerance.
|
inline |
|
inline |
Definition at line 61 of file AxisBox.hpp.
62 {
63 return maxVect;
64 }
References maxVect.
Referenced by moab::operator||().
|
inline |
|
inline |
Definition at line 56 of file AxisBox.hpp.
57 {
58 return minVect;
59 }
References minVect.
Referenced by moab::operator||().
intersect
Definition at line 157 of file AxisBox.hpp.
158 {
159 for( int i = 0; i < 3; ++i )
160 {
161 if( minVect[i] < other.minVect[i] ) minVect[i] = other.minVect[i];
162 if( maxVect[i] > other.maxVect[i] ) maxVect[i] = other.maxVect[i];
163 }
164 return *this;
165 }
unite
Definition at line 167 of file AxisBox.hpp.
168 {
169 for( int i = 0; i < 3; ++i )
170 {
171 if( minVect[i] > other.minVect[i] ) minVect[i] = other.minVect[i];
172 if( maxVect[i] < other.maxVect[i] ) maxVect[i] = other.maxVect[i];
173 }
174 return *this;
175 }
|
inline |
unite
Definition at line 177 of file AxisBox.hpp.
178 {
179 for( int i = 0; i < 3; ++i )
180 {
181 if( minVect[i] > point[i] ) minVect[i] = point[i];
182 if( maxVect[i] < point[i] ) maxVect[i] = point[i];
183 }
184 return *this;
185 }
|
inline |
Check that box is valid.
Check that box is defined (contains at least a single point.)
Definition at line 215 of file AxisBox.hpp.
216 {
217 return minVect[0] <= maxVect[0] && minVect[1] <= maxVect[1] && minVect[2] <= maxVect[2];
218 }
|
private |
Definition at line 112 of file AxisBox.hpp.
Referenced by AxisBox(), center(), closest_position_within_box(), diagonal(), intersects(), maximum(), operator&=(), operator|=(), and valid().
|
private |
Definition at line 112 of file AxisBox.hpp.
Referenced by AxisBox(), center(), closest_position_within_box(), diagonal(), intersects(), minimum(), operator&=(), operator|=(), and valid().