Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?xml version="1.0" ?>
<Node name="root" dt="0.005" gravity="0 -9.81 0" >
<RequiredPlugin name="OpenGL Visual" pluginName="SofaOpenglVisual"/>
<RequiredPlugin name="Haptic"pluginName='SofaHaptics'/>
<RequiredPlugin name="Geomagic" pluginName="Geomagic" />
<RequiredPlugin name="Misc Collision" pluginName="SofaMiscCollision" />
<VisualStyle displayFlags="hideBehaviorModels hideCollisionModels hideMappings hideForceFields" />
<DefaultPipeline name="pipeline" depth="6" verbose="0"/>
<BruteForceDetection name="detection" />
<DefaultContactManager name="response" response="FrictionContact" />
<FreeMotionAnimationLoop/>
<DiscreteIntersection/>
<LCPConstraintSolver tolerance="0.001" maxIt="1000" displayTime="True"/>
<GeomagicDriver name="GeomagicDevice" deviceName="Default Device" maxInputForceFeedback="3.0" forceScale="50.0" scale="1" drawDeviceFrame="1" positionBase="0 0 0" drawDevice="0" orientationBase="0 0.707 0 -0.707" />
<!--GeomagicDriver name="GeomagicDevice" deviceName="Default Device" maxInputForceFeedback="3.0" forceScale="50.0" scale="1" drawDeviceFrame="1" positionBase="0 0 0" drawDevice="0" orientationBase="0 0.707 0 -0.707" filename="haptic_force.txt" writeHapticForce="true" /-->
<Node name="Liver" gravity="0 -9.81 0">
<EulerImplicitSolver name="cg_odesolver" />
<CGLinearSolver name="linear solver" iterations="25" tolerance="1e-09" threshold="1e-09" />
<MeshGmshLoader name="meshLoader" filename="mesh/liver.msh" />
<MeshTopology src="@meshLoader" />
<TetrahedronSetTopologyContainer name="topo" src="@meshLoader" />
<MechanicalObject name="dofs" src="@meshLoader" ry="-90" />
<TetrahedronSetGeometryAlgorithms template="Vec3d" name="GeomAlgo" />
<DiagonalMass name="computed using mass density" massDensity="1" />
<TetrahedralCorotationalFEMForceField template="Vec3d" name="FEM" method="large" poissonRatio="0.3" youngModulus="6000" computeGlobalMatrix="0" />
<PrecomputedConstraintCorrection recompute="true"/>
<FixedConstraint name="FixedConstraint" indices="3 39 64" />
<Node name="Visu" tags="Visual" gravity="0 -9.81 0">
<MeshObjLoader name="meshLoader_2" filename="mesh/liver-smooth.obj" handleSeams="1" />
<OglModel name="VisualModel" src="@meshLoader_2" ry="-90"/>
<BarycentricMapping name="visual mapping" input="@../dofs" output="@VisualModel" />
</Node>
<Node name="Surf" gravity="0 -9.81 0">
<!--MechanicalObject name="tetrahedron" src="@../meshLoader" ry="-90"/-->
<!--TetrahedronModel name="CollisionModel"/-->
<!--IdentityMapping name="Tet mapping" input="@.." output="@tetrahedron" /-->
<TetrahedronSetTopologyContainer name="topo" src="@../meshLoader"/>
<MechanicalObject name="spheres" />
<TetrahedronCollisionModel name="CollisionModel" />
<IdentityMapping name="sphere mapping" input="@../dofs" output="@spheres"/>
</Node>
</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.005" />
<LCPForceFeedback activate="true" forceCoef="0.005"/> <!-- 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="1.0 0.2 0.2 1.0" 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" />
<PointCollisionModel contactStiffness="10" />
<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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment