Flow123d
JS_before_hm-2072-g4aad0192b
|
Go to the documentation of this file.
18 #ifndef BOX_ELEMENT_HH_
19 #define BOX_ELEMENT_HH_
60 <<
"out of bounds: <" << EI_interval_left::val
61 <<
", " << EI_interval_right::val <<
">\n");
64 static const unsigned int dimension = 3;
79 min_vertex_.fill( std::numeric_limits<double>::signaling_NaN() );
80 max_vertex_.fill( std::numeric_limits<double>::signaling_NaN() );
87 : min_vertex_(min), max_vertex_(min)
96 : min_vertex_(min), max_vertex_(max)
98 ASSERT( arma::min( min <= max ) ).error(
"Wrong coordinates in constructor.");
114 max_vertex_[axis] = max;
123 min_vertex_[axis] = min;
143 double min(
unsigned int axis)
const {
150 double max(
unsigned int axis)
const {
158 double size(
unsigned int axis)
const {
159 return max()[axis] - min()[axis];
167 return (max_vertex_ + min_vertex_) / 2.0;
176 return (max_vertex_[axis] + min_vertex_[axis])/2;
187 for (
unsigned int i=0; i<dimension; i++) {
188 if ((point(i) + epsilon < min_vertex_(i)) ||
189 (point(i) > epsilon + max_vertex_(i)))
return false;
205 for (
unsigned int i=0; i<dimension; i++) {
206 if ( (min_vertex_(i) > b2.
max_vertex_(i) + epsilon) ||
207 (b2.
min_vertex_(i) > max_vertex_(i) + epsilon ) )
return false;
218 return max_vertex_(axis) + epsilon <
value;
227 return min_vertex_(axis) - epsilon >
value;
234 void split(
unsigned int axis,
double splitting_point,
238 if (min_vertex_[axis] <= splitting_point && splitting_point <= max_vertex_[axis] ) {
241 left.max_vertex_[axis] = splitting_point;
242 right.min_vertex_[axis] = splitting_point;
244 THROW( ExcSplitting() << EI_interval_left(min_vertex_[axis])
245 << EI_interval_right(max_vertex_[axis])
246 << EI_split_point(splitting_point) );
254 for(
unsigned int j=0; j<dimension; j++) {
256 min_vertex_(j) = std::min( point[j], min_vertex_[j] );
257 max_vertex_(j) = std::max( point[j], max_vertex_[j] );
265 for(
unsigned int j=0; j<dimension; j++) {
267 min_vertex_[j] = std::min( box.
min_vertex_[j], min_vertex_[j] );
268 max_vertex_[j] = std::max( box.
max_vertex_[j], max_vertex_[j] );
276 auto diff=max_vertex_ - min_vertex_;
277 return (diff[1] > diff[0])
278 ? ( diff[2] > diff[1] ? 2 : 1 )
279 : ( diff[2] > diff[0] ? 2 : 0 );
288 Point projected_point;
289 for (
unsigned int i=0; i<dimension; ++i) {
290 if ( projection_gt(i, point[i]) ) projected_point[i] = min_vertex_(i);
291 else if ( projection_lt(i, point[i]) ) projected_point[i] = max_vertex_(i);
292 else projected_point[i] = point[i];
295 return projected_point;
302 return size( longest_axis() );
318 << box.
min(2) <<
"; "
321 << 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)
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
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)
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)
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