KiCad PCB EDA Suite
|
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 SFVEC3F & | Min () const |
Return the minimum vertex pointer. | |
const SFVEC3F & | Max () 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 | |
Manage a bounding box defined by two SFVEC3F min max points.
BBOX_3D::BBOX_3D | ( | ) |
Create with default values a bounding box (not initialized)
Definition at line 37 of file bbox_3d.cpp.
References Reset().
|
explicit |
Initialize a bounding box with a given point.
aPbInit | a point for the bounding box initialization. |
Definition at line 43 of file bbox_3d.cpp.
Initialize a bounding box with a minimum and a maximum point.
aPbMin | the minimum point to initialize the bounding box. |
aPbMax | the maximum point to initialize the bounding box. |
Definition at line 50 of file bbox_3d.cpp.
References Set().
BBOX_3D::~BBOX_3D | ( | ) |
Definition at line 56 of file bbox_3d.cpp.
void BBOX_3D::ApplyTransformation | ( | glm::mat4 | aTransformMatrix | ) |
Apply a transformation matrix to the box points.
aTransformMatrix | matrix 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.
SFVEC3F BBOX_3D::GetCenter | ( | ) | const |
Return the center point of the bounding box.
Definition at line 132 of file bbox_3d.cpp.
Referenced by CYLINDER::CYLINDER(), MODEL_3D::Draw(), DUMMY_BLOCK::DUMMY_BLOCK(), EDA_3D_MODEL_VIEWER::OnPaint(), HLBVH_SAH_Evaluator::operator()(), TRIANGLE::pre_calc_const(), BVH_PBRT::recursiveBuild(), RENDER_3D_RAYTRACE_BASE::Reload(), RENDER_3D_OPENGL::renderTransparentModels(), ROUND_SEGMENT::ROUND_SEGMENT(), Scale(), and XY_PLANE::XY_PLANE().
float BBOX_3D::GetCenter | ( | unsigned int | aAxis | ) | const |
Return the center point of the bounding box for one axis (0, 1 or 2).
Definition at line 138 of file bbox_3d.cpp.
const SFVEC3F BBOX_3D::GetExtent | ( | ) | const |
Definition at line 145 of file bbox_3d.cpp.
Referenced by GetMaxDimension(), LAYER_ITEM::Intersect(), MaxDimension(), SurfaceArea(), Volume(), and XY_PLANE::XY_PLANE().
float BBOX_3D::GetMaxDimension | ( | ) | const |
Definition at line 167 of file bbox_3d.cpp.
References GetExtent().
Referenced by EDA_3D_MODEL_VIEWER::OnPaint(), and RENDER_3D_RAYTRACE_BASE::Reload().
bool BBOX_3D::Inside | ( | const BBOX_3D & | aBBox | ) | const |
Check if a bounding box is inside this bounding box.
aBBox | the bounding box to test if it is inside |
Definition at line 241 of file bbox_3d.cpp.
References Inside(), IsInitialized(), Max(), and Min().
bool BBOX_3D::Inside | ( | const SFVEC3F & | aPoint | ) | const |
Check if a point is inside this bounding box.
aPoint | point 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().
bool BBOX_3D::Intersect | ( | const RAY & | aRay | ) | const |
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.
aRay | The ray to intersect the box. |
aOutHitt0 | The distance point of the ray of the intersection (if true). |
aOutHitt1 | The distance point of the ray of the exit (if true). |
Definition at line 268 of file bbox_3d.cpp.
References RAY::m_dirIsNeg, RAY::m_InvDir, m_max, m_min, and RAY::m_Origin.
bool BBOX_3D::Intersect | ( | const RAY & | aRay, |
float * | t | ||
) | const |
aRay | The ray to intersect the box. |
t | The distance point of the ray of the intersection (if true). |
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, and RAY::m_Origin.
Referenced by getFirstHit(), NL_3D_VIEWER_PLUGIN_IMPL::GetHitLookAt(), getLastHit(), BVH_PBRT::Intersect(), CONTAINER_3D::Intersect(), DUMMY_BLOCK::Intersect(), LAYER_ITEM::Intersect(), BVH_PBRT::IntersectP(), DUMMY_BLOCK::IntersectP(), LAYER_ITEM::IntersectP(), and EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position().
bool BBOX_3D::Intersects | ( | const BBOX_3D & | aBBox | ) | const |
Test if a bounding box intersects this box.
aBBox | the 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().
bool BBOX_3D::IsInitialized | ( | ) | const |
Check if this bounding box is already initialized.
Definition at line 88 of file bbox_3d.cpp.
Referenced by ApplyTransformation(), DrawBoundingBox(), Inside(), Intersects(), MODEL_3D::MODEL_3D(), RENDER_3D_RAYTRACE_BASE::Reload(), Scale(), Set(), Union(), and Volume().
|
inline |
Return the maximum vertex pointer.
Definition at line 199 of file bbox_3d.h.
References m_max.
Referenced by BVH_PBRT::buildUpperSAH(), DrawBoundingBox(), NL_3D_VIEWER_PLUGIN_IMPL::GetModelExtents(), NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL::GetModelExtents(), Inside(), FRUSTUM::Intersect(), CYLINDER::Intersect(), LAYER_ITEM::Intersect(), ROUND_SEGMENT::Intersect(), CYLINDER::IntersectP(), LAYER_ITEM::IntersectP(), ROUND_SEGMENT::IntersectP(), LAYER_ITEM::Intersects(), MODEL_3D::MakeBbox(), HLBVH_SAH_Evaluator::operator()(), CompareToBucket::operator()(), BVH_PBRT::recursiveBuild(), RENDER_3D_RAYTRACE_BASE::Reload(), ROUND_SEGMENT::ROUND_SEGMENT(), and Set().
unsigned int BBOX_3D::MaxDimension | ( | ) | const |
Definition at line 151 of file bbox_3d.cpp.
References GetExtent().
Referenced by BVH_PBRT::buildUpperSAH(), and BVH_PBRT::recursiveBuild().
|
inline |
Return the minimum vertex pointer.
Definition at line 192 of file bbox_3d.h.
References m_min.
Referenced by BVH_PBRT::buildUpperSAH(), DrawBoundingBox(), NL_3D_VIEWER_PLUGIN_IMPL::GetModelExtents(), NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL::GetModelExtents(), Inside(), FRUSTUM::Intersect(), CYLINDER::Intersect(), LAYER_ITEM::Intersect(), ROUND_SEGMENT::Intersect(), CYLINDER::IntersectP(), LAYER_ITEM::IntersectP(), ROUND_SEGMENT::IntersectP(), LAYER_ITEM::Intersects(), MODEL_3D::MakeBbox(), HLBVH_SAH_Evaluator::operator()(), CompareToBucket::operator()(), BVH_PBRT::recursiveBuild(), RENDER_3D_RAYTRACE_BASE::Reload(), ROUND_SEGMENT::ROUND_SEGMENT(), and Set().
Definition at line 261 of file bbox_3d.cpp.
Referenced by BVH_PBRT::HLBVHBuild(), and BVH_PBRT::recursiveBuild().
void BBOX_3D::Reset | ( | ) |
Reset the bounding box to zero and de-initialize it.
Definition at line 95 of file bbox_3d.cpp.
Referenced by ACCELERATOR_3D::ACCELERATOR_3D(), ApplyTransformation(), BBOX_3D(), BOARD_ADAPTER::BOARD_ADAPTER(), BVH_PBRT::buildUpperSAH(), BVH_PBRT::BVH_PBRT(), BVHPrimitiveInfo::BVHPrimitiveInfo(), CONTAINER_3D_BASE::Clear(), CONTAINER_3D_BASE::CONTAINER_3D_BASE(), DUMMY_BLOCK::DUMMY_BLOCK(), BVH_PBRT::emitLBVH(), BVH_PBRT::HLBVHBuild(), LAYER_ITEM::LAYER_ITEM(), TRIANGLE::pre_calc_const(), BVH_PBRT::recursiveBuild(), ROUND_SEGMENT::ROUND_SEGMENT(), and XY_PLANE::XY_PLANE().
void BBOX_3D::Scale | ( | float | aScale | ) |
Scales a bounding box by its center.
aScale | scale 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().
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().
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().
void BBOX_3D::Set | ( | const BBOX_3D & | aBBox | ) |
Definition at line 80 of file bbox_3d.cpp.
References IsInitialized(), Max(), Min(), and Set().
Set bounding box with new parameters.
aPbMin | the minimum point to set for the bounding box. |
aPbMax | the maximum point to set for the bounding box. |
Definition at line 68 of file bbox_3d.cpp.
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().
void BBOX_3D::Set | ( | const SFVEC3F & | aPoint | ) |
Set bounding box to one point.
aPoint | the single point to set the bounding box to. |
Definition at line 61 of file bbox_3d.cpp.
float BBOX_3D::SurfaceArea | ( | ) | const |
Definition at line 174 of file bbox_3d.cpp.
References GetExtent().
Referenced by BVH_PBRT::buildUpperSAH(), and BVH_PBRT::recursiveBuild().
void BBOX_3D::Union | ( | const BBOX_3D & | aBBox | ) |
Recalculate the bounding box adding other bounding box.
aBBox | the bounding box to be bounded. |
Definition at line 116 of file bbox_3d.cpp.
References IsInitialized(), m_max, and m_min.
void BBOX_3D::Union | ( | const SFVEC3F & | aPoint | ) |
Recalculate the bounding box adding a point.
aPoint | the point to be bounded. |
Definition at line 102 of file bbox_3d.cpp.
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().
float BBOX_3D::Volume | ( | ) | const |
Calculate the volume of a bounding box.
Definition at line 251 of file bbox_3d.cpp.
References GetExtent(), and IsInitialized().
|
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().
|
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().