1313g_needleTotalMass = 0.04
1414
1515g_gelRegularGridParameters = [
16- {
17- "n" :[6 , 4 , 4 ],
18- "min" :[- 0.150 , - 0.050 , - 0.250 ],
19- "max" :[0.150 , 0.0099 , - 0.100 ]
20- },
21- {
22- "n" :[6 , 4 , 4 ],
23- "min" :[- 0.150 , 0.0101 , - 0.250 ],
24- "max" :[0.150 , 0.060 , - 0.100 ]
25- }
16+ {
17+ "n" :[6 , 4 , 4 ],
18+ "min" :[- 0.150 , - 0.050 , - 0.250 ],
19+ "max" :[0.150 , 0.0099 , - 0.100 ]
20+ },
21+ {
22+ "n" :[6 , 4 , 4 ],
23+ "min" :[- 0.150 , 0.0101 , - 0.250 ],
24+ "max" :[0.150 , 0.060 , - 0.100 ]
25+ },
26+ {
27+ "n" :[12 , 4 , 8 ],
28+ "min" :[- 0.150 , - 0.080 , - 0.250 ],
29+ "max" :[0.150 , - 0.0501 , - 0.100 ]
30+ }
2631] #Again all in mm
2732g_gelMechanicalParameters = {
2833 "youngModulus" :8e5 ,
2934 "poissonRatio" :0.45 ,
3035 "method" :"large"
3136}
3237g_gelTotalMass = 1
33- g_cubeColor = [[0.8 , 0.34 , 0.34 , 0.3 ],[0.6 , 0.6 , 0 , 0.3 ]]
34- g_wireColor = [[0.8 , 0.34 , 0.34 , 1 ],[0.6 , 0.6 , 0 , 1 ]]
38+ g_cubeColor = [[0.8 , 0.34 , 0.34 , 0.3 ],[0.6 , 0.6 , 0 , 0.3 ],[ 1 , 1 , 1 , 0.3 ] ]
39+ g_wireColor = [[0.8 , 0.34 , 0.34 , 1 ],[0.6 , 0.6 , 0 , 1 ],[ 1 , 1 , 1 , 1 ] ]
3540g_gelFixedBoxROI = [[- 0.155 , - 0.055 , - 0.255 , - 0.145 , 0.065 , - 0.095 ], [0.155 , - 0.055 , - 0.255 , 0.145 , 0.065 , - 0.095 ]]
3641
3742# Function called when the scene graph is being created
@@ -71,35 +76,26 @@ def createScene(root):
7176 root .addObject ("GenericConstraintSolver" , tolerance = 0.00001 , maxIt = 5000 , regularizationTerm = 0.001 )
7277 root .addObject ("CollisionLoop" )
7378
74- root .addObject ("CollisionPipeline" , name = "pipeline" , depth = 6 , verbose = 0 )
75- root .addObject ("BruteForceBroadPhase" )
76- root .addObject ("BVHNarrowPhase" )
77- root .addObject ("CollisionResponse" , response = "FrictionContact" )
78- root .addObject ("LocalMinDistance" , name = "proximity" , alarmDistance = 0.002 , contactDistance = 0.0005 )
79-
8079 needleBaseMaster = root .addChild ("NeedleBaseMaster" )
81- needleBaseMaster .addObject ("MechanicalObject" , name = "mstate_baseMaster" , position = [0.04 ,0.25 ,- 0.2 , 0 , 0 , 0 , 1 ], template = "Rigid3d" , showObjectScale = 0.002 , showObject = False , drawMode = 1 )
82- needleBaseMaster .addObject ("LinearMovementProjectiveConstraint" ,indices = [0 ], keyTimes = [0 ,0.5 ,1 ,7 ,8 ],movements =
83- [ [0.04 , 0.15 ,- 0.2 ,0 ,0 ,0 ]
84- , [0.04 , 0.30 ,- 0.2 ,0 ,0 ,0 ]
85- , [0.04 , 0.30 ,- 0.2 ,0 ,0 ,- 3.14 / 2 ]
86- , [0.04 , 0.14 ,- 0.2 ,0 ,0 ,- 3.14 / 2 ]
87- , [0.03 , 0.14 ,- 0.2 ,0 ,0 ,- 3.14 / 2 + 3.14 / 16 ]
80+ needleBaseMaster .addObject ("MechanicalObject" , name = "mstate_baseMaster" , position = [0.04 ,0.15 ,- 0.2 , 0 , 0 , 0 , 1 ], template = "Rigid3d" , showObjectScale = 0.002 , showObject = False , drawMode = 1 )
81+ needleBaseMaster .addObject ("LinearMovementProjectiveConstraint" ,indices = [0 ], keyTimes = [0 ,1 ,7 ,8 ],movements =
82+ [ [0.04 , 0.15 , 0.2 , 0 , 0 , 0 ]
83+ , [0.04 , 0.30 , - 0.2 , - 3.14 / 2 , 0 , 0 ]
84+ , [0.04 , 0.145 , - 0.2 , - 3.14 / 2 , 0 , 0 ]
85+ , [0.03 , 0.145 , - 0.2 , - 3.14 / 2 + 3.14 / 16 , 0 , 0 ]
8886 ],relativeMovements = False )
8987
9088
91-
9289 needle = root .addChild ("Needle" )
9390 needle .addObject ("EulerImplicitSolver" , firstOrder = True )
9491 needle .addObject ("EigenSparseLU" , name = "LinearSolver" , template = "CompressedRowSparseMatrixd" )
95- needle .addObject ("EdgeSetTopologyContainer" , name = "Container" , position = [[i * g_needleLength / (g_needleNumberOfElems ) + g_needleBaseOffset [0 ], g_needleBaseOffset [1 ], g_needleBaseOffset [2 ]] for i in range (g_needleNumberOfElems + 1 )]
96- , edges = [[i , i + 1 ] for i in range (g_needleNumberOfElems )])
97-
92+ needle .addObject ("EdgeSetTopologyContainer" , name = "Container"
93+ , position = [[g_needleBaseOffset [0 ], g_needleBaseOffset [1 ], - (i * g_needleLength / (g_needleNumberOfElems ) + g_needleBaseOffset [2 ])] for i in range (g_needleNumberOfElems + 1 )]
94+ , edges = [[i , i + 1 ] for i in range (g_needleNumberOfElems )]
95+ )
9896 needle .addObject ("EdgeSetTopologyModifier" , name = "modifier" )
9997 needle .addObject ("PointSetTopologyModifier" , name = "modifier2" )
100-
10198 needle .addObject ("MechanicalObject" , name = "mstate" , template = "Rigid3d" , showObjectScale = 0.0002 , showObject = False , drawMode = 1 )
102-
10399 needle .addObject ("UniformMass" , totalMass = g_needleTotalMass )
104100 needle .addObject ("BeamFEMForceField" , name = "FEM" , ** g_needleMechanicalParameters )
105101 needle .addObject ("LinearSolverConstraintCorrection" , printLog = False , linearSolver = "@LinearSolver" )
@@ -108,31 +104,27 @@ def createScene(root):
108104 needleBase .addObject ("PointSetTopologyContainer" , name = "Container_base" , position = [0 , 0 , 0 ])
109105 needleBase .addObject ("MechanicalObject" ,name = "mstate_base" , template = "Rigid3d" ,)
110106 needleBase .addObject ("RestShapeSpringsForceField" ,points = [0 ],stiffness = 1e8 , angularStiffness = 1e8 ,external_points = [0 ],external_rest_shape = "@/NeedleBaseMaster/mstate_baseMaster" )
111-
112107 needleBase .addObject ("SubsetMapping" , indices = "0" )
113108
114109 needleBodyCollision = needle .addChild ("bodyCollision" )
115110 needleBodyCollision .addObject ("EdgeSetTopologyContainer" , name = "Container_body" , src = "@../Container" )
116111 needleBodyCollision .addObject ("MechanicalObject" ,name = "mstate_body" , template = "Vec3d" ,)
117112 needleBodyCollision .addObject ("EdgeGeometry" ,name = "geom_body" ,mstate = "@mstate_body" , topology = "@Container_body" )
118113 needleBodyCollision .addObject ("EdgeNormalHandler" , name = "NeedleBeams" , geometry = "@geom_body" )
119-
120114 needleBodyCollision .addObject ("IdentityMapping" )
121115
122-
123116 needleTipCollision = needle .addChild ("tipCollision" )
124- needleTipCollision .addObject ("MechanicalObject" ,name = "mstate_tip" ,position = [g_needleLength + g_needleBaseOffset [0 ], g_needleBaseOffset [1 ], g_needleBaseOffset [2 ]],template = "Vec3d" ,)
117+ needleTipCollision .addObject ("PointSetTopologyContainer" , name = "Container_tip"
118+ , position = [g_needleBaseOffset [0 ], g_needleBaseOffset [1 ], - (g_needleLength + g_needleBaseOffset [2 ])])
119+ needleTipCollision .addObject ("MechanicalObject" ,name = "mstate_tip" )#,position=[g_needleLength+g_needleBaseOffset[0], g_needleBaseOffset[1], g_needleBaseOffset[2]],template="Vec3d",)
125120 needleTipCollision .addObject ("PointGeometry" ,name = "geom_tip" ,mstate = "@mstate_tip" )
126121 needleTipCollision .addObject ("RigidMapping" ,globalToLocalCoords = True ,index = g_needleNumberOfElems )
127122
128-
129123 needleVisual = needle .addChild ("visual" )
130124 needleVisual .addObject ("QuadSetTopologyContainer" , name = "Container_visu" )
131125 needleVisual .addObject ("QuadSetTopologyModifier" , name = "Modifier" )
132126 needleVisual .addObject ("Edge2QuadTopologicalMapping" , nbPointsOnEachCircle = 8 , radius = g_needleRadius , input = "@../Container" , output = "@Container_visu" )
133-
134127 needleVisual .addObject ("MechanicalObject" , name = "mstate_visu" , showObjectScale = 0.0002 , showObject = True , drawMode = 1 )
135-
136128 needleVisual .addObject ("TubularMapping" , nbPointsOnEachCircle = 8 , radius = g_needleRadius , input = "@../mstate" , output = "@mstate_visu" )
137129
138130 needleOGL = needleVisual .addChild ("OGL" )
@@ -152,23 +144,22 @@ def createScene(root):
152144 gelTopo .addObject ("RegularGridTopology" , name = "HexaTop" , ** g_gelRegularGridParameters [i ])
153145
154146 volume = root .addChild ("Layer" + str (i ))
155- volume .addObject ("EulerImplicitSolver" )
156- volume .addObject ("EigenSimplicialLDLT" , name = "LinearSolver" , template = 'CompressedRowSparseMatrixMat3x3d' )
147+ if (i < 2 ):
148+ volume .addObject ("EulerImplicitSolver" )
149+ volume .addObject ("EigenSimplicialLDLT" , name = "LinearSolver" , template = 'CompressedRowSparseMatrixMat3x3d' )
157150 volume .addObject ("TetrahedronSetTopologyContainer" , name = "TetraContainer" , position = "@../" + gelGridTopoName + "/HexaTop.position" )
158151 volume .addObject ("TetrahedronSetTopologyModifier" , name = "TetraModifier" )
159152 volume .addObject ("Hexa2TetraTopologicalMapping" , input = "@../" + gelGridTopoName + "/HexaTop" , output = "@TetraContainer" , swapping = False )
160-
161153 volume .addObject ("MechanicalObject" , name = "mstate_gel" , template = "Vec3d" )
162154 volume .addObject ("TetrahedronGeometry" , name = "geom_tetra" , mstate = "@mstate_gel" , topology = "@TetraContainer" , draw = False )
163155 volume .addObject ("AABBBroadPhase" ,name = "AABBTetra" ,geometry = "@geom_tetra" ,nbox = [3 ,3 ,3 ],thread = 1 )
164156 volume .addObject ("TetrahedronFEMForceField" , name = "FF" ,** g_gelMechanicalParameters )
165157 volume .addObject ("MeshMatrixMass" , name = "Mass" ,totalMass = g_gelTotalMass )
166-
167158 volume .addObject ("BoxROI" ,name = "BoxROI" ,box = g_gelFixedBoxROI )
168159 volume .addObject ("RestShapeSpringsForceField" , stiffness = 1e6 , points = "@BoxROI.indices" )
169160 volume .addObject ("FixedLagrangianConstraint" , indices = "@BoxROI.indices" )
170-
171- volume .addObject ("LinearSolverConstraintCorrection" , printLog = False , linearSolver = "@LinearSolver" )
161+ if ( i < 2 ):
162+ volume .addObject ("LinearSolverConstraintCorrection" , printLog = False , linearSolver = "@LinearSolver" )
172163
173164 volumeCollision = volume .addChild ("collision" )
174165 volumeCollision .addObject ("TriangleSetTopologyContainer" , name = "TriContainer" )
@@ -178,11 +169,6 @@ def createScene(root):
178169 volumeCollision .addObject ("TriangleGeometry" , name = "geom_tri" , mstate = "@mstate_gelColi" , topology = "@TriContainer" ,draw = False )
179170 volumeCollision .addObject ("PhongTriangleNormalHandler" , name = "SurfaceTriangles" , geometry = "@geom_tri" )
180171 volumeCollision .addObject ("AABBBroadPhase" ,name = "AABBTriangles" ,thread = 1 ,nbox = [2 ,2 ,3 ])
181-
182- #volumeCollision.addObject("TriangleCollisionModel", name="colli_tri", group=i)
183- #volumeCollision.addObject("LineCollisionModel", name="colli_line", group=i)
184- #volumeCollision.addObject("PointCollisionModel", name="colli_point", group=i)
185-
186172 volumeCollision .addObject ("IdentityMapping" , name = "identityMappingToCollision" , input = "@../mstate_gel" , output = "@mstate_gelColi" , isMechanical = True )
187173
188174 volumeVisu = volumeCollision .addChild ("visu" )
@@ -191,7 +177,7 @@ def createScene(root):
191177 triangles = "@../TriContainer.triangles" ,
192178 color = g_cubeColor [i ],name = "volume_visu" ,template = "Vec3d" )
193179 volumeVisu .addObject ("IdentityMapping" )
194-
180+
195181 volumeVisuWire = volume .addChild ("visu_wire" )
196182 volumeVisuWire .addObject ("VisualStyle" , displayFlags = "showWireframe" )
197183 volumeVisuWire .addObject ("OglModel" , position = "@../TetraContainer.position" ,
@@ -209,21 +195,20 @@ def createScene(root):
209195
210196 for i in range (0 ,2 ):
211197 algo = root .addChild ("algo" + str (i ))
198+ punctureForce = 1.5 if i < 2 else 2000
212199 algo .addObject ("InsertionAlgorithm" , name = "InsertionAlgo" + str (i ),
213200 tipGeom = "@/Needle/tipCollision/geom_tip" ,
214201 surfGeom = "@/Layer" + str (i )+ "/collision/geom_tri" ,
215202 shaftGeom = "@/Needle/bodyCollision/geom_body" ,
216203 volGeom = "@/Layer" + str (i )+ "/geom_tetra" ,
217- punctureForceThreshold = 1.5 ,
204+ punctureForceThreshold = punctureForce ,
218205 tipDistThreshold = 0.005 ,
219206 drawcollision = True ,
220207 drawPointsScale = 0.0001
221208 )
222- algo .addObject ("DistanceFilter" , algo = "@InsertionAlgo" + str (i ), distance = 0.01 )
209+ algo .addObject ("DistanceFilter" , name = "DistanceFilter" + str ( i ), algo = "@InsertionAlgo" + str (i ), distance = 0.01 )
223210 algo .addObject ("SecondDirection" , name = "punctureDirection" + str (i ), handler = "@../Layer" + str (i )+ "/collision/SurfaceTriangles" )
224- algo .addObject ("ConstraintUnilateral" , name = "cs_Uni" + str (i ), input = "@InsertionAlgo" + str (i )+ ".collisionOutput" , directions = "@punctureDirection" + str (i ),draw_scale = 0.001 )
225- algo .addObject ("FirstDirection" , name = "bindDirection" + str (i ), handler = "@../Needle/bodyCollision/NeedleBeams" )
226- algo .addObject ("ConstraintInsertion" , name = "cs_Ins" + str (i ), input = "@InsertionAlgo" + str (i )+ ".insertionOutput" , directions = "@bindDirection" + str (i ), draw_scale = 0.002 , frictionCoeff = 0.00 )
227-
228- #algo.addObject("SecondDirection",name="punctureDirectionInv",handler="@Layer1/collisionInvert/SurfaceTriangles")
229- #algo.addObject("ConstraintUnilateral", name="invCnstr", input="@InsertionAlgo.collisionOutput",directions="@punctureDirectionInv",draw_scale=0.001,mu=0.1)
211+ algo .addObject ("ConstraintUnilateral" , name = "cs_Uni" + str (i ), input = "@InsertionAlgo" + str (i )+ ".collisionOutput" , directions = "@punctureDirection" + str (i ), draw_scale = 0.001 , mu = 0.1 )
212+ if (i < 2 ):
213+ algo .addObject ("FirstDirection" , name = "bindDirection" + str (i ), handler = "@../Needle/bodyCollision/NeedleBeams" )
214+ algo .addObject ("ConstraintInsertion" , name = "cs_Ins" + str (i ), input = "@InsertionAlgo" + str (i )+ ".insertionOutput" , directions = "@bindDirection" + str (i ), draw_scale = 0.002 , frictionCoeff = 0.00 )
0 commit comments