Modeling - Optimize interference detection in polyhedra#924
Modeling - Optimize interference detection in polyhedra#924dpasukhi wants to merge 1 commit intoOpen-Cascade-SAS:IRfrom
Conversation
dpasukhi
commented
Dec 16, 2025
- Added new test files: IntPatch_PolyhedronBVH_Test.cxx and IntPatch_BVHTraversal.{cxx,hxx} for enhanced testing of BVH traversal.
- Refactored IntPatch_InterferencePolyhedron to utilize BVH for efficient triangle pair detection, improving performance in interference checks.
- Removed unused includes and redundant code to streamline the implementation.
- Added new test files: IntPatch_PolyhedronBVH_Test.cxx and IntPatch_BVHTraversal.{cxx,hxx} for enhanced testing of BVH traversal.
- Refactored IntPatch_InterferencePolyhedron to utilize BVH for efficient triangle pair detection, improving performance in interference checks.
- Removed unused includes and redundant code to streamline the implementation.
There was a problem hiding this comment.
Pull request overview
This PR optimizes interference detection in polyhedra by replacing the legacy Bnd_BoundSortBox-based approach with a modern BVH (Bounding Volume Hierarchy) implementation. The changes improve performance through O(log n) spatial queries instead of linear search.
Key Changes:
- Introduced
IntPatch_PolyhedronBVHto wrap polyhedra as BVH primitive sets - Implemented
IntPatch_BVHTraversalfor efficient dual-tree traversal to find candidate triangle pairs - Refactored
IntPatch_InterferencePolyhedron::Interference()to use BVH-based detection
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| IntPolyh/IntPolyh_MaillageAffinage.cxx | Removed unused Bnd_BoundSortBox include |
| IntPatch/IntPatch_PolyhedronBVH.hxx | New header defining BVH wrapper for polyhedra with triangle indexing |
| IntPatch/IntPatch_PolyhedronBVH.cxx | Implementation of BVH primitive set interface and index mapping |
| IntPatch/IntPatch_InterferencePolyhedron.cxx | Replaced legacy grid-based detection with BVH traversal |
| IntPatch/IntPatch_BVHTraversal.hxx | New header for BVH dual-tree traversal with pair collection |
| IntPatch/IntPatch_BVHTraversal.cxx | Implementation of BVH traversal with AABB overlap tests |
| IntPatch/FILES.cmake | Added new BVH-related source files to build configuration |
| GTests/IntPatch_PolyhedronBVH_Test.cxx | Comprehensive unit tests for BVH functionality |
| GTests/FILES.cmake | Added new test file to test suite |
| myIndexMap(1, 1) | ||
| { | ||
| myIndexMap.Init(0); |
There was a problem hiding this comment.
The initialization pattern creates an array with range [1,1] and then immediately overwrites it with Init(0). This is inefficient and confusing. Consider initializing myIndexMap with the correct range [0,0] directly in the initializer list: myIndexMap(0, 0). The same issue occurs in the second constructor at lines 41-43.
| const opencascade::handle<BVH_Tree<Standard_Real, 3>>& aBVH1 = theSet1.BVH(); | ||
| const opencascade::handle<BVH_Tree<Standard_Real, 3>>& aBVH2 = theSet2.BVH(); |
There was a problem hiding this comment.
Use Handle(BVH_Tree<Standard_Real, 3>) instead of opencascade::handle<...> to follow OCCT naming conventions. The Handle macro is the standard OCCT pattern for reference-counted objects.
|
Great! 👍 |
|
Dear @eryar I like your feature requests. At the moment I filtering some tickets from mantis before frizzing it. |
👌 I have learned a lot from OCC, If I have any new ideas, I will share with you on the Github. |