Commit 1fab6ffe authored by Nghia Truong's avatar Nghia Truong

ENH: Add function to check if a geometry has previously been added to the octree

parent 436bc967
......@@ -409,7 +409,6 @@ LooseOctree::clear()
{
clearPrimitive(static_cast<OctreePrimitiveType>(type));
}
// Remove all geometry pointers
m_sGeometryIndices.clear();
......@@ -549,8 +548,7 @@ LooseOctree::addAnalyticalGeometry(const std::shared_ptr<Geometry>& geometry)
void
LooseOctree::addGeometry(const uint32_t geomIdx)
{
LOG_IF(FATAL, (m_sGeometryIndices.find(geomIdx) != m_sGeometryIndices.end()))
<< "Geometry has previously been added";
LOG_IF(FATAL, (hasGeometry(geomIdx))) << "Geometry has previously been added";
m_sGeometryIndices.insert(geomIdx);
}
......@@ -647,7 +645,10 @@ LooseOctree::build()
void
LooseOctree::update()
{
LOG_IF(FATAL, (!m_bCompleteBuild)) << "Tree must be built before calling to update()";
if (!m_bCompleteBuild)
{
build();
}
(!m_bAlwaysRebuild) ? incrementalUpdate() : rebuild();
}
......
......@@ -46,6 +46,7 @@ class DebugRenderGeometry;
///
/// \brief The OctreePrimitiveType enum
/// Type of primitive stored in the octree
/// \todo Add line primitive to geometry
///
enum OctreePrimitiveType
{
......@@ -289,8 +290,11 @@ private:
/// Count the number of (classified) primitives stored in this node
uint32_t m_PrimitiveCounts[OctreePrimitiveType::NumPrimitiveTypes];
ParallelUtils::SpinLock m_PrimitiveLock[OctreePrimitiveType::NumPrimitiveTypes]; ///> Mutex lock for thread-safe primitive list modification
ParallelUtils::SpinLock m_NodeSplitingLock; ///> Mutex lock for thread-safe splitting node
/// Mutex lock for thread-safe primitive list modification
ParallelUtils::SpinLock m_PrimitiveLock[OctreePrimitiveType::NumPrimitiveTypes];
/// Mutex lock for thread-safe splitting node
ParallelUtils::SpinLock m_NodeSplitingLock;
};
///
......@@ -387,6 +391,16 @@ public:
///
uint32_t getMaxNumPrimitivesInNodes() const;
///
/// \brief Get number of geometries that have been added to the octree
///
size_t getNumGeometries() const { return m_sGeometryIndices.size(); }
///
/// \brief Check if a geometry with the given geometry index has been added to the octree before
///
bool hasGeometry(uint32_t geomIdx) const { return m_sGeometryIndices.find(geomIdx) != m_sGeometryIndices.end(); }
///
/// \brief Add a PointSet geometry into the tree
/// (the points will not be populated to tree nodes until calling to build())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment