KiCad PCB EDA Suite
BBOX_2D Struct Reference

Manage a bounding box defined by two SFVEC2F min max points. More...

#include <bbox_2d.h>

Public Member Functions

 BBOX_2D ()
 Create with default values a bounding box (not initialized). More...
 
 BBOX_2D (const SFVEC2F &aPbInit)
 Initialize a bounding box with a given point. More...
 
 BBOX_2D (const SFVEC2F &aPbMin, const SFVEC2F &aPbMax)
 Initialize a bounding box with a minimum and a maximum point. More...
 
 ~BBOX_2D ()
 
void Set (const SFVEC2F &aPbMin, const SFVEC2F &aPbMax)
 Set bounding box with new parameters. More...
 
void Set (const BBOX_2D &aBBox)
 Set bounding box based on another bounding box. More...
 
void Union (const SFVEC2F &aPoint)
 Recalculate the bounding box adding a point. More...
 
void Union (const BBOX_2D &aBBox)
 Recalculate the bounding box adding other bounding box. More...
 
void Scale (float aScale)
 Scale a bounding box by its center. More...
 
void ScaleNextUp ()
 Scale a bounding box to the next float representation making it larger. More...
 
void ScaleNextDown ()
 Scale a bounding box to the next float representation making it smaller. More...
 
bool Intersects (const BBOX_2D &aBBox) const
 Test if a bounding box intersects this box. More...
 
bool Intersects (const SFVEC2F &aCenter, float aRadiusSquared) const
 Test if a circle intersects this box. More...
 
bool Inside (const SFVEC2F &aPoint) const
 Check is a point is inside this bounding box. More...
 
float Area () const
 Calculate the area of a bounding box. More...
 
bool IsInitialized () const
 Check if this bounding box is already initialized. More...
 
void Reset ()
 Reset the bounding box to zero and uninitialize it. More...
 
SFVEC2F GetCenter () const
 
SFVEC2F GetExtent () const
 
const SFVEC2FMin () const
 
const SFVEC2FMax () const
 
unsigned int MaxDimension () const
 
float Perimeter () const
 
bool Intersect (const RAY2D &aRay, float *t) const
 
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

Manage a bounding box defined by two SFVEC2F min max points.

Definition at line 41 of file bbox_2d.h.

Constructor & Destructor Documentation

◆ BBOX_2D() [1/3]

BBOX_2D::BBOX_2D ( )

Create with default values a bounding box (not initialized).

Definition at line 37 of file bbox_2d.cpp.

38 {
39  Reset();
40 }
void Reset()
Reset the bounding box to zero and uninitialize it.
Definition: bbox_2d.cpp:86

References Reset().

◆ BBOX_2D() [2/3]

BBOX_2D::BBOX_2D ( const SFVEC2F aPbInit)
explicit

Initialize a bounding box with a given point.

Parameters
aPbInita point for the bounding box initialization.

Definition at line 43 of file bbox_2d.cpp.

