6#include <istd/TRange.h>
7#include <i3d/CVector3d.h>
27 i3d::CVector3d GetLeftBottomNear();
28 void SetLeftBottomNear(
const i3d::CVector3d& point);
30 i3d::CVector3d GetRightBottomNear();
31 void SetRightBottomNear(
const i3d::CVector3d& point);
33 i3d::CVector3d GetLeftTopNear();
34 void SetLeftTopNear(
const i3d::CVector3d& point);
36 i3d::CVector3d GetRightTopNear();
37 void SetRightTopNear(
const i3d::CVector3d& point);
39 i3d::CVector3d GetLeftBottomFar();
40 void SetLeftBottomFar(
const i3d::CVector3d& point);
42 i3d::CVector3d GetRightBottomFar();
43 void SetRightBottomFar(
const i3d::CVector3d& point);
45 i3d::CVector3d GetLeftTopFar();
46 void SetLeftTopFar(
const i3d::CVector3d& point);
48 i3d::CVector3d GetRightTopFar();
49 void SetRightTopFar(
const i3d::CVector3d& point);
51 double GetLeft()
const;
52 void SetLeft(
double left);
54 double GetTop()
const;
55 void SetTop(
double top);
57 double GetRight()
const;
58 void SetRight(
double right);
60 double GetBottom()
const;
61 void SetBottom(
double bottom);
63 double GetNear()
const;
64 void SetNear(
double near);
66 double GetFar()
const;
67 void SetFar(
double far);
69 double GetWidth()
const;
70 double GetHeight()
const;
71 double GetDepth()
const;
73 i3d::CVector3d GetCenterPoint();
74 void ExpandToPoint(
const i3d::CVector3d& point);
76 const istd::CRange& GetHorizontalRange()
const;
77 istd::CRange& GetHorizontalRangeRef();
78 void SetHorizontalRange(
const istd::CRange& range);
80 const istd::CRange& GetVerticalRange()
const;
81 istd::CRange& GetVerticalRangeRef();
82 void SetVerticalRange(
const istd::CRange& range);
84 const istd::CRange& GetDeepRange()
const;
85 istd::CRange& GetDeepRangeRef();
86 void SetDeepRange(
const istd::CRange& range);
98 bool Contains(
const i3d::CVector3d& point)
const;
110 bool operator==(
const CCuboid &
object);
112 bool operator!=(
const CCuboid &
object);
115 istd::CRange m_horizontalRange;
116 istd::CRange m_verticalRange;
117 istd::CRange m_depthRange;
127inline i3d::CVector3d CCuboid::GetLeftBottomNear()
129 return i3d::CVector3d(m_horizontalRange.GetMinValue(), m_verticalRange.GetMinValue(), m_depthRange.GetMinValue());
133inline void CCuboid::SetLeftBottomNear(
const i3d::CVector3d& point)
135 m_horizontalRange.SetMinValue(point.GetX());
136 m_verticalRange.SetMinValue(point.GetY());
137 m_depthRange.SetMinValue(point.GetZ());
141inline i3d::CVector3d CCuboid::GetRightBottomNear()
143 return i3d::CVector3d(m_horizontalRange.GetMaxValue(), m_verticalRange.GetMinValue(), m_depthRange.GetMinValue());
147inline void CCuboid::SetRightBottomNear(
const i3d::CVector3d& point)
149 m_horizontalRange.SetMaxValue(point.GetX());
150 m_verticalRange.SetMinValue(point.GetY());
151 m_depthRange.SetMinValue(point.GetZ());
155inline i3d::CVector3d CCuboid::GetLeftTopNear()
157 return i3d::CVector3d(m_horizontalRange.GetMinValue(), m_verticalRange.GetMaxValue(), m_depthRange.GetMinValue());
161inline void CCuboid::SetLeftTopNear(
const i3d::CVector3d& point)
163 m_horizontalRange.SetMinValue(point.GetX());
164 m_verticalRange.SetMaxValue(point.GetY());
165 m_depthRange.SetMinValue(point.GetZ());
169inline i3d::CVector3d CCuboid::GetRightTopNear()
171 return i3d::CVector3d(m_horizontalRange.GetMaxValue(), m_verticalRange.GetMaxValue(), m_depthRange.GetMinValue());
175inline void CCuboid::SetRightTopNear(
const i3d::CVector3d& point)
177 m_horizontalRange.SetMaxValue(point.GetX());
178 m_verticalRange.SetMaxValue(point.GetY());
179 m_depthRange.SetMinValue(point.GetZ());
183inline i3d::CVector3d CCuboid::GetLeftBottomFar()
185 return i3d::CVector3d(m_horizontalRange.GetMinValue(), m_verticalRange.GetMinValue(), m_depthRange.GetMaxValue());
189inline void CCuboid::SetLeftBottomFar(
const i3d::CVector3d& point)
191 m_horizontalRange.SetMinValue(point.GetX());
192 m_verticalRange.SetMinValue(point.GetY());
193 m_depthRange.SetMaxValue(point.GetZ());
197inline i3d::CVector3d CCuboid::GetRightBottomFar()
199 return i3d::CVector3d(m_horizontalRange.GetMaxValue(), m_verticalRange.GetMinValue(), m_depthRange.GetMaxValue());
203inline void CCuboid::SetRightBottomFar(
const i3d::CVector3d& point)
205 m_horizontalRange.SetMaxValue(point.GetX());
206 m_verticalRange.SetMinValue(point.GetY());
207 m_depthRange.SetMaxValue(point.GetZ());
211inline i3d::CVector3d CCuboid::GetLeftTopFar()
213 return i3d::CVector3d(m_horizontalRange.GetMinValue(), m_verticalRange.GetMaxValue(), m_depthRange.GetMaxValue());
217inline void CCuboid::SetLeftTopFar(
const i3d::CVector3d& point)
219 m_horizontalRange.SetMinValue(point.GetX());
220 m_verticalRange.SetMaxValue(point.GetY());
221 m_depthRange.SetMaxValue(point.GetZ());
225inline i3d::CVector3d CCuboid::GetRightTopFar()
227 return i3d::CVector3d(m_horizontalRange.GetMaxValue(), m_verticalRange.GetMaxValue(), m_depthRange.GetMaxValue());
231inline void CCuboid::SetRightTopFar(
const i3d::CVector3d& point)
233 m_horizontalRange.SetMaxValue(point.GetX());
234 m_verticalRange.SetMaxValue(point.GetY());
235 m_depthRange.SetMaxValue(point.GetZ());
239inline double CCuboid::GetLeft()
const
241 return m_horizontalRange.GetMinValue();
245inline void CCuboid::SetLeft(
double left)
247 m_horizontalRange.SetMinValue(left);
251inline double CCuboid::GetTop()
const
253 return m_verticalRange.GetMaxValue();
257inline void CCuboid::SetTop(
double top)
259 m_verticalRange.SetMaxValue(top);
263inline double CCuboid::GetRight()
const
265 return m_horizontalRange.GetMaxValue();
269inline void CCuboid::SetRight(
double right)
271 m_horizontalRange.SetMaxValue(right);
275inline double CCuboid::GetBottom()
const
277 return m_verticalRange.GetMinValue();
281inline void CCuboid::SetBottom(
double bottom)
283 m_verticalRange.SetMinValue(bottom);
287inline double CCuboid::GetNear()
const
289 return m_depthRange.GetMinValue();
293inline void CCuboid::SetNear(
double nearValue)
295 m_depthRange.SetMinValue(nearValue);
299inline double CCuboid::GetFar()
const
301 return m_depthRange.GetMaxValue();
305inline void CCuboid::SetFar(
double farValue)
307 m_depthRange.SetMaxValue(farValue);
311inline double CCuboid::GetWidth()
const
313 return m_horizontalRange.GetLength();
317inline double CCuboid::GetHeight()
const
319 return m_verticalRange.GetLength();
323inline double CCuboid::GetDepth()
const
325 return m_depthRange.GetLength();
329inline i3d::CVector3d CCuboid::GetCenterPoint()
331 return i3d::CVector3d(
332 (m_horizontalRange.GetMaxValue() + m_horizontalRange.GetMinValue()) / 2.0,
333 (m_verticalRange.GetMaxValue() + m_verticalRange.GetMinValue()) / 2.0,
334 (m_depthRange.GetMaxValue() + m_depthRange.GetMinValue()) / 2.0);
338inline void CCuboid::ExpandToPoint(
const i3d::CVector3d& point)
340 if ((point.GetX() > m_horizontalRange.GetMaxValue())){
341 m_horizontalRange.SetMaxValue(point.GetX());
342 }
else if ((point.GetX() < m_horizontalRange.GetMinValue())){
343 m_horizontalRange.SetMinValue(point.GetX());
345 if ((point.GetY() > m_verticalRange.GetMaxValue())){
346 m_verticalRange.SetMaxValue(point.GetY());
347 }
else if ((point.GetY() < m_verticalRange.GetMinValue())){
348 m_verticalRange.SetMinValue(point.GetY());
350 if ((point.GetZ() > m_depthRange.GetMaxValue())){
351 m_depthRange.SetMaxValue(point.GetZ());
352 }
else if ((point.GetZ() < m_depthRange.GetMinValue())){
353 m_depthRange.SetMinValue(point.GetZ());
358inline const istd::CRange& CCuboid::GetHorizontalRange()
const
360 return m_horizontalRange;
364inline istd::CRange& CCuboid::GetHorizontalRangeRef()
366 return m_horizontalRange;
370inline void CCuboid::SetHorizontalRange(
const istd::CRange& range)
372 m_horizontalRange = range;
376inline const istd::CRange& CCuboid::GetVerticalRange()
const
378 return m_verticalRange;
382inline istd::CRange& CCuboid::GetVerticalRangeRef()
384 return m_verticalRange;
388inline void CCuboid::SetVerticalRange(
const istd::CRange& range)
390 m_verticalRange = range;
394inline const istd::CRange& CCuboid::GetDeepRange()
const
400inline istd::CRange& CCuboid::GetDeepRangeRef()
406inline void CCuboid::SetDeepRange(
const istd::CRange& range)
408 m_depthRange = range;
412inline bool CCuboid::IsValid()
const
414 return (m_horizontalRange.GetLength() > I_BIG_EPSILON) && (m_verticalRange.GetLength() > I_BIG_EPSILON) && (m_depthRange.GetLength() > I_BIG_EPSILON);
421 bool xOverlap = (GetLeft() <= other.GetRight()) && (GetRight() >= other.GetLeft());
422 bool yOverlap = (GetBottom() <= other.GetTop()) && (GetTop() >= other.GetBottom());
423 bool zOverlap = (GetNear() <= other.GetFar()) && (GetFar() >= other.GetNear());
425 return xOverlap && yOverlap && zOverlap;
432 bool xContained = (point.GetX() >= GetLeft()) && (point.GetX() <= GetRight());
433 bool yContained = (point.GetY() >= GetBottom()) && (point.GetY() <= GetTop());
434 bool zContained = (point.GetZ() >= GetNear()) && (point.GetZ() <= GetFar());
436 return xContained && yContained && zContained;
453inline bool CCuboid::operator==(
const CCuboid &
object)
455 return ((m_horizontalRange ==
object.m_horizontalRange)
456 && (m_verticalRange ==
object.m_verticalRange)
457 && (m_depthRange ==
object.m_depthRange));
460inline bool CCuboid::operator!=(
const CCuboid &
object)
462 return !(operator==(
object));
bool Contains(const i3d::CVector3d &point) const
static const imt3d::CCuboid & GetInvalid()
static const imt3d::CCuboid & GetEmpty()
bool Intersects(const CCuboid &other) const