Fix GCC compilation errors.
// Find best split
for (Standard_Integer anAxis = 0; anAxis < (N < 4 ? N : 3); ++anAxis)
{
- if (BVH::VecComp<T, N>::Get (aSize, anAxis) <= THE_NODE_MIN_SIZE)
+ if (BVH::VecComp<T, N>::Get (aSize, anAxis) <= BVH::THE_NODE_MIN_SIZE)
continue;
BVH_BinVector aBins;
#include <BVH_Types.hxx>
-//! Axis aligned bounding box (AABB).
+//! Defines axis aligned bounding box (AABB) based on BVH vectors.
+//! \tparam T Numeric data type
+//! \tparam N Vector dimension
template<class T, int N>
class BVH_Box
{
public:
//! Creates uninitialized bounding box.
- BVH_Box() : myInitialized (Standard_False) {}
+ BVH_Box() : myIsInited (Standard_False) {}
//! Creates bounding box of given point.
BVH_Box (const BVH_VecNt& thePoint)
- : myMinPoint (thePoint),
- myMaxPoint (thePoint),
- myInitialized (Standard_True) {}
+ : myMinPoint (thePoint),
+ myMaxPoint (thePoint),
+ myIsInited (Standard_True) {}
//! Creates copy of another bounding box.
BVH_Box (const BVH_Box& theBox)
- : myMinPoint (theBox.myMinPoint),
- myMaxPoint (theBox.myMaxPoint),
- myInitialized (theBox.myInitialized) {}
+ : myMinPoint (theBox.myMinPoint),
+ myMaxPoint (theBox.myMaxPoint),
+ myIsInited (theBox.myIsInited) {}
//! Creates bounding box from corner points.
BVH_Box (const BVH_VecNt& theMinPoint,
const BVH_VecNt& theMaxPoint)
- : myMinPoint (theMinPoint),
- myMaxPoint (theMaxPoint),
- myInitialized (Standard_True) {}
+ : myMinPoint (theMinPoint),
+ myMaxPoint (theMaxPoint),
+ myIsInited (Standard_True) {}
public:
//! Returns center of bounding box.
BVH_VecNt Center() const;
+ //! Returns center of bounding box along the given axis.
+ T Center (const Standard_Integer theAxis) const;
+
protected:
- BVH_VecNt myMinPoint; //!< Minimum point of bounding box
- BVH_VecNt myMaxPoint; //!< Maximum point of bounding box
- Standard_Boolean myInitialized; //!< Is bounding box valid?
+ BVH_VecNt myMinPoint; //!< Minimum point of bounding box
+ BVH_VecNt myMaxPoint; //!< Maximum point of bounding box
+ Standard_Boolean myIsInited; //!< Is bounding box initialized?
};
+namespace BVH
+{
+ //! Tool class for calculating box center along the given axis.
+ //! \tparam T Numeric data type
+ //! \tparam N Vector dimension
+ template<class T, int N>
+ struct CenterAxis
+ {
+ // Not implemented
+ };
+
+ template<class T>
+ struct CenterAxis<T, 2>
+ {
+ static T Center (const BVH_Box<T, 2>& theBox, const Standard_Integer theAxis)
+ {
+ if (theAxis == 0)
+ {
+ return (theBox.CornerMin().x() + theBox.CornerMax().x()) * static_cast<T> (0.5);
+ }
+ else if (theAxis == 1)
+ {
+ return (theBox.CornerMin().y() + theBox.CornerMax().y()) * static_cast<T> (0.5);
+ }
+ return static_cast<T> (0.0);
+ }
+ };
+
+ template<class T>
+ struct CenterAxis<T, 3>
+ {
+ static T Center (const BVH_Box<T, 3>& theBox, const Standard_Integer theAxis)
+ {
+ if (theAxis == 0)
+ {
+ return (theBox.CornerMin().x() + theBox.CornerMax().x()) * static_cast<T> (0.5);
+ }
+ else if (theAxis == 1)
+ {
+ return (theBox.CornerMin().y() + theBox.CornerMax().y()) * static_cast<T> (0.5);
+ }
+ else if (theAxis == 2)
+ {
+ return (theBox.CornerMin().z() + theBox.CornerMax().z()) * static_cast<T> (0.5);
+ }
+ return static_cast<T> (0.0);
+ }
+ };
+
+ template<class T>
+ struct CenterAxis<T, 4>
+ {
+ static T Center (const BVH_Box<T, 4>& theBox, const Standard_Integer theAxis)
+ {
+ if (theAxis == 0)
+ {
+ return (theBox.CornerMin().x() + theBox.CornerMax().x()) * static_cast<T> (0.5);
+ }
+ else if (theAxis == 1)
+ {
+ return (theBox.CornerMin().y() + theBox.CornerMax().y()) * static_cast<T> (0.5);
+ }
+ else if (theAxis == 2)
+ {
+ return (theBox.CornerMin().z() + theBox.CornerMax().z()) * static_cast<T> (0.5);
+ }
+ return static_cast<T> (0.0);
+ }
+ };
+
+ //! Tool class for calculating surface area of the box.
+ //! \tparam T Numeric data type
+ //! \tparam N Vector dimension
+ template<class T, int N>
+ struct SurfaceCalculator
+ {
+ // Not implemented
+ };
+
+ template<class T>
+ struct SurfaceCalculator<T, 2>
+ {
+ static T Area (const typename BVH_Box<T, 2>::BVH_VecNt& theSize)
+ {
+ return theSize.x() * theSize.y();
+ }
+ };
+
+ template<class T>
+ struct SurfaceCalculator<T, 3>
+ {
+ static T Area (const typename BVH_Box<T, 3>::BVH_VecNt& theSize)
+ {
+ return ( theSize.x() * theSize.y() +
+ theSize.x() * theSize.z() +
+ theSize.z() * theSize.y() ) * static_cast<T> (2.0);
+ }
+ };
+
+ template<class T>
+ struct SurfaceCalculator<T, 4>
+ {
+ static T Area (const typename BVH_Box<T, 4>::BVH_VecNt& theSize)
+ {
+ return ( theSize.x() * theSize.y() +
+ theSize.x() * theSize.z() +
+ theSize.z() * theSize.y() ) * static_cast<T> (2.0);
+ }
+ };
+
+ //! Tool class for calculate component-wise vector minimum
+ //! and maximum (optimized version).
+ //! \tparam T Numeric data type
+ //! \tparam N Vector dimension
+ template<class T, int N>
+ struct BoxMinMax
+ {
+ typedef typename BVH::VectorType<T, N>::Type BVH_VecNt;
+
+ static void CwiseMin (BVH_VecNt& theVec1, const BVH_VecNt& theVec2)
+ {
+ theVec1.x() = Min (theVec1.x(), theVec2.x());
+ theVec1.y() = Min (theVec1.y(), theVec2.y());
+ theVec1.z() = Min (theVec1.z(), theVec2.z());
+ }
+
+ static void CwiseMax (BVH_VecNt& theVec1, const BVH_VecNt& theVec2)
+ {
+ theVec1.x() = Max (theVec1.x(), theVec2.x());
+ theVec1.y() = Max (theVec1.y(), theVec2.y());
+ theVec1.z() = Max (theVec1.z(), theVec2.z());
+ }
+ };
+
+ template<class T>
+ struct BoxMinMax<T, 2>
+ {
+ typedef typename BVH::VectorType<T, 2>::Type BVH_VecNt;
+
+ static void CwiseMin (BVH_VecNt& theVec1, const BVH_VecNt& theVec2)
+ {
+ theVec1.x() = Min (theVec1.x(), theVec2.x());
+ theVec1.y() = Min (theVec1.y(), theVec2.y());
+ }
+
+ static void CwiseMax (BVH_VecNt& theVec1, const BVH_VecNt& theVec2)
+ {
+ theVec1.x() = Max (theVec1.x(), theVec2.x());
+ theVec1.y() = Max (theVec1.y(), theVec2.y());
+ }
+ };
+}
+
#include <BVH_Box.lxx>
#endif // _BVH_Box_Header
#include <Standard_ShortReal.hxx>
-namespace BVH
-{
- template<class T, int N>
- struct CenterAxis {
- // Not implemented
- };
-
- template<class T>
- struct CenterAxis<T, 2>
- {
- static T Center (const BVH_Box<T, 2>& theBox,
- const Standard_Integer theAxis)
- {
- if (theAxis == 0)
- {
- return (theBox.CornerMin().x() + theBox.CornerMax().x()) * static_cast<T> (0.5);
- }
- else if (theAxis == 1)
- {
- return (theBox.CornerMin().y() + theBox.CornerMax().y()) * static_cast<T> (0.5);
- }
- return static_cast<T> (0.0);
- }
- };
-
- template<class T>
- struct CenterAxis<T, 3>
- {
- static T Center (const BVH_Box<T, 3>& theBox,
- const Standard_Integer theAxis)
- {
- if (theAxis == 0)
- {
- return (theBox.CornerMin().x() + theBox.CornerMax().x()) * static_cast<T> (0.5);
- }
- else if (theAxis == 1)
- {
- return (theBox.CornerMin().y() + theBox.CornerMax().y()) * static_cast<T> (0.5);
- }
- else if (theAxis == 2)
- {
- return (theBox.CornerMin().z() + theBox.CornerMax().z()) * static_cast<T> (0.5);
- }
- return static_cast<T> (0.0);
- }
- };
-
- template<class T>
- struct CenterAxis<T, 4>
- {
- static T Center (const BVH_Box<T, 4>& theBox,
- const Standard_Integer theAxis)
- {
- if (theAxis == 0)
- {
- return (theBox.CornerMin().x() + theBox.CornerMax().x()) * static_cast<T> (0.5);
- }
- else if (theAxis == 1)
- {
- return (theBox.CornerMin().y() + theBox.CornerMax().y()) * static_cast<T> (0.5);
- }
- else if (theAxis == 2)
- {
- return (theBox.CornerMin().z() + theBox.CornerMax().z()) * static_cast<T> (0.5);
- }
- return static_cast<T> (0.0);
- }
- };
-}
-
// =======================================================================
// function : Clear
// purpose :
template<class T, int N>
void BVH_Box<T, N>::Clear()
{
- myInitialized = Standard_False;
+ myIsInited = Standard_False;
}
// =======================================================================
template<class T, int N>
Standard_Boolean BVH_Box<T, N>::IsValid() const
{
- return myInitialized;
+ return myIsInited;
}
// =======================================================================
template<class T, int N>
void BVH_Box<T, N>::Add (const BVH_VecNt& thePoint)
{
- if (!myInitialized)
+ if (!myIsInited)
{
myMinPoint = thePoint;
myMaxPoint = thePoint;
- myInitialized = Standard_True;
+ myIsInited = Standard_True;
}
else
{
}
}
-namespace BVH
-{
- template<class T, int N>
- struct BoxMinMax
- {
- typedef typename BVH::VectorType<T, N>::Type BVH_VecNt;
-
- static void CwiseMin (BVH_VecNt& theVec1, const BVH_VecNt& theVec2)
- {
- theVec1.x() = Min (theVec1.x(), theVec2.x());
- theVec1.y() = Min (theVec1.y(), theVec2.y());
- theVec1.z() = Min (theVec1.z(), theVec2.z());
- }
-
- static void CwiseMax (BVH_VecNt& theVec1, const BVH_VecNt& theVec2)
- {
- theVec1.x() = Max (theVec1.x(), theVec2.x());
- theVec1.y() = Max (theVec1.y(), theVec2.y());
- theVec1.z() = Max (theVec1.z(), theVec2.z());
- }
- };
-
- template<class T>
- struct BoxMinMax<T, 2>
- {
- typedef typename BVH::VectorType<T, 2>::Type BVH_VecNt;
-
- static void CwiseMin (BVH_VecNt& theVec1, const BVH_VecNt& theVec2)
- {
- theVec1.x() = Min (theVec1.x(), theVec2.x());
- theVec1.y() = Min (theVec1.y(), theVec2.y());
- }
-
- static void CwiseMax (BVH_VecNt& theVec1, const BVH_VecNt& theVec2)
- {
- theVec1.x() = Max (theVec1.x(), theVec2.x());
- theVec1.y() = Max (theVec1.y(), theVec2.y());
- }
- };
-}
-
// =======================================================================
// function : Combine
// purpose :
template<class T, int N>
void BVH_Box<T, N>::Combine (const BVH_Box& theBox)
{
- if (theBox.myInitialized)
+ if (theBox.myIsInited)
{
- if (!myInitialized)
+ if (!myIsInited)
{
myMinPoint = theBox.myMinPoint;
myMaxPoint = theBox.myMaxPoint;
- myInitialized = Standard_True;
+ myIsInited = Standard_True;
}
else
{
}
}
-namespace BVH
-{
- template<class T, int N>
- struct SurfaceCalculator
- {
- // Not implemented
- };
-
- template<class T>
- struct SurfaceCalculator<T, 2>
- {
- static T Area (const typename BVH_Box<T, 2>::BVH_VecNt& theSize)
- {
- return theSize.x() * theSize.y();
- }
- };
-
- template<class T>
- struct SurfaceCalculator<T, 3>
- {
- static T Area (const typename BVH_Box<T, 3>::BVH_VecNt& theSize)
- {
- return ( theSize.x() * theSize.y() +
- theSize.x() * theSize.z() +
- theSize.z() * theSize.y() ) * static_cast<T> (2.0);
- }
- };
-
- template<class T>
- struct SurfaceCalculator<T, 4>
- {
- static T Area (const typename BVH_Box<T, 4>::BVH_VecNt& theSize)
- {
- return ( theSize.x() * theSize.y() +
- theSize.x() * theSize.z() +
- theSize.z() * theSize.y() ) * static_cast<T> (2.0);
- }
- };
-}
-
// =======================================================================
// function : Area
// purpose :
template<class T, int N>
T BVH_Box<T, N>::Area() const
{
- return !myInitialized ? static_cast<T> (0.0) :
- BVHTools::SurfaceCalculator<T, N>::Area (myMaxPoint - myMinPoint);
+ return !myIsInited ? static_cast<T> (0.0) :
+ BVH::SurfaceCalculator<T, N>::Area (myMaxPoint - myMinPoint);
}
// =======================================================================
{
return (myMinPoint + myMaxPoint) * static_cast<T> (0.5);
}
+
+// =======================================================================
+// function : Center
+// purpose :
+// =======================================================================
+template<class T, int N>
+T BVH_Box<T, N>::Center (const Standard_Integer theAxis) const
+{
+ return BVH::CenterAxis<T, N>::Center (*this, theAxis);
+}
#include <BVH_Set.hxx>
#include <BVH_Tree.hxx>
-namespace
+namespace BVH
{
//! Minimum node size to split.
const Standard_Real THE_NODE_MIN_SIZE = 1e-5;
}
-//! Performs building of BVH tree.
+//! Performs construction of BVH tree using bounding
+//! boxes (AABBs) of abstract objects.
+//! \tparam T Numeric data type
+//! \tparam N Vector dimension
template<class T, int N>
class BVH_Builder
{
public:
- //! Creates abstract BVH builder.
+ //! Creates new abstract BVH builder.
BVH_Builder (const Standard_Integer theLeafNodeSize,
const Standard_Integer theMaxTreeDepth);
//! Releases resources of BVH builder.
virtual ~BVH_Builder();
-public:
-
- //! Builds BVH using specified algorithm.
+ //! Builds BVH using specific algorithm.
virtual void Build (BVH_Set<T, N>* theSet,
BVH_Tree<T, N>* theBVH,
const BVH_Box<T, N>& theBox) = 0;
+protected:
+
//! Updates depth of constructed BVH tree.
void UpdateDepth (BVH_Tree<T, N>* theBVH,
const Standard_Integer theLevel)
protected:
- Standard_Integer myMaxTreeDepth; //!< Maximum depth of constructed BVH
- Standard_Integer myLeafNodeSize; //!< Maximum number of primitives per leaf
+ Standard_Integer myMaxTreeDepth; //!< Maximum depth of constructed BVH
+ Standard_Integer myLeafNodeSize; //!< Maximum number of objects per leaf
};
#include <BVH_ObjectSet.hxx>
#include <BVH_Builder.hxx>
-//! BVH geometry as a set of abstract geometric objects.
+//! BVH geometry as a set of abstract geometric objects
+//! organized with bounding volume hierarchy (BVH).
+//! \tparam T Numeric data type
+//! \tparam N Vector dimension
template<class T, int N>
class BVH_Geometry : public BVH_ObjectSet<T, N>
{
//! Marks geometry as outdated.
virtual void MarkDirty();
- //! Returns AABB of whole geometry.
+ //! Returns AABB of the whole geometry.
virtual BVH_Box<T, N> Box() const;
- //! Returns constructed BVH tree.
+ //! Returns BVH tree (and builds it if necessary).
virtual const NCollection_Handle<BVH_Tree<T, N> >& BVH();
- //! Returns the method (builder) to construct BVH.
+ //! Returns the method (builder) used to construct BVH.
virtual const NCollection_Handle<BVH_Builder<T, N> >& Builder() const;
- //! Sets the method (builder) to construct BVH.
+ //! Sets the method (builder) used to construct BVH.
virtual void SetBuilder (NCollection_Handle<BVH_Builder<T, N> >& theBuilder);
protected:
for (Standard_Integer aPrimIdx = aData.y(); aPrimIdx <= aData.z(); ++aPrimIdx)
{
- const typename BVH_Box<T, N> aBox = theSet->Box (aPrimIdx);
+ const BVH_Box<T, N> aBox = theSet->Box (aPrimIdx);
if (aPrimIdx == aData.y())
{
std::vector<BVH_EncodedLink>::iterator theStart,
std::vector<BVH_EncodedLink>::iterator theFinal)
{
- if (theFinal - theStart > myLeafNodeSize && theBit >= 0)
+ if (theFinal - theStart > BVH_Builder<T, N>::myLeafNodeSize && theBit >= 0)
{
std::vector<BVH_EncodedLink>::iterator aPosition = std::lower_bound (
theStart, theFinal, BVH_EncodedLink(), BVH::BitComparator (theBit));
#include <NCollection_Handle.hxx>
-//! Abstract geometric object.
+//! Abstract geometric object bounded by BVH box.
+//! \tparam T Numeric data type
+//! \tparam N Vector dimension
template<class T, int N>
class BVH_Object
{
public:
- //! Returns AABB of geometric object.
+ //! Returns AABB of the geometric object.
virtual BVH_Box<T, N> Box() const = 0;
- //! Returns properties of geometric object.
+ //! Returns properties of the geometric object.
virtual const NCollection_Handle<BVH_Properties>& Properties() const;
- //! Sets properties of geometric object.
+ //! Sets properties of the geometric object.
virtual void SetProperties (const NCollection_Handle<BVH_Properties>& theProperties);
- //! Marks object state as outdated.
+ //! Marks object state as outdated (needs BVH rebuilding).
virtual void MarkDirty();
protected:
- Standard_Boolean myIsDirty; //!< Marks that internal object state need to be updated
+ Standard_Boolean myIsDirty; //!< Marks internal object state as outdated
NCollection_Handle<BVH_Properties> myProperties; //!< Generic properties assigned to the object
};
#include <BVH_Set.hxx>
#include <BVH_Object.hxx>
-#include <NCollection_Vector.hxx>
-
-//! Set of abstract geometric objects to build BVH.
+//! Array of abstract entities (bounded by BVH boxes) to built BVH.
+//! \tparam T Numeric data type
+//! \tparam N Vector dimension
template<class T, int N>
class BVH_ObjectSet : public BVH_Set<T, N>
{
public:
- //! Type for array of geometric objects.
+ //! Type of array of geometric objects.
typedef NCollection_Vector<NCollection_Handle<BVH_Object<T, N> > > BVH_ObjectList;
public:
- //! Creates set of geometric objects.
+ //! Creates new set of geometric objects.
BVH_ObjectSet();
//! Releases resources of set of geometric objects.
public:
- //! Clears all geometric objects.
+ //! Removes all geometric objects.
virtual void Clear();
- //! Returns array of geometric objects.
+ //! Returns reference to the array of geometric objects.
BVH_ObjectList& Objects();
- //! Returns array of geometric objects.
+ //! Returns reference to the array of geometric objects.
const BVH_ObjectList& Objects() const;
public:
//! Return total number of objects.
virtual Standard_Integer Size() const;
- //! Returns AABB of specified object.
+ //! Returns AABB of the given object.
virtual BVH_Box<T, N> Box (const Standard_Integer theIndex) const;
- //! Returns centroid position in specified axis.
+ //! Returns centroid position along the given axis.
virtual T Center (const Standard_Integer theIndex, const Standard_Integer theAxis) const;
- //! Swaps indices of two specified objects in the set.
+ //! Performs transposing the two given objects in the set.
virtual void Swap (const Standard_Integer theIndex1, const Standard_Integer theIndex2);
protected:
T BVH_ObjectSet<T, N>::Center (const Standard_Integer theIndex,
const Standard_Integer theAxis) const
{
- typename BVH_Set<T, N>::BVH_BoxNt aBox = myObjects.Value (theIndex)->Box();
- return BVH::CenterAxis<T, N>::Center (aBox, theAxis);
+ // Note: general implementation, not optimal
+ return BVH::CenterAxis<T, N>::Center (myObjects.Value (theIndex)->Box(), theAxis);
}
// =======================================================================
void BVH_ObjectSet<T, N>::Swap (const Standard_Integer theIndex1,
const Standard_Integer theIndex2)
{
- NCollection_Handle<BVH_Object<T, N> > anObject1 = myObjects.Value (theIndex1);
- NCollection_Handle<BVH_Object<T, N> > anObject2 = myObjects.Value (theIndex2);
-
- myObjects.ChangeValue (theIndex1) = anObject2;
- myObjects.ChangeValue (theIndex2) = anObject1;
+ std::swap (myObjects.ChangeValue (theIndex1),
+ myObjects.ChangeValue (theIndex2));
}
#include <BVH_Object.hxx>
#include <BVH_Builder.hxx>
-//! Set of abstract geometric primitives.
+//! Set of abstract geometric primitives organized with bounding
+//! volume hierarchy (BVH). Unlike an object set, this collection
+//! is designed for storing structural elements of a single object
+//! (such as triangles in the object triangulation). Because there
+//! may be a large number of such elements, the implementations of
+//! this interface should be sufficiently optimized.
+//! \tparam T Numeric data type
+//! \tparam N Vector dimension
template<class T, int N>
class BVH_PrimitiveSet : public BVH_Object<T, N>, public BVH_Set<T, N>
{
//! Returns AABB of primitive set.
virtual BVH_Box<T, N> Box() const;
- //! Returns constructed BVH tree.
+ //! Returns BVH tree (and builds it if necessary).
virtual const NCollection_Handle<BVH_Tree<T, N> >& BVH();
- //! Returns the method (builder) to construct BVH.
+ //! Returns the method (builder) used to construct BVH.
virtual const NCollection_Handle<BVH_Builder<T, N> >& Builder() const;
- //! Sets the method (builder) to construct BVH.
+ //! Sets the method (builder) used to construct BVH.
virtual void SetBuilder (NCollection_Handle<BVH_Builder<T, N> >& theBuilder);
protected:
#include <BVH_Box.hxx>
-//! Set of abstract entities to build BVH.
+//! Set of abstract entities (bounded by BVH boxes). This is
+//! the minimal geometry interface needed to construct BVH.
+//! \tparam T Numeric data type
+//! \tparam N Vector dimension
template<class T, int N>
class BVH_Set
{
//! Releases resources of set of objects.
virtual ~BVH_Set() = 0;
- //! Returns AABB of entire set of objects.
+ //! Returns AABB of the entire set of objects.
virtual BVH_Box<T, N> Box() const;
public:
- //! Return total number of objects.
+ //! Returns total number of objects.
virtual Standard_Integer Size() const = 0;
- //! Returns AABB of specified object.
+ //! Returns AABB of the given object.
virtual BVH_Box<T, N> Box (const Standard_Integer theIndex) const = 0;
- //! Returns centroid position in specified axis.
+ //! Returns centroid position along the given axis.
virtual T Center (const Standard_Integer theIndex,
const Standard_Integer theAxis) const = 0;
- //! Swaps indices of two specified objects in the set.
+ //! Performs transposing the two given objects in the set.
virtual void Swap (const Standard_Integer theIndex1,
const Standard_Integer theIndex2) = 0;
{
const T aNodeSize = BVH::VecComp<T, N>::Get (theBVH->MaxPoint (theNode), anAxis) -
BVH::VecComp<T, N>::Get (theBVH->MinPoint (theNode), anAxis);
- if (aNodeSize <= THE_NODE_MIN_SIZE)
+ if (aNodeSize <= BVH::THE_NODE_MIN_SIZE)
{
continue;
}
}
}
+ delete [] aLftSet;
+ delete [] aRghSet;
+
if (aMinSplitAxis == -1)
{
return;
//! Returns minimum point of the given node.
BVH_VecNt& MinPoint (const Standard_Integer theNodeIndex)
{
- return BVH::ArrayOp<T, N>::ChangeValue (myMinPointBuffer, theNodeIndex);
+ return BVH::Array<T, N>::ChangeValue (myMinPointBuffer, theNodeIndex);
}
//! Returns maximum point of the given node.
BVH_VecNt& MaxPoint (const Standard_Integer theNodeIndex)
{
- return BVH::ArrayOp<T, N>::ChangeValue (myMaxPointBuffer, theNodeIndex);
+ return BVH::Array<T, N>::ChangeValue (myMaxPointBuffer, theNodeIndex);
}
//! Returns minimum point of the given node.
const BVH_VecNt& MinPoint (const Standard_Integer theNodeIndex) const
{
- return BVH::ArrayOp<T, N>::Value (myMinPointBuffer, theNodeIndex);
+ return BVH::Array<T, N>::Value (myMinPointBuffer, theNodeIndex);
}
//! Returns maximum point of the given node.
const BVH_VecNt& MaxPoint (const Standard_Integer theNodeIndex) const
{
- return BVH::ArrayOp<T, N>::Value (myMaxPointBuffer, theNodeIndex);
+ return BVH::Array<T, N>::Value (myMaxPointBuffer, theNodeIndex);
}
//! Returns index of left child of the given inner node.
Standard_Integer& LeftChild (const Standard_Integer theNodeIndex)
{
- return BVH::ArrayOp<Standard_Integer, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).y();
+ return BVH::Array<Standard_Integer, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).y();
}
//! Returns index of left child of the given inner node.
Standard_Integer LeftChild (const Standard_Integer theNodeIndex) const
{
- return BVH::ArrayOp<Standard_Integer, 4>::Value (myNodeInfoBuffer, theNodeIndex).y();
+ return BVH::Array<Standard_Integer, 4>::Value (myNodeInfoBuffer, theNodeIndex).y();
}
//! Returns index of right child of the given inner node.
Standard_Integer& RightChild (const Standard_Integer theNodeIndex)
{
- return BVH::ArrayOp<Standard_Integer, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).z();
+ return BVH::Array<Standard_Integer, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).z();
}
//! Returns index of right child of the given inner node.
Standard_Integer RightChild (const Standard_Integer theNodeIndex) const
{
- return BVH::ArrayOp<Standard_Integer, 4>::Value (myNodeInfoBuffer, theNodeIndex).z();
+ return BVH::Array<Standard_Integer, 4>::Value (myNodeInfoBuffer, theNodeIndex).z();
}
//! Returns index of first primitive of the given leaf node.
Standard_Integer& BegPrimitive (const Standard_Integer theNodeIndex)
{
- return BVH::ArrayOp<Standard_Integer, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).y();
+ return BVH::Array<Standard_Integer, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).y();
}
//! Returns index of first primitive of the given leaf node.
Standard_Integer BegPrimitive (const Standard_Integer theNodeIndex) const
{
- return BVH::ArrayOp<Standard_Integer, 4>::Value (myNodeInfoBuffer, theNodeIndex).y();
+ return BVH::Array<Standard_Integer, 4>::Value (myNodeInfoBuffer, theNodeIndex).y();
}
//! Returns index of last primitive of the given leaf node.
Standard_Integer& EndPrimitive (const Standard_Integer theNodeIndex)
{
- return BVH::ArrayOp<Standard_Integer, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).z();
+ return BVH::Array<Standard_Integer, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).z();
}
//! Returns index of last primitive of the given leaf node.
Standard_Integer EndPrimitive (const Standard_Integer theNodeIndex) const
{
- return BVH::ArrayOp<Standard_Integer, 4>::Value (myNodeInfoBuffer, theNodeIndex).z();
+ return BVH::Array<Standard_Integer, 4>::Value (myNodeInfoBuffer, theNodeIndex).z();
}
//! Returns number of primitives for the given tree node.
//! Returns level (depth) of the given node.
Standard_Integer& Level (const Standard_Integer theNodeIndex)
{
- return BVH::ArrayOp<Standard_Integer, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).w();
+ return BVH::Array<Standard_Integer, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).w();
}
//! Returns level (depth) of the given node.
Standard_Integer Level (const Standard_Integer theNodeIndex) const
{
- return BVH::ArrayOp<Standard_Integer, 4>::Value (myNodeInfoBuffer, theNodeIndex).w();
+ return BVH::Array<Standard_Integer, 4>::Value (myNodeInfoBuffer, theNodeIndex).w();
}
//! Is node a leaf (outer)?
Standard_Boolean IsOuter (const Standard_Integer theNodeIndex) const
{
- return BVH::ArrayOp<Standard_Integer, 4>::Value (myNodeInfoBuffer, theNodeIndex).x() > 0;
+ return BVH::Array<Standard_Integer, 4>::Value (myNodeInfoBuffer, theNodeIndex).x() > 0;
}
//! Sets node type to 'outer'.
void SetOuter (const Standard_Integer theNodeIndex)
{
- BVH::ArrayOp<Standard_Integer, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).x() = 1;
+ BVH::Array<Standard_Integer, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).x() = 1;
}
//! Sets node type to 'inner'.
void SetInner (const Standard_Integer theNodeIndex)
{
- BVH::ArrayOp<Standard_Integer, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).x() = 0;
+ BVH::Array<Standard_Integer, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).x() = 0;
}
//! Returns total number of BVH nodes.
Standard_Integer Length() const
{
- return BVH::ArrayOp<Standard_Integer, 4>::Size (myNodeInfoBuffer);
+ return BVH::Array<Standard_Integer, 4>::Size (myNodeInfoBuffer);
}
//! Returns depth of BVH tree from last build.
{
myDepth = 0;
- BVH::ArrayOp<T, N>::Clear (myMinPointBuffer);
- BVH::ArrayOp<T, N>::Clear (myMaxPointBuffer);
+ BVH::Array<T, N>::Clear (myMinPointBuffer);
+ BVH::Array<T, N>::Clear (myMaxPointBuffer);
- BVH::ArrayOp<Standard_Integer, 4>::Clear (myNodeInfoBuffer);
+ BVH::Array<Standard_Integer, 4>::Clear (myNodeInfoBuffer);
}
// =======================================================================
Standard_Integer BVH_Tree<T, N>::AddLeafNode (const Standard_Integer theBegElem,
const Standard_Integer theEndElem)
{
- BVH::ArrayOp<Standard_Integer, 4>::Append (myNodeInfoBuffer, BVH_Vec4i (1, theBegElem, theEndElem, 0));
+ BVH::Array<Standard_Integer, 4>::Append (myNodeInfoBuffer, BVH_Vec4i (1, theBegElem, theEndElem, 0));
- return static_cast<Standard_Integer> (BVH::ArrayOp<Standard_Integer, 4>::Size (myNodeInfoBuffer) - 1);
+ return static_cast<Standard_Integer> (BVH::Array<Standard_Integer, 4>::Size (myNodeInfoBuffer) - 1);
}
// =======================================================================
Standard_Integer BVH_Tree<T, N>::AddInnerNode (const Standard_Integer theLftChild,
const Standard_Integer theRghChild)
{
- BVH::ArrayOp<Standard_Integer, 4>::Append (myNodeInfoBuffer, BVH_Vec4i (0, theLftChild, theRghChild, 0));
+ BVH::Array<Standard_Integer, 4>::Append (myNodeInfoBuffer, BVH_Vec4i (0, theLftChild, theRghChild, 0));
- return static_cast<Standard_Integer> (BVH::ArrayOp<Standard_Integer, 4>::Size (myNodeInfoBuffer) - 1);
+ return static_cast<Standard_Integer> (BVH::Array<Standard_Integer, 4>::Size (myNodeInfoBuffer) - 1);
}
// =======================================================================
const Standard_Integer theBegElem,
const Standard_Integer theEndElem)
{
- BVH::ArrayOp<T, N>::Append (myMinPointBuffer, theMinPoint);
- BVH::ArrayOp<T, N>::Append (myMaxPointBuffer, theMaxPoint);
+ BVH::Array<T, N>::Append (myMinPointBuffer, theMinPoint);
+ BVH::Array<T, N>::Append (myMaxPointBuffer, theMaxPoint);
- BVH::ArrayOp<Standard_Integer, 4>::Append (myNodeInfoBuffer, BVH_Vec4i (1, theBegElem, theEndElem, 0));
+ BVH::Array<Standard_Integer, 4>::Append (myNodeInfoBuffer, BVH_Vec4i (1, theBegElem, theEndElem, 0));
- return static_cast<Standard_Integer> (BVH::ArrayOp<Standard_Integer, 4>::Size (myNodeInfoBuffer) - 1);
+ return static_cast<Standard_Integer> (BVH::Array<Standard_Integer, 4>::Size (myNodeInfoBuffer) - 1);
}
// =======================================================================
const Standard_Integer theLftChild,
const Standard_Integer theRghChild)
{
- BVH::ArrayOp<T, N>::Append (myMinPointBuffer, theMinPoint);
- BVH::ArrayOp<T, N>::Append (myMaxPointBuffer, theMaxPoint);
+ BVH::Array<T, N>::Append (myMinPointBuffer, theMinPoint);
+ BVH::Array<T, N>::Append (myMaxPointBuffer, theMaxPoint);
- BVH::ArrayOp<Standard_Integer, 4>::Append (myNodeInfoBuffer, BVH_Vec4i (0, theLftChild, theRghChild, 0));
+ BVH::Array<Standard_Integer, 4>::Append (myNodeInfoBuffer, BVH_Vec4i (0, theLftChild, theRghChild, 0));
- return static_cast<Standard_Integer> (BVH::ArrayOp<Standard_Integer, 4>::Size (myNodeInfoBuffer) - 1);
+ return static_cast<Standard_Integer> (BVH::Array<Standard_Integer, 4>::Size (myNodeInfoBuffer) - 1);
}
// =======================================================================
namespace BVH
{
+ //! Internal function for recursive calculation of
+ //! surface area heuristic (SAH) of the given tree.
template<class T, int N>
void EstimateSAH (const BVH_Tree<T, N>* theTree,
const Standard_Integer theNode,
- T theProbability,
+ T theProb,
T& theSAH)
{
BVH_Box<T, N> aBox (theTree->MinPoint (theNode),
if (theTree->IsOuter (theNode))
{
- theSAH += theProbability * (theTree->EndPrimitive (theNode) - theTree->BegPrimitive (theNode) + 1);
+ theSAH += theProb * (theTree->EndPrimitive (theNode) - theTree->BegPrimitive (theNode) + 1);
}
else
{
- theSAH += theProbability * static_cast<T> (2.0);
+ theSAH += theProb * static_cast<T> (2.0);
BVH_Box<T, N> aLftBox (theTree->MinPoint (theTree->LeftChild (theNode)),
theTree->MaxPoint (theTree->LeftChild (theNode)));
- if (theProbability > 0.0)
+ if (theProb > 0.0)
{
EstimateSAH (theTree, theTree->LeftChild (theNode),
- theProbability * aLftBox.Area() / aBox.Area(), theSAH);
+ theProb * aLftBox.Area() / aBox.Area(), theSAH);
}
BVH_Box<T, N> aRghBox (theTree->MinPoint (theTree->RightChild (theNode)),
theTree->MaxPoint (theTree->RightChild (theNode)));
- if (theProbability > 0.0)
+ if (theProb > 0.0)
{
EstimateSAH (theTree, theTree->RightChild (theNode),
- theProbability * aRghBox.Area() / aBox.Area(), theSAH);
+ theProb * aRghBox.Area() / aBox.Area(), theSAH);
}
}
}
#include <BVH_PrimitiveSet.hxx>
-//! Triangulation as an example of primitive set.
+//! Triangulation as an example of BVH primitive set.
+//! \tparam T Numeric data type
+//! \tparam N Vector dimension
template<class T, int N>
class BVH_Triangulation : public BVH_PrimitiveSet<T, N>
{
public:
- //! Creates new triangulation.
+ //! Creates empty triangulation.
BVH_Triangulation();
- //! Releases resources of geometric object.
+ //! Releases resources of triangulation.
virtual ~BVH_Triangulation();
public:
//! Array of vertex coordinates.
typename BVH::ArrayType<T, N>::Type Vertices;
- //! Array of indices of triangle indicies vertices.
+ //! Array of indices of triangle vertices.
BVH_Array4i Elements;
public:
- //! Return total number of triangles.
+ //! Returns total number of triangles.
virtual Standard_Integer Size() const;
- //! Returns AABB of specified triangle.
+ //! Returns AABB of the given triangle.
virtual BVH_Box<T, N> Box (const Standard_Integer theIndex) const;
- //! Returns centroid position in specified axis.
+ //! Returns centroid position along the given axis.
virtual T Center (const Standard_Integer theIndex,
const Standard_Integer theAxis) const;
- //! Swaps indices of two specified triangles.
+ //! Performs transposing the two given triangles in the set.
virtual void Swap (const Standard_Integer theIndex1,
const Standard_Integer theIndex2);
template<class T, int N>
Standard_Integer BVH_Triangulation<T, N>::Size() const
{
- return BVH::ArrayOp<Standard_Integer, 4>::Size (Elements);
+ return BVH::Array<Standard_Integer, 4>::Size (Elements);
}
// =======================================================================
template<class T, int N>
BVH_Box<T, N> BVH_Triangulation<T, N>::Box (const Standard_Integer theIndex) const
{
- const BVH_Vec4i& anIndex = BVH::ArrayOp<Standard_Integer, 4>::Value (Elements, theIndex);
+ const BVH_Vec4i& anIndex = BVH::Array<Standard_Integer, 4>::Value (Elements, theIndex);
- const BVH_VecNt& aPoint0 = BVH::ArrayOp<T, N>::Value (Vertices, anIndex.x());
- const BVH_VecNt& aPoint1 = BVH::ArrayOp<T, N>::Value (Vertices, anIndex.y());
- const BVH_VecNt& aPoint2 = BVH::ArrayOp<T, N>::Value (Vertices, anIndex.z());
+ const BVH_VecNt& aPoint0 = BVH::Array<T, N>::Value (Vertices, anIndex.x());
+ const BVH_VecNt& aPoint1 = BVH::Array<T, N>::Value (Vertices, anIndex.y());
+ const BVH_VecNt& aPoint2 = BVH::Array<T, N>::Value (Vertices, anIndex.z());
BVH_VecNt aMinPoint = aPoint0;
BVH_VecNt aMaxPoint = aPoint0;
T BVH_Triangulation<T, N>::Center (const Standard_Integer theIndex,
const Standard_Integer theAxis) const
{
- const BVH_Vec4i& anIndex = BVH::ArrayOp<Standard_Integer, 4>::Value (Elements, theIndex);
+ const BVH_Vec4i& anIndex = BVH::Array<Standard_Integer, 4>::Value (Elements, theIndex);
- const BVH_VecNt& aPoint0 = BVH::ArrayOp<T, N>::Value (Vertices, anIndex.x());
- const BVH_VecNt& aPoint1 = BVH::ArrayOp<T, N>::Value (Vertices, anIndex.y());
- const BVH_VecNt& aPoint2 = BVH::ArrayOp<T, N>::Value (Vertices, anIndex.z());
+ const BVH_VecNt& aPoint0 = BVH::Array<T, N>::Value (Vertices, anIndex.x());
+ const BVH_VecNt& aPoint1 = BVH::Array<T, N>::Value (Vertices, anIndex.y());
+ const BVH_VecNt& aPoint2 = BVH::Array<T, N>::Value (Vertices, anIndex.z());
return ( BVH::VecComp<T, N>::Get (aPoint0, theAxis) +
BVH::VecComp<T, N>::Get (aPoint1, theAxis) +
void BVH_Triangulation<T, N>::Swap (const Standard_Integer theIndex1,
const Standard_Integer theIndex2)
{
- BVH_Vec4i& anIndices1 = BVH::ArrayOp<Standard_Integer, 4>::ChangeValue (Elements, theIndex1);
- BVH_Vec4i& anIndices2 = BVH::ArrayOp<Standard_Integer, 4>::ChangeValue (Elements, theIndex2);
+ BVH_Vec4i& anIndices1 = BVH::Array<Standard_Integer, 4>::ChangeValue (Elements, theIndex1);
+ BVH_Vec4i& anIndices2 = BVH::Array<Standard_Integer, 4>::ChangeValue (Elements, theIndex2);
std::swap (anIndices1, anIndices2);
}
// Use this macro to switch between STL and OCCT vector types
#define _BVH_USE_STD_VECTOR_
+#include <vector>
+
+#include <NCollection_Mat4.hxx>
#include <NCollection_Vec2.hxx>
#include <NCollection_Vec3.hxx>
-#include <NCollection_Vec4.hxx>
#include <NCollection_Vector.hxx>
-#include <NCollection_Mat4.hxx>
-#include <Standard_Type.hxx>
-
-#include <vector>
namespace BVH
{
- //! Allows for fast switching between Eigen and NCollection vectors.
+ //! Tool class for selecting appropriate vector type (Eigen or NCollection).
+ //! \tparam T Numeric data type
+ //! \tparam N Component number
template<class T, int N> struct VectorType
{
// Not implemented
typedef NCollection_Vec4<T> Type;
};
- template<class T, int N = 1> struct ArrayType
- {
- #ifndef _BVH_USE_STD_VECTOR_
- typedef NCollection_Vector<typename VectorType<T, N>::Type> Type;
- #else
- typedef std::vector<typename VectorType<T, N>::Type> Type;
- #endif
- };
-
- //! Allows to fast switching between Eigen and NCollection matrices.
+ //! Tool class for selecting appropriate matrix type (Eigen or NCollection).
+ //! \tparam T Numeric data type
+ //! \tparam N Matrix dimension
template<class T, int N> struct MatrixType
{
// Not implemented
typedef NCollection_Mat4<T> Type;
};
- template<class T>
- static inline Standard_Integer IntFloor (const T theValue)
+ //! Tool class for selecting type of array of vectors (STD or NCollection vector).
+ //! \tparam T Numeric data type
+ //! \tparam N Component number
+ template<class T, int N = 1> struct ArrayType
{
- const Standard_Integer aRes = static_cast<Standard_Integer> (theValue);
-
- return aRes - static_cast<Standard_Integer> (aRes > theValue);
- }
+ #ifndef _BVH_USE_STD_VECTOR_
+ typedef NCollection_Vector<typename VectorType<T, N>::Type> Type;
+ #else
+ typedef std::vector<typename VectorType<T, N>::Type> Type;
+ #endif
+ };
}
//! 2D vector of integers.
//! 4x4 matrix of double precision reals.
typedef BVH::MatrixType<Standard_Real, 4>::Type BVH_Mat4d;
-#include <BVH_Types.lxx>
+namespace BVH
+{
+ //! Tool class for accessing specific vector component (by index).
+ //! \tparam T Numeric data type
+ //! \tparam N Component number
+ template<class T, int N> struct VecComp
+ {
+ // Not implemented
+ };
+
+ template<class T> struct VecComp<T, 2>
+ {
+ typedef typename BVH::VectorType<T, 2>::Type BVH_Vec2t;
+
+ static T Get (const BVH_Vec2t& theVec, const Standard_Integer theAxis)
+ {
+ return theAxis == 0 ? theVec.x() : theVec.y();
+ }
+ };
+
+ template<class T> struct VecComp<T, 3>
+ {
+ typedef typename BVH::VectorType<T, 3>::Type BVH_Vec3t;
+
+ static T Get (const BVH_Vec3t& theVec, const Standard_Integer theAxis)
+ {
+ return theAxis == 0 ? theVec.x() : ( theAxis == 1 ? theVec.y() : theVec.z() );
+ }
+ };
+
+ template<class T> struct VecComp<T, 4>
+ {
+ typedef typename BVH::VectorType<T, 4>::Type BVH_Vec4t;
+
+ static T Get (const BVH_Vec4t& theVec, const Standard_Integer theAxis)
+ {
+ return theAxis == 0 ? theVec.x() :
+ (theAxis == 1 ? theVec.y() : ( theAxis == 2 ? theVec.z() : theVec.w() ));
+ }
+ };
+
+ //! Tool class providing typical operations on the array. It allows
+ //! for interoperability between STD vector and NCollection vector.
+ //! \tparam T Numeric data type
+ //! \tparam N Component number
+ template<class T, int N = 1> struct Array
+ {
+ typedef typename BVH::ArrayType<T, N>::Type BVH_ArrayNt;
+
+ static inline const typename BVH::VectorType<T, N>::Type& Value (
+ const BVH_ArrayNt& theArray, const Standard_Integer theIndex)
+ {
+#ifdef _BVH_USE_STD_VECTOR_
+ return theArray[theIndex];
+#else
+ return theArray.Value (theIndex);
+#endif
+ }
+
+ static inline typename BVH::VectorType<T, N>::Type& ChangeValue (
+ BVH_ArrayNt& theArray, const Standard_Integer theIndex)
+ {
+#ifdef _BVH_USE_STD_VECTOR_
+ return theArray[theIndex];
+#else
+ return theArray.ChangeValue (theIndex);
+#endif
+ }
+
+ static inline void Append (BVH_ArrayNt& theArray,
+ const typename BVH::VectorType<T, N>::Type& theElement)
+ {
+#ifdef _BVH_USE_STD_VECTOR_
+ theArray.push_back (theElement);
+#else
+ theArray.Append (theElement);
+#endif
+ }
+
+ static inline Standard_Integer Size (const BVH_ArrayNt& theArray)
+ {
+#ifdef _BVH_USE_STD_VECTOR_
+ return static_cast<Standard_Integer> (theArray.size());
+#else
+ return static_cast<Standard_Integer> (theArray.Size());
+#endif
+ }
+
+ static inline void Clear (BVH_ArrayNt& theArray)
+ {
+#ifdef _BVH_USE_STD_VECTOR_
+ theArray.clear();
+#else
+ theArray.Clear();
+#endif
+ }
+ };
+
+ template<class T>
+ static inline Standard_Integer IntFloor (const T theValue)
+ {
+ const Standard_Integer aRes = static_cast<Standard_Integer> (theValue);
+
+ return aRes - static_cast<Standard_Integer> (aRes > theValue);
+ }
+}
#endif // _BVH_Types_Header
+++ /dev/null
-// Created on: 2013-12-20
-// Created by: Denis BOGOLEPOV
-// Copyright (c) 2013-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-namespace BVH
-{
- template<class T, int N> struct VecComp
- {
- // Not implemented
- };
-
- template<class T> struct VecComp<T, 2>
- {
- typedef typename BVH::VectorType<T, 2>::Type BVH_Vec2t;
-
- static T Get (const BVH_Vec2t& theVec,
- const Standard_Integer theAxis)
- {
- return theAxis == 0 ? theVec.x() : theVec.y();
- }
- };
-
- template<class T> struct VecComp<T, 3>
- {
- typedef typename BVH::VectorType<T, 3>::Type BVH_Vec3t;
-
- static T Get (const BVH_Vec3t& theVec,
- const Standard_Integer theAxis)
- {
- return theAxis == 0 ? theVec.x() : ( theAxis == 1 ? theVec.y() : theVec.z() );
- }
- };
-
- template<class T> struct VecComp<T, 4>
- {
- typedef typename BVH::VectorType<T, 4>::Type BVH_Vec4t;
-
- static T Get (const BVH_Vec4t& theVec,
- const Standard_Integer theAxis)
- {
- return theAxis == 0
- ? theVec.x()
- : (theAxis == 1 ? theVec.y() : ( theAxis == 2 ? theVec.z() : theVec.w() ));
- }
- };
-
- template<class T, int N = 1> struct ArrayOp
- {
- typedef typename BVH::ArrayType<T, N>::Type BVH_ArrayNt;
-
- static inline
- const typename BVH::VectorType<T, N>::Type& Value (const BVH_ArrayNt& theArray,
- const Standard_Integer theIndex)
- {
- #ifdef _BVH_USE_STD_VECTOR_
- return theArray[theIndex];
- #else
- return theArray.Value (theIndex);
- #endif
- }
-
- static inline
- typename BVH::VectorType<T, N>::Type& ChangeValue (BVH_ArrayNt& theArray,
- const Standard_Integer theIndex)
- {
- #ifdef _BVH_USE_STD_VECTOR_
- return theArray[theIndex];
- #else
- return theArray.ChangeValue (theIndex);
- #endif
- }
-
- static inline void Append (BVH_ArrayNt& theArray,
- const typename BVH::VectorType<T, N>::Type& theElement)
- {
- #ifdef _BVH_USE_STD_VECTOR_
- theArray.push_back (theElement);
- #else
- theArray.Append (theElement);
- #endif
- }
-
- static inline Standard_Integer Size (const BVH_ArrayNt& theArray)
- {
- #ifdef _BVH_USE_STD_VECTOR_
- return static_cast<Standard_Integer> (theArray.size());
- #else
- return static_cast<Standard_Integer> (theArray.Size());
- #endif
- }
-
- static inline void Clear (BVH_ArrayNt& theArray)
- {
- #ifdef _BVH_USE_STD_VECTOR_
- theArray.clear();
- #else
- theArray.Clear();
- #endif
- }
- };
-}
BVH_Triangulation.hxx
BVH_Triangulation.lxx
BVH_Types.hxx
-BVH_Types.lxx
BVH_QueueBuilder.hxx
BVH_QueueBuilder.lxx