0025159: Collections and common types in BVH package are named in non-conformant...
authordbp <dbp@opencascade.com>
Thu, 9 Oct 2014 11:31:24 +0000 (15:31 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 9 Oct 2014 12:02:10 +0000 (16:02 +0400)
Fix GCC compilation errors.

19 files changed:
src/BVH/BVH_BinnedBuilder.lxx
src/BVH/BVH_Box.hxx
src/BVH/BVH_Box.lxx
src/BVH/BVH_Builder.hxx
src/BVH/BVH_Geometry.hxx
src/BVH/BVH_LinearBuilder.lxx
src/BVH/BVH_Object.hxx
src/BVH/BVH_ObjectSet.hxx
src/BVH/BVH_ObjectSet.lxx
src/BVH/BVH_PrimitiveSet.hxx
src/BVH/BVH_Set.hxx
src/BVH/BVH_SweepPlaneBuilder.lxx
src/BVH/BVH_Tree.hxx
src/BVH/BVH_Tree.lxx
src/BVH/BVH_Triangulation.hxx
src/BVH/BVH_Triangulation.lxx
src/BVH/BVH_Types.hxx
src/BVH/BVH_Types.lxx [deleted file]
src/BVH/FILES

index 3ea88cd..7ad8c22 100644 (file)
@@ -165,7 +165,7 @@ void BVH_BinnedBuilder<T, N, Bins>::BuildNode (BVH_Set<T, N>*         theSet,
   // 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;
index fc1f4a7..95c2d7c 100644 (file)
@@ -18,7 +18,9 @@
 
 #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
 {
@@ -29,26 +31,26 @@ public:
 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:
 
@@ -85,14 +87,170 @@ 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
index b727561..5082c66 100644 (file)
 
 #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  :
@@ -92,7 +22,7 @@ namespace BVH
 template<class T, int N>
 void BVH_Box<T, N>::Clear()
 {
-  myInitialized = Standard_False;
+  myIsInited = Standard_False;
 }
 
 // =======================================================================
@@ -102,7 +32,7 @@ void BVH_Box<T, N>::Clear()
 template<class T, int N>
 Standard_Boolean BVH_Box<T, N>::IsValid() const
 {
-  return myInitialized;
+  return myIsInited;
 }
 
 // =======================================================================
@@ -112,12 +42,12 @@ Standard_Boolean BVH_Box<T, N>::IsValid() const
 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
   {
@@ -126,47 +56,6 @@ void BVH_Box<T, N>::Add (const BVH_VecNt& thePoint)
   }
 }
 
-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  :
@@ -174,14 +63,14 @@ namespace BVH
 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
     {
@@ -191,46 +80,6 @@ void BVH_Box<T, N>::Combine (const BVH_Box& theBox)
   }
 }
 
-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  :
@@ -238,8 +87,8 @@ namespace BVH
 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);
 }
 
 // =======================================================================
@@ -301,3 +150,13 @@ typename BVH_Box<T, N>::BVH_VecNt BVH_Box<T, N>::Center() const
 {
   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);
+}
index 1521343..d42ff32 100644 (file)
 #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)
@@ -57,8 +60,8 @@ public:
 
 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
 
 };
 
index 6bc38f6..9c2c322 100644 (file)
 #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>
 {
@@ -36,16 +39,16 @@ public:
   //! 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:
index 26a7d0d..3507771 100644 (file)
@@ -149,7 +149,7 @@ namespace BVH
 
       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())
         {
@@ -179,7 +179,7 @@ Standard_Integer BVH_LinearBuilder<T, N>::EmitHierachy (BVH_Tree<T, N>*
                                                         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));
index 96a36fb..2c36cea 100644 (file)
@@ -21,7 +21,9 @@
 
 #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
 {
@@ -35,21 +37,21 @@ public:
 
 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
 
 };
index 39db008..20964e1 100644 (file)
 #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.
@@ -40,13 +40,13 @@ public:
 
 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:
@@ -54,13 +54,13 @@ 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:
index 3140af3..87d9352 100644 (file)
@@ -95,8 +95,8 @@ template<class T, int N>
 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);
 }
 
 // =======================================================================
