Skip to content
Merged
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
53 changes: 21 additions & 32 deletions scenes/InsertionGeomagic.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ def createScene(root):
root.addObject("ConstraintAttachButtonSetting")
root.addObject("VisualStyle", displayFlags="showVisualModels hideBehaviorModels showCollisionModels hideMappings hideForceFields showWireframe showInteractionForceFields" )
root.addObject("FreeMotionAnimationLoop")
root.addObject("GenericConstraintSolver", tolerance=0.00001, maxIt=5000, printLog=False, computeConstraintForces=True)
root.addObject("GenericConstraintSolver", tolerance=0.00001, maxIt=5000)
root.addObject("CollisionLoop")

root.addObject("GeomagicDriver"
, name='GeomagicDevice'
, deviceName='Default Device'
, scale='0.02'
, drawDeviceFrame='false'
, drawDevice='false'
, manualStart='0'
, positionBase='0.12 0 0'
, orientationBase='0 0.174 0 -0.985'
, scale=0.02
, drawDeviceFrame=False
, drawDevice=False
, manualStart=False
, positionBase=[0.12, 0, 0]
, orientationBase=[0, 0.174, 0, -0.985]
)

toolController = root.addChild("ToolController")
toolController.addObject("MechanicalObject", name="mstate_baseMaster", position="@GeomagicDevice.positionDevice", template="Rigid3d", showObjectScale=0.01, showObject="false", drawMode=1)
toolController.addObject("MechanicalObject", name="mstate_baseMaster", position="@GeomagicDevice.positionDevice", template="Rigid3d", showObjectScale=0.01, showObject=False, drawMode=1)

needle = root.addChild("Needle")
needle.addObject("EulerImplicitSolver", firstOrder=True)
Expand All @@ -88,30 +88,29 @@ def createScene(root):
needle.addObject("EdgeSetTopologyModifier", name="modifier")
needle.addObject("PointSetTopologyModifier", name="modifier2")

needle.addObject("MechanicalObject", name="mstate", template="Rigid3d", showObjectScale=0.002, showObject="false", drawMode=1)
needle.addObject("MechanicalObject", name="mstate", template="Rigid3d", showObjectScale=0.002, showObject=False, drawMode=1)

needle.addObject("UniformMass", totalMass=g_needleTotalMass)
needle.addObject("BeamFEMForceField", name="FEM", **g_needleMechanicalParameters)
# needle.addObject("FixedLagrangianConstraint", indices="0" )
needle.addObject("LinearSolverConstraintCorrection", printLog="false", linearSolver="@LinearSolver")
needle.addObject("LCPForceFeedback", activate='1', forceCoef='0.01')
needle.addObject("LinearSolverConstraintCorrection", linearSolver="@LinearSolver")
needle.addObject("LCPForceFeedback", activate=1, forceCoef=0.01)

needleBase = needle.addChild("needleBase")
needleBase.addObject("PointSetTopologyContainer", name="Container_base", position="@../mstate.position")#"@../../GeomagicDevice.positionBase")
needleBase.addObject("PointSetTopologyContainer", name="Container_base", position="@../mstate.position")
needleBase.addObject("MechanicalObject",name="mstate_base", template="Rigid3d")
needleBase.addObject("RestShapeSpringsForceField",points=[0],stiffness=1e9, angularStiffness=1e9,external_points=[0],external_rest_shape="@/ToolController/mstate_baseMaster")
needleBase.addObject("SubsetMapping", indices="0")
needleBase.addObject("SubsetMapping", indices=0)

needleBodyCollision = needle.addChild("bodyCollision")
needleBodyCollision.addObject("EdgeSetTopologyContainer", name="Container_body", src="@../Container")
needleBodyCollision.addObject("MechanicalObject",name="mstate_body", template="Vec3d", drawMode=0, showObject="false", showObjectScale="10")
needleBodyCollision.addObject("MechanicalObject",name="mstate_body", template="Vec3d", drawMode=0, showObject=False, showObjectScale=10)
needleBodyCollision.addObject("EdgeGeometry",name="geom_body",mstate="@mstate_body", topology="@Container_body")
needleBodyCollision.addObject("EdgeNormalHandler", name="NeedleBeams", geometry="@geom_body")

needleBodyCollision.addObject("IdentityMapping")

needleTipCollision = needle.addChild("tipCollision")
needleTipCollision.addObject("MechanicalObject",name="mstate_tip",position=[g_needleBaseOffset[0], g_needleBaseOffset[1], -(g_needleLength+g_needleBaseOffset[2])],template="Vec3d", showObject="false", showObjectScale=20)
needleTipCollision.addObject("MechanicalObject",name="mstate_tip",position=[g_needleBaseOffset[0], g_needleBaseOffset[1], -(g_needleLength+g_needleBaseOffset[2])],template="Vec3d", showObject=False, showObjectScale=20)
needleTipCollision.addObject("PointGeometry",name="geom_tip",mstate="@mstate_tip")
needleTipCollision.addObject("RigidMapping",globalToLocalCoords=True,index=g_needleNumberOfElems)

Expand All @@ -121,47 +120,38 @@ def createScene(root):
needleVisual.addObject("QuadSetTopologyModifier", name="Modifier")
needleVisual.addObject("Edge2QuadTopologicalMapping", nbPointsOnEachCircle=8, radius=g_needleRadius, input="@../Container", output="@Container_visu")

needleVisual.addObject("MechanicalObject", name="mstate_visu", showObjectScale="0.0002", showObject="false", drawMode="1")
needleVisual.addObject("MechanicalObject", name="mstate_visu", showObjectScale=0.0002, showObject=False, drawMode=1)

needleVisual.addObject("TubularMapping", nbPointsOnEachCircle=8, radius=g_needleRadius, input="@../mstate", output="@mstate_visu")

needleOGL = needleVisual.addChild("OGL")
needleOGL.addObject("OglModel", position="@../Container_visu.position",
vertices="@../Container_visu.position",
quads="@../Container_visu.quads",
color="0.4 0.34 0.34",
color=[0.4, 0.34, 0.34],
material="texture Ambient 1 0.4 0.34 0.34 1.0 Diffuse 0 0.4 0.34 0.34 1.0 Specular 1 0.4 0.34 0.34 0.1 Emissive 1 0.5 0.54 0.54 .01 Shininess 1 20",
name="visualOgl")
needleOGL.addObject("IdentityMapping")



#gelTopo = root.addChild("GelGridTopo")
#gelTopo.addObject("RegularGridTopology", name="HexaTop", **g_gelRegularGridParameters)


volume = root.addChild("Volume")
volume.addObject("EulerImplicitSolver")
volume.addObject("EigenSimplicialLDLT", name="LinearSolver", template='CompressedRowSparseMatrixMat3x3d')
#volume.addObject("TetrahedronSetTopologyContainer", name="TetraContainer", position="@../GelGridTopo/HexaTop.position")
volume.addObject("MeshGmshLoader", name="meshLoader", filename="mesh/liver.msh", scale3d="0.08 0.08 0.08", translation="0 -0.3 -0.2")
volume.addObject("MeshGmshLoader", name="meshLoader", filename="mesh/liver.msh", scale3d=[0.08, 0.08, 0.08], translation=[0, -0.3, -0.2])
volume.addObject("TetrahedronSetTopologyContainer", name="TetraContainer", position="@meshLoader.position", tetrahedra="@meshLoader.tetrahedra")
volume.addObject("TetrahedronSetTopologyModifier", name="TetraModifier")
#volume.addObject("Hexa2TetraTopologicalMapping", input="@../GelGridTopo/HexaTop", output="@TetraContainer", swapping="false")

volume.addObject("MechanicalObject", name="mstate_gel", template="Vec3d")
volume.addObject("TetrahedronGeometry", name="geom_tetra", mstate="@mstate_gel", topology="@TetraContainer", draw=False)
#volume.addObject("TriangleGeometry", name="tri_geom", mstate="@mstate_gel", topology="@TetraContainer",draw=True)
volume.addObject("PhongTriangleNormalHandler", name="InternalTriangles", geometry="@geom_tetra")
volume.addObject("AABBBroadPhase",name="AABBTetra",geometry="@geom_tetra",nbox=[3,3,3],thread=1)
#volume.addObject("ParallelTetrahedronFEMForceField", name="FF",**g_gelMechanicalParameters)
volume.addObject("TetrahedronFEMForceField", name="FF",**g_gelMechanicalParameters)
volume.addObject("MeshMatrixMass", name="Mass",totalMass=g_gelTotalMass)

volume.addObject("BoxROI",name="BoxROI",box=g_gelFixedBoxROI)
volume.addObject("RestShapeSpringsForceField", stiffness='1e6',points="@BoxROI.indices" )
volume.addObject("RestShapeSpringsForceField", stiffness=1e6,points="@BoxROI.indices" )

volume.addObject("LinearSolverConstraintCorrection", printLog="false", linearSolver="@LinearSolver")
volume.addObject("LinearSolverConstraintCorrection", printLog=False, linearSolver="@LinearSolver")

