Home › Forum › SOFA › Programming with SOFA › [SOLVED] Mapping different meshes
Tagged: mapping, SOFA_2006, Windows_10
- This topic has 6 replies, 4 voices, and was last updated 3 years, 7 months ago by Times.
-
AuthorPosts
-
7 April 2021 at 17:28 #19082agnesenardiBlocked
Hi everyone, I’m new to Sofa and I’m developing a brain surgical procedure with SOFA. In order to reduce the computational time of the simulation I tought it would be better to use two different meshes: a finer one for the visual model and a coarser for mechanical and collision model. Right now I’m working with the Sofa Carving plugin in order to simulate the first step of a surgical procedure, i.e. the opening of the skull made using a drill. As already said, I uploaded a finer mesh of the skull for the visual model and a coarser one for the mechanical and collision model. The problem I’m facing is that the visual mesh does not behave as the collision mesh. While the collision model modifies and some tetrahedra are removed during carving, the visual model remains as it is.
I also made a test by using the same mesh for all the models (visualization, mechanics and collision) and in this way everything works fine (also the modification on the visual mesh can be seen). This test made me think that there could be a problem in the mapping between the two different meshes but I cannot find it.I enclose here my code with inside the two versions (the first one with different meshes and the second one with the same mesh) and the meshes that are needed so that you can understand better my problem.
<?xml version='1.0'?> <Node name='root' dt='0.02' gravity='0 0 0'> <RequiredPlugin name="SofaOpenglVisual"/> <RequiredPlugin name="SofaMiscCollision"/> <RequiredPlugin name="CImgPlugin"/> <RequiredPlugin name='SofaHaptics'/> <RequiredPlugin name='SofaPython'/> <RequiredPlugin name="SoftRobots"/> <RequiredPlugin name="Carving" pluginName="SofaCarving"/> <VisualStyle displayFlags='showVisualModels' /> <GenericConstraintSolver tolerance="1e-07" maxIterations="1000"/> <FreeMotionAnimationLoop/> <DefaultPipeline name="CollisionPipeline"/> <BruteForceDetection name='N2' /> <DefaultContactManager name="Response" response="FrictionContact" responseParams='mu=0.8'/> <LocalMinDistance name="Intersection" alarmDistance="0.5" contactDistance="0.02" useLMDFilters="0"/> <DefaultCollisionGroupManager/> <CarvingManager active="true" carvingDistance="-0.02"/> <!-- Skull up node- CASE 1: visualization mesh different from mechanics and collision mesh--> <Node name="Skull_up"> <EulerImplicitSolver name="cg_odesolver" rayleighStiffness="0.1" rayleighMass="0.1" /> <CGLinearSolver name="linear solver" iterations="25" tolerance="1e-09" threshold="1e-09" /> <MeshGmshLoader name="Skull" filename="mesh/skull_up_coarse3.msh" /> <TetrahedronSetTopologyContainer name="Container1" src="@Skull" /> <TetrahedronSetTopologyModifier name="Modifier1" /> <TriangleSetTopologyAlgorithms template="Vec3d" name="algo" /> <TetrahedronSetGeometryAlgorithms template="Vec3d" name="GeomAlgo1" /> <MechanicalObject name="dofs" src="@Skull" template="Vec3d"/> <UniformMass/> <TetrahedronFEMForceField name="FEM" youngModulus="19000" poissonRatio="0.24" computeGlobalMatrix="false" method="large" /> <Node name="VisuSkullUp" tags="Visual"> <MeshGmshLoader name="Skull_up" filename="mesh/skull_up_fine3.msh" /> <OglModel src="@Skull_up" name="Skull_up_ogl" color="grey"/> <BarycentricMapping name="MechanicalMapping" input="@../dofs" output="@Skull_up_ogl"/> </Node> <Node name='CollisionSkull'> <include href="Objects/TriangleSetTopology.xml" src="@../Skull" tags=" " /> <Tetra2TriangleTopologicalMapping name="SkullTriangle" input="@../Container1" output="@Container" /> <MechanicalObject src="@SkullTriangle" name="CollObject" template="Vec3d"/> <TriangleCollisionModel tags="CarvingSurface" group="1"/> </Node> </Node> <!-- Skull up node - CASE 2: same mesh for visual, mechanics and collision models--> <!--<Node name="Skull_up"> <EulerImplicitSolver name="cg_odesolver" rayleighStiffness="0.1" rayleighMass="0.1" /> <CGLinearSolver name="linear solver" iterations="25" tolerance="1e-09" threshold="1e-09" /> <MeshGmshLoader name="Skull" filename="mesh/skull_up_coarse3.msh" /> <TetrahedronSetTopologyContainer name="Container1" src="@Skull" /> <TetrahedronSetTopologyModifier name="Modifier1" /> <TriangleSetTopologyAlgorithms template="Vec3d" name="algo" /> <TetrahedronSetGeometryAlgorithms template="Vec3d" name="GeomAlgo1" /> <MechanicalObject name="dofs" src="@Skull" template="Vec3d"/> <UniformMass/> <TetrahedronFEMForceField name="FEM" youngModulus="19000" poissonRatio="0.24" computeGlobalMatrix="false" method="large" /> <Node name="VisuSkullUp" tags="Visual"> <include href="Objects/TriangleSetTopology.xml" src="@../Skull" tags=" " /> <Tetra2TriangleTopologicalMapping name="SkullTriangle" input="@../Container1" output="@Container" /> <OglModel src="@SkullTriangle" name="Skull_up_ogl" color="grey"/> <BarycentricMapping name="MechanicalMapping" input="@../dofs" output="@Skull_up_ogl"/> </Node> <Node name='CollisionSkull'> <include href="Objects/TriangleSetTopology.xml" src="@../Skull" tags=" " /> <Tetra2TriangleTopologicalMapping name="SkullTriangle" input="@../Container1" output="@Container" /> <MechanicalObject src="@SkullTriangle" name="CollObject" template="Vec3d"/> <TriangleCollisionModel tags="CarvingSurface" group="1"/> </Node> </Node>--> <!--Skull down node--> <Node name="Skull_down"> <Node name="VisuSkullDown" tags="Visual" gravity="0 0 0"> <MeshGmshLoader name="Skull_down" filename="mesh/skull_down_fine3.msh" /> <OglModel src="@Skull_down" name="Skull_down_ogl" color="grey"/> </Node> </Node> <Node name="Drill"> <EulerImplicitSolver name="ODE solver" rayleighStiffness="0.01" rayleighMass="1.0"/> <CGLinearSolver name="linear solver" iterations="25" tolerance="1e-10" threshold="10e-10"/> <MeshGmshLoader name="Drill" filename="mesh/drill.msh"/> <MechanicalObject name="instrumentState" src="@Drill" template="Rigid3d" dx="88" dy="3" dz="50" rz="-90" scale="2.5" tags="Omni"/> <UniformMass /> <UncoupledConstraintCorrection/> <Node name="Drill_visu" > <MeshGmshLoader name="visual_loader" filename="mesh/drill_visu.msh" /> <OglModel template="Vec3d" src="@visual_loader" name="visual_drill" color="red" scale="2.5" /> <RigidMapping template="Rigid3d,Vec3d" name="visualMapping" input="@instrumentState" output="@visual_drill" /> </Node> <Node name="carvingElement" > <MechanicalObject name="Particle" template="Vec3d" /> <SphereCollisionModel radius="1.35" tags="CarvingTool" color="blue"/> <RigidMapping template="Rigid3d,Vec3d" name="collisionMapping" input="@instrumentState" output="@Particle" /> </Node> <LinearMovementConstraint name="LM" template="Rigid3d" keyTimes="0 5 10 15 20" movements="0 0 0 0 0 0 -10 0 0 0 0 0 -20 0 0 0 0 0 -30 0 0 0 0 0 -40 0 0 0 0 0" /> </Node> </Node> </Node>
link to the meshes:
https://polimi365-my.sharepoint.com/:f:/g/personal/10503849_polimi_it/EhYbbL3oIz5Co1rsFUXBGlABnyvh0wd6OtBFTn1i5vbCXQThank you very much
Agnese9 April 2021 at 11:00 #19096HugoKeymasterHi @agnesenardi
Indeed topological changes are not yet properly propagated through the BarycentricMapping. This is something which is contained within our Topology roadmap, but this work is pretty intense.
Could this explain your issue?
Stay tuned about the SOFA roadmap advances 😉Best,
Hugo
9 April 2021 at 11:11 #19097agnesenardiBlockedHi @hugo,
thank you for your fast reply, I look forward to the next developments.Best,
Agnese Nardi9 April 2021 at 16:00 #19109TimesBlockedHi @agnesenardi
Could you please let me know with which software you use for meshing? I tried using gmsh, but Sofa insists that the file is not a true .msh file.9 April 2021 at 16:36 #19119amazierBlockedHi @akTheTimes,
Sorry to pop in the conversation but I already had troubles loading .msh files in SOFA. I think my mistake was to want to save the .msh in the last version. If I remember well my SOFA was only working when in the export of Gmsh I was checking the box “.msh V2 Ascii file”.
Let me know if it helps. Have a nice day,
Arnaud9 April 2021 at 19:03 #1912511 April 2021 at 15:42 #19132 -
AuthorPosts
- You must be logged in to reply to this topic.