KiCad PCB EDA Suite
CBBOX2D Struct Reference

Class CBBOX manages a bounding box defined by two SFVEC2F min max points. More...

#include <cbbox2d.h>

Public Member Functions

 CBBOX2D ()
 Constructor CBBOX2D Create with default values a bounding box (not inizialized) More...
 
 CBBOX2D (const SFVEC2F &aPbInit)
 Constructor CBBOX2D Initialize a bounding box with a given point. More...
 
 CBBOX2D (const SFVEC2F &aPbMin, const SFVEC2F &aPbMax)
 Constructor CBBOX2D Initialize a bounding box with a minimon and a maximun point. More...
 
 ~CBBOX2D ()
 
void Set (const SFVEC2F &aPbMin, const SFVEC2F &aPbMax)
 Function Set Set bounding box with new parameters. More...
 
void Set (const CBBOX2D &aBBox)
 Function Set Set bounding box based on another bounding box. More...
 
void Union (const SFVEC2F &aPoint)
 Function Union recalculate the bounding box adding a point. More...
 
void Union (const CBBOX2D &aBBox)
 Function Union recalculate the bounding box adding other bounding box. More...
 
void Scale (float aScale)
 Function Scale scales a bounding box by its center. More...
 
void ScaleNextUp ()
 Function ScaleNextUp scales a bounding box to the next float representation making it larger. More...
 
void ScaleNextDown ()
 Function ScaleNextDown scales a bounding box to the next float representation making it smaller. More...
 
bool Intersects (const CBBOX2D &aBBox) const
 Function Intersects test if a bounding box intersects this box. More...
 
bool Intersects (const SFVEC2F &aCenter, float aRadiusSquared) const
 Function Intersects test if a circle intersects this box. More...
 
bool Inside (const SFVEC2F &aPoint) const
 Function Inside check is a point is inside this bounding box. More...
 
float Area () const
 Function Area calculate the area of a bounding box. More...
 
bool IsInitialized () const
 Function IsInitialized check if this bounding box is already initialized. More...
 
void Reset ()
 Function Reset reset the bounding box to zero and de-initialized it. More...
 
SFVEC2F GetCenter () const
 Function GetCenter return the center point of the bounding box. More...
 
SFVEC2F GetExtent () const
 Function GetExtent. More...
 
const SFVEC2FMin () const
 Function Min return the minimun vertex pointer. More...
 
const SFVEC2FMax () const
 Function Max return the maximum vertex pointer. More...
 
unsigned int MaxDimension () const
 Function MaxDimension. More...
 
float Perimeter () const
 Function Perimeter. More...
 
bool Intersect (const RAY2D &aRay, float *t) const
 Function Intersect. More...
 
bool Intersect (const RAY2D &aRay, float *aOutHitT0, float *aOutHitT1) const
 
bool Intersect (const RAYSEG2D &aRaySeg) const
 

Private Attributes

SFVEC2F m_min
 point of the lower position of the bounding box More...
 
SFVEC2F m_max
 point of the higher position of the bounding box More...
 

Detailed Description

Class CBBOX manages a bounding box defined by two SFVEC2F min max points.

Definition at line 40 of file cbbox2d.h.

Constructor & Destructor Documentation

CBBOX2D::CBBOX2D ( )

Constructor CBBOX2D Create with default values a bounding box (not inizialized)

Definition at line 37 of file cbbox2d.cpp.

References Reset().

38 {
39  Reset();
40 }
void Reset()
Function Reset reset the bounding box to zero and de-initialized it.
Definition: cbbox2d.cpp:88
CBBOX2D::CBBOX2D ( const SFVEC2F aPbInit)
explicit

Constructor CBBOX2D Initialize a bounding box with a given point.

Parameters
aPbInita point for the bounding box initialization

Definition at line 43 of file cbbox2d.cpp.

References m_max, and m_min.

44 {
45  m_min = aPbInit;
46  m_max = aPbInit;
47 }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
CBBOX2D::CBBOX2D ( const SFVEC2F aPbMin,
const SFVEC2F aPbMax 
)

Constructor CBBOX2D Initialize a bounding box with a minimon and a maximun point.

Parameters
aPbMinthe minimun point to initialize the bounding box
aPbMaxthe maximun point to initialize the bounding box

Definition at line 50 of file cbbox2d.cpp.

References Set().

51 {
52  Set( aPbMin, aPbMax );
53 }
void Set(const SFVEC2F &aPbMin, const SFVEC2F &aPbMax)
Function Set Set bounding box with new parameters.
Definition: cbbox2d.cpp:61
CBBOX2D::~CBBOX2D ( )

Definition at line 56 of file cbbox2d.cpp.

57 {
58 }

Member Function Documentation

float CBBOX2D::Area ( ) const

Function Area calculate the area of a bounding box.

Returns
float - area of this bounding box

Definition at line 234 of file cbbox2d.cpp.

References GetExtent().

235 {
236  SFVEC2F extent = GetExtent();
237  return extent.x * extent.y;
238 }
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
SFVEC2F GetExtent() const
Function GetExtent.
Definition: cbbox2d.cpp:127
SFVEC2F CBBOX2D::GetCenter ( ) const

Function GetCenter return the center point of the bounding box.

Returns
SFVEC2F - the position of the center of this bounding box

Definition at line 121 of file cbbox2d.cpp.

References m_max, and m_min.

Referenced by CDUMMYBLOCK2D::CDUMMYBLOCK2D(), CFILLEDCIRCLE2D::CFILLEDCIRCLE2D(), CITEMLAYERCSG2D::CITEMLAYERCSG2D(), CPOLYGON4PTS2D::CPOLYGON4PTS2D(), CPOLYGONBLOCK2D::CPOLYGONBLOCK2D(), CRING2D::CRING2D(), CROUNDSEGMENT2D::CROUNDSEGMENT2D(), CTRIANGLE2D::CTRIANGLE2D(), and Scale().

122 {
123  return (m_max + m_min) * 0.5f;
124 }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
SFVEC2F CBBOX2D::GetExtent ( ) const

Function GetExtent.

Returns
SFVEC2F - max-min

Definition at line 127 of file cbbox2d.cpp.

References m_max, and m_min.

Referenced by Area(), Convert_path_polygon_to_polygon_blocks_and_dummy_blocks(), MaxDimension(), Perimeter(), and C3D_RENDER_RAYTRACING::reload().

128 {
129  return m_max - m_min;
130 }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
bool CBBOX2D::Inside ( const SFVEC2F aPoint) const

Function Inside check is a point is inside this bounding box.

Parameters
aPointpoint to test

Definition at line 225 of file cbbox2d.cpp.

References IsInitialized(), m_max, and m_min.

Referenced by extractPathsFrom(), and CDUMMYBLOCK2D::IsPointInside().

226 {
227  wxASSERT( IsInitialized() );
228 
229  return ( ( aPoint.x >= m_min.x ) && ( aPoint.x <= m_max.x ) &&
230  ( aPoint.y >= m_min.y ) && ( aPoint.y <= m_max.y ) );
231 }
bool IsInitialized() const
Function IsInitialized check if this bounding box is already initialized.
Definition: cbbox2d.cpp:79
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
bool CBBOX2D::Intersect ( const RAY2D aRay,
float *  t 
) const

Function Intersect.

Parameters
aRay= ray to intersect the box
t= distance point of the ray of the intersection (if true)
Returns
true if the ray hits the box

Definition at line 242 of file cbbox2d.cpp.

References RAY2D::m_InvDir, m_max, m_min, RAY2D::m_Origin, max, and min.

