KiCad PCB EDA Suite
Loading...
Searching...
No Matches
BBOX_3D Struct Reference

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

#include <bbox_3d.h>

Public Member Functions

 BBOX_3D ()
 Create with default values a bounding box (not initialized)
 
 BBOX_3D (const SFVEC3F &aPbInit)
 Initialize a bounding box with a given point.
 
 BBOX_3D (const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
 Initialize a bounding box with a minimum and a maximum point.
 
 ~BBOX_3D ()
 
void Set (const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
 Set bounding box with new parameters.
 
void Set (const BBOX_3D &aBBox)
 
void Set (const SFVEC3F &aPoint)
 Set bounding box to one point.
 
void Union (const SFVEC3F &aPoint)
 Recalculate the bounding box adding a point.
 
void Union (const BBOX_3D &aBBox)
 Recalculate the bounding box adding other bounding box.
 
void Scale (float aScale)
 Scales 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_3D &aBBox) const
 Test if a bounding box intersects this box.
 
bool Inside (const SFVEC3F &aPoint) const
 Check if a point is inside this bounding box.
 
bool Inside (const BBOX_3D &aBBox) const
 Check if a bounding box is inside this bounding box.
 
void ApplyTransformation (glm::mat4 aTransformMatrix)
 Apply a transformation matrix to the box points.
 
float Volume () const
 Calculate the volume of a bounding box.
 
bool IsInitialized () const
 Check if this bounding box is already initialized.
 
void Reset ()
 Reset the bounding box to zero and de-initialize it.
 
SFVEC3F GetCenter () const
 Return the center point of the bounding box.
 
float GetCenter (unsigned int aAxis) const
 Return the center point of the bounding box for one axis (0, 1 or 2).
 
SFVEC3F Offset (const SFVEC3F &p) const
 
const SFVEC3F GetExtent () const
 
const SFVEC3FMin () const
 Return the minimum vertex pointer.
 
const SFVEC3FMax () const
 Return the maximum vertex pointer.
 
unsigned int MaxDimension () const
 
float GetMaxDimension () const
 
float SurfaceArea () const
 
bool Intersect (const RAY &aRay, float *t) const
 
bool Intersect (const RAY &aRay) const
 
bool Intersect (const RAY &aRay, float *aOutHitt0, float *aOutHitt1) const
 Fetch the enter and exit position when a ray starts inside the bounding box.
 

Private Attributes

SFVEC3F m_min
 (12) point of the lower position of the bounding box
 
SFVEC3F m_max
 (12) point of the higher position of the bounding box
 

Detailed Description

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

Definition at line 42 of file bbox_3d.h.

Constructor & Destructor Documentation

◆ BBOX_3D() [1/3]

BBOX_3D::BBOX_3D ( )

Create with default values a bounding box (not initialized)

Definition at line 37 of file bbox_3d.cpp.

References Reset().

◆ BBOX_3D() [2/3]

BBOX_3D::BBOX_3D ( const SFVEC3F 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_3d.cpp.

References m_max, and m_min.

◆ BBOX_3D() [3/3]

BBOX_3D::BBOX_3D ( const SFVEC3F aPbMin,
const SFVEC3F 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_3d.cpp.

References Set().

◆ ~BBOX_3D()

BBOX_3D::~BBOX_3D ( )

Definition at line 56 of file bbox_3d.cpp.

Member Function Documentation

◆ ApplyTransformation()

void BBOX_3D::ApplyTransformation ( glm::mat4  aTransformMatrix)

Apply a transformation matrix to the box points.

Parameters
aTransformMatrixmatrix to apply to the points of the bounding box

Definition at line 306 of file bbox_3d.cpp.

References IsInitialized(), m_max, m_min, Reset(), Union(), v1, and v2.

◆ GetCenter() [1/2]

SFVEC3F BBOX_3D::GetCenter ( ) const

◆ GetCenter() [2/2]

float BBOX_3D::GetCenter ( unsigned int  aAxis) const

Return the center point of the bounding box for one axis (0, 1 or 2).

Returns
float - the position of the center of this bounding box for the axis

Definition at line 138 of file bbox_3d.cpp.

References m_max, and m_min.

◆ GetExtent()

const SFVEC3F BBOX_3D::GetExtent ( ) const
Returns
SFVEC3F - max-min.

Definition at line 145 of file bbox_3d.cpp.

References m_max, and m_min.

Referenced by GetMaxDimension(), LAYER_ITEM::Intersect(), MaxDimension(), SurfaceArea(), Volume(), and XY_PLANE::XY_PLANE().

◆ GetMaxDimension()

float BBOX_3D::GetMaxDimension ( ) const
Returns
the max dimension.

Definition at line 167 of file bbox_3d.cpp.

References GetExtent().

Referenced by EDA_3D_MODEL_VIEWER::OnPaint(), and RENDER_3D_RAYTRACE_BASE::Reload().

◆ Inside() [1/2]

bool BBOX_3D::Inside ( const BBOX_3D 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 241 of file bbox_3d.cpp.

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

◆ Inside() [2/2]

bool BBOX_3D::Inside ( const SFVEC3F aPoint) const

Check if a point is inside this bounding box.

Parameters
aPointpoint to test.

Definition at line 231 of file bbox_3d.cpp.

References IsInitialized(), m_max, and m_min.

Referenced by Inside(), and LAYER_ITEM::Intersect().

◆ Intersect() [1/3]

bool BBOX_3D::Intersect ( const RAY aRay) const

◆ Intersect() [2/3]

bool BBOX_3D::Intersect ( const RAY aRay,
float *  aOutHitt0,
float *  aOutHitt1 
) const

Fetch the enter and exit position when a ray starts inside the bounding box.

Parameters
aRayThe ray to intersect the box.
aOutHitt0The distance point of the ray of the intersection (if true).
aOutHitt1The distance point of the ray of the exit (if true).
Returns
true if the ray hits the box

Definition at line 268 of file bbox_3d.cpp.

References RAY::m_dirIsNeg, RAY::m_InvDir, m_max, m_min, and RAY::m_Origin.

◆ Intersect() [3/3]

bool BBOX_3D::Intersect ( const RAY aRay,
float *  t 
) const

◆ Intersects()

bool BBOX_3D::Intersects ( const BBOX_3D aBBox) const

Test if a bounding box intersects this box.

Parameters
aBBoxthe bounding box to check if it intersects.

Definition at line 218 of file bbox_3d.cpp.

References IsInitialized(), m_max, and m_min.

Referenced by CYLINDER::Intersects(), DUMMY_BLOCK::Intersects(), LAYER_ITEM::Intersects(), XY_PLANE::Intersects(), ROUND_SEGMENT::Intersects(), and TRIANGLE::Intersects().

◆ IsInitialized()

bool BBOX_3D::IsInitialized ( ) const

Check if this bounding box is already initialized.

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

Definition at line 88 of file bbox_3d.cpp.

References m_max, and m_min.

Referenced by ApplyTransformation(), DrawBoundingBox(), Inside(), Intersects(), MODEL_3D::MODEL_3D(), RENDER_3D_RAYTRACE_BASE::Reload(), Scale(), Set(), Union(), and Volume().

◆ Max()

◆ MaxDimension()

unsigned int BBOX_3D::MaxDimension ( ) const
Returns
the index of the max dimension (0=x, 1=y, 2=z).

Definition at line 151 of file bbox_3d.cpp.

References GetExtent().

Referenced by BVH_PBRT::buildUpperSAH(), and BVH_PBRT::recursiveBuild().

◆ Min()

◆ Offset()

SFVEC3F BBOX_3D::Offset ( const SFVEC3F p) const
Returns
SFVEC3F - return the offset relative to max-min.

Definition at line 261 of file bbox_3d.cpp.

References m_max, and m_min.

Referenced by BVH_PBRT::HLBVHBuild(), and BVH_PBRT::recursiveBuild().

◆ Reset()

◆ Scale()

void BBOX_3D::Scale ( float  aScale)

Scales a bounding box by its center.

Parameters
aScalescale factor to apply.

Definition at line 182 of file bbox_3d.cpp.

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

Referenced by LAYER_ITEM::LAYER_ITEM(), and RENDER_3D_RAYTRACE_BASE::Reload().

◆ ScaleNextDown()

void BBOX_3D::ScaleNextDown ( )

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

Definition at line 206 of file bbox_3d.cpp.

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

◆ ScaleNextUp()

void BBOX_3D::ScaleNextUp ( )

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

Definition at line 194 of file bbox_3d.cpp.

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

Referenced by CYLINDER::CYLINDER(), LAYER_ITEM::LAYER_ITEM(), TRIANGLE::pre_calc_const(), and ROUND_SEGMENT::ROUND_SEGMENT().

◆ Set() [1/3]

void BBOX_3D::Set ( const BBOX_3D aBBox)

Definition at line 80 of file bbox_3d.cpp.

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

◆ Set() [2/3]

void BBOX_3D::Set ( const SFVEC3F aPbMin,
const SFVEC3F aPbMax 
)

Set bounding box with new parameters.

Parameters
aPbMinthe minimum point to set for the bounding box.
aPbMaxthe maximum point to set for the bounding box.

Definition at line 68 of file bbox_3d.cpp.

References m_max, and m_min.

Referenced by BBOX_3D(), CYLINDER::CYLINDER(), DUMMY_BLOCK::DUMMY_BLOCK(), BVHBuildNode::InitInterior(), LAYER_ITEM::LAYER_ITEM(), TRIANGLE::pre_calc_const(), ROUND_SEGMENT::ROUND_SEGMENT(), Set(), and XY_PLANE::XY_PLANE().

◆ Set() [3/3]

void BBOX_3D::Set ( const SFVEC3F aPoint)

Set bounding box to one point.

Parameters
aPointthe single point to set the bounding box to.

Definition at line 61 of file bbox_3d.cpp.

References m_max, and m_min.

◆ SurfaceArea()

float BBOX_3D::SurfaceArea ( ) const
Returns
the surface area of the box.

Definition at line 174 of file bbox_3d.cpp.

References GetExtent().

Referenced by BVH_PBRT::buildUpperSAH(), and BVH_PBRT::recursiveBuild().

◆ Union() [1/2]

void BBOX_3D::Union ( const BBOX_3D aBBox)

Recalculate the bounding box adding other bounding box.

Parameters
aBBoxthe bounding box to be bounded.

Definition at line 116 of file bbox_3d.cpp.

References IsInitialized(), m_max, and m_min.

◆ Union() [2/2]

void BBOX_3D::Union ( const SFVEC3F aPoint)

Recalculate the bounding box adding a point.

Parameters
aPointthe point to be bounded.

Definition at line 102 of file bbox_3d.cpp.

References m_max, and m_min.

Referenced by CONTAINER_3D_BASE::Add(), ApplyTransformation(), BVH_PBRT::buildUpperSAH(), BVH_PBRT::emitLBVH(), BVH_PBRT::HLBVHBuild(), BVHBuildNode::InitInterior(), MODEL_3D::MODEL_3D(), TRIANGLE::pre_calc_const(), and BVH_PBRT::recursiveBuild().

◆ Volume()

float BBOX_3D::Volume ( ) const

Calculate the volume of a bounding box.

Returns
float - volume of this bounding box.

Definition at line 251 of file bbox_3d.cpp.

References GetExtent(), and IsInitialized().

Member Data Documentation

◆ m_max

SFVEC3F BBOX_3D::m_max
private

(12) point of the higher position of the bounding box

Definition at line 238 of file bbox_3d.h.

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

◆ m_min

SFVEC3F BBOX_3D::m_min
private

(12) point of the lower position of the bounding box

Definition at line 237 of file bbox_3d.h.

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


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