volumeCollision = volume.addChild("collision")
volumeCollision.addObject("TriangleSetTopologyContainer", name="TriContainer")
Expand Down Expand Up @@ -198,11 +188,10 @@ def createScene(root):
slideDistance=0.003,
drawcollision=True,
sphereRadius=0.0001
#projective=True
)
root.addObject("DistanceFilter",algo="@InsertionAlgo",distance=0.01)
root.addObject("SecondDirection",name="punctureDirection",handler="@Volume/collision/SurfaceTriangles")
root.addObject("ConstraintUnilateral",input="@InsertionAlgo.output",directions="@punctureDirection",draw_scale="0.001")#, mu="0.001")
root.addObject("ConstraintUnilateral",input="@InsertionAlgo.output",directions="@punctureDirection",draw_scale=0.001, mu=0.001)

root.addObject("FirstDirection",name="bindDirection", handler="@Needle/bodyCollision/NeedleBeams")
root.addObject("ConstraintInsertion",input="@InsertionAlgo.outputList", directions="@bindDirection",draw_scale="0.01", frictionCoeff=0.000)
34 changes: 17 additions & 17 deletions scenes/NeedleInsertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,17 @@ def createScene(root):
root.addObject("ConstraintAttachButtonSetting")
root.addObject("VisualStyle", displayFlags="showVisualModels hideBehaviorModels showCollisionModels hideMappings hideForceFields showWireframe showInteractionForceFields" )
root.addObject("FreeMotionAnimationLoop")
root.addObject("GenericConstraintSolver", tolerance=0.00001, maxIt=5000, printLog=False, computeConstraintForces=True)
root.addObject("GenericConstraintSolver", tolerance=0.00001, maxIt=5000)
root.addObject("CollisionLoop")

needleBaseMaster = root.addChild("NeedleBaseMaster")
needleBaseMaster.addObject("MechanicalObject", name="mstate_baseMaster", position=[0.04, 0.04, 0, 0, 0, 0, 1], template="Rigid3d", showObjectScale=0.002, showObject="true", drawMode=1)
needleBaseMaster.addObject("LinearMovementProjectiveConstraint",indices=[0], keyTimes=[0,1,7,9],movements=[[0.04, 0.04,0,0,0,0],[0.04, 0.04,0.05,0,3.14/2,0],[0.04, 0.04,-0.07,0,3.14/2,0],[0.05, 0.04,-0.07,0,3.14/2 + 3.14/16,0]],relativeMovements=False)
needleBaseMaster.addObject("MechanicalObject", name="mstate_baseMaster", position=[0.04, 0.04, 0, 0, 0, 0, 1], template="Rigid3d", showObjectScale=0.002, showObject=False, drawMode=1)
needleBaseMaster.addObject("LinearMovementProjectiveConstraint",indices=[0], keyTimes=[0,1,7,9],movements=
[ [0.04, 0.04,0,0,0,0]
, [0.04, 0.04,0.05,0,3.14/2,0]
, [0.04, 0.04,-0.07,0,3.14/2,0]
, [0.05, 0.04,-0.07,0,3.14/2 + 3.14/16,0]
],relativeMovements=False)



Expand All @@ -77,12 +82,11 @@ def createScene(root):
needle.addObject("EdgeSetTopologyModifier", name="modifier")
needle.addObject("PointSetTopologyModifier", name="modifier2")

needle.addObject("MechanicalObject", name="mstate", template="Rigid3d", showObjectScale=0.0002, showObject="true", drawMode=1)
needle.addObject("MechanicalObject", name="mstate", template="Rigid3d", showObjectScale=0.0002, showObject=False, drawMode=1)

needle.addObject("UniformMass", totalMass=g_needleTotalMass)
needle.addObject("BeamFEMForceField", name="FEM", **g_needleMechanicalParameters)
# needle.addObject("FixedLagrangianConstraint", indices="0" )
needle.addObject("LinearSolverConstraintCorrection", printLog="false", linearSolver="@LinearSolver")
needle.addObject("LinearSolverConstraintCorrection", printLog=False, linearSolver="@LinearSolver")

needleBase = needle.addChild("needleBase")
needleBase.addObject("PointSetTopologyContainer", name="Container_base", position=[0, 0, 0])
Expand Down Expand Up @@ -111,15 +115,15 @@ def createScene(root):
needleVisual.addObject("QuadSetTopologyModifier", name="Modifier")
needleVisual.addObject("Edge2QuadTopologicalMapping", nbPointsOnEachCircle=8, radius=g_needleRadius, input="@../Container", output="@Container_visu")

