Skip to content

[CGAL Intersection Detection] PR Sofa and cgal intersection detection#2

Open
FadiWahbeh wants to merge 7 commits into
masterfrom
SOFA_CGAL_Intersection_Detection
Open

[CGAL Intersection Detection] PR Sofa and cgal intersection detection#2
FadiWahbeh wants to merge 7 commits into
masterfrom
SOFA_CGAL_Intersection_Detection

Conversation

@FadiWahbeh

Copy link
Copy Markdown

Based on #1

PR 01 — SOFA → CGAL Detection Bridge

Goal

This PR validates the first bridge between SOFA and CGAL inside MeshRepulsionEngine.

The component now:

  • reads masterState, slaveState, masterTopology, and slaveTopology from SOFA;
  • builds a CGAL::Surface_mesh from the SOFA master surface;
  • builds a CGAL::Surface_mesh from the SOFA slave surface for validation/debug;
  • uses CGAL::Side_of_triangle_mesh to classify slave vertices as:
    • inside the master mesh;
    • on the boundary of the master mesh;
    • outside the master mesh;
  • prints diagnostic information in the terminal.

Modify Test Scene

scenes/MeshRepulsion.scn

The scene uses the OBJ files at the paths defined in the MeshOBJLoader components.

Example:

<MeshOBJLoader name="loader" filename="./data/mesh/liver_coarse.obj"/>
<MeshOBJLoader name="loader" filename="./data/mesh/diaphragm.obj"/>

Build

From the SOFA build environment, rebuild the plugin:

"/c/Program Files/CMake/bin/cmake.exe" --build /c/projects/sofa-build --config Release --target CGALPlugin

Run

From the SOFA binary directory:

cd /c/projects/sofa-build/bin/Release 

./runSofa.exe /c/projects/sofa-plugins/CGALPlugin/scenes/MeshRepulsion_PR01.scn

Expected Console Output

When the scene is loaded and/or when the simulation starts, the terminal should show a diagnostic line similar to:

[CGAL detection] step=1 masterVertices=600 masterTriangles=1200 slaveVertices=752 slaveTriangles=1500 inside=112 boundary=0 outside=640 slaveCgalFaces=1500

What This PR Proves

This PR proves that:

  • SOFA links are valid;
  • CGAL can be called from inside MeshRepulsionEngine;
  • the master obstacle can be converted from SOFA topology/positions to a CGAL surface mesh;
  • the slave mesh can also be converted to a CGAL surface mesh for validation/debug;
  • the current slave positions can be acquire from SOFA;
  • slave vertices can be classified as inside, boundary, or outside the master mesh.

Not Included Yet

This PR does not include:

  • vertex displacement;
  • face/edge/sphere collision detection;
  • volumetric .msh slave handling;
  • tetrahedral FEM scene;
  • OBJ export.

Next Step

The next PR will use the CGAL detection result to compute a small smooth displacement for slave vertices detected inside the master mesh.

The objective of PR 02 will be:

CGAL detects inside vertices → compute a small repulsion vector → update slave positions smoothly

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants