Skip to content

Modeling - Optimize interference detection in polyhedra#924

Open
dpasukhi wants to merge 1 commit intoOpen-Cascade-SAS:IRfrom
dpasukhi:intpitch_bvh
Open

Modeling - Optimize interference detection in polyhedra#924
dpasukhi wants to merge 1 commit intoOpen-Cascade-SAS:IRfrom
dpasukhi:intpitch_bvh

Conversation

@dpasukhi
Copy link
Copy Markdown
Member

  • 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.
@dpasukhi
Copy link
Copy Markdown
Member Author

@dpasukhi dpasukhi requested a review from Copilot December 16, 2025 09:25
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_PolyhedronBVH to wrap polyhedra as BVH primitive sets
  • Implemented IntPatch_BVHTraversal for 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

Comment on lines +29 to +31
myIndexMap(1, 1)
{
myIndexMap.Init(0);
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +54 to +55
const opencascade::handle<BVH_Tree<Standard_Real, 3>>& aBVH1 = theSet1.BVH();
const opencascade::handle<BVH_Tree<Standard_Real, 3>>& aBVH2 = theSet2.BVH();
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot generated this review using guidance from repository custom instructions.
@eryar
Copy link
Copy Markdown

eryar commented Dec 16, 2025

Great! 👍

@dpasukhi
Copy link
Copy Markdown
Member Author

Dear @eryar I like your feature requests.
If you still some interesting ideas - let me know or report them in the GitHub ;)

At the moment I filtering some tickets from mantis before frizzing it.

@eryar
Copy link
Copy Markdown

eryar commented Dec 16, 2025

Dear @eryar I like your feature requests. If you still some interesting ideas - let me know or report them in the GitHub ;)

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.
Thanks for your awesome work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants