Flow123d
master-d6c300039
|
Go to the documentation of this file.
18 #ifndef BOX_ELEMENT_HH_
19 #define BOX_ELEMENT_HH_
59 <<
"out of bounds: <" << EI_interval_left::val
60 <<
", " << EI_interval_right::val <<
">\n");
63 static const unsigned int dimension = 3;
78 min_vertex_.fill( std::numeric_limits<double>::signaling_NaN() );
79 max_vertex_.fill( std::numeric_limits<double>::signaling_NaN() );
86 : min_vertex_(min), max_vertex_(min)
95 : min_vertex_(min), max_vertex_(max)
97 ASSERT( arma::min( min <= max ) ).error(
"Wrong coordinates in constructor.");
113 max_vertex_[axis] = max;
122 min_vertex_[axis] = min;
142 double min(
unsigned int axis)
const {
149 double max(
unsigned int axis)
const {
157 double size(
unsigned int axis)
const {
158 return max()[axis] - min()[axis];
166 return (max_vertex_ + min_vertex_) / 2.0;
174 ASSERT_LT(axis, dimension).error(
"Invalid axis!\n");
175 return (max_vertex_[axis] + min_vertex_[axis])/2;
186 for (
unsigned int i=0; i<dimension; i++) {
187 if ((point(i) + epsilon < min_vertex_(i)) ||
188 (point(i) > epsilon + max_vertex_(i)))
return false;
204 for (
unsigned int i=0; i<dimension; i++) {
205 if ( (min_vertex_(i) > b2.
max_vertex_(i) + epsilon) ||
206 (b2.
min_vertex_(i) > max_vertex_(i) + epsilon ) )
return false;
217 return max_vertex_(axis) + epsilon <
value;
226 return min_vertex_(axis) - epsilon >
value;
233 void split(
unsigned int axis,
double splitting_point,
237 if (min_vertex_[axis] <= splitting_point && splitting_point <= max_vertex_[axis] ) {
240 left.max_vertex_[axis] = splitting_point;
241 right.min_vertex_[axis] = splitting_point;
243 THROW( ExcSplitting() << EI_interval_left(min_vertex_[axis])
244 << EI_interval_right(max_vertex_[axis])
245 << EI_split_point(splitting_point) );
253 for(
unsigned int j=0; j<dimension; j++) {
255 min_vertex_(j) = std::min( point[j], min_vertex_[j] );
256 max_vertex_(j) = std::max( point[j], max_vertex_[j] );
264 for(
unsigned int j=0; j<dimension; j++) {
266 min_vertex_[j] = std::min( box.
min_vertex_[j], min_vertex_[j] );
267 max_vertex_[j] = std::max( box.
max_vertex_[j], max_vertex_[j] );
275 auto diff=max_vertex_ - min_vertex_;
276 return (diff[1] > diff[0])
277 ? ( diff[2] > diff[1] ? 2 : 1 )
278 : ( diff[2] > diff[0] ? 2 : 0 );
287 Point projected_point;
288 for (
unsigned int i=0; i<dimension; ++i) {
289 if ( projection_gt(i, point[i]) ) projected_point[i] = min_vertex_(i);
290 else if ( projection_lt(i, point[i]) ) projected_point[i] = max_vertex_(i);
291 else projected_point[i] = point[i];
294 return projected_point;
301 return size( longest_axis() );
317 << box.
min(2) <<
"; "
320 << box.
max(2) <<
")";
void set_max(unsigned int axis, double max)
bool projection_gt(unsigned int axis, double value) const
void expand(const Point &point)
unsigned char longest_axis() const
Space< dimension >::Point Point
Currently we assume.
double projection_center(unsigned int axis) const
static constexpr bool value
Point max_vertex_
maximal coordinates of bounding box
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
double size(unsigned int axis) const
ostream & operator<<(ostream &stream, const BoundingBox &box)
Overloads output operator for box.
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
Bounding box in 3d ambient space.
static const double epsilon
stabilization parameter
bool contains_point(const Point &point) const
Point min_vertex_
minimal coordinates of bounding box
bool intersect(const BoundingBox &b2) const
void expand(const BoundingBox &box)
void split(unsigned int axis, double splitting_point, BoundingBox &left, BoundingBox &right) const
BoundingBox(const Point &min, const Point &max)
void set_min(unsigned int axis, double min)
#define TYPEDEF_ERR_INFO(EI_Type, Type)
Macro to simplify declaration of error_info types.
double longest_size() const
Global macros to enhance readability and debugging, general constants.
bool projection_lt(unsigned int axis, double value) const
#define ASSERT_LE(a, b)
Definition of comparative assert macro (Less or Equal) only for debug mode.
const Point & max() const
BoundingBox(const Point &min)
double max(unsigned int axis) const
#define DECLARE_EXCEPTION(ExcName, Format)
Macro for simple definition of exceptions.
Point project_point(const Point &point) const
const Point & min() const
double min(unsigned int axis) const