@@ -107,9 +107,6 @@ template<class T, int N>
 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));
 }
index a1e7f4c..93b08a2 100644 (file)
 #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>
 {
@@ -40,13 +47,13 @@ public:
   //! 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:
index 743288b..274f09f 100644 (file)
 
 #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
 {
@@ -34,22 +37,22 @@ public:
   //! 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;
 
index 1708206..9454fba 100644 (file)
@@ -70,7 +70,7 @@ void BVH_SweepPlaneBuilder<T, N>::BuildNode (BVH_Set<T, N>*         theSet,
   {
     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;
     }
@@ -114,6 +114,9 @@ void BVH_SweepPlaneBuilder<T, N>::BuildNode (BVH_Set<T, N>*         theSet,
     }
   }
 
+  delete [] aLftSet;
+  delete [] aRghSet;
+
   if (aMinSplitAxis == -1)
   {
     return;
index 5aeecd0..fecaabd 100644 (file)
@@ -50,73 +50,73 @@ public:
   //! 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.
@@ -128,37 +128,37 @@ public:
   //! 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.
index ac3d5a5..e0bd7d0 100644 (file)
@@ -22,10 +22,10 @@ void BVH_Tree<T, N>::Clear()
 {
   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);
 }
 
 // =======================================================================
@@ -36,9 +36,9 @@ template<class T, int N>
 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);
 }
 
 // =======================================================================
@@ -49,9 +49,9 @@ template<class T, int N>
 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);
 }
 
 // =======================================================================
@@ -64,12 +64,12 @@ Standard_Integer BVH_Tree<T, N>::AddLeafNode (const BVH_VecNt&       theMinPoint
                                               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);
 }
 
 // =======================================================================
@@ -82,12 +82,12 @@ Standard_Integer BVH_Tree<T, N>::AddInnerNode (const BVH_VecNt&       theMinPoin
                                                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);
 }
 
 // =======================================================================
@@ -116,10 +116,12 @@ Standard_Integer BVH_Tree<T, N>::AddInnerNode (const BVH_Box<T, N>&   theAABB,
 
 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),
@@ -127,28 +129,28 @@ namespace BVH
 
     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);
       }
     }
   }
index f809d5f..cd91f90 100644 (file)
@@ -18,7 +18,9 @@
 
 #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>
 {
@@ -28,10 +30,10 @@ public:
 
 public:
 
-  //! Creates new triangulation.
+  //! Creates empty triangulation.
   BVH_Triangulation();
 
-  //! Releases resources of geometric object.
+  //! Releases resources of triangulation.
   virtual ~BVH_Triangulation();
 
 public:
@@ -39,22 +41,22 @@ 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);
 
index 5cc9d64..19ff30f 100644 (file)
@@ -40,7 +40,7 @@ BVH_Triangulation<T, N>::~BVH_Triangulation()
 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);
 }
 
 // =======================================================================
@@ -50,11 +50,11 @@ Standard_Integer BVH_Triangulation<T, N>::Size() const
 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;
@@ -75,11 +75,11 @@ template<class T, int N>
 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) +
@@ -94,8 +94,8 @@ template<class T, int N>
 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);
 }
index d67f04f..afada81 100644 (file)
 // 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
@@ -56,16 +56,9 @@ namespace BVH
     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
@@ -76,13 +69,17 @@ namespace BVH
     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.
@@ -133,6 +130,111 @@ typedef BVH::MatrixType<Standard_ShortReal, 4>::Type BVH_Mat4f;
 //! 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
diff --git a/src/BVH/BVH_Types.lxx b/src/BVH/BVH_Types.lxx
deleted file mode 100644 (file)
index b4d5650..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-// 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
-    }
-  };
-}
index c50ec7b..5c73d63 100644 (file)
@@ -31,6 +31,5 @@ BVH_Tree.lxx
 BVH_Triangulation.hxx
 BVH_Triangulation.lxx
 BVH_Types.hxx
-BVH_Types.lxx
 BVH_QueueBuilder.hxx
 BVH_QueueBuilder.lxx