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

Referenced by Inside(), Intersects(), Set(), and Union().

◆ 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

Return the center point of the bounding box.

Returns
SFVEC3F - the position of the center of this bounding box.

Definition at line 132 of file bbox_3d.cpp.

References m_max, and m_min.

Referenced by MODEL_3D::Draw(), DUMMY_BLOCK::DUMMY_BLOCK(), HLBVH_SAH_Evaluator::operator()(), BVH_PBRT::recursiveBuild(), RENDER_3D_RAYTRACE_BASE::Reload(), RENDER_3D_OPENGL::renderTransparentModels(), Scale(), and XY_PLANE::XY_PLANE().

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

◆ 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 BBOX_3D(), 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().

◆ 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
Parameters
aRayThe ray to intersect the box.
tThe distance point of the ray of the intersection (if true).
Returns
true if the ray hits the box.

Definition at line 46 of file bbox_3d_ray.cpp.

References RAY::c_xy, RAY::c_xz, RAY::c_yx, RAY::c_yz, RAY::c_zx, RAY::c_zy, RAY::ibyj, RAY::ibyk, RAY::jbyi, RAY::jbyk, RAY::kbyi, RAY::kbyj, RAY::m_Classification, RAY::m_InvDir, m_max, m_min, RAY::m_Origin, MMM, MMO, MMP, MOM, MOO, MOP, MPM, MPO, MPP, OMM, OMO, OMP, OOM, OOP, OPM, OPO, OPP, PMM, PMO, PMP, POM, POO, POP, PPM, PPO, and PPP.

Referenced by getFirstHit(), getLastHit(), BVH_PBRT::Intersect(), BVH_PBRT::Intersect(), and BVH_PBRT::IntersectP().

◆ 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 BBOX_3D(), IsInitialized(), m_max, and m_min.

◆ 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(), Inside(), Intersects(), MODEL_3D::MODEL_3D(), RENDER_3D_RAYTRACE_BASE::Reload(), Scale(), Set(), Union(), and Volume().

◆ Max()

const SFVEC3F & BBOX_3D::Max ( ) const
inline

◆ 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(), and result.

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

◆ Min()

const SFVEC3F & BBOX_3D::Min ( ) const
inline

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

void BBOX_3D::Reset ( )

Reset the bounding box to zero and de-initialize it.

Definition at line 95 of file bbox_3d.cpp.

References m_max, and m_min.

Referenced by ApplyTransformation(), BBOX_3D(), BVH_PBRT::buildUpperSAH(), BVH_PBRT::emitLBVH(), BVH_PBRT::HLBVHBuild(), and BVH_PBRT::recursiveBuild().

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

◆ Set() [1/3]

void BBOX_3D::Set ( const BBOX_3D & aBBox)

Definition at line 80 of file bbox_3d.cpp.

References BBOX_3D(), 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(), and Set().

◆ 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 BBOX_3D(), 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 ApplyTransformation(), BVH_PBRT::buildUpperSAH(), BVH_PBRT::emitLBVH(), BVH_PBRT::HLBVHBuild(), MODEL_3D::MODEL_3D(), 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

◆ m_min

SFVEC3F BBOX_3D::m_min
private

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