20 #ifndef Tulip_BOUNDINGBOX_H
21 #define Tulip_BOUNDINGBOX_H
25 #include <tulip/Vector.h>
26 #include <tulip/tulipconf.h>
85 BoundingBox(
const tlp::Vec3f &min,
const tlp::Vec3f &max,
bool checkMinMax =
false);
96 inline void init(
const tlp::Vec3f &coord) {
97 (*this)[0] = (*this)[1] = coord;
108 return ((*
this)[0] + (*
this)[1]) / 2.f;
118 return ((*
this)[1][0] - (*
this)[0][0]);
128 return ((*
this)[1][1] - (*
this)[0][1]);
138 return ((*
this)[1][2] - (*
this)[0][2]);
149 void expand(
const tlp::Vec3f &coord,
bool noCheck =
false);
158 inline void expand(
const std::vector<tlp::Vec3f> &coords) {
159 auto it = coords.begin();
161 for (++it; it < coords.end(); ++it)
190 void scale(
const tlp::Vec3f &factor);
207 bool contains(
const tlp::Vec3f &coord,
bool noCheck =
false)
const;
232 bool intersect(
const Vec3f &segStart,
const Vec3f &segEnd)
const;
This class represents the 3D bounding box of an object. It is mostly used to determine whether or not...
void init(const tlp::Vec3f &coord)
init the bounding box with the point passed as parameter.
void getCompleteBB(Vec3f bb[8]) const
The vector passed as parameter is modified to contain the 8 points of the bounding box....
bool contains(const tlp::Vec3f &coord, bool noCheck=false) const
Checks if the given vector is inside the current bounding box. If the bounding box is invalid the res...
bool intersect(const Vec3f &segStart, const Vec3f &segEnd) const
Checks if the bounding box intersects a given line segment. If the bounding box is invalid the result...
void clear()
restore an invalid state.
Vec3f center() const
Returns the geometrical center of the bounding box. An assertion is raised in debug mode if the Bound...
BoundingBox()
Creates an invalid boundig box. The minimum is (1, 1, 1) and the maximum is (-1, -1,...
BoundingBox(const tlp::Vec3f &min, const tlp::Vec3f &max, bool checkMinMax=false)
Creates a bounding box that must be valid. Validity is checked in debug mode by an assert.
float height() const
Returns the height of the bounding box An assertion is raised in debug mode if the bounding box is no...
float depth() const
Returns the depth of the bounding box An assertion is raised in debug mode if the bounding box is not...
bool contains(const tlp::BoundingBox &boundingBox) const
Checks if the given bounding box is inside the current bounding box. If one of the bounding boxes is ...
bool isValid() const
Checks whether the bounding box's lowest point is less than it's highest point. "Less Than" means axi...
bool intersect(const tlp::BoundingBox &boundingBox) const
Checks if the given bounding box intersects the current one. If one of the bounding box is invalid re...
float width() const
Returns the width of the bounding box An assertion is raised in debug mode if the BoundingBox is not ...
void expand(const tlp::Vec3f &coord, bool noCheck=false)
Expands the bounding box to one containing the point passed as parameter. If the parameter is inside ...
void expand(const std::vector< tlp::Vec3f > &coords)
Expands the bounding box to one containing all the point of the vector passed as parameter.
void expand(const tlp::BoundingBox &bb, bool noCheck=false)
Expands the bounding box to one containing the bounding box passed as parameter. If the parameter is ...
void translate(const tlp::Vec3f &vec)
Translates the bounding box by the displacement given by the vector passed as parameter.
void scale(const tlp::Vec3f &factor)
Scales the bounding box, i.e. multiplying its components by a vector passed as parameter.