31 #include <boost/range/algorithm/partition.hpp> 32 #include <boost/range/algorithm/nth_element.hpp> 44 std::lock_guard<std::mutex> lock(
m_lock );
119 #define BVH_CONTAINER2D_MAX_OBJ_PER_LEAF 4 139 for( LIST_OBJECT2D::const_iterator ii =
m_objects.begin(); ii !=
m_objects.end(); ++ii )
175 wxASSERT( aNodeParent !=
nullptr );
177 wxASSERT( aNodeParent->
m_LeafList.size() > 0 );
196 switch( axis_to_split )
205 for( CONST_LIST_OBJECT2D::const_iterator ii = aNodeParent->
m_LeafList.begin();
209 const OBJECT_2D*
object = static_cast<const OBJECT_2D*>( *ii );
211 if( i < (aNodeParent->
m_LeafList.size() / 2 ) )
237 wxASSERT( aNodeParent->
m_LeafList.size() == 0 );
246 wxASSERT( aNodeParent !=
nullptr );
265 wxASSERT( aNode !=
nullptr );
280 obj->
Intersect( aSegRay,
nullptr,
nullptr ) )
319 wxASSERT( aNode !=
nullptr );
330 for( CONST_LIST_OBJECT2D::const_iterator ii = aNode->
m_LeafList.begin();
334 const OBJECT_2D* obj = static_cast<const OBJECT_2D*>( *ii );
337 aOutList.push_back( obj );
CONST_LIST_OBJECT2D m_LeafList
Store the list of objects if that node is a Leaf.
std::list< const OBJECT_2D * > CONST_LIST_OBJECT2D
bool IntersectAny(const RAYSEG2D &aSegRay) const override
Intersect and check if a segment ray hits a object or is inside it.
bool IntersectAny(const RAYSEG2D &aSegRay) const override
Intersect and check if a segment ray hits a object or is inside it.
void recursiveBuild_MIDDLE_SPLIT(BVH_CONTAINER_NODE_2D *aNodeParent)
const SFVEC2F & GetCentroid() const
CONTAINER_2D_BASE(OBJECT_2D_TYPE aObjType)
std::list< BVH_CONTAINER_NODE_2D * > m_elementsToDelete
bool recursiveIntersectAny(const BVH_CONTAINER_NODE_2D *aNode, const RAYSEG2D &aSegRay) const
bool Inside(const SFVEC2F &aPoint) const
Check is a point is inside this bounding box.
BVH_CONTAINER_NODE_2D * m_Children[2]
void GetListObjectsIntersects(const BBOX_2D &aBBox, CONST_LIST_OBJECT2D &aOutList) const override
Get a list of objects that intersects a bounding box.
void Reset()
Reset the bounding box to zero and uninitialize it.
const BBOX_2D & GetBBox() const
#define BVH_CONTAINER2D_MAX_OBJ_PER_LEAF
virtual bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const =0
static bool sortByCentroidX(const OBJECT_2D *a, const OBJECT_2D *b)
Manage a bounding box defined by two SFVEC2F min max points.
BVH_CONTAINER_NODE_2D * m_tree
bool Intersect(const RAY2D &aRay, float *t) const
void Union(const SFVEC2F &aPoint)
Recalculate the bounding box adding a point.
static bool sortByCentroidZ(const OBJECT_2D *a, const OBJECT_2D *b)
void GetListObjectsIntersects(const BBOX_2D &aBBox, CONST_LIST_OBJECT2D &aOutList) const override
Get a list of objects that intersects a bounding box.
static bool sortByCentroidY(const OBJECT_2D *a, const OBJECT_2D *b)
unsigned int MaxDimension() const
bool Intersects(const BBOX_2D &aBBox) const
Test if a bounding box intersects this box.
virtual ~CONTAINER_2D_BASE()
void recursiveGetListObjectsIntersects(const BVH_CONTAINER_NODE_2D *aNode, const BBOX_2D &aBBox, CONST_LIST_OBJECT2D &aOutList) const
virtual bool IsPointInside(const SFVEC2F &aPoint) const =0
virtual bool Intersects(const BBOX_2D &aBBox) const =0
a.Intersects(b) ⇔ !a.Disjoint(b) ⇔ !(a ∩ b = ∅)
bool IsInitialized() const
Check if this bounding box is already initialized.