Skip to content

Commit 1f24c84

Browse files
authored
[scene] Quick clean-up of scene files (#44)
1 parent 95826cd commit 1f24c84

3 files changed

Lines changed: 48 additions & 63 deletions

File tree

scenes/InsertionGeomagic.py

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,22 @@ def createScene(root):
6262
root.addObject("ConstraintAttachButtonSetting")
6363
root.addObject("VisualStyle", displayFlags="showVisualModels hideBehaviorModels showCollisionModels hideMappings hideForceFields showWireframe showInteractionForceFields" )
6464
root.addObject("FreeMotionAnimationLoop")
65-
root.addObject("GenericConstraintSolver", tolerance=0.00001, maxIt=5000, printLog=False, computeConstraintForces=True)
65+
root.addObject("GenericConstraintSolver", tolerance=0.00001, maxIt=5000)
6666
root.addObject("CollisionLoop")
6767

6868
root.addObject("GeomagicDriver"
6969
, name='GeomagicDevice'
7070
, deviceName='Default Device'
71-
, scale='0.02'
72-
, drawDeviceFrame='false'
73-
, drawDevice='false'
74-
, manualStart='0'
75-
, positionBase='0.12 0 0'
76-
, orientationBase='0 0.174 0 -0.985'
71+
, scale=0.02
72+
, drawDeviceFrame=False
73+
, drawDevice=False
74+
, manualStart=False
75+
, positionBase=[0.12, 0, 0]
76+
, orientationBase=[0, 0.174, 0, -0.985]
7777
)
7878

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

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

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

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

9998
needleBase = needle.addChild("needleBase")
100-
needleBase.addObject("PointSetTopologyContainer", name="Container_base", position="@../mstate.position")#"@../../GeomagicDevice.positionBase")
99+
needleBase.addObject("PointSetTopologyContainer", name="Container_base", position="@../mstate.position")
101100
needleBase.addObject("MechanicalObject",name="mstate_base", template="Rigid3d")
102101
needleBase.addObject("RestShapeSpringsForceField",points=[0],stiffness=1e9, angularStiffness=1e9,external_points=[0],external_rest_shape="@/ToolController/mstate_baseMaster")
103-
needleBase.addObject("SubsetMapping", indices="0")
102+
needleBase.addObject("SubsetMapping", indices=0)
104103

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

111110
needleBodyCollision.addObject("IdentityMapping")
112111

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

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

124-
needleVisual.addObject("MechanicalObject", name="mstate_visu", showObjectScale="0.0002", showObject="false", drawMode="1")
123+
needleVisual.addObject("MechanicalObject", name="mstate_visu", showObjectScale=0.0002, showObject=False, drawMode=1)
125124

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

128127
needleOGL = needleVisual.addChild("OGL")
129128
needleOGL.addObject("OglModel", position="@../Container_visu.position",
130129
vertices="@../Container_visu.position",
131130
quads="@../Container_visu.quads",
132-
color="0.4 0.34 0.34",
131+
color=[0.4, 0.34, 0.34],
133132
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",
134133
name="visualOgl")
135134
needleOGL.addObject("IdentityMapping")
136135

137136

138-
139-
#gelTopo = root.addChild("GelGridTopo")
140-
#gelTopo.addObject("RegularGridTopology", name="HexaTop", **g_gelRegularGridParameters)
141-
142-
143137
volume = root.addChild("Volume")
144138
volume.addObject("EulerImplicitSolver")
145139
volume.addObject("EigenSimplicialLDLT", name="LinearSolver", template='CompressedRowSparseMatrixMat3x3d')
146-
#volume.addObject("TetrahedronSetTopologyContainer", name="TetraContainer", position="@../GelGridTopo/HexaTop.position")
147-
volume.addObject("MeshGmshLoader", name="meshLoader", filename="mesh/liver.msh", scale3d="0.08 0.08 0.08", translation="0 -0.3 -0.2")
140+
volume.addObject("MeshGmshLoader", name="meshLoader", filename="mesh/liver.msh", scale3d=[0.08, 0.08, 0.08], translation=[0, -0.3, -0.2])
148141
volume.addObject("TetrahedronSetTopologyContainer", name="TetraContainer", position="@meshLoader.position", tetrahedra="@meshLoader.tetrahedra")
149142
volume.addObject("TetrahedronSetTopologyModifier", name="TetraModifier")
150-
#volume.addObject("Hexa2TetraTopologicalMapping", input="@../GelGridTopo/HexaTop", output="@TetraContainer", swapping="false")
151143

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

161151
volume.addObject("BoxROI",name="BoxROI",box=g_gelFixedBoxROI)
162-
volume.addObject("RestShapeSpringsForceField", stiffness='1e6',points="@BoxROI.indices" )
152+
volume.addObject("RestShapeSpringsForceField", stiffness=1e6,points="@BoxROI.indices" )
163153

164-
volume.addObject("LinearSolverConstraintCorrection", printLog="false", linearSolver="@LinearSolver")
154+
volume.addObject("LinearSolverConstraintCorrection", printLog=False, linearSolver="@LinearSolver")
165155

166156
volumeCollision = volume.addChild("collision")
167157
volumeCollision.addObject("TriangleSetTopologyContainer", name="TriContainer")
@@ -198,11 +188,10 @@ def createScene(root):
198188
slideDistance=0.003,
199189
drawcollision=True,
200190
sphereRadius=0.0001
201-
#projective=True
202191
)
203192
root.addObject("DistanceFilter",algo="@InsertionAlgo",distance=0.01)
204193
root.addObject("SecondDirection",name="punctureDirection",handler="@Volume/collision/SurfaceTriangles")
205-
root.addObject("ConstraintUnilateral",input="@InsertionAlgo.output",directions="@punctureDirection",draw_scale="0.001")#, mu="0.001")
194+
root.addObject("ConstraintUnilateral",input="@InsertionAlgo.output",directions="@punctureDirection",draw_scale=0.001, mu=0.001)
206195

207196
root.addObject("FirstDirection",name="bindDirection", handler="@Needle/bodyCollision/NeedleBeams")
208197
root.addObject("ConstraintInsertion",input="@InsertionAlgo.outputList", directions="@bindDirection",draw_scale="0.01", frictionCoeff=0.000)

scenes/NeedleInsertion.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,17 @@ def createScene(root):
5959
root.addObject("ConstraintAttachButtonSetting")
6060
root.addObject("VisualStyle", displayFlags="showVisualModels hideBehaviorModels showCollisionModels hideMappings hideForceFields showWireframe showInteractionForceFields" )
6161
root.addObject("FreeMotionAnimationLoop")
62-
root.addObject("GenericConstraintSolver", tolerance=0.00001, maxIt=5000, printLog=False, computeConstraintForces=True)
62+
root.addObject("GenericConstraintSolver", tolerance=0.00001, maxIt=5000)
6363
root.addObject("CollisionLoop")
6464

6565
needleBaseMaster = root.addChild("NeedleBaseMaster")
66-
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)
67-
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)
66+
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)
67+
needleBaseMaster.addObject("LinearMovementProjectiveConstraint",indices=[0], keyTimes=[0,1,7,9],movements=
68+
[ [0.04, 0.04,0,0,0,0]
69+
, [0.04, 0.04,0.05,0,3.14/2,0]
70+
, [0.04, 0.04,-0.07,0,3.14/2,0]
71+
, [0.05, 0.04,-0.07,0,3.14/2 + 3.14/16,0]
72+
],relativeMovements=False)
6873

6974

7075

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

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

8287
needle.addObject("UniformMass", totalMass=g_needleTotalMass)
8388
needle.addObject("BeamFEMForceField", name="FEM", **g_needleMechanicalParameters)
84-
# needle.addObject("FixedLagrangianConstraint", indices="0" )
85-
needle.addObject("LinearSolverConstraintCorrection", printLog="false", linearSolver="@LinearSolver")
89+
needle.addObject("LinearSolverConstraintCorrection", printLog=False, linearSolver="@LinearSolver")
8690

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

114-
needleVisual.addObject("MechanicalObject", name="mstate_visu", showObjectScale="0.0002", showObject="true", drawMode="1")
118+
needleVisual.addObject("MechanicalObject", name="mstate_visu", showObjectScale=0.0002, showObject=True, drawMode=1)
115119

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

118122
needleOGL = needleVisual.addChild("OGL")
119123
needleOGL.addObject("OglModel", position="@../Container_visu.position",
120124
vertices="@../Container_visu.position",
121125
quads="@../Container_visu.quads",
122-
color="0.4 0.34 0.34",
126+
color=[0.4, 0.34, 0.34],
123127
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",
124128
name="visualOgl")
125129
needleOGL.addObject("IdentityMapping")
@@ -135,21 +139,18 @@ def createScene(root):
135139
volume.addObject("EigenSimplicialLDLT", name="LinearSolver", template='CompressedRowSparseMatrixMat3x3d')
136140
volume.addObject("TetrahedronSetTopologyContainer", name="TetraContainer", position="@../GelGridTopo/HexaTop.position")
137141
volume.addObject("TetrahedronSetTopologyModifier", name="TetraModifier")
138-
volume.addObject("Hexa2TetraTopologicalMapping", input="@../GelGridTopo/HexaTop", output="@TetraContainer", swapping="false")
142+
volume.addObject("Hexa2TetraTopologicalMapping", input="@../GelGridTopo/HexaTop", output="@TetraContainer", swapping=False)
139143

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

149150
volume.addObject("BoxROI",name="BoxROI",box=g_gelFixedBoxROI)
150-
volume.addObject("RestShapeSpringsForceField", stiffness='1e6',points="@BoxROI.indices" )
151+
volume.addObject("RestShapeSpringsForceField", stiffness=1e6,points="@BoxROI.indices" )
151152

152-
volume.addObject("LinearSolverConstraintCorrection", printLog="false", linearSolver="@LinearSolver")
153+
volume.addObject("LinearSolverConstraintCorrection", printLog=False, linearSolver="@LinearSolver")
153154

154155
volumeCollision = volume.addChild("collision")
155156
volumeCollision.addObject("TriangleSetTopologyContainer", name="TriContainer")
@@ -186,11 +187,10 @@ def createScene(root):
186187
slideDistance=0.003,
187188
drawcollision=True,
188189
sphereRadius=0.0001
189-
#projective=True
190190
)
191191
root.addObject("DistanceFilter",algo="@InsertionAlgo",distance=0.01)
192192
root.addObject("SecondDirection",name="punctureDirection",handler="@Volume/collision/SurfaceTriangles")
193-
root.addObject("ConstraintUnilateral",input="@InsertionAlgo.output",directions="@punctureDirection",draw_scale="0.001")#, mu="0.001")
193+
root.addObject("ConstraintUnilateral",input="@InsertionAlgo.output",directions="@punctureDirection",draw_scale=0.001)
194194

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

0 commit comments

Comments
 (0)