243 {
244  wxASSERT( t );
245 
246  const float tx1 = (m_min.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
247  const float tx2 = (m_max.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
248 
249  float tmin = glm::min( tx1, tx2 );
250  float tmax = glm::max( tx1, tx2 );
251 
252  const float ty1 = (m_min.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
253  const float ty2 = (m_max.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
254 
255  tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
256  tmax = glm::min( tmax, glm::max( ty1, ty2 ) );
257 
258  if( tmin > 0.0f )
259  *t = tmin;
260  else
261  *t = tmax;
262 
263  return (tmax >= 0.0f) && (tmax >= tmin);
264 }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
#define max(a, b)
Definition: auxiliary.h:86
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
SFVEC2F m_InvDir
Definition: ray.h:78
SFVEC2F m_Origin
Definition: ray.h:76
#define min(a, b)
Definition: auxiliary.h:85
bool CBBOX2D::Intersect ( const RAY2D aRay,
float *  aOutHitT0,
float *  aOutHitT1 
) const

Definition at line 292 of file cbbox2d.cpp.

References RAY2D::m_InvDir, m_max, m_min, RAY2D::m_Origin, max, and min.

293 {
294  wxASSERT( aOutHitT0 );
295  wxASSERT( aOutHitT1 );
296 
297  const float tx1 = (m_min.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
298  const float tx2 = (m_max.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
299 
300  float tmin = glm::min( tx1, tx2 );
301  float tmax = glm::max( tx1, tx2 );
302 
303  const float ty1 = (m_min.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
304  const float ty2 = (m_max.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
305 
306  tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
307  tmax = glm::min( tmax, glm::max( ty1, ty2 ) );
308 
309  *aOutHitT0 = (tmin > 0.0f)?tmin:0.0f;
310  *aOutHitT1 = tmax;
311 
312  return (tmax >= 0.0f) && (tmax >= tmin);
313 }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
#define max(a, b)
Definition: auxiliary.h:86
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
SFVEC2F m_InvDir
Definition: ray.h:78
SFVEC2F m_Origin
Definition: ray.h:76
#define min(a, b)
Definition: auxiliary.h:85
bool CBBOX2D::Intersect ( const RAYSEG2D aRaySeg) const

Definition at line 267 of file cbbox2d.cpp.

References RAYSEG2D::m_InvDir, RAYSEG2D::m_Length, m_max, m_min, RAYSEG2D::m_Start, max, and min.

268 {
269  const float tx1 = (m_min.x - aRaySeg.m_Start.x) * aRaySeg.m_InvDir.x;
270  const float tx2 = (m_max.x - aRaySeg.m_Start.x) * aRaySeg.m_InvDir.x;
271 
272  float tmin = glm::min( tx1, tx2 );
273  float tmax = glm::max( tx1, tx2 );
274 
275  const float ty1 = (m_min.y - aRaySeg.m_Start.y) * aRaySeg.m_InvDir.y;
276  const float ty2 = (m_max.y - aRaySeg.m_Start.y) * aRaySeg.m_InvDir.y;
277 
278  tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
279  tmax = glm::min( tmax, glm::max( ty1, ty2 ) );
280 
281  if( (tmax >= 0.0f) && (tmax >= tmin) )
282  {
283  const float t = (tmin > 0.0f)?tmin:tmax;
284 
285  return ( t < aRaySeg.m_Length );
286  }
287 
288  return false;
289 }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
float m_Length
Definition: ray.h:93
SFVEC2F m_InvDir
Definition: ray.h:92
SFVEC2F m_Start
Definition: ray.h:88
#define max(a, b)
Definition: auxiliary.h:86
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
#define min(a, b)
Definition: auxiliary.h:85
bool CBBOX2D::Intersects ( const CBBOX2D aBBox) const

Function Intersects test if a bounding box intersects this box.

Parameters
aBBoxthe bounding box to check if it inversects

Definition at line 213 of file cbbox2d.cpp.

References IsInitialized(), m_max, and m_min.

Referenced by extractPathsFrom(), CFILLEDCIRCLE2D::Intersects(), CRING2D::Intersects(), CTRIANGLE2D::Intersects(), CPOLYGON4PTS2D::Intersects(), CROUNDSEGMENT2D::Intersects(), CITEMLAYERCSG2D::Intersects(), CPOLYGONBLOCK2D::Intersects(), CDUMMYBLOCK2D::Intersects(), CFILLEDCIRCLE2D::IsBBoxInside(), CTRIANGLE2D::IsBBoxInside(), CROUNDSEGMENT2D::IsBBoxInside(), and CBVHCONTAINER2D::recursiveGetListObjectsIntersects().

214 {
215  wxASSERT( IsInitialized() );
216  wxASSERT( aBBox.IsInitialized() );
217 
218  const bool x = ( m_max.x >= aBBox.m_min.x ) && ( m_min.x <= aBBox.m_max.x );
219  const bool y = ( m_max.y >= aBBox.m_min.y ) && ( m_min.y <= aBBox.m_max.y );
220 
221  return ( x && y );
222 }
bool IsInitialized() const
Function IsInitialized check if this bounding box is already initialized.
Definition: cbbox2d.cpp:79
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
bool CBBOX2D::Intersects ( const SFVEC2F aCenter,
float  aRadiusSquared 
) const

Function Intersects test if a circle intersects this box.

Parameters
aBBoxthe bounding box to check if it intersects

Definition at line 186 of file cbbox2d.cpp.

References m_max, and m_min.

187 {
188  float fDistSq = 0.0f;
189 
190  for( unsigned int i = 0; i < 2; i++ )
191  {
192  if( aCenter[i] < m_min[i] )
193  {
194  const float fDist = aCenter[i] - m_min[i];
195 
196  fDistSq += fDist * fDist;
197  }
198  else
199  {
200  if( aCenter[i] > m_max[i] )
201  {
202  const float fDist = aCenter[i] - m_max[i];
203 
204  fDistSq += fDist * fDist;
205  }
206  }
207  }
208 
209  return ( fDistSq <= aRadiusSquared );
210 }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
bool CBBOX2D::IsInitialized ( ) const

Function IsInitialized check if this bounding box is already initialized.

Returns
bool - return true if it was initialized, false if otherwise

Definition at line 79 of file cbbox2d.cpp.

References m_max, and m_min.

Referenced by CFILLEDCIRCLE2D::CFILLEDCIRCLE2D(), CITEMLAYERCSG2D::CITEMLAYERCSG2D(), CPOLYGON4PTS2D::CPOLYGON4PTS2D(), CPOLYGONBLOCK2D::CPOLYGONBLOCK2D(), CRING2D::CRING2D(), CROUNDSEGMENT2D::CROUNDSEGMENT2D(), CTRIANGLE2D::CTRIANGLE2D(), CBVHCONTAINER2D::GetListObjectsIntersects(), Inside(), Intersects(), CBVHCONTAINER2D::recursiveBuild_MIDDLE_SPLIT(), CBVHCONTAINER2D::recursiveGetListObjectsIntersects(), Scale(), and Set().

80 {
81  return !( ( FLT_MAX == m_min.x) ||
82  ( FLT_MAX == m_min.y) ||
83  (-FLT_MAX == m_max.x) ||
84  (-FLT_MAX == m_max.y) );
85 }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
const SFVEC2F& CBBOX2D::Max ( ) const
inline

Function Max return the maximum vertex pointer.

Returns
SFVEC2F - the maximun vertice position

Definition at line 183 of file cbbox2d.h.

References m_max.

Referenced by CLAYERITEM::CLAYERITEM(), Convert_path_polygon_to_polygon_blocks_and_dummy_blocks(), C3D_RENDER_RAYTRACING::create_3d_object_from(), CROUNDSEGMENT2D::CROUNDSEGMENT2D(), extractPathsFrom(), CROUNDSEGMENT2D::Intersects(), CFILLEDCIRCLE2D::IsBBoxInside(), CROUNDSEGMENT2D::IsBBoxInside(), and Set().

183 { return m_max; }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
unsigned int CBBOX2D::MaxDimension ( ) const

Function MaxDimension.

Returns
the index of the max dimention (0=x, 1=y)

Definition at line 133 of file cbbox2d.cpp.

References GetExtent().

Referenced by CBVHCONTAINER2D::recursiveBuild_MIDDLE_SPLIT().

134 {
135  unsigned int result = 0;
136  const SFVEC2F extent = GetExtent();
137 
138  if( extent.y > extent.x ) result = 1;
139 
140  return result;
141 }
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
SFVEC2F GetExtent() const
Function GetExtent.
Definition: cbbox2d.cpp:127
const SFVEC2F& CBBOX2D::Min ( ) const
inline

Function Min return the minimun vertex pointer.

Returns
SFVEC2F - the minimun vertice position

Definition at line 176 of file cbbox2d.h.

References m_min.

Referenced by CLAYERITEM::CLAYERITEM(), Convert_path_polygon_to_polygon_blocks_and_dummy_blocks(), C3D_RENDER_RAYTRACING::create_3d_object_from(), CROUNDSEGMENT2D::CROUNDSEGMENT2D(), extractPathsFrom(), CROUNDSEGMENT2D::Intersects(), CFILLEDCIRCLE2D::IsBBoxInside(), CROUNDSEGMENT2D::IsBBoxInside(), and Set().

176 { return m_min; }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
float CBBOX2D::Perimeter ( ) const

Function Perimeter.

Returns
the surface are of the box

Definition at line 144 of file cbbox2d.cpp.

References GetExtent().

145 {
146  const SFVEC2F extent = GetExtent();
147 
148  return 2.0f * ( extent.x + extent.y );
149 }
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
SFVEC2F GetExtent() const
Function GetExtent.
Definition: cbbox2d.cpp:127
void CBBOX2D::Reset ( )

Function Reset reset the bounding box to zero and de-initialized it.

Definition at line 88 of file cbbox2d.cpp.

References m_max, and m_min.

Referenced by CBBOX2D(), CBVHCONTAINER2D::CBVHCONTAINER2D(), CFILLEDCIRCLE2D::CFILLEDCIRCLE2D(), CGENERICCONTAINER2D::CGENERICCONTAINER2D(), CINFO3D_VISU::CINFO3D_VISU(), CITEMLAYERCSG2D::CITEMLAYERCSG2D(), CGENERICCONTAINER2D::Clear(), Convert_path_polygon_to_polygon_blocks_and_dummy_blocks(), CPOLYGON4PTS2D::CPOLYGON4PTS2D(), CPOLYGONBLOCK2D::CPOLYGONBLOCK2D(), CRING2D::CRING2D(), CROUNDSEGMENT2D::CROUNDSEGMENT2D(), CTRIANGLE2D::CTRIANGLE2D(), Polygon_Calc_BBox_3DU(), Polygon_Convert(), and CBVHCONTAINER2D::recursiveBuild_MIDDLE_SPLIT().

89 {
90  m_min = SFVEC2F( FLT_MAX, FLT_MAX );
91  m_max = SFVEC2F(-FLT_MAX,-FLT_MAX );
92 }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
void CBBOX2D::Scale ( float  aScale)

Function Scale scales a bounding box by its center.

Parameters
aScalescale factor to apply

Definition at line 152 of file cbbox2d.cpp.

References GetCenter(), IsInitialized(), m_max, and m_min.

153 {
154  wxASSERT( IsInitialized() );
155 
156  const SFVEC2F scaleV( aScale, aScale );
157  const SFVEC2F centerV = GetCenter();
158 
159  m_min = (m_min - centerV) * scaleV + centerV;
160  m_max = (m_max - centerV) * scaleV + centerV;
161 }
bool IsInitialized() const
Function IsInitialized check if this bounding box is already initialized.
Definition: cbbox2d.cpp:79
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
SFVEC2F GetCenter() const
Function GetCenter return the center point of the bounding box.
Definition: cbbox2d.cpp:121
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
void CBBOX2D::ScaleNextDown ( )

Function ScaleNextDown scales a bounding box to the next float representation making it smaller.

Definition at line 174 of file cbbox2d.cpp.

References m_max, m_min, NextFloatDown(), and NextFloatUp().

175 {
176  m_min.x = NextFloatUp( m_min.x );
177  m_min.y = NextFloatUp( m_min.y );
178 
179  m_max.x = NextFloatDown( m_max.x );
180  m_max.y = NextFloatDown( m_max.y );
181 }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
float NextFloatDown(float v)
Definition: 3d_fastmath.h:157
float NextFloatUp(float v)
Definition: 3d_fastmath.h:136
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
void CBBOX2D::ScaleNextUp ( )

Function ScaleNextUp scales a bounding box to the next float representation making it larger.

Definition at line 164 of file cbbox2d.cpp.

References m_max, m_min, NextFloatDown(), and NextFloatUp().

Referenced by CDUMMYBLOCK2D::CDUMMYBLOCK2D(), CFILLEDCIRCLE2D::CFILLEDCIRCLE2D(), CITEMLAYERCSG2D::CITEMLAYERCSG2D(), CLAYERITEM::CLAYERITEM(), Convert_path_polygon_to_polygon_blocks_and_dummy_blocks(), CPOLYGON4PTS2D::CPOLYGON4PTS2D(), CPOLYGONBLOCK2D::CPOLYGONBLOCK2D(), CRING2D::CRING2D(), CROUNDSEGMENT2D::CROUNDSEGMENT2D(), CTRIANGLE2D::CTRIANGLE2D(), Polygon_Calc_BBox_3DU(), and Polygon_Convert().

165 {
166  m_min.x = NextFloatDown( m_min.x );
167  m_min.y = NextFloatDown( m_min.y );
168 
169  m_max.x = NextFloatUp( m_max.x );
170  m_max.y = NextFloatUp( m_max.y );
171 }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
float NextFloatDown(float v)
Definition: 3d_fastmath.h:157
float NextFloatUp(float v)
Definition: 3d_fastmath.h:136
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
void CBBOX2D::Set ( const SFVEC2F aPbMin,
const SFVEC2F aPbMax 
)

Function Set Set bounding box with new parameters.

Parameters
aPbMinthe minimun point to initialize the bounding box
aPbMaxthe maximun point to initialize the bounding box

Definition at line 61 of file cbbox2d.cpp.

References m_max, and m_min.

Referenced by CBBOX2D(), CDUMMYBLOCK2D::CDUMMYBLOCK2D(), CFILLEDCIRCLE2D::CFILLEDCIRCLE2D(), CITEMLAYERCSG2D::CITEMLAYERCSG2D(), CRING2D::CRING2D(), CROUNDSEGMENT2D::CROUNDSEGMENT2D(), and Set().

62 {
63  m_min.x = fminf( aPbMin.x, aPbMax.x );
64  m_min.y = fminf( aPbMin.y, aPbMax.y );
65 
66  m_max.x = fmaxf( aPbMin.x, aPbMax.x );
67  m_max.y = fmaxf( aPbMin.y, aPbMax.y );
68 }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
void CBBOX2D::Set ( const CBBOX2D aBBox)

Function Set Set bounding box based on another bounding box.

Parameters
CBBOX2Da bounding box to initialize this one

Definition at line 71 of file cbbox2d.cpp.

References IsInitialized(), Max(), Min(), and Set().

72 {
73  wxASSERT( aBBox.IsInitialized() );
74 
75  Set( aBBox.Min(), aBBox.Max() );
76 }
bool IsInitialized() const
Function IsInitialized check if this bounding box is already initialized.
Definition: cbbox2d.cpp:79
void Set(const SFVEC2F &aPbMin, const SFVEC2F &aPbMax)
Function Set Set bounding box with new parameters.
Definition: cbbox2d.cpp:61
const SFVEC2F & Min() const
Function Min return the minimun vertex pointer.
Definition: cbbox2d.h:176
const SFVEC2F & Max() const
Function Max return the maximum vertex pointer.
Definition: cbbox2d.h:183
void CBBOX2D::Union ( const SFVEC2F aPoint)

Function Union recalculate the bounding box adding a point.

Parameters
aPointthe point to be bounded

Definition at line 95 of file cbbox2d.cpp.

References m_max, and m_min.

Referenced by CGENERICCONTAINER2D::Add(), Convert_path_polygon_to_polygon_blocks_and_dummy_blocks(), CPOLYGON4PTS2D::CPOLYGON4PTS2D(), CPOLYGONBLOCK2D::CPOLYGONBLOCK2D(), CTRIANGLE2D::CTRIANGLE2D(), Polygon_Calc_BBox_3DU(), Polygon_Convert(), and CBVHCONTAINER2D::recursiveBuild_MIDDLE_SPLIT().

96 {
97  // get the minimun value between the added point and the existent bounding box
98  m_min.x = fminf( m_min.x, aPoint.x );
99  m_min.y = fminf( m_min.y, aPoint.y );
100 
101  // get the maximun value between the added point and the existent bounding box
102  m_max.x = fmaxf( m_max.x, aPoint.x );
103  m_max.y = fmaxf( m_max.y, aPoint.y );
104 }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211
void CBBOX2D::Union ( const CBBOX2D aBBox)

Function Union recalculate the bounding box adding other bounding box.

Parameters
aBBoxthe bounding box to be bounded

Definition at line 107 of file cbbox2d.cpp.

References m_max, and m_min.

108 {
109  // get the minimun value between the added bounding box and
110  // the existent bounding box
111  m_min.x = fminf( m_min.x, aBBox.m_min.x );
112  m_min.y = fminf( m_min.y, aBBox.m_min.y );
113 
114  // get the maximun value between the added bounding box and
115  // the existent bounding box
116  m_max.x = fmaxf( m_max.x, aBBox.m_max.x );
117  m_max.y = fmaxf( m_max.y, aBBox.m_max.y );
118 }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: cbbox2d.h:212
SFVEC2F m_min
point of the lower position of the bounding box
Definition: cbbox2d.h:211

Member Data Documentation

SFVEC2F CBBOX2D::m_max
private

point of the higher position of the bounding box

Definition at line 212 of file cbbox2d.h.

Referenced by CBBOX2D(), GetCenter(), GetExtent(), Inside(), Intersect(), Intersects(), IsInitialized(), Max(), Reset(), Scale(), ScaleNextDown(), ScaleNextUp(), Set(), and Union().

SFVEC2F CBBOX2D::m_min
private

point of the lower position of the bounding box

Definition at line 211 of file cbbox2d.h.

Referenced by CBBOX2D(), GetCenter(), GetExtent(), Inside(), Intersect(), Intersects(), IsInitialized(), Min(), Reset(), Scale(), ScaleNextDown(), ScaleNextUp(), Set(), and Union().


The documentation for this struct was generated from the following files: