MeVisLab Toolbox Reference
WEMBoundingBox.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #pragma once
14 
15 #include "MLWEMIncludes.h"
16 
17 ML_START_NAMESPACE
18 
20 
23 {
24 public:
26  bool contains(const Vector3& position) const;
28  Vector3 getMin() const { return _min; }
30  Vector3 getMax() const{ return _max; }
32  Vector3 getCenter() const { return (_min + _max) * 0.5; }
34  double getRadius() const { return (_max - getCenter()).length(); }
36  bool isCentered() const { return (getCenter() == NULL_VEC); }
38  bool isScalable() const { return (getRadius() > WEM_EPSILON); }
40  void reset();
42  void setExtents(const Vector3& min, const Vector3& max);
44  bool isValid() const;
47 
48 private:
50  Vector3 _min = Vector3(std::numeric_limits<double>::max(), std::numeric_limits<double>::max(),
51  std::numeric_limits<double>::max());
53  Vector3 _max = Vector3(std::numeric_limits<double>::min(), std::numeric_limits<double>::min(),
54  std::numeric_limits<double>::min());
55 };
56 
59 
60 
62 
63 ML_END_NAMESPACE
const double WEM_EPSILON
Epsilon value used in Vector3 comparisons.
Definition: MLWEMIncludes.h:22
#define NULL_VEC
Definition: MLWEMIncludes.h:57
#define MLWEM_EXPORT
Definition: MLWEMSystem.h:18
This class represents an axis aligned bounding box for a WEMPatch.
Vector3 getMin() const
Returns minimum bounding box extent.
Vector3 getMax() const
Returns maximum bounding box extent.
void reset()
Resets object to default constructed state.
bool contains(const Vector3 &position) const
Returns whether the bounding box contains the given position.
double getRadius() const
Returns radius.
Vector3 getCenter() const
Returns center of bounding box.
bool isValid() const
returns true if is a valid box
bool isScalable() const
Returns whether the bounding box is scalable.
void setExtents(const Vector3 &min, const Vector3 &max)
Sets extents minimum and maximum and update center and radius.
WEMBoundingBox & operator&=(const WEMBoundingBox &other)
returns the united bounding box of this and other
bool isCentered() const
Returns whether the bounding box is centered.
WEMBoundingBox MLWEM_EXPORT operator&(WEMBoundingBox x, const WEMBoundingBox &y)
Returns the united bounding box of x and y.
Tvec3< MLdouble > Vector3
A vector with 3 components of type double.
Definition: mlVector3.h:300