Back to home page

EIC code displayed by LXR

 
 

    


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

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_ObjectSet_HeaderFile
0017 #define BVH_ObjectSet_HeaderFile
0018 
0019 #include <BVH_Set.hxx>
0020 #include <BVH_Object.hxx>
0021 
0022 //! Array of abstract entities (bounded by BVH boxes) to built BVH.
0023 //! \tparam T Numeric data type
0024 //! \tparam N Vector dimension
0025 template<class T, int N>
0026 class BVH_ObjectSet : public BVH_Set<T, N>
0027 {
0028 public:
0029 
0030   //! Type of array of geometric objects.
0031   typedef NCollection_Vector<opencascade::handle<BVH_Object<T, N> > > BVH_ObjectList;
0032 
0033 public:
0034 
0035   //! Creates new set of geometric objects.
0036   BVH_ObjectSet() {}
0037 
0038   //! Releases resources of set of geometric objects.
0039   virtual ~BVH_ObjectSet() {}
0040 
0041 public:
0042 
0043   //! Removes all geometric objects.
0044   virtual void Clear()
0045   {
0046     for (typename BVH_ObjectList::Iterator anObjectIter (myObjects); anObjectIter.More(); anObjectIter.Next())
0047     {
0048       anObjectIter.ChangeValue().Nullify();
0049     }
0050     myObjects.Clear();
0051   }
0052 
0053   //! Returns reference to the array of geometric objects.
0054   BVH_ObjectList& Objects() { return myObjects; }
0055 
0056   //! Returns reference to the  array of geometric objects.
0057   const BVH_ObjectList& Objects() const { return myObjects; }
0058 
0059 public:
0060 
0061   //! Return total number of objects.
0062   virtual Standard_Integer Size() const Standard_OVERRIDE { return myObjects.Size(); }
0063 
0064   //! Returns AABB of entire set of objects.
0065   using BVH_Set<T, N>::Box;
0066 
0067   //! Returns AABB of the given object.
0068   virtual BVH_Box<T, N> Box (const Standard_Integer theIndex) const Standard_OVERRIDE { return myObjects.Value (theIndex)->Box(); }
0069 
0070   //! Returns centroid position along the given axis.
0071   virtual T Center (const Standard_Integer theIndex, const Standard_Integer theAxis) const Standard_OVERRIDE
0072   {
0073     // Note: general implementation, not optimal
0074     return BVH::CenterAxis<T, N>::Center (myObjects.Value (theIndex)->Box(), theAxis);
0075   }
0076 
0077   //! Performs transposing the two given objects in the set.
0078   virtual void Swap (const Standard_Integer theIndex1, const Standard_Integer theIndex2) Standard_OVERRIDE
0079   {
0080     std::swap (myObjects.ChangeValue (theIndex1),
0081                myObjects.ChangeValue (theIndex2));
0082   }
0083 
0084 protected:
0085 
0086   BVH_ObjectList myObjects; //!< Array of geometric objects
0087 
0088 };
0089 
0090 #endif // _BVH_ObjectSet_Header