KiCad PCB EDA Suite
CCONTAINER Class Reference

#include <ccontainer.h>

Inheritance diagram for CCONTAINER:
CGENERICCONTAINER

Public Member Functions

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

Protected Attributes

CBBOX m_bbox
 
LIST_OBJECT m_objects
 

Detailed Description

Definition at line 76 of file ccontainer.h.

Member Function Documentation

void CGENERICCONTAINER::Add ( COBJECT aObject)
inlineinherited

Definition at line 52 of file ccontainer.h.

References COBJECT::GetBBox(), and CBBOX::Union().

Referenced by C3D_RENDER_RAYTRACING::add_3D_models(), C3D_RENDER_RAYTRACING::create_3d_object_from(), C3D_RENDER_RAYTRACING::insert3DPadHole(), C3D_RENDER_RAYTRACING::insert3DViaHole(), and C3D_RENDER_RAYTRACING::reload().

53  {
54  if( aObject ) // Only add if it is a valid pointer
55  {
56  m_objects.push_back( aObject );
57  m_bbox.Union( aObject->GetBBox() );
58  }
59  }
LIST_OBJECT m_objects
Definition: ccontainer.h:45
void Union(const SFVEC3F &aPoint)
Function Union recalculate the bounding box adding a point.
Definition: cbbox.cpp:105
const CBBOX & GetBBox() const
Definition: cobject.h:94
void CGENERICCONTAINER::Clear ( )
inherited

Definition at line 39 of file ccontainer.cpp.

References CGENERICCONTAINER::m_bbox, CGENERICCONTAINER::m_objects, and CBBOX::Reset().

Referenced by C3D_RENDER_RAYTRACING::reload(), and CGENERICCONTAINER::~CGENERICCONTAINER().

40 {
41  if( !m_objects.empty() )
42  {
43  for( LIST_OBJECT::iterator ii = m_objects.begin();
44  ii != m_objects.end();
45  ++ii )
46  {
47  delete *ii;
48  *ii = NULL;
49  }
50 
51  m_objects.clear();
52  }
53 
54  m_bbox.Reset();
55 }
LIST_OBJECT m_objects
Definition: ccontainer.h:45
void Reset()
Function Reset reset the bounding box to zero and de-initialized it.
Definition: cbbox.cpp:98
void CGENERICCONTAINER::ConvertTo ( CONST_VECTOR_OBJECT aOutVector) const
inherited

Definition at line 64 of file ccontainer.cpp.

References CGENERICCONTAINER::m_objects.

Referenced by CBVH_PBRT::CBVH_PBRT().

65 {
66  aOutVector.resize( m_objects.size() );
67 
68  if( !m_objects.empty() )
69  {
70  unsigned int i = 0;
71 
72  for( LIST_OBJECT::const_iterator ii = m_objects.begin();
73  ii != m_objects.end();
74  ++ii )
75  {
76  wxASSERT( (*ii) != NULL );
77 
78  aOutVector[i++] = static_cast<const COBJECT *>(*ii);
79  }
80  }
81 }
LIST_OBJECT m_objects
Definition: ccontainer.h:45
const CBBOX& CGENERICCONTAINER::GetBBox ( ) const
inlineinherited

Definition at line 67 of file ccontainer.h.

References CGENERICCONTAINER::m_bbox.

Referenced by C3D_RENDER_RAYTRACING::reload().

67 { return m_bbox; }
const LIST_OBJECT& CGENERICCONTAINER::GetList ( ) const
inlineinherited

Definition at line 63 of file ccontainer.h.

References CGENERICCONTAINER::m_objects.

Referenced by CBVH_PBRT::CBVH_PBRT(), and C3D_RENDER_RAYTRACING::reload().

63 { return m_objects; }
LIST_OBJECT m_objects
Definition: ccontainer.h:45
bool CCONTAINER::Intersect ( const RAY aRay,
HITINFO aHitInfo 
) const
overridevirtual

Implements CGENERICCONTAINER.

Definition at line 84 of file ccontainer.cpp.

References COBJECT::Intersect(), CBBOX::Intersect(), CGENERICCONTAINER::m_bbox, and CGENERICCONTAINER::m_objects.

85 {
86 
87  if( !m_bbox.Intersect( aRay ) )
88  return false;
89 
90  bool hitted = false;
91 
92  for( LIST_OBJECT::const_iterator ii = m_objects.begin();
93  ii != m_objects.end();
94  ++ii )
95  {
96  const COBJECT *object = static_cast<const COBJECT *>(*ii);
97 
98  if( object->Intersect( aRay, aHitInfo) )
99  hitted = true;
100  }
101 
102  return hitted;
103 }
LIST_OBJECT m_objects
Definition: ccontainer.h:45
bool Intersect(const RAY &aRay, float *t) const
Function Intersect.
Definition: cbbox_ray.cpp:46
virtual bool Intersect(const RAY &aRay, HITINFO &aHitInfo) const =0
Functions Intersect.
bool CCONTAINER::IntersectP ( const RAY aRay,
float  aMaxDistance 
) const
overridevirtual

Implements CGENERICCONTAINER.

Definition at line 106 of file ccontainer.cpp.

References COBJECT::IntersectP(), and CGENERICCONTAINER::m_objects.

107 {
108 /*
109  if( !m_bbox.Inside( aRay.m_Origin ) )
110  if( !m_bbox.Intersect( aRay ) )
111  return false;
112 */
113  for( LIST_OBJECT::const_iterator ii = m_objects.begin();
114  ii != m_objects.end();
115  ++ii )
116  {
117  const COBJECT *object = static_cast<const COBJECT *>(*ii);
118 
119  if( object->IntersectP( aRay, aMaxDistance ) )
120  return true;
121  }
122 
123  return false;
124 }
LIST_OBJECT m_objects
Definition: ccontainer.h:45
virtual bool IntersectP(const RAY &aRay, float aMaxDistance) const =0
Functions Intersect for shadow test.

Member Data Documentation

CBBOX CGENERICCONTAINER::m_bbox
protectedinherited

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