Home › Forum › SOFA › Using SOFA › Crash in Carving Manager when using a triangular surface mesh.
Tagged: Carving a surface mesh, SOFA_2012, Windows_10
- This topic has 1 reply, 2 voices, and was last updated 3 years, 2 months ago by
epernod.
-
AuthorPosts
-
28 May 2021 at 09:46 #19588
Singh
BlockedHi all,
I have been trying to carve a triangular surface mesh, by using carving manager.
Following is the scene file that I have been using.<?xml version="1.0" ?> <Node name="root" dt="0.005" gravity="0 0 0" > <RequiredPlugin name="SofaOpenglVisual"/> <RequiredPlugin pluginName='SofaHaptics'/> <VisualStyle displayFlags="hideBehaviorModels hideCollisionModels hideMappings hideForceFields" /> <RequiredPlugin name="Geomagic plugin" pluginName="Geomagic" /> <RequiredPlugin name="Carving" pluginName="SofaCarving" /> <DefaultPipeline name="pipeline" depth="6" verbose="0"/> <BruteForceDetection name="detection" /> <DefaultContactManager name="response" response="FrictionContact" /> <LocalMinDistance name="proximity" alarmDistance="1.5" contactDistance="0.05" angleCone="0.0" /> <FreeMotionAnimationLoop/> <GenericConstraintSolver maxIt="1000" tolerance="1e-6" computeConstraintForces="1" /> <GeomagicDriver name="GeomagicDevice" deviceName="Default Device" scale="1" drawDeviceFrame="0" positionBase="0 0 0" drawDevice="0" orientationBase="0 0.707 0 -0.707"/> <CarvingManager active="@GeomagicDevice.button1" carvingDistance="0.0" key="k" /> <MeshObjLoader name="meshLoader_colission" filename="c:/open_prj/sofa/src/examples/MembraneCutting/Data/in/10x10x0_5_membrane_top.obj"/> <Node name="Sheet" gravity="0 0 0"> <EulerImplicitSolver name="cg_odesolver" /> <CGLinearSolver name="linear solver" iterations="25" tolerance="1e-09" threshold="1e-09" /> <MeshObjLoader name="meshLoader" filename="c:/open_prj/sofa/src/examples/MembraneCutting/Data/in/10x10x0_5_membrane_top.obj" scale="1" createSubelements="true" translation = "0 0 -5"/> <include href="Objects/TriangleSetTopology.xml" src="@meshLoader" /> <MechanicalObject name="dofs" src="@meshLoader" /> <TriangleSetTopologyContainer name="topo" src="@meshLoader" /> <TriangleSetTopologyModifier name="Modifier" /> <TriangleSetTopologyAlgorithms name="TopoAlgo" template="Vec3d" /> <TriangleSetGeometryAlgorithms template="Vec3d" name="GeomAlgo" /> <DiagonalMass name="computed using mass density" massDensity="1" /> <TriangularFEMForceField template="Vec3d" name="FEM" youngModulus="6000" poissonRatio="0.35" method="large" showStressValue="false" fracturable ="true" showStressVector="false" showFracturableTriangles="true" hosfordExponant="10.0" criteriaValue="1000" computePrincipalStress="true"/> <PrecomputedConstraintCorrection recompute="true"/> <!-- <FixedConstraint name="FixedConstraint" indices="2" /> --> <FixedConstraint name="FixedConstraint" indices="130 104 87 119" /> <Node name="Visu" tags="Visual" gravity="0 0 0"> <MeshObjLoader name="meshLoader_2" filename="c:/open_prj/sofa/src/examples/MembraneCutting/Data/in/10x10x0_5_membrane_top.obj" handleSeams="1" /> <OglModel name="VisualModel" texturename="c:/open_prj/sofa/src/examples/MembraneCutting/Data/in/texture_inside_brain.bmp" putOnlyTexCoords="true" src="@../meshLoader" /> <BarycentricMapping name="visual mapping" input="@../dofs" output="@VisualModel" /> </Node> <Node name="Collision" gravity="0 0 0"> <MeshTopology src="@../meshLoader"/> <MechanicalObject name="CollisionMO" scale="1.0"/> <TriangleCollisionModel name="CollisionModel2" simulated="1" contactStiffness="3" bothSide="1" tags="CarvingSurface"/> <LineCollisionModel /> <PointCollisionModel/> <BarycentricMapping name="CollisionMapping" input="@../dofs" output="@CollisionMO" /> </Node> <!-- <CarvingManager active="@GeomagicDevice.button1" carvingDistance="-0.01" key="k" triangleInfo="@FEM.triangleInfo"/> --> </Node> <!-- ADDED: the Mechanical state Controller gathers events from the Omni driver and populates the Mechanical state --> <Node name="Omni"> <MechanicalObject template="Rigid3d" name="DOFs" position="@GeomagicDevice.positionDevice"/> <MechanicalStateController template="Rigid3d" listening="true" mainDirection="-1.0 0.0 0.0" handleEventTriggersUpdate="true"/> <Node name="VisuAvatar" activated="false" > <MeshObjLoader name="meshLoader_0" filename="mesh/sphere.obj" scale="0.1" handleSeams="1" /> <OglModel name="Visual" src="@meshLoader_0" color="gray"/> <RigidMapping input="@.." output="@Visual" index="0"/> </Node> <Node name="RefModel"> <MeshObjLoader filename="Demos/Dentistry/data/mesh/dental_instrument_centerline.obj" name="loader"/> <MeshTopology src="@loader" /> <MechanicalObject src="@loader" name="instrumentRefState1" ry="-180" rz="-90" dz="3.5" dx="-0.3" /> <RigidMapping /> </Node> <Node name="RefModelRight" > <MeshObjLoader filename="Demos/Dentistry/data/mesh/dental_instrument_centerline.obj" name="loader"/> <MeshTopology src="@loader" /> <MechanicalObject src="@loader" name="instrumentRefState2" ry="-180" rz="-90" dz="3.5" dx="-0.3" dy="0.5" /> <RigidMapping /> </Node> <Node name="RefModelLeft" > <MeshObjLoader filename="Demos/Dentistry/data/mesh/dental_instrument_centerline.obj" name="loader"/> <MeshTopology src="@loader" /> <MechanicalObject src="@loader" name="instrumentRefState3" ry="-180" rz="-90" dz="3.5" dx="-0.3" dy="-0.5" /> <RigidMapping /> </Node> </Node> <Node name="Instrument" > <EulerImplicitSolver name="ODE solver" rayleighStiffness="0.05" rayleighMass="1.0" /> <CGLinearSolver name="linear solver" iterations="25" tolerance="1e-10" threshold="10e-10" /> <MechanicalObject name="instrumentState" template="Rigid3d" /> <UniformMass name="mass" totalMass="0.5" /> <LCPForceFeedback activate="true" forceCoef="0.01"/> <!-- ADDED : Compute a force-feedback for the device --> <UncoupledConstraintCorrection/> <Node name="VisualModel" > <MeshObjLoader name="meshLoader_1" filename="Demos/Dentistry/data/mesh/dental_instrument.obj" handleSeams="1" /> <OglModel name="InstrumentVisualModel" src="@meshLoader_1" color="gray" ry="-180" rz="-90" dz="3.5" dx="-0.3"/> <RigidMapping name="MM->VM mapping" input="@instrumentState" output="@InstrumentVisualModel" /> </Node> <Node name="CollisionModel" > <MeshObjLoader filename="Demos/Dentistry/data/mesh/dental_instrument_centerline.obj" name="loader"/> <MeshTopology src="@loader" /> <MechanicalObject src="@loader" name="instrumentCollisionState1" ry="-180" rz="-90" dz="3.5" dx="-0.3" /> <LineCollisionModel contactStiffness="10" /> <PointCollisionModel contactStiffness="10"/> <SphereCollisionModel radius="0.02" contactStiffness="10" tags="CarvingTool" listRadius="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1"/> <RigidMapping name="MM->CM mapping" input="@instrumentState" output="@instrumentCollisionState1" /> </Node> <Node name="RefModelRight" > <MeshObjLoader filename="Demos/Dentistry/data/mesh/dental_instrument_centerline.obj" name="loader"/> <MeshTopology src="@loader" /> <MechanicalObject src="@loader" name="instrumentCollisionState2" ry="-180" rz="-90" dz="3.5" dx="-0.3" dy="0.5" /> <RigidMapping name="MM->CM mapping" input="@instrumentState" output="@instrumentCollisionState2" /> </Node> <Node name="RefModelLeft" > <MeshObjLoader filename="Demos/Dentistry/data/mesh/dental_instrument_centerline.obj" name="loader"/> <MeshTopology src="@loader" /> <MechanicalObject src="@loader" name="instrumentCollisionState3" ry="-180" rz="-90" dz="3.5" dx="-0.3" dy="-0.5" /> <RigidMapping name="MM->CM mapping" input="@instrumentState" output="@instrumentCollisionState3" /> </Node> <VectorSpringForceField template="Vec3d" object1="@Omni/RefModel/instrumentRefState1" object2="@Instrument/CollisionModel/instrumentCollisionState1" stiffness="10" viscosity="0" /> <VectorSpringForceField template="Vec3d" object1="@Omni/RefModelRight/instrumentRefState2" object2="@Instrument/RefModelRight/instrumentCollisionState2" stiffness="10" viscosity="0" /> <VectorSpringForceField template="Vec3d" object1="@Omni/RefModelLeft/instrumentRefState3" object2="@Instrument/RefModelLeft/instrumentCollisionState3" stiffness="10" viscosity="0" /> </Node> </Node>
Attaching the triangular mesh as well.
triangular surface meshThe only change that I did inside CarvingManager.cpp is:
@@ -96,12 +97,14 @@ void CarvingManager::init() for (size_t i=0;i<models.size();++i) { core::CollisionModel* m = models[i]; - m->getContext()->get(topoMapping); - if (topoMapping == NULL) continue; + /*m->getContext()->get(topoMapping); + if (topoMapping == NULL) continue;*/ m_surfaceCollisionModels.push_back(m); } } +
When I run the above scene, and try the carve the triangular mesh, the application crashes, and I see the following logs at the console
[ERROR] [TriangularFEMForceField(FEM)] Indices given in parameters are wrong>> a=128 b=129 and c=130 whereas the size of the vector p is 130 [ERROR] [TriangularFEMForceField(FEM)] Indices given in parameters are wrong>> a=129 b=98 and c=130 whereas the size of the vector p is 130
Would be great if you could help me find what am I doing wrong here.
Thanks!
11 June 2021 at 12:18 #19678epernod
BlockedHi,
I see several potential problems:
1. The topology mapping check in the loop is important, why did you commented it?
2. In the node where your triangleCollisionModel is located, the topology object is MeshTopology which is for static topology, so it won’t handle carving.
3. You are using a barycentric mapping between 2 triangulation, we are working on it right now to propagate topological changes.Best regards
-
AuthorPosts
- You must be logged in to reply to this topic.