|
|
|||
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_BVHTraversal_HeaderFile 0015 #define IntPatch_BVHTraversal_HeaderFile 0016 0017 #include <BVH_Traverse.hxx> 0018 #include <NCollection_DynamicArray.hxx> 0019 0020 class IntPatch_PolyhedronBVH; 0021 0022 //! Performs BVH tree traversal of two polyhedra to find candidate triangle pairs 0023 //! for intersection testing. This class implements the BVH_PairTraverse interface 0024 //! to efficiently find potentially intersecting triangles using bounding box tests. 0025 //! 0026 //! The traversal collects pairs of original (1-based) triangle indices that have 0027 //! overlapping bounding boxes, which should then be tested for actual geometric 0028 //! intersection using IntPatch_InterferencePolyhedron::Intersect(). 0029 class IntPatch_BVHTraversal : public BVH_PairTraverse<double, 3> 0030 { 0031 public: 0032 //! Pair of triangle indices (both 1-based, original indices in polyhedra). 0033 struct TrianglePair 0034 { 0035 int First; //!< Triangle index in first polyhedron (1-based) 0036 int Second; //!< Triangle index in second polyhedron (1-based) 0037 0038 TrianglePair(int theFirst = 0, int theSecond = 0) 0039 : First(theFirst), 0040 Second(theSecond) 0041 { 0042 } 0043 }; 0044 0045 public: 0046 //! Creates an empty traversal object. 0047 Standard_EXPORT IntPatch_BVHTraversal(); 0048 0049 //! Destructor. 0050 Standard_EXPORT virtual ~IntPatch_BVHTraversal(); 0051 0052 //! Performs BVH traversal and collects candidate triangle pairs. 0053 //! @param[in] theSet1 BVH set for the first polyhedron 0054 //! @param[in] theSet2 BVH set for the second polyhedron 0055 //! @param[in] theSelfInterference if true, skip pairs where first index >= second index 0056 //! (used for self-intersection where we don't want to test same pair twice) 0057 //! @return number of collected pairs 0058 Standard_EXPORT int Perform(IntPatch_PolyhedronBVH& theSet1, 0059 IntPatch_PolyhedronBVH& theSet2, 0060 bool theSelfInterference = false); 0061 0062 //! Returns the collected triangle pairs. 0063 const NCollection_DynamicArray<TrianglePair>& Pairs() const { return myPairs; } 0064 0065 //! Clears the collected pairs. 0066 void Clear() { myPairs.Clear(); } 0067 0068 public: //! @name BVH_PairTraverse interface implementation 0069 //! Rejects pair of nodes if their bounding boxes don't overlap. 0070 //! @param[in] theCMin1 minimum corner of the first node's bounding box 0071 //! @param[in] theCMax1 maximum corner of the first node's bounding box 0072 //! @param[in] theCMin2 minimum corner of the second node's bounding box 0073 //! @param[in] theCMax2 maximum corner of the second node's bounding box 0074 //! @param[out] theMetric unused metric parameter 0075 //! @return true if the pair should be rejected (no overlap), false otherwise 0076 Standard_EXPORT virtual bool RejectNode(const BVH_Vec3d& theCMin1, 0077 const BVH_Vec3d& theCMax1, 0078 const BVH_Vec3d& theCMin2, 0079 const BVH_Vec3d& theCMax2, 0080 double& theMetric) const override; 0081 0082 //! Accepts a pair of leaf elements and stores their original indices. 0083 //! @param[in] theIndex1 0-based index in the first BVH set 0084 //! @param[in] theIndex2 0-based index in the second BVH set 0085 //! @return true (always accepts the pair) 0086 Standard_EXPORT virtual bool Accept(const int theIndex1, const int theIndex2) override; 0087 0088 private: 0089 IntPatch_PolyhedronBVH* mySet1; //!< First BVH set 0090 IntPatch_PolyhedronBVH* mySet2; //!< Second BVH set 0091 bool mySelfInterference; //!< Self-interference mode flag 0092 NCollection_DynamicArray<TrianglePair> myPairs; //!< Collected triangle pairs 0093 }; 0094 0095 #endif // IntPatch_BVHTraversal_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|