Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions scenes/MeshRepulsion_patient_01.scn
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0"?>
<!-- =========================================================================
PR08 : CGAL detection -> standard SOFA RepulsiveSpringForceField

Goal:
- CGAL detects inside vertices and edge/face crossings.
- CGAL builds spring pairs only every N steps.
- The standard SOFA RepulsiveSpringForceField applies the mechanical force.
- The master AABB tree is built once by default; it is not rebuilt at each step.

Objects:
- liver_coarse.msh = MASTER, fixed.
- diaphragm.msh = SLAVE 1, tetra volume + mapped contact surface.
- bone.msh = SLAVE 2, triangle-only surface fallback.

No translation / rotation / scale is applied.
========================================================================= -->
<Node name="root" gravity="0 0 0" dt="0.003">
<RequiredPlugin pluginName="Sofa.Component.AnimationLoop"/>
<RequiredPlugin pluginName="Sofa.Component.IO.Mesh"/>
<RequiredPlugin pluginName="Sofa.Component.Mapping.Linear"/>
<RequiredPlugin pluginName="Sofa.Component.Setting"/>
<RequiredPlugin pluginName="Sofa.Component.StateContainer"/>
<RequiredPlugin pluginName="Sofa.Component.Topology.Container.Constant"/>
<RequiredPlugin pluginName="Sofa.Component.Topology.Container.Dynamic"/>
<RequiredPlugin pluginName="Sofa.Component.Topology.Mapping"/>
<RequiredPlugin pluginName="Sofa.Component.Topology.Utility"/>
<RequiredPlugin pluginName="Sofa.Component.Visual"/>
<RequiredPlugin pluginName="Sofa.GL.Component.Rendering3D"/>
<RequiredPlugin pluginName="Sofa.Component.LinearSolver.Iterative"/>
<RequiredPlugin pluginName="Sofa.Component.Mass"/>
<RequiredPlugin pluginName="Sofa.Component.ODESolver.Backward"/>
<RequiredPlugin pluginName="Sofa.Component.SolidMechanics.FEM.Elastic"/>
<RequiredPlugin pluginName="Sofa.Component.SolidMechanics.Spring"/>
<RequiredPlugin pluginName="CGALPlugin"/>

<BackgroundSetting color="0 0.16862745098 0.21176470588"/>
<VisualStyle displayFlags="showVisualModels showBehaviorModels"/>
<DefaultAnimationLoop/>

<Node name="MasterLiver">
<MeshGmshLoader name="loader" filename="./STL_Intersection_Objects/Patient_01/liver_coarse_patient_01.msh"/>
<MechanicalObject name="dofs" template="Vec3d" position="@loader.position" showObject="false"/>
<TriangleSetTopologyContainer name="topology" src="@loader"/>
<TriangleSetTopologyModifier name="topologyModifier"/>
<TriangleSetGeometryAlgorithms name="geometryAlgorithms" template="Vec3d"/>

<Node name="Visual">
<OglModel name="visu" src="@../loader" color="1 0.05 0.05 1.0"/>
<IdentityMapping input="@../dofs" output="@visu"/>
</Node>
</Node>

<Node name="SlaveDiaphragmVolume">
<EulerImplicitSolver name="odesolver" rayleighStiffness="0.25" rayleighMass="0.45"/>
<CGLinearSolver name="linearsolver" iterations="60" tolerance="1.0e-6" threshold="1.0e-6"/>

<MeshGmshLoader name="volumeLoader" filename="./STL_Intersection_Objects/Patient_01/diaphragm_patient_01.msh"/>
<MechanicalObject name="dofs" template="Vec3d" position="@volumeLoader.position" showObject="false"/>
<TetrahedronSetTopologyContainer name="topology" src="@volumeLoader"/>
<TetrahedronSetTopologyModifier name="topologyModifier"/>
<TetrahedronSetGeometryAlgorithms name="geometryAlgorithms" template="Vec3d"/>

<!-- to adapt to the scene -->
<!--
<BoxROI name="box_roi" box="0 0 0 300 300 70 0 0 220 300 300 300" drawBoxes="1"/>
<FixedProjectiveConstraint indices="@[-1].indices" />
-->
<UniformMass totalMass="1.2"/>
<TetrahedronFEMForceField name="tetraFEM" template="Vec3d" method="large" youngModulus="5000" poissonRatio="0.45"/>

<RestShapeSpringsForceField stiffness="100" angularStiffness="100" />


