Sofa cgal tetrahedron push with repulsive force#4
Open
FadiWahbeh wants to merge 3 commits into
Open
Conversation
7e795f5 to
89860d5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on #2
PS : don't merge or take in consideration PR #3 because it's not used and won't be used. Also, GitHub didn't let me add the .msh objects.
PR 02 — CGAL Detection → SOFA ForceField
Goal
This PR turns
MeshRepulsionEngineinto a realForceField. It uses the PR 01 CGAL detection to generate penalty forces that push the slave out of the master, and lets the SOFA solver integrate those forces together with mass, FEM and damping. CGAL is used only for geometric detection and contact direction; SOFA integrates the motion.The component now:
ForceField<DataTypes>(templated,Vec3Types), implementingaddForce,addDForce,addKToMatrixandgetPotentialEnergy;Side_of_triangle_meshinside/outside tester once (cached), since the master is static;safetyDistanceof the surface;mergeContact);F = stiffness * penetration * nalong the master-oriented normal (orientedNormalFromClosestFace), with:crossingDepthgiving edge/face crossings a force even when the vertex is outside the safety band,maxForceclamping the per-vertex magnitude,contactDampingopposing the vertex velocity;neighborhoodRings,neighborWeight) to better preserve the slave shape (applyDistributedForce);addDForce,addKToMatrix);Data / API
New Data exposed by the component:
Read-only diagnostics:
Performance
Two fixes were required to keep the scene interactive:
Side_of_triangle_meshtester and the master AABB tree are built once, not per contact (they were previously rebuilt for every contact, which dropped the scene to ~0.5-1 FPS);m_isSurfaceVertexmask); interior vertices follow the surface through the FEM.Modify Test Scene
The slave now carries a solver, a mass, and the repulsion ForceField:
Test Scenes
Three patient scenes are provided. Each one loads its own liver (master) and diaphragm (slave) and runs the same repulsion component.
The slave is a tetrahedral volume driven by a
TetrahedronFEMForceField: CGAL reads the boundary surface triangles to detect contacts, while the volumetric FEM integrates the resulting forces and preserves the organ shape. Surface and volume share the same DOFs, so a force applied by CGAL on a surface vertex propagates through the volume.Click to expand XML configuration — Patient 01
Click to expand XML configuration — Patient 08
Click to expand XML configuration — Patient 16
Observation on Patient 16
Patient 16 and 08 are the case that the slave rotates and re-enters the master from the opposite side before coming back out. This is an unanchored deformable body under one-sided contact forces, pushing one side out injects momentum that might makes the free body pivot, so the opposite side dips into the master, generates its own contacts, and gets pushed out in turn. Patients 01 is more stable. The solution to this issue is to try and fixe a region of the slave so it wouldn't pevot twords the master.
Build
Run
What This PR Proves
Not Included Yet