needleVisual.addObject("MechanicalObject", name="mstate_visu", showObjectScale="0.0002", showObject="true", drawMode="1")
needleVisual.addObject("MechanicalObject", name="mstate_visu", showObjectScale=0.0002, showObject=True, drawMode=1)

needleVisual.addObject("TubularMapping", nbPointsOnEachCircle=8, radius=g_needleRadius, input="@../mstate", output="@mstate_visu")

needleOGL = needleVisual.addChild("OGL")
needleOGL.addObject("OglModel", position="@../Container_visu.position",
vertices="@../Container_visu.position",
quads="@../Container_visu.quads",
color="0.4 0.34 0.34",
color=[0.4, 0.34, 0.34],
material="texture Ambient 1 0.4 0.34 0.34 1.0 Diffuse 0 0.4 0.34 0.34 1.0 Specular 1 0.4 0.34 0.34 0.1 Emissive 1 0.5 0.54 0.54 .01 Shininess 1 20",
name="visualOgl")
needleOGL.addObject("IdentityMapping")
Expand All @@ -135,21 +139,18 @@ def createScene(root):
volume.addObject("EigenSimplicialLDLT", name="LinearSolver", template='CompressedRowSparseMatrixMat3x3d')
volume.addObject("TetrahedronSetTopologyContainer", name="TetraContainer", position="@../GelGridTopo/HexaTop.position")
volume.addObject("TetrahedronSetTopologyModifier", name="TetraModifier")
volume.addObject("Hexa2TetraTopologicalMapping", input="@../GelGridTopo/HexaTop", output="@TetraContainer", swapping="false")
volume.addObject("Hexa2TetraTopologicalMapping", input="@../GelGridTopo/HexaTop", output="@TetraContainer", swapping=False)

volume.addObject("MechanicalObject", name="mstate_gel", template="Vec3d")
volume.addObject("TetrahedronGeometry", name="geom_tetra", mstate="@mstate_gel", topology="@TetraContainer", draw=False)
#volume.addObject("TriangleGeometry", name="tri_geom", mstate="@mstate_gel", topology="@TetraContainer",draw=True)
volume.addObject("PhongTriangleNormalHandler", name="InternalTriangles", geometry="@geom_tetra")
volume.addObject("AABBBroadPhase",name="AABBTetra",geometry="@geom_tetra",nbox=[3,3,3],thread=1)
#volume.addObject("ParallelTetrahedronFEMForceField", name="FF",**g_gelMechanicalParameters)
volume.addObject("TetrahedronFEMForceField", name="FF",**g_gelMechanicalParameters)
volume.addObject("MeshMatrixMass", name="Mass",totalMass=g_gelTotalMass)

volume.addObject("BoxROI",name="BoxROI",box=g_gelFixedBoxROI)
volume.addObject("RestShapeSpringsForceField", stiffness='1e6',points="@BoxROI.indices" )
volume.addObject("RestShapeSpringsForceField", stiffness=1e6,points="@BoxROI.indices" )

volume.addObject("LinearSolverConstraintCorrection", printLog="false", linearSolver="@LinearSolver")
volume.addObject("LinearSolverConstraintCorrection", printLog=False, linearSolver="@LinearSolver")

volumeCollision = volume.addChild("collision")
volumeCollision.addObject("TriangleSetTopologyContainer", name="TriContainer")
Expand Down Expand Up @@ -186,11 +187,10 @@ def createScene(root):
slideDistance=0.003,
drawcollision=True,
sphereRadius=0.0001
#projective=True
)
root.addObject("DistanceFilter",algo="@InsertionAlgo",distance=0.01)
root.addObject("SecondDirection",name="punctureDirection",handler="@Volume/collision/SurfaceTriangles")
root.addObject("ConstraintUnilateral",input="@InsertionAlgo.output",directions="@punctureDirection",draw_scale="0.001")#, mu="0.001")
root.addObject("ConstraintUnilateral",input="@InsertionAlgo.output",directions="@punctureDirection",draw_scale=0.001)

root.addObject("FirstDirection",name="bindDirection", handler="@Needle/bodyCollision/NeedleBeams")
root.addObject("ConstraintInsertion",input="@InsertionAlgo.outputList", directions="@bindDirection",draw_scale="0.002", frictionCoeff=0.05)
root.addObject("ConstraintInsertion",input="@InsertionAlgo.outputList", directions="@bindDirection",draw_scale=0.002, frictionCoeff=0.05)
Loading