<Node name="ContactSurface">
<MechanicalObject name="surfaceDofs" template="Vec3d" position="@../volumeLoader.position" showObject="false"/>
<TriangleSetTopologyContainer name="surfaceTopology" src="@../volumeLoader"/>
<TriangleSetTopologyModifier name="surfaceTopologyModifier"/>
<TriangleSetGeometryAlgorithms name="surfaceGeometryAlgorithms" template="Vec3d"/>
<BarycentricMapping name="surfaceToVolumeMapping" input="@../dofs" output="@surfaceDofs" mapForces="true" mapMasses="false"/>

<MeshRepulsionEngine name="diaphragmCgalSpringPairs" template="Vec3d"
masterState="@../../MasterLiver/dofs"
masterTopology="@../../MasterLiver/topology"
slaveState="@surfaceDofs"
slaveTopology="@surfaceTopology"
repulsiveSpringField="@diaphragmRepulsiveSprings"
safetyDistance="1.2"
crossingDepth="2.2"
pushInsideVertices="true"
pushEdgeCrossings="true"
pushFaceCrossings="false"
rebuildMasterEveryStep="false"
computeEveryNSteps="4"
maxPairs="2500"
maxEdgesCheckedPerUpdate="8000"
maxFacesCheckedPerUpdate="0"
logEveryNSteps="20"
stiffness="10000"
maxForce="10000"
/>

<Node name="Visual">
<OglModel name="visu" src="@../../volumeLoader" color="0.15 0.55 1.0 0.35"/>
<IdentityMapping input="@../surfaceDofs" output="@visu"/>
</Node>

<Node name="CollisionMesh">
<MeshOBJLoader name="loader_surface" filename="./STL_Intersection_Objects/Patient_01/diaphragm_patient_01.obj"/>
<MechanicalObject name="collisionDofs" template="Vec3d" position="@loader_surface.position"/>
<TriangleSetTopologyContainer name="collisionTopology" src="@loader_surface"/>
<TriangleSetTopologyModifier name="collisionTopologyModifier"/>
<TriangleSetGeometryAlgorithms name="collisionGeometryAlgorithms" template="Vec3d" drawEdges="1"/>
<BarycentricMapping input="@../surfaceDofs" output="@collisionDofs"/>
<MeshExporter triangles="@collisionTopology.triangles" edges="@collisionTopology.edges" position="@collisionDofs.position" exportAtEnd="1" filename="toto.obj"/>
</Node>

</Node>
</Node>
</Node>
91 changes: 91 additions & 0 deletions scenes/MeshRepulsion_patient_08.scn
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0"?>
<!-- =========================================================================
PR08 : CGAL detection -> standard SOFA RepulsiveSpringForceField
Patient 16. Master = liver (.obj). Slave = diaphragm tetra.
No translation / rotation / scale is applied.
========================================================================= -->
<Node name="root" gravity="0 0 0" dt="0.003">
<RequiredPlugin pluginName="Sofa.Component.AnimationLoop"/>
<RequiredPlugin pluginName="Sofa.Component.IO.Mesh"/>
<RequiredPlugin pluginName="Sofa.Component.Mapping.Linear"/>
<RequiredPlugin pluginName="Sofa.Component.Setting"/>
<RequiredPlugin pluginName="Sofa.Component.StateContainer"/>
<RequiredPlugin pluginName="Sofa.Component.Topology.Container.Constant"/>
<RequiredPlugin pluginName="Sofa.Component.Topology.Container.Dynamic"/>
<RequiredPlugin pluginName="Sofa.Component.Topology.Mapping"/>
<RequiredPlugin pluginName="Sofa.Component.Topology.Utility"/>
<RequiredPlugin pluginName="Sofa.Component.Visual"/>
<RequiredPlugin pluginName="Sofa.GL.Component.Rendering3D"/>
<RequiredPlugin pluginName="Sofa.Component.LinearSolver.Iterative"/>
<RequiredPlugin pluginName="Sofa.Component.Mass"/>
<RequiredPlugin pluginName="Sofa.Component.ODESolver.Backward"/>
<RequiredPlugin pluginName="Sofa.Component.SolidMechanics.FEM.Elastic"/>
<RequiredPlugin pluginName="Sofa.Component.SolidMechanics.Spring"/>
<RequiredPlugin pluginName="CGALPlugin"/>

<BackgroundSetting color="0 0.16862745098 0.21176470588"/>
<VisualStyle displayFlags="showVisualModels"/>
<DefaultAnimationLoop/>

