| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
#ifndef __BOUNDINGBOX_H__ |
| 30 |
#define __BOUNDINGBOX_H__ |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
#include <vector> |
| 36 |
#include "minivector.h" |
| 37 |
|
| 38 |
class BoundingBox |
| 39 |
{ |
| 40 |
public: |
| 41 |
|
| 42 |
BoundingBox(Vec3d bmin_g=Vec3d(0,0,0), Vec3d bmax_g=Vec3d(1,1,1)): bmin_(bmin_g), bmax_(bmax_g) { updateData();} |
| 43 |
BoundingBox(const std::vector<Vec3d> & vertices); |
| 44 |
template<class Triangle> BoundingBox(const std::vector<Triangle> & tripool); |
| 45 |
|
| 46 |
|
| 47 |
const Vec3d & bmin() const { return bmin_;} |
| 48 |
const Vec3d & bmax() const { return bmax_;} |
| 49 |
|
| 50 |
const Vec3d & center() const { return center_;} |
| 51 |
const Vec3d & halfSides() const { return halfSides_;} |
| 52 |
|
| 53 |
double diameter() const { return len(bmax_-bmin_); } |
| 54 |
|
| 55 |
|
| 56 |
void setbmin(const Vec3d & bmin_g) { bmin_=bmin_g; updateData();} |
| 57 |
void setbmin(double x, double y, double z) { bmin_=Vec3d(x,y,z); updateData();} |
| 58 |
void setbmax(const Vec3d & bmax_g) { bmax_=bmax_g; updateData();} |
| 59 |
void setbmax(double x, double y, double z) { bmax_=Vec3d(x,y,z); updateData();} |
| 60 |
|
| 61 |
void render() const; |
| 62 |
|
| 63 |
double distanceToPoint(const Vec3d & point) const; |
| 64 |
bool checkInside(const Vec3d & point) const; |
| 65 |
|
| 66 |
|
| 67 |
void verifyBox() const; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
void expand(double expansionFactor); |
| 72 |
void regularize(); |
| 73 |
|
| 74 |
bool lineSegmentIntersection(const Vec3d & segmentStart, const Vec3d & segmentEnd, Vec3d * intersection) const; |
| 75 |
|
| 76 |
void print() const; |
| 77 |
|
| 78 |
protected: |
| 79 |
|
| 80 |
void updateData(); |
| 81 |
Vec3d center_, halfSides_; |
| 82 |
Vec3d bmin_,bmax_; |
| 83 |
}; |
| 84 |
|
| 85 |
#endif |