KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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).
 
 BBOX_2D (const SFVEC2F &aPbInit)
 Initialize a bounding box with a given point.
 
 BBOX_2D (const SFVEC2F &aPbMin, const SFVEC2F &aPbMax)
 Initialize a bounding box with a minimum and a maximum point.
 
 ~BBOX_2D ()
 
void Set (const SFVEC2F &aPbMin, const SFVEC2F &aPbMax)
 Set bounding box with new parameters.
 
void Set (const BBOX_2D &aBBox)
 Set bounding box based on another bounding box.
 
void Union (const SFVEC2F &aPoint)
 Recalculate the bounding box adding a point.
 
void Union (const BBOX_2D &aBBox)
 Recalculate the bounding box adding other bounding box.
 
void Scale (float aScale)
 Scale a bounding box by its center.
 
void ScaleNextUp ()
 Scale a bounding box to the next float representation making it larger.
 
void ScaleNextDown ()
 Scale a bounding box to the next float representation making it smaller.
 
bool Intersects (const BBOX_2D &aBBox) const
 Test if a bounding box intersects this box.
 
bool Intersects (const SFVEC2F &aCenter, float aRadiusSquared) const
 Test if a circle intersects this box.
 
bool Inside (const SFVEC2F &aPoint) const
 Check is a point is inside this bounding box.
 
bool Inside (const BBOX_2D &aBBox) const
 Check if a bounding box is inside this bounding box.
 
float Area () const
 Calculate the area of a bounding box.
 
bool IsInitialized () const
 Check if this bounding box is already initialized.
 
void Reset ()
 Reset the bounding box to zero and uninitialize it.
 
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
 
SFVEC2F m_max
 point of the higher position of the bounding box
 

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.

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.

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.

References Set().

◆ ~BBOX_2D()

BBOX_2D::~BBOX_2D ( )

Definition at line 56 of file bbox_2d.cpp.

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 242 of file bbox_2d.cpp.

References GetExtent().

◆ GetCenter()

◆ GetExtent()

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

Definition at line 125 of file bbox_2d.cpp.

References m_max, and m_min.

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

◆ Inside() [1/2]

bool BBOX_2D::Inside ( const BBOX_2D aBBox) const

Check if a bounding box is inside this bounding box.

Parameters
aBBoxthe bounding box to test if it is inside
Returns
true if aBBox is smaller and all points are inside

Definition at line 232 of file bbox_2d.cpp.

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

◆ Inside() [2/2]

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.

References IsInitialized(), m_max, and m_min.

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

◆ Intersect() [1/3]

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

Definition at line 300 of file bbox_2d.cpp.

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

◆ Intersect() [2/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 250 of file bbox_2d.cpp.

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

Referenced by BVH_CONTAINER_2D::recursiveIntersectAny().

◆ Intersect() [3/3]

bool BBOX_2D::Intersect ( const RAYSEG2D aRaySeg) const

Definition at line 275 of file bbox_2d.cpp.

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

◆ Intersects() [1/2]

◆ 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.

References m_max, and m_min.

◆ IsInitialized()

◆ Max()

◆ 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.

References GetExtent().

Referenced by BVH_CONTAINER_2D::recursiveBuild_MIDDLE_SPLIT().

◆ Min()

◆ Perimeter()

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

Definition at line 142 of file bbox_2d.cpp.

References GetExtent().

◆ Reset()

◆ 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.

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.

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

◆ ScaleNextUp()

◆ Set() [1/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.

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

◆ Set() [2/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.

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().

◆ Union() [1/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.

References m_max, and m_min.

◆ Union() [2/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.

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().

Member Data Documentation

◆ m_max

SFVEC2F BBOX_2D::m_max
private

point of the higher position of the bounding box

Definition at line 206 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 205 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: