KiCad PCB EDA Suite
CONTAINER_3D Class Reference

#include <container_3d.h>

Inheritance diagram for CONTAINER_3D:
CONTAINER_3D_BASE

Public Member Functions

bool Intersect (const RAY &aRay, HITINFO &aHitInfo) const override
 
bool IntersectP (const RAY &aRay, float aMaxDistance) const override
 
void Add (OBJECT_3D *aObject)
 
void Clear ()
 
const LIST_OBJECTGetList () const
 
void ConvertTo (CONST_VECTOR_OBJECT &aOutVector) const
 
const BBOX_3DGetBBox () const
 

Protected Attributes

BBOX_3D m_bbox
 
LIST_OBJECT m_objects
 

Detailed Description

Definition at line 74 of file container_3d.h.

Member Function Documentation

◆ Add()

void CONTAINER_3D_BASE::Add ( OBJECT_3D aObject)
inlineinherited

Definition at line 48 of file container_3d.h.

49  {
50  if( aObject )
51  {
52  m_objects.push_back( aObject );
53  m_bbox.Union( aObject->GetBBox() );
54  }
55  }
void Union(const SFVEC3F &aPoint)
Recalculate the bounding box adding a point.
Definition: bbox_3d.cpp:102
LIST_OBJECT m_objects
Definition: container_3d.h:70
const BBOX_3D & GetBBox() const
Definition: object_3d.h:92

References OBJECT_3D::GetBBox(), CONTAINER_3D_BASE::m_bbox, CONTAINER_3D_BASE::m_objects, and BBOX_3D::Union().

Referenced by RENDER_3D_RAYTRACE::addModels(), RENDER_3D_RAYTRACE::createItemsFromContainer(), RENDER_3D_RAYTRACE::createObject(), RENDER_3D_RAYTRACE::insertHole(), and RENDER_3D_RAYTRACE::Reload().

◆ Clear()

void CONTAINER_3D_BASE::Clear ( )
inherited

Definition at line 39 of file container_3d.cpp.

40 {
41  if( !m_objects.empty() )
42  {
43  for( LIST_OBJECT::iterator ii = m_objects.begin(); ii != m_objects.end(); ++ii )
44  {
45  delete *ii;
46  *ii = nullptr;
47  }
48 
49  m_objects.clear();
50  }
51 
52  m_bbox.Reset();
53 }
LIST_OBJECT m_objects
Definition: container_3d.h:70
void Reset()
Reset the bounding box to zero and de-initialize it.
Definition: bbox_3d.cpp:95

References CONTAINER_3D_BASE::m_bbox, CONTAINER_3D_BASE::m_objects, and BBOX_3D::Reset().

Referenced by RENDER_3D_RAYTRACE::Reload(), and CONTAINER_3D_BASE::~CONTAINER_3D_BASE().

◆ ConvertTo()

void CONTAINER_3D_BASE::ConvertTo ( CONST_VECTOR_OBJECT aOutVector) const
inherited

Definition at line 62 of file container_3d.cpp.

63 {
64  aOutVector.resize( m_objects.size() );
65 
66  if( !m_objects.empty() )
67  {
68  unsigned int i = 0;
69 
70  for( LIST_OBJECT::const_iterator ii = m_objects.begin(); ii != m_objects.end(); ++ii )
71  {
72  wxASSERT( (*ii) != nullptr );
73 
74  aOutVector[i++] = static_cast<const OBJECT_3D*>( *ii );
75  }
76  }
77 }
LIST_OBJECT m_objects
Definition: container_3d.h:70

References CONTAINER_3D_BASE::m_objects.

Referenced by BVH_PBRT::BVH_PBRT().

◆ GetBBox()

const BBOX_3D& CONTAINER_3D_BASE::GetBBox ( ) const
inlineinherited

Definition at line 63 of file container_3d.h.

63 { return m_bbox; }

References CONTAINER_3D_BASE::m_bbox.

Referenced by RENDER_3D_RAYTRACE::Reload().

◆ GetList()

const LIST_OBJECT& CONTAINER_3D_BASE::GetList ( ) const
inlineinherited

Definition at line 59 of file container_3d.h.

59 { return m_objects; }
LIST_OBJECT m_objects
Definition: container_3d.h:70

References CONTAINER_3D_BASE::m_objects.

Referenced by BVH_PBRT::BVH_PBRT(), and RENDER_3D_RAYTRACE::Reload().

◆ Intersect()

bool CONTAINER_3D::Intersect ( const RAY aRay,
HITINFO aHitInfo 
) const
overridevirtual

Implements CONTAINER_3D_BASE.

Definition at line 80 of file container_3d.cpp.

81 {
82 
83  if( !m_bbox.Intersect( aRay ) )
84  return false;
85 
86  bool hitted = false;
87 
88  for( LIST_OBJECT::const_iterator ii = m_objects.begin(); ii != m_objects.end(); ++ii )
89  {
90  const OBJECT_3D *object = static_cast<const OBJECT_3D *>( *ii );
91 
92  if( object->Intersect( aRay, aHitInfo) )
93  hitted = true;
94  }
95 
96  return hitted;
97 }
virtual bool Intersect(const RAY &aRay, HITINFO &aHitInfo) const =0
bool Intersect(const RAY &aRay, float *t) const
Definition: bbox_3d_ray.cpp:46
LIST_OBJECT m_objects
Definition: container_3d.h:70

References OBJECT_3D::Intersect(), BBOX_3D::Intersect(), CONTAINER_3D_BASE::m_bbox, and CONTAINER_3D_BASE::m_objects.

◆ IntersectP()

bool CONTAINER_3D::IntersectP ( const RAY aRay,
float  aMaxDistance 
) const
overridevirtual

Implements CONTAINER_3D_BASE.

Definition at line 100 of file container_3d.cpp.

101 {
102  for( LIST_OBJECT::const_iterator ii = m_objects.begin(); ii != m_objects.end(); ++ii )
103  {
104  const OBJECT_3D *object = static_cast<const OBJECT_3D*>( *ii );
105 
106  if( object->IntersectP( aRay, aMaxDistance ) )
107  return true;
108  }
109 
110  return false;
111 }
virtual bool IntersectP(const RAY &aRay, float aMaxDistance) const =0
LIST_OBJECT m_objects
Definition: container_3d.h:70

References OBJECT_3D::IntersectP(), and CONTAINER_3D_BASE::m_objects.

Member Data Documentation

◆ m_bbox

BBOX_3D CONTAINER_3D_BASE::m_bbox
protectedinherited

◆ m_objects


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