Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:18

0001 // Created on: 2013-12-20
0002 // Created by: Denis BOGOLEPOV
0003 // Copyright (c) 2013-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef BVH_Builder_HeaderFile
0017 #define BVH_Builder_HeaderFile
0018 
0019 #include <BVH_Set.hxx>
0020 #include <BVH_BinaryTree.hxx>
0021 
0022 //! A non-template class for using as base for BVH_Builder
0023 //! (just to have a named base class).
0024 class BVH_BuilderTransient : public Standard_Transient
0025 {
0026   DEFINE_STANDARD_RTTIEXT(BVH_BuilderTransient, Standard_Transient)
0027 public:
0028 
0029   //! Returns the maximum depth of constructed BVH.
0030   Standard_Integer MaxTreeDepth() const { return myMaxTreeDepth; }
0031 
0032   //! Returns the maximum number of sub-elements in the leaf.
0033   Standard_Integer LeafNodeSize() const { return myLeafNodeSize; }
0034 
0035   //! Returns parallel flag.
0036   inline Standard_Boolean IsParallel() const
0037   {
0038     return myIsParallel;
0039   }
0040 
0041   //! Set parallel flag contolling possibility of parallel execution.
0042   inline void SetParallel(const Standard_Boolean isParallel)
0043   {
0044     myIsParallel = isParallel;
0045   }
0046 
0047 protected:
0048 
0049   //! Creates new abstract BVH builder.
0050   BVH_BuilderTransient (const Standard_Integer theLeafNodeSize,
0051                         const Standard_Integer theMaxTreeDepth)
0052   : myMaxTreeDepth (theMaxTreeDepth),
0053     myLeafNodeSize (theLeafNodeSize),
0054     myIsParallel   (Standard_False) {}
0055 
0056 protected:
0057 
0058   Standard_Integer myMaxTreeDepth; //!< Maximum depth of constructed BVH
0059   Standard_Integer myLeafNodeSize; //!< Maximum number of objects per leaf
0060   Standard_Boolean myIsParallel;   //!< Parallel execution flag.
0061 };
0062 
0063 //! Performs construction of BVH tree using bounding
0064 //! boxes (AABBs) of abstract objects.
0065 //! \tparam T Numeric data type
0066 //! \tparam N Vector dimension
0067 template<class T, int N>
0068 class BVH_Builder : public BVH_BuilderTransient
0069 {
0070 public:
0071 
0072   //! Builds BVH using specific algorithm.
0073   virtual void Build (BVH_Set<T, N>*       theSet,
0074                       BVH_Tree<T, N>*      theBVH,
0075                       const BVH_Box<T, N>& theBox) const = 0;
0076 
0077 protected:
0078 
0079   //! Creates new abstract BVH builder.
0080   BVH_Builder (const Standard_Integer theLeafNodeSize,
0081                const Standard_Integer theMaxTreeDepth)
0082   : BVH_BuilderTransient (theLeafNodeSize, theMaxTreeDepth) {}
0083 
0084   //! Updates depth of constructed BVH tree.
0085   void updateDepth (BVH_Tree<T, N>*        theBVH,
0086                     const Standard_Integer theLevel) const
0087   {
0088     if (theLevel > theBVH->myDepth)
0089     {
0090       theBVH->myDepth = theLevel;
0091     }
0092   }
0093 
0094 };
0095 
0096 #endif // _BVH_Builder_Header