Changeset 863 for GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h
- Timestamp:
- 04/29/06 19:11:23 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h
r860 r863 8 8 #include "Containers.h" 9 9 10 namespace GtpVisibilityPreprocessor { 11 10 12 class Ray; 11 13 class Polygon3; 12 14 class Mesh; 13 15 14 / / --------------------------------------------------------15 //CAABox class.16 //This is a box in 3-space, defined by min and max17 //corner vectors. Many useful operations are defined18 //on this19 // -------------------------------------------------------- 16 /** 17 CAABox class. 18 This is a box in 3-space, defined by min and max 19 corner vectors. Many useful operations are defined 20 on this 21 */ 20 22 class AxisAlignedBox3 21 23 { 22 24 protected: 23 25 Vector3 mMin, mMax; 24 26 public: 25 27 // Constructors. … … 34 36 // max(center + Vector3(radius)) {} 35 37 36 // initialization to the non existing bounding box 38 /** initialization to the non existing bounding box 39 */ 37 40 void Initialize() { 38 41 mMin = Vector3(MAXFLOAT); … … 40 43 } 41 44 42 // The center of the box 45 /** The center of the box 46 */ 43 47 Vector3 Center() const { return 0.5 * (mMin + mMax); } 44 48 45 // The diagonal of the box 49 /** The diagonal of the box 50 */ 46 51 Vector3 Diagonal() const { return (mMax -mMin); } 47 52 … … 110 115 void Include (const PolygonContainer &polys); 111 116 void Include(Mesh *mesh); 112 // Expand the axis-aligned box to include given values in particular axis 117 118 /** Expand the axis-aligned box to include given values in particular axis. 119 */ 113 120 void Include(const int &axis, const float &newBound); 114 121 … … 123 130 friend inline bool OverlapS(const AxisAlignedBox3 &,const AxisAlignedBox3 &); 124 131 125 // Overlap returns 1 if the two axis-aligned boxes overlap for a given 126 // epsilon. If eps > 0.0, then the boxes has to have the real intersection 127 // box, if eps < 0.0, then the boxes need not intersect really, they 128 // can be at eps distance in the projection 132 /** Overlap returns 1 if the two axis-aligned boxes overlap for a given 133 epsilon. If eps > 0.0, then the boxes has to have the real intersection 134 box, if eps < 0.0, then the boxes need not intersect really, they 135 can be at eps distance in the projection. 136 */ 129 137 friend inline bool Overlap(const AxisAlignedBox3 &, 130 const AxisAlignedBox3 &, 131 float eps); 132 133 // Includes returns true if a includes b (completely 138 const AxisAlignedBox3 &, 139 float eps); 140 141 /** Returns 'factor' of overlap of first box with the second box. i.e., a number 142 between 0 (no overlap) and 1 (same box). 143 */ 144 friend inline float FactorOfOverlap(const AxisAlignedBox3 &, const AxisAlignedBox3 &); 145 146 /** Includes returns true if a includes b (completely) 147 */ 134 148 bool Includes(const AxisAlignedBox3 &b) const; 135 149 136 150 virtual int IsInside(const Vector3 &v) const; 137 151 138 // Test if the box is really sensefull 152 /** Test if the box makes sense. 153 */ 139 154 virtual bool IsCorrect(); 140 155 141 // To answer true requires the box of real volume of non-zero value 156 /** To answer true requires the box of real volume of non-zero value. 157 */ 142 158 bool IsSingularOrIncorrect() const; 143 159 144 // When the box is not of non-zero or negative surface area 160 /** When the box is not of non-zero or negative surface area. 161 */ 145 162 bool IsCorrectAndNotPoint() const; 146 163 147 // Returns true when the box degenerates to a point 164 /** Returns true when the box degenerates to a point. 165 */ 148 166 bool IsPoint() const; 149 167 168 /** Scales the box with the factor. 169 */ 150 170 void Scale(const float scale) { 151 171 Vector3 newSize = Size()*(scale*0.5f); … … 155 175 } 156 176 177 /** Returns the square of the minimal and maximal distance to 178 a point on the box. 179 */ 157 180 void 158 181 GetSqrDistances(const Vector3 &point, … … 348 371 @returns true if ray hits the bounding box. 349 372 */ 350 bool GetRaySegment(const Ray &ray, 351 float &minT, 352 float &maxT) const; 373 bool GetRaySegment(const Ray &ray, float &minT, float &maxT) const; 353 374 354 375 /** If the boxes are intersecting on a common face, this function … … 519 540 } 520 541 542 inline float FactorOfOverlap(const AxisAlignedBox3 &box1, const AxisAlignedBox3 &box2) 543 { 544 const AxisAlignedBox3 isect = Intersect(box1, box2); 545 return isect.GetVolume() / box1.GetVolume(); 546 } 521 547 522 548 inline int operator==(const AxisAlignedBox3 &A, const AxisAlignedBox3 &B) … … 526 552 527 553 528 554 } 529 555 530 556
Note: See TracChangeset
for help on using the changeset viewer.