44 {
45  m_min = aPbInit;
46  m_max = aPbInit;
47 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198

References m_max, and m_min.

◆ BBOX_2D() [3/3]

BBOX_2D::BBOX_2D ( const SFVEC2F aPbMin,
const SFVEC2F aPbMax 
)

Initialize a bounding box with a minimum and a maximum point.

Parameters
aPbMinthe minimum point to initialize the bounding box.
aPbMaxthe maximum point to initialize the bounding box.

Definition at line 50 of file bbox_2d.cpp.

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

References Set().

◆ ~BBOX_2D()

BBOX_2D::~BBOX_2D ( )

Definition at line 56 of file bbox_2d.cpp.

57 {
58 }

Member Function Documentation

◆ Area()

float BBOX_2D::Area ( ) const

Calculate the area of a bounding box.

Returns
area of this bounding box.

Definition at line 232 of file bbox_2d.cpp.

233 {
234  SFVEC2F extent = GetExtent();
235  return extent.x * extent.y;
236 }
SFVEC2F GetExtent() const
Definition: bbox_2d.cpp:125
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42

References GetExtent().

◆ GetCenter()

SFVEC2F BBOX_2D::GetCenter ( ) const
Returns
the position of the center of this bounding box.

Definition at line 119 of file bbox_2d.cpp.

120 {
121  return ( m_max + m_min ) * 0.5f;
122 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198

References m_max, and m_min.

Referenced by DUMMY_BLOCK_2D::DUMMY_BLOCK_2D(), FILLED_CIRCLE_2D::FILLED_CIRCLE_2D(), LAYER_ITEM_2D::LAYER_ITEM_2D(), POLYGON_2D::POLYGON_2D(), POLYGON_4PT_2D::POLYGON_4PT_2D(), RING_2D::RING_2D(), ROUND_SEGMENT_2D::ROUND_SEGMENT_2D(), Scale(), and TRIANGLE_2D::TRIANGLE_2D().

◆ GetExtent()

SFVEC2F BBOX_2D::GetExtent ( ) const
Returns
SFVEC2F - max-min

Definition at line 125 of file bbox_2d.cpp.

126 {
127  return m_max - m_min;
128 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198

References m_max, and m_min.

Referenced by Area(), ConvertPolygonToBlocks(), MaxDimension(), and Perimeter().

◆ Inside()

bool BBOX_2D::Inside ( const SFVEC2F aPoint) const

Check is a point is inside this bounding box.

Parameters
aPointpoint to test.

Definition at line 223 of file bbox_2d.cpp.

224 {
225  wxASSERT( IsInitialized() );
226 
227  return ( ( aPoint.x >= m_min.x ) && ( aPoint.x <= m_max.x ) &&
228  ( aPoint.y >= m_min.y ) && ( aPoint.y <= m_max.y ) );
229 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198
bool IsInitialized() const
Check if this bounding box is already initialized.
Definition: bbox_2d.cpp:79

References IsInitialized(), m_max, and m_min.

Referenced by extractPathsFrom(), DUMMY_BLOCK_2D::IsPointInside(), and BVH_CONTAINER_2D::recursiveIntersectAny().

◆ Intersect() [1/3]

bool BBOX_2D::Intersect ( const RAY2D aRay,
float *  t 
) const
Parameters
aRayis a ray to intersect the box.
tis the distance point of the ray of the intersection (if true).
Returns
true if the ray hits the box.

Definition at line 240 of file bbox_2d.cpp.

241 {
242  wxASSERT( t );
243 
244  const float tx1 = ( m_min.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
245  const float tx2 = ( m_max.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
246 
247  float tmin = glm::min( tx1, tx2 );
248  float tmax = glm::max( tx1, tx2 );
249 
250  const float ty1 = ( m_min.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
251  const float ty2 = ( m_max.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
252 
253  tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
254  tmax = glm::min( tmax, glm::max( ty1, ty2 ) );
255 
256  if( tmin > 0.0f )
257  *t = tmin;
258  else
259  *t = tmax;
260 
261  return (tmax >= 0.0f) && (tmax >= tmin);
262 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
SFVEC2F m_InvDir
Definition: ray.h:102
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198
SFVEC2F m_Origin
Definition: ray.h:100

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

Referenced by BVH_CONTAINER_2D::recursiveIntersectAny().

◆ Intersect() [2/3]

bool BBOX_2D::Intersect ( const RAY2D aRay,
float *  aOutHitT0,
float *  aOutHitT1 
) const

Definition at line 290 of file bbox_2d.cpp.

291 {
292  wxASSERT( aOutHitT0 );
293  wxASSERT( aOutHitT1 );
294 
295  const float tx1 = ( m_min.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
296  const float tx2 = ( m_max.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
297 
298  float tmin = glm::min( tx1, tx2 );
299  float tmax = glm::max( tx1, tx2 );
300 
301  const float ty1 = ( m_min.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
302  const float ty2 = ( m_max.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
303 
304  tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
305  tmax = glm::min( tmax, glm::max( ty1, ty2 ) );
306 
307  *aOutHitT0 = ( tmin > 0.0f ) ? tmin : 0.0f;
308  *aOutHitT1 = tmax;
309 
310  return ( tmax >= 0.0f ) && ( tmax >= tmin );
311 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
SFVEC2F m_InvDir
Definition: ray.h:102
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198
SFVEC2F m_Origin
Definition: ray.h:100

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

◆ Intersect() [3/3]

bool BBOX_2D::Intersect ( const RAYSEG2D aRaySeg) const

Definition at line 265 of file bbox_2d.cpp.

266 {
267  const float tx1 = (m_min.x - aRaySeg.m_Start.x) * aRaySeg.m_InvDir.x;
268  const float tx2 = (m_max.x - aRaySeg.m_Start.x) * aRaySeg.m_InvDir.x;
269 
270  float tmin = glm::min( tx1, tx2 );
271  float tmax = glm::max( tx1, tx2 );
272 
273  const float ty1 = (m_min.y - aRaySeg.m_Start.y) * aRaySeg.m_InvDir.y;
274  const float ty2 = (m_max.y - aRaySeg.m_Start.y) * aRaySeg.m_InvDir.y;
275 
276  tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
277  tmax = glm::min( tmax, glm::max( ty1, ty2 ) );
278 
279  if( (tmax >= 0.0f) && (tmax >= tmin) )
280  {
281  const float t = (tmin > 0.0f)?tmin:tmax;
282 
283  return ( t < aRaySeg.m_Length );
284  }
285 
286  return false;
287 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
float m_Length
Definition: ray.h:117
SFVEC2F m_InvDir
Definition: ray.h:116
SFVEC2F m_Start
Definition: ray.h:112
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198

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

◆ Intersects() [1/2]

bool BBOX_2D::Intersects ( const BBOX_2D aBBox) const

Test if a bounding box intersects this box.

Parameters
aBBoxthe bounding box to check if it intersects.

Definition at line 211 of file bbox_2d.cpp.

212 {
213  wxASSERT( IsInitialized() );
214  wxASSERT( aBBox.IsInitialized() );
215 
216  const bool x = ( m_max.x >= aBBox.m_min.x ) && ( m_min.x <= aBBox.m_max.x );
217  const bool y = ( m_max.y >= aBBox.m_min.y ) && ( m_min.y <= aBBox.m_max.y );
218 
219  return ( x && y );
220 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198
bool IsInitialized() const
Check if this bounding box is already initialized.
Definition: bbox_2d.cpp:79

References IsInitialized(), m_max, and m_min.

Referenced by extractPathsFrom(), RING_2D::Intersects(), FILLED_CIRCLE_2D::Intersects(), TRIANGLE_2D::Intersects(), POLYGON_4PT_2D::Intersects(), ROUND_SEGMENT_2D::Intersects(), LAYER_ITEM_2D::Intersects(), POLYGON_2D::Intersects(), DUMMY_BLOCK_2D::Intersects(), FILLED_CIRCLE_2D::IsBBoxInside(), TRIANGLE_2D::IsBBoxInside(), ROUND_SEGMENT_2D::IsBBoxInside(), and BVH_CONTAINER_2D::recursiveGetListObjectsIntersects().

◆ Intersects() [2/2]

bool BBOX_2D::Intersects ( const SFVEC2F aCenter,
float  aRadiusSquared 
) const

Test if a circle intersects this box.

Parameters
aBBoxthe bounding box to check if it intersects.

Definition at line 184 of file bbox_2d.cpp.

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

References m_max, and m_min.

◆ IsInitialized()

bool BBOX_2D::IsInitialized ( ) const

Check if this bounding box is already initialized.

Returns
True if it was initialized, otherwise false.

Definition at line 79 of file bbox_2d.cpp.

80 {
81  return !( ( FLT_MAX == m_min.x ) || ( FLT_MAX == m_min.y ) || ( -FLT_MAX == m_max.x )
82  || ( -FLT_MAX == m_max.y ) );
83 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198

References m_max, and m_min.

Referenced by FILLED_CIRCLE_2D::FILLED_CIRCLE_2D(), BVH_CONTAINER_2D::GetIntersectingObjects(), Inside(), Intersects(), LAYER_ITEM_2D::LAYER_ITEM_2D(), POLYGON_2D::POLYGON_2D(), POLYGON_4PT_2D::POLYGON_4PT_2D(), BVH_CONTAINER_2D::recursiveBuild_MIDDLE_SPLIT(), BVH_CONTAINER_2D::recursiveGetListObjectsIntersects(), RING_2D::RING_2D(), ROUND_SEGMENT_2D::ROUND_SEGMENT_2D(), Scale(), Set(), and TRIANGLE_2D::TRIANGLE_2D().

◆ Max()

const SFVEC2F& BBOX_2D::Max ( ) const
inline
Returns
the maximum vertex position.

Definition at line 172 of file bbox_2d.h.

172 { return m_max; }
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198

References m_max.

Referenced by ConvertPolygonToBlocks(), RENDER_3D_RAYTRACE::createObject(), extractPathsFrom(), ROUND_SEGMENT_2D::Intersects(), FILLED_CIRCLE_2D::IsBBoxInside(), ROUND_SEGMENT_2D::IsBBoxInside(), LAYER_ITEM::LAYER_ITEM(), ROUND_SEGMENT_2D::ROUND_SEGMENT_2D(), and Set().

◆ MaxDimension()

unsigned int BBOX_2D::MaxDimension ( ) const
Returns
the index of the max dimension (0=x, 1=y)

Definition at line 131 of file bbox_2d.cpp.

132 {
133  unsigned int result = 0;
134  const SFVEC2F extent = GetExtent();
135 
136  if( extent.y > extent.x ) result = 1;
137 
138  return result;
139 }
SFVEC2F GetExtent() const
Definition: bbox_2d.cpp:125
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42

References GetExtent().

Referenced by BVH_CONTAINER_2D::recursiveBuild_MIDDLE_SPLIT().

◆ Min()

const SFVEC2F& BBOX_2D::Min ( ) const
inline
Returns
the minimum vertex position.

Definition at line 167 of file bbox_2d.h.

167 { return m_min; }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197

References m_min.

Referenced by ConvertPolygonToBlocks(), RENDER_3D_RAYTRACE::createObject(), extractPathsFrom(), ROUND_SEGMENT_2D::Intersects(), FILLED_CIRCLE_2D::IsBBoxInside(), ROUND_SEGMENT_2D::IsBBoxInside(), LAYER_ITEM::LAYER_ITEM(), ROUND_SEGMENT_2D::ROUND_SEGMENT_2D(), and Set().

◆ Perimeter()

float BBOX_2D::Perimeter ( ) const
Returns
the surface area of the box.

Definition at line 142 of file bbox_2d.cpp.

143 {
144  const SFVEC2F extent = GetExtent();
145 
146  return 2.0f * ( extent.x + extent.y );
147 }
SFVEC2F GetExtent() const
Definition: bbox_2d.cpp:125
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42

References GetExtent().

◆ Reset()

void BBOX_2D::Reset ( )

Reset the bounding box to zero and uninitialize it.

Definition at line 86 of file bbox_2d.cpp.

87 {
88  m_min = SFVEC2F( FLT_MAX, FLT_MAX );
89  m_max = SFVEC2F( -FLT_MAX,-FLT_MAX );
90 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198

References m_max, and m_min.

Referenced by BBOX_2D(), BVH_CONTAINER_2D::BVH_CONTAINER_2D(), CONTAINER_2D_BASE::Clear(), CONTAINER_2D_BASE::CONTAINER_2D_BASE(), ConvertPolygonToBlocks(), FILLED_CIRCLE_2D::FILLED_CIRCLE_2D(), LAYER_ITEM_2D::LAYER_ITEM_2D(), POLYGON_2D::POLYGON_2D(), POLYGON_4PT_2D::POLYGON_4PT_2D(), BVH_CONTAINER_2D::recursiveBuild_MIDDLE_SPLIT(), RING_2D::RING_2D(), ROUND_SEGMENT_2D::ROUND_SEGMENT_2D(), and TRIANGLE_2D::TRIANGLE_2D().

◆ Scale()

void BBOX_2D::Scale ( float  aScale)

Scale a bounding box by its center.

Parameters
aScalescale factor to apply

Definition at line 150 of file bbox_2d.cpp.

151 {
152  wxASSERT( IsInitialized() );
153 
154  const SFVEC2F scaleV( aScale, aScale );
155  const SFVEC2F centerV = GetCenter();
156 
157  m_min = ( m_min - centerV ) * scaleV + centerV;
158  m_max = ( m_max - centerV ) * scaleV + centerV;
159 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
SFVEC2F GetCenter() const
Definition: bbox_2d.cpp:119
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198
bool IsInitialized() const
Check if this bounding box is already initialized.
Definition: bbox_2d.cpp:79

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

◆ ScaleNextDown()

void BBOX_2D::ScaleNextDown ( )

Scale a bounding box to the next float representation making it smaller.

Definition at line 172 of file bbox_2d.cpp.

173 {
174  m_min.x = NextFloatUp( m_min.x );
175  m_min.y = NextFloatUp( m_min.y );
176 
177  m_max.x = NextFloatDown( m_max.x );
178  m_max.y = NextFloatDown( m_max.y );
179 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
float NextFloatDown(float v)
Definition: 3d_fastmath.h:157
float NextFloatUp(float v)
Definition: 3d_fastmath.h:136
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198

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

◆ ScaleNextUp()

void BBOX_2D::ScaleNextUp ( )

Scale a bounding box to the next float representation making it larger.

Definition at line 162 of file bbox_2d.cpp.

163 {
164  m_min.x = NextFloatDown( m_min.x );
165  m_min.y = NextFloatDown( m_min.y );
166 
167  m_max.x = NextFloatUp( m_max.x );
168  m_max.y = NextFloatUp( m_max.y );
169 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
float NextFloatDown(float v)
Definition: 3d_fastmath.h:157
float NextFloatUp(float v)
Definition: 3d_fastmath.h:136
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198

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

Referenced by ConvertPolygonToBlocks(), DUMMY_BLOCK_2D::DUMMY_BLOCK_2D(), FILLED_CIRCLE_2D::FILLED_CIRCLE_2D(), LAYER_ITEM::LAYER_ITEM(), LAYER_ITEM_2D::LAYER_ITEM_2D(), POLYGON_2D::POLYGON_2D(), POLYGON_4PT_2D::POLYGON_4PT_2D(), RING_2D::RING_2D(), ROUND_SEGMENT_2D::ROUND_SEGMENT_2D(), and TRIANGLE_2D::TRIANGLE_2D().

◆ Set() [1/2]

void BBOX_2D::Set ( const SFVEC2F aPbMin,
const SFVEC2F aPbMax 
)

Set bounding box with new parameters.

Parameters
aPbMinthe minimum point to initialize the bounding box.
aPbMaxthe maximum point to initialize the bounding box.

Definition at line 61 of file bbox_2d.cpp.

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_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198

References m_max, and m_min.

Referenced by BBOX_2D(), DUMMY_BLOCK_2D::DUMMY_BLOCK_2D(), FILLED_CIRCLE_2D::FILLED_CIRCLE_2D(), LAYER_ITEM_2D::LAYER_ITEM_2D(), RING_2D::RING_2D(), ROUND_SEGMENT_2D::ROUND_SEGMENT_2D(), and Set().

◆ Set() [2/2]

void BBOX_2D::Set ( const BBOX_2D aBBox)

Set bounding box based on another bounding box.

Parameters
BBOX_2Da bounding box to initialize this one.

Definition at line 71 of file bbox_2d.cpp.

72 {
73  wxASSERT( aBBox.IsInitialized() );
74 
75  Set( aBBox.Min(), aBBox.Max() );
76 }
void Set(const SFVEC2F &aPbMin, const SFVEC2F &aPbMax)
Set bounding box with new parameters.
Definition: bbox_2d.cpp:61
const SFVEC2F & Max() const
Definition: bbox_2d.h:172
const SFVEC2F & Min() const
Definition: bbox_2d.h:167
bool IsInitialized() const
Check if this bounding box is already initialized.
Definition: bbox_2d.cpp:79

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

◆ Union() [1/2]

void BBOX_2D::Union ( const SFVEC2F aPoint)

Recalculate the bounding box adding a point.

Parameters
aPointthe point to be bounded

Definition at line 93 of file bbox_2d.cpp.

94 {
95  // get the minimum value between the added point and the existent bounding box
96  m_min.x = fminf( m_min.x, aPoint.x );
97  m_min.y = fminf( m_min.y, aPoint.y );
98 
99  // get the maximum value between the added point and the existent bounding box
100  m_max.x = fmaxf( m_max.x, aPoint.x );
101  m_max.y = fmaxf( m_max.y, aPoint.y );
102 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198

References m_max, and m_min.

Referenced by CONTAINER_2D_BASE::Add(), ConvertPolygonToBlocks(), POLYGON_2D::POLYGON_2D(), POLYGON_4PT_2D::POLYGON_4PT_2D(), BVH_CONTAINER_2D::recursiveBuild_MIDDLE_SPLIT(), and TRIANGLE_2D::TRIANGLE_2D().

◆ Union() [2/2]

void BBOX_2D::Union ( const BBOX_2D aBBox)

Recalculate the bounding box adding other bounding box.

Parameters
aBBoxthe bounding box to be bounded.

Definition at line 105 of file bbox_2d.cpp.

106 {
107  // get the minimum value between the added bounding box and
108  // the existent bounding box
109  m_min.x = fminf( m_min.x, aBBox.m_min.x );
110  m_min.y = fminf( m_min.y, aBBox.m_min.y );
111 
112  // get the maximum value between the added bounding box and
113  // the existent bounding box
114  m_max.x = fmaxf( m_max.x, aBBox.m_max.x );
115  m_max.y = fmaxf( m_max.y, aBBox.m_max.y );
116 }
SFVEC2F m_min
point of the lower position of the bounding box
Definition: bbox_2d.h:197
SFVEC2F m_max
point of the higher position of the bounding box
Definition: bbox_2d.h:198

References m_max, and m_min.

Member Data Documentation

◆ m_max

SFVEC2F BBOX_2D::m_max
private

point of the higher position of the bounding box

Definition at line 198 of file bbox_2d.h.

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

◆ m_min

SFVEC2F BBOX_2D::m_min
private

point of the lower position of the bounding box

Definition at line 197 of file bbox_2d.h.

Referenced by BBOX_2D(), 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: