2 // Created: 08.09.05 20:55:36
3 // Author: Alexander GRIGORIEV
4 // Copyright: Open Cascade 2005
8 #ifndef Bnd_B3x_RealLast
9 #define Bnd_B3x_RealLast RealType(1e30);
15 inline Bnd_B3x::Bnd_B3x ()
23 * Center of the created box
25 * Half-diagonal of the box, both X and Y should be non-negative
27 inline Bnd_B3x::Bnd_B3x (const gp_XYZ& theCenter,
28 const gp_XYZ& theHSize)
30 myCenter[0] = RealType(theCenter.X());
31 myCenter[1] = RealType(theCenter.Y());
32 myCenter[2] = RealType(theCenter.Z());
33 myHSize[0] = RealType(theHSize.X());
34 myHSize[1] = RealType(theHSize.Y());
35 myHSize[2] = RealType(theHSize.Z());
41 inline void Bnd_B3x::Clear ()
43 myCenter[0] = Bnd_B3x_RealLast;
44 myCenter[1] = Bnd_B3x_RealLast;
45 myCenter[2] = Bnd_B3x_RealLast;
46 myHSize[0] = -Bnd_B3x_RealLast;
47 myHSize[1] = -Bnd_B3x_RealLast;
48 myHSize[2] = -Bnd_B3x_RealLast;
52 * Check if the box is empty.
54 inline Standard_Boolean Bnd_B3x::IsVoid () const
56 return (myHSize[0] < -1e-5);
60 * Update the box by point.
62 inline void Bnd_B3x::Add (const gp_Pnt& thePnt)
68 * Update the box by another box.
70 inline void Bnd_B3x::Add (const Bnd_B3x& theBox)
72 if (theBox.IsVoid() == Standard_False) {
73 Add (theBox.CornerMin());
74 Add (theBox.CornerMax());
81 inline gp_XYZ Bnd_B3x::CornerMin () const
83 return gp_XYZ (myCenter[0] - myHSize[0],
84 myCenter[1] - myHSize[1],
85 myCenter[2] - myHSize[2]);
91 inline gp_XYZ Bnd_B3x::CornerMax () const
93 return gp_XYZ (myCenter[0] + myHSize[0],
94 myCenter[1] + myHSize[1],
95 myCenter[2] + myHSize[2]);
99 * Query the square diagonal.
101 inline Standard_Real Bnd_B3x::SquareExtent () const
103 return 4 * (myHSize[0] * myHSize[0] +
104 myHSize[1] * myHSize[1] +
105 myHSize[2] * myHSize[2]);
109 * Set the Center coordinates.
111 inline void Bnd_B3x::SetCenter (const gp_XYZ& theCenter)
113 myCenter[0] = RealType(theCenter.X());
114 myCenter[1] = RealType(theCenter.Y());
115 myCenter[2] = RealType(theCenter.Z());
119 * Set the Center coordinates.
121 inline void Bnd_B3x::SetHSize (const gp_XYZ& theHSize)
123 myHSize[0] = RealType(theHSize.X());
124 myHSize[1] = RealType(theHSize.Y());
125 myHSize[2] = RealType(theHSize.Z());
131 * absolute value of this parameter is added to the box size in all dimensions.
133 inline void Bnd_B3x::Enlarge (const Standard_Real aDiff)
135 const Standard_Real aD = Abs(aDiff);
136 myHSize[0] += RealType(aD);
137 myHSize[1] += RealType(aD);
138 myHSize[2] += RealType(aD);
142 * Intersection Box - Point
144 inline Standard_Boolean Bnd_B3x::IsOut (const gp_XYZ& thePnt) const
146 return (Abs(RealType(thePnt.X()) - myCenter[0]) > myHSize[0] ||
147 Abs(RealType(thePnt.Y()) - myCenter[1]) > myHSize[1] ||
148 Abs(RealType(thePnt.Z()) - myCenter[2]) > myHSize[2]);
152 * Intersection Box-Box.
154 inline Standard_Boolean Bnd_B3x::IsOut (const Bnd_B3x& theBox) const
156 return (Abs(theBox.myCenter[0]-myCenter[0]) > theBox.myHSize[0]+myHSize[0] ||
157 Abs(theBox.myCenter[1]-myCenter[1]) > theBox.myHSize[1]+myHSize[1] ||
158 Abs(theBox.myCenter[2]-myCenter[2]) > theBox.myHSize[2]+myHSize[2]);
162 * Test the complete inclusion of this box in theBox.
164 inline Standard_Boolean Bnd_B3x::IsIn (const Bnd_B3x& theBox) const
166 return (Abs(theBox.myCenter[0]-myCenter[0]) < theBox.myHSize[0]-myHSize[0] &&
167 Abs(theBox.myCenter[1]-myCenter[1]) < theBox.myHSize[1]-myHSize[1] &&
168 Abs(theBox.myCenter[2]-myCenter[2]) < theBox.myHSize[2]-myHSize[2]);