<Node name="MasterLiver">
<MeshOBJLoader name="loader" filename="./STL_Intersection_Objects/Patient_08/liver_coarse_patient_08.msh"/>
<MechanicalObject name="dofs" template="Vec3d" position="@loader.position" showObject="false"/>
<TriangleSetTopologyContainer name="topology" src="@loader"/>
<TriangleSetTopologyModifier name="topologyModifier"/>
<TriangleSetGeometryAlgorithms name="geometryAlgorithms" template="Vec3d"/>

<Node name="Visual">
<OglModel name="visu" src="@../loader" color="1 0.05 0.05 1.0"/>
<IdentityMapping input="@../dofs" output="@visu"/>
</Node>
</Node>

<Node name="SlaveDiaphragmVolume">
<EulerImplicitSolver name="odesolver" rayleighStiffness="0.25" rayleighMass="0.45"/>
<CGLinearSolver name="linearsolver" iterations="60" tolerance="1.0e-6" threshold="1.0e-6"/>

<MeshGmshLoader name="volumeLoader" filename="./STL_Intersection_Objects/Patient_08/diaphragm_patient_08.msh"/>
<MechanicalObject name="dofs" template="Vec3d" position="@volumeLoader.position" showObject="false"/>
<TetrahedronSetTopologyContainer name="topology" src="@volumeLoader"/>
<TetrahedronSetTopologyModifier name="topologyModifier"/>
<TetrahedronSetGeometryAlgorithms name="geometryAlgorithms" template="Vec3d"/>

<UniformMass totalMass="1.2"/>
<TetrahedronFEMForceField name="tetraFEM" template="Vec3d" method="large" youngModulus="5000" poissonRatio="0.45"/>
<RestShapeSpringsForceField stiffness="100" angularStiffness="100" />

<Node name="ContactSurface">
<MechanicalObject name="surfaceDofs" template="Vec3d" position="@../volumeLoader.position" showObject="false"/>
<TriangleSetTopologyContainer name="surfaceTopology" src="@../volumeLoader"/>
<TriangleSetTopologyModifier name="surfaceTopologyModifier"/>
<TriangleSetGeometryAlgorithms name="surfaceGeometryAlgorithms" template="Vec3d"/>
<BarycentricMapping name="surfaceToVolumeMapping" input="@../dofs" output="@surfaceDofs" mapForces="true" mapMasses="false"/>

<MeshRepulsionEngine name="diaphragmCgalSpringPairs" template="Vec3d"
masterState="@../../MasterLiver/dofs"
masterTopology="@../../MasterLiver/topology"
slaveState="@surfaceDofs"
slaveTopology="@surfaceTopology"
repulsiveSpringField="@diaphragmRepulsiveSprings"
safetyDistance="1.2"
crossingDepth="2.2"
pushInsideVertices="true"
pushEdgeCrossings="true"
pushFaceCrossings="true"
rebuildMasterEveryStep="false"
computeEveryNSteps="4"
maxPairs="2500"
maxEdgesCheckedPerUpdate="8000"
maxFacesCheckedPerUpdate="0"
logEveryNSteps="20"
stiffness="10000"
maxForce="10000"
/>

<Node name="Visual">
<OglModel name="visu" src="@../../volumeLoader" color="0.15 0.55 1.0 0.35"/>
<IdentityMapping input="@../surfaceDofs" output="@visu"/>
</Node>
</Node>
</Node>
</Node>
91 changes: 91 additions & 0 deletions scenes/MeshRepulsion_patient_16.scn
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0"?>
<!-- =========================================================================
PR08 : CGAL detection -> standard SOFA RepulsiveSpringForceField
Patient 08. Master = liver (.msh, surface used). Slave = diaphragm tetra.
No translation / rotation / scale is applied.
========================================================================= -->
<Node name="root" gravity="0 0 0" dt="0.003">
<RequiredPlugin pluginName="Sofa.Component.AnimationLoop"/>
<RequiredPlugin pluginName="Sofa.Component.IO.Mesh"/>
<RequiredPlugin pluginName="Sofa.Component.Mapping.Linear"/>
<RequiredPlugin pluginName="Sofa.Component.Setting"/>
<RequiredPlugin pluginName="Sofa.Component.StateContainer"/>
<RequiredPlugin pluginName="Sofa.Component.Topology.Container.Constant"/>
<RequiredPlugin pluginName="Sofa.Component.Topology.Container.Dynamic"/>
<RequiredPlugin pluginName="Sofa.Component.Topology.Mapping"/>
<RequiredPlugin pluginName="Sofa.Component.Topology.Utility"/>
<RequiredPlugin pluginName="Sofa.Component.Visual"/>
<RequiredPlugin pluginName="Sofa.GL.Component.Rendering3D"/>
<RequiredPlugin pluginName="Sofa.Component.LinearSolver.Iterative"/>
<RequiredPlugin pluginName="Sofa.Component.Mass"/>
<RequiredPlugin pluginName="Sofa.Component.ODESolver.Backward"/>
<RequiredPlugin pluginName="Sofa.Component.SolidMechanics.FEM.Elastic"/>
<RequiredPlugin pluginName="Sofa.Component.SolidMechanics.Spring"/>
<RequiredPlugin pluginName="CGALPlugin"/>

<BackgroundSetting color="0 0.16862745098 0.21176470588"/>
<VisualStyle displayFlags="showVisualModels"/>
<DefaultAnimationLoop/>

<Node name="MasterLiver">
<MeshGmshLoader name="loader" filename="./STL_Intersection_Objects/Patient_16/liver_coarse_patient_16.msh"/>
<MechanicalObject name="dofs" template="Vec3d" position="@loader.position" showObject="false"/>
<TriangleSetTopologyContainer name="topology" src="@loader"/>
<TriangleSetTopologyModifier name="topologyModifier"/>
<TriangleSetGeometryAlgorithms name="geometryAlgorithms" template="Vec3d"/>

<Node name="Visual">
<OglModel name="visu" src="@../loader" color="1 0.05 0.05 1.0"/>
<IdentityMapping input="@../dofs" output="@visu"/>
</Node>
</Node>

<Node name="SlaveDiaphragmVolume">
<EulerImplicitSolver name="odesolver" rayleighStiffness="0.25" rayleighMass="0.45"/>
<CGLinearSolver name="linearsolver" iterations="60" tolerance="1.0e-6" threshold="1.0e-6"/>

<MeshGmshLoader name="volumeLoader" filename="./STL_Intersection_Objects/Patient_16/diaphragm_patient_16.msh"/>
<MechanicalObject name="dofs" template="Vec3d" position="@volumeLoader.position" showObject="false"/>
<TetrahedronSetTopologyContainer name="topology" src="@volumeLoader"/>
<TetrahedronSetTopologyModifier name="topologyModifier"/>
<TetrahedronSetGeometryAlgorithms name="geometryAlgorithms" template="Vec3d"/>

<UniformMass totalMass="1.2"/>
<TetrahedronFEMForceField name="tetraFEM" template="Vec3d" method="large" youngModulus="5000" poissonRatio="0.45"/>
<RestShapeSpringsForceField stiffness="100" angularStiffness="100" />

<Node name="ContactSurface">
<MechanicalObject name="surfaceDofs" template="Vec3d" position="@../volumeLoader.position" showObject="false"/>
<TriangleSetTopologyContainer name="surfaceTopology" src="@../volumeLoader"/>
<TriangleSetTopologyModifier name="surfaceTopologyModifier"/>
<TriangleSetGeometryAlgorithms name="surfaceGeometryAlgorithms" template="Vec3d"/>
<BarycentricMapping name="surfaceToVolumeMapping" input="@../dofs" output="@surfaceDofs" mapForces="true" mapMasses="false"/>

<MeshRepulsionEngine name="diaphragmCgalSpringPairs" template="Vec3d"
masterState="@../../MasterLiver/dofs"
masterTopology="@../../MasterLiver/topology"
slaveState="@surfaceDofs"
slaveTopology="@surfaceTopology"
repulsiveSpringField="@diaphragmRepulsiveSprings"
safetyDistance="1.2"
crossingDepth="2.2"
pushInsideVertices="true"
pushEdgeCrossings="true"
pushFaceCrossings="false"
rebuildMasterEveryStep="false"
computeEveryNSteps="4"
maxPairs="2500"
maxEdgesCheckedPerUpdate="8000"
maxFacesCheckedPerUpdate="0"
logEveryNSteps="20"
stiffness="10000"
maxForce="10000"
/>

<Node name="Visual">
<OglModel name="visu" src="@../../volumeLoader" color="0.15 0.55 1.0 0.35"/>
<IdentityMapping input="@../surfaceDofs" output="@visu"/>
</Node>
</Node>
</Node>
</Node>
Loading