|
|
|||
File indexing completed on 2026-09-28 09:20:43
0001 // Copyright (c) 2024 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef IntPatch_PolyhedronBVH_HeaderFile 0015 #define IntPatch_PolyhedronBVH_HeaderFile 0016 0017 #include <BVH_PrimitiveSet.hxx> 0018 #include <BVH_LinearBuilder.hxx> 0019 #include <NCollection_DynamicArray.hxx> 0020 0021 class IntPatch_Polyhedron; 0022 0023 //! Wraps IntPatch_Polyhedron as a BVH_PrimitiveSet for efficient spatial queries. 0024 //! This class provides a BVH (Bounding Volume Hierarchy) representation of a polyhedron's 0025 //! triangles, enabling O(log n) spatial queries instead of linear search. 0026 //! 0027 //! The class stores a reference to the polyhedron (no data copy) and maintains 0028 //! an index mapping to track triangle reordering during BVH construction. 0029 class IntPatch_PolyhedronBVH : public BVH_PrimitiveSet<double, 3> 0030 { 0031 public: 0032 //! Creates an empty BVH set. 0033 Standard_EXPORT IntPatch_PolyhedronBVH(); 0034 0035 //! Creates BVH set from the given polyhedron. 0036 //! @param[in] thePoly the polyhedron to wrap (must remain valid during BVH lifetime) 0037 Standard_EXPORT IntPatch_PolyhedronBVH(const IntPatch_Polyhedron& thePoly); 0038 0039 //! Destructor. 0040 Standard_EXPORT virtual ~IntPatch_PolyhedronBVH(); 0041 0042 //! Initializes BVH set from the given polyhedron. 0043 //! @param[in] thePoly the polyhedron to wrap (must remain valid during BVH lifetime) 0044 Standard_EXPORT void Init(const IntPatch_Polyhedron& thePoly); 0045 0046 //! Clears the BVH set. 0047 Standard_EXPORT void Clear(); 0048 0049 public: //! @name BVH_Set interface implementation 0050 // Make inherited Box() method visible 0051 using BVH_PrimitiveSet<double, 3>::Box; 0052 0053 //! Returns the total number of triangles. 0054 Standard_EXPORT virtual int Size() const override; 0055 0056 //! Returns AABB of the triangle with the given index. 0057 //! @param[in] theIndex 0-based triangle index (after BVH reordering) 0058 Standard_EXPORT virtual BVH_Box<double, 3> Box(const int theIndex) const override; 0059 0060 //! Returns centroid coordinate of the triangle along the given axis. 0061 //! @param[in] theIndex 0-based triangle index (after BVH reordering) 0062 //! @param[in] theAxis axis index (0=X, 1=Y, 2=Z) 0063 Standard_EXPORT virtual double Center(const int theIndex, const int theAxis) const override; 0064 0065 //! Swaps two triangles in the set (used during BVH construction). 0066 //! @param[in] theIndex1 first triangle index 0067 //! @param[in] theIndex2 second triangle index 0068 Standard_EXPORT virtual void Swap(const int theIndex1, const int theIndex2) override; 0069 0070 public: //! @name Additional methods 0071 //! Returns the original (1-based) triangle index in the polyhedron 0072 //! for the given 0-based index after BVH reordering. 0073 //! @param[in] theIndex 0-based triangle index (after BVH reordering) 0074 //! @return 1-based original triangle index in the polyhedron 0075 Standard_EXPORT int OriginalIndex(const int theIndex) const; 0076 0077 //! Returns true if the BVH set is initialized. 0078 bool IsInitialized() const { return myPoly != nullptr; } 0079 0080 private: 0081 const IntPatch_Polyhedron* myPoly; //!< Reference to the wrapped polyhedron 0082 NCollection_DynamicArray<int> myIndexMap; //!< Maps current indices to original 1-based indices 0083 }; 0084 0085 #endif // IntPatch_PolyhedronBVH_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|