Skip to content

Commit 9e8a726

Browse files
committed
[scenes] Fix python scenes
1 parent c1813cd commit 9e8a726

4 files changed

Lines changed: 55 additions & 32 deletions

File tree

examples/python3/Cochlear-Implant-Insertion/Scene_Cochlea.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
def createScene(rootNode):
99
rootNode.addObject('RequiredPlugin',name='BeamAdapter', pluginName='BeamAdapter ')
1010
rootNode.addObject('RequiredPlugin',name='SofaPython3', pluginName='SofaPython3')
11-
rootNode.addObject('RequiredPlugin',name='SOFA Modules', pluginName='Sofa.Component.AnimationLoop Sofa.Component.Collision.Detection.Algorithm Sofa.Component.Collision.Detection.Intersection Sofa.Component.Collision.Geometry Sofa.Component.Collision.Response.Contact Sofa.Component.Constraint.Lagrangian.Correction Sofa.Component.Constraint.Lagrangian.Solver Sofa.Component.Constraint.Projective Sofa.Component.IO.Mesh Sofa.Component.LinearSolver.Direct Sofa.Component.ODESolver.Backward Sofa.Component.SolidMechanics.Spring Sofa.Component.Topology.Container.Constant Sofa.Component.Topology.Container.Dynamic Sofa.Component.Topology.Container.Grid Sofa.Component.Topology.Mapping Sofa.Component.Visual Sofa.GL.Component.Rendering3D')
11+
rootNode.addObject('RequiredPlugin',name='SOFA Modules', pluginName='Sofa.Component.AnimationLoop Sofa.Component.Collision.Detection.Algorithm Sofa.Component.Collision.Detection.Intersection Sofa.Component.Collision.Geometry Sofa.Component.Collision.Response.Contact Sofa.Component.Constraint.Lagrangian.Correction Sofa.Component.Constraint.Lagrangian.Solver Sofa.Component.Constraint.Projective Sofa.Component.IO.Mesh Sofa.Component.LinearSolver.Direct Sofa.Component.ODESolver.Backward Sofa.Component.SolidMechanics.Spring Sofa.Component.Topology.Container.Constant Sofa.Component.Topology.Container.Dynamic Sofa.Component.Topology.Container.Grid Sofa.Component.Mapping.Linear Sofa.Component.Topology.Mapping Sofa.Component.StateContainer Sofa.Component.Visual Sofa.GL.Component.Rendering3D')
1212
rootNode.findData('dt').value=0.01
1313
rootNode.findData('gravity').value=[0,0,0]
1414
rootNode.addObject('VisualStyle', displayFlags='showVisualModels hideBehaviorModels showCollisionModels hideMappings hideForceFields showInteractionForceFields hideWireframe')
15+
1516
rootNode.addObject('DefaultVisualManagerLoop')
1617
rootNode.addObject('FreeMotionAnimationLoop')
1718
rootNode.addObject('GenericConstraintSolver', tolerance="1e-3", maxIterations="5000", unbuilt="false")
18-
rootNode.addObject('DefaultPipeline', depth="6", verbose="0", draw="1")
19+
rootNode.addObject('CollisionPipeline', depth="6", verbose="0", draw="1")
1920
rootNode.addObject('BruteForceBroadPhase', name='N2')
2021
rootNode.addObject('BVHNarrowPhase')
21-
rootNode.addObject('DefaultContactManager', response="FrictionContactConstraint", responseParams="mu=0.65")
22+
rootNode.addObject('CollisionResponse', response="FrictionContactConstraint", responseParams="mu=0.65")
2223
rootNode.addObject('LocalMinDistance', name="Proximity", alarmDistance="0.6", contactDistance="0.44", angleCone="0.01")
2324

2425

@@ -32,8 +33,14 @@ def createScene(rootNode):
3233
visuCochleaNode = cochleaNode.addChild('visuCochleaNode')
3334
visuCochleaNode.addObject('OglModel', name="VisualModel", color="3.0 0.5 0.0 0.9")
3435

36+
3537
topoLines_cath = rootNode.addChild('topoLines_cath')
36-
topoLines_cath.addObject('WireRestShape', template="Rigid3d", printLog=False, name="catheterRestShape", length="20", straightLength="20", spireDiameter="0", spireHeight="0.0", densityOfBeams="40", numEdges="20", numEdgesCollis="20", youngModulus="2.5e5", youngModulusExtremity="2.5e5", radius="@../Proximity.contactDistance")
38+
topoLines_cath.addObject('RodStraightSection', name='StraightSection',
39+
length=20.0, radius="@../Proximity.contactDistance",
40+
nbEdgesCollis=20, nbEdgesVisu=20,
41+
youngModulus=2.5e5, massDensity=0.000005, poissonRatio=0.3)
42+
43+
topoLines_cath.addObject('WireRestShape', name='catheterRestShape', template="Rigid3d", wireMaterials="@StraightSection")
3744
topoLines_cath.addObject('EdgeSetTopologyContainer', name="meshLinesCath")
3845
topoLines_cath.addObject('EdgeSetTopologyModifier', name="Modifier")
3946
topoLines_cath.addObject('EdgeSetGeometryAlgorithms', name="GeomAlgo", template="Rigid3d")
@@ -52,7 +59,7 @@ def createScene(rootNode):
5259
InstrumentCombined.addObject('WireBeamInterpolation', name="InterpolCatheter", WireRestShape="@../topoLines_cath/catheterRestShape", radius="3.0", printLog=False)
5360
InstrumentCombined.addObject('AdaptiveBeamForceFieldAndMass', name="CatheterForceField", massDensity="0.000005", interpolation="@InterpolCatheter", printLog=False)
5461
InstrumentCombined.addObject('LinearSolverConstraintCorrection', printLog=False, wire_optimization="true")
55-
InstrumentCombined.addObject("FixedConstraint", indices="0")
62+
InstrumentCombined.addObject("FixedProjectiveConstraint", indices="0")
5663
InstrumentCombined.addObject('RestShapeSpringsForceField', name="MeasurementFF", points="@m_ircontroller.indexFirstNode", stiffness="1e10", recompute_indices="1", angularStiffness="1e10", external_rest_shape="@../RefStartingPos/ReferencePos", external_points="0", drawSpring="1", springColor="1 0 0 1")
5764

5865
CollisInstrumentCombined = InstrumentCombined.addChild('CollisInstrumentCombined')

examples/python3/SingleBeam.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@
44
def createScene(rootNode):
55

66
# rootNode
7-
rootNode.addObject('RequiredPlugin', pluginName='BeamAdapter SofaBoundaryCondition SofaGeneralLinearSolver SofaConstraint SofaImplicitOdeSolver')
7+
rootNode.addObject('RequiredPlugin', pluginName='BeamAdapter Sofa.Component.Constraint.Projective Sofa.Component.LinearSolver.Direct Sofa.Component.ODESolver.Backward Sofa.Component.StateContainer Sofa.Component.Topology.Container.Constant Sofa.Component.Topology.Container.Grid Sofa.Component.Visual')
88
rootNode.addObject('VisualStyle', displayFlags='showBehaviorModels showCollisionModels hideBoundingCollisionModels showForceFields')
99
rootNode.addObject('DefaultAnimationLoop')
1010
rootNode.addObject('DefaultVisualManagerLoop')
1111

1212
# rootNode/BeamModel
13-
BeamModel = rootNode.addChild('BeamModel')
14-
BeamModel = BeamModel
13+
BeamModel = rootNode.addChild('BeamModel', bbox="-3 -6 -3 3 3 3")
1514
BeamModel.addObject('EulerImplicitSolver', rayleighStiffness='0', rayleighMass='0', printLog='false')
1615
BeamModel.addObject('BTDLinearSolver', verbose='0')
17-
BeamModel.addObject('MechanicalObject', template='Rigid3d', name='DOFs', position='0 0 0 0 0 0 1 2 0 0 0 0 0 1 4 0 0 0 0 0 1 6 0 0 0 0 0 1')
18-
BeamModel.addObject('MeshTopology', name='lines', lines='0 1 1 2 2 3')
19-
BeamModel.addObject('FixedConstraint', name='FixedConstraint', indices='0')
16+
BeamModel.addObject('RegularGridTopology', name='MeshLines', n=[200, 1, 1], min=[0, 0, 0], max=[100, 0, 0])
17+
BeamModel.addObject('MechanicalObject', template='Rigid3d', name='DOFs', position='@MeshLines.positions')
18+
BeamModel.addObject('FixedProjectiveConstraint', name='FixedConstraint', indices='0')
2019
BeamModel.addObject('BeamInterpolation', name='BeamInterpolation', radius='0.1')
2120
BeamModel.addObject('AdaptiveBeamForceFieldAndMass', name='BeamForceField', computeMass='1', massDensity='10')
2221

examples/python3/SingleBeamDeployment.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,37 @@
33

44
def createScene(rootNode):
55

6-
rootNode.addObject('RequiredPlugin', pluginName='BeamAdapter SofaBoundaryCondition SofaConstraint SofaDeformable SofaGeneralLinearSolver SofaImplicitOdeSolver')
6+
rootNode.addObject('RequiredPlugin', pluginName='BeamAdapter Sofa.Component.Constraint.Projective Sofa.Component.LinearSolver.Direct Sofa.Component.ODESolver.Backward Sofa.Component.StateContainer Sofa.Component.Topology.Container.Constant Sofa.Component.Topology.Container.Grid Sofa.Component.Visual Sofa.Component.SolidMechanics.Spring Sofa.Component.Topology.Container.Dynamic')
77
rootNode.addObject('VisualStyle', displayFlags='showVisualModels showBehaviorModels showCollisionModels hideMappings showForceFields')
88

99
rootNode.addObject('DefaultAnimationLoop')
1010
rootNode.addObject('DefaultVisualManagerLoop')
1111

1212
topoLines = rootNode.addChild('EdgeTopology')
13-
topoLines.addObject('WireRestShape', name='BeamRestShape',
14-
straightLength=980.0, length=1000.0,
15-
numEdges=200, youngModulus=20000,
16-
spireDiameter=25, numEdgesCollis=[50,10],
17-
printLog=True, template='Rigid3d', spireHeight=0.0,
18-
densityOfBeams=[30,5], youngModulusExtremity=20000)
13+
topoLines.addObject('RodStraightSection', name='StraightSection',
14+
length=980.0, radius=1,
15+
nbEdgesCollis=30, nbEdgesVisu=196,
16+
youngModulus=20000)
17+
18+
topoLines.addObject('RodSpireSection', name='SpireSection',
19+
length=20.0, radius=1,
20+
nbEdgesCollis=5, nbEdgesVisu=4,
21+
spireDiameter=25, spireHeight=0,
22+
youngModulus=20000)
23+
topoLines.addObject('WireRestShape', name='BeamRestShape', template="Rigid3d",
24+
wireMaterials="@StraightSection @SpireSection")
25+
1926
topoLines.addObject('EdgeSetTopologyContainer', name='meshLinesBeam')
2027
topoLines.addObject('EdgeSetTopologyModifier', name='Modifier')
2128
topoLines.addObject('EdgeSetGeometryAlgorithms', name='GeomAlgo', template='Rigid3d')
2229
topoLines.addObject('MechanicalObject', name='dofTopo2', template='Rigid3d')
2330

2431

25-
BeamMechanics = rootNode.addChild('BeamModel')
32+
33+
BeamMechanics = rootNode.addChild('BeamModel', bbox="0 0 0 10 10 10")
2634
BeamMechanics.addObject('EulerImplicitSolver', rayleighStiffness=0.2, printLog=False, rayleighMass=0.1)
2735
BeamMechanics.addObject('BTDLinearSolver', verification=False, subpartSolve=False, verbose=False)
28-
BeamMechanics.addObject('RegularGridTopology', name='MeshLines', drawEdges=True
36+
BeamMechanics.addObject('RegularGridTopology', name='MeshLines', drawEdges=True,
2937
nx=60, ny=1, nz=1,
3038
xmax=0.0, xmin=0.0, ymin=0, ymax=0, zmax=0, zmin=0,
3139
p0=[0,0,0])
@@ -37,7 +45,7 @@ def createScene(rootNode):
3745
startingPos=[0, 0, 0, 0, 0, 0, 1], xtip=[0, 0, 0], printLog=True,
3846
rotationInstrument=[0, 0, 0], step=0.5, speed=0.5,
3947
listening=True, controlledInstrument=0)
40-
BeamMechanics.addObject('FixedConstraint', indices=0, name='FixedConstraint')
48+
BeamMechanics.addObject('FixedProjectiveConstraint', indices=0, name='FixedConstraint')
4149
BeamMechanics.addObject('RestShapeSpringsForceField', name="RestSPForceField", points='@DeployController.indexFirstNode', angularStiffness=1e8, stiffness=1e8)
4250

4351

examples/python3/SingleBeamDeploymentCollision.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,41 @@
33

44
def createScene(rootNode):
55

6-
rootNode.addObject('RequiredPlugin', pluginName='BeamAdapter SofaMeshCollision SofaBoundaryCondition SofaConstraint SofaMiscCollision SofaDeformable SofaGeneralLinearSolver SofaImplicitOdeSolver')
6+
rootNode.addObject('RequiredPlugin', name="plug1", pluginName='BeamAdapter Sofa.Component.Constraint.Projective Sofa.Component.LinearSolver.Direct Sofa.Component.ODESolver.Backward Sofa.Component.StateContainer Sofa.Component.Topology.Container.Constant Sofa.Component.Topology.Container.Grid Sofa.Component.Visual Sofa.Component.SolidMechanics.Spring Sofa.Component.Topology.Container.Dynamic')
7+
rootNode.addObject('RequiredPlugin', name="plug2", pluginName='Sofa.Component.AnimationLoop Sofa.Component.Collision.Detection.Algorithm Sofa.Component.Collision.Detection.Intersection Sofa.Component.Collision.Geometry Sofa.Component.Collision.Response.Contact Sofa.Component.Constraint.Lagrangian.Correction Sofa.Component.Constraint.Lagrangian.Solver Sofa.Component.IO.Mesh')
78
rootNode.addObject('VisualStyle', displayFlags='hideVisualModels hideBehaviorModels showCollisionModels hideMappings showInteractionForceFields')
89

910
rootNode.addObject('FreeMotionAnimationLoop')
1011
rootNode.addObject('DefaultVisualManagerLoop')
1112

1213
rootNode.addObject('LCPConstraintSolver', mu='0.1', tolerance='1e-10', maxIt='1000', build_lcp='false')
13-
rootNode.addObject('DefaultPipeline', draw='0', depth='6', verbose='1')
14+
rootNode.addObject('CollisionPipeline', draw='0', depth='6', verbose='1')
1415
rootNode.addObject('BruteForceBroadPhase', name='N2')
1516
rootNode.addObject('BVHNarrowPhase')
16-
rootNode.addObject('LocalMinDistance', contactDistance='1', alarmDistance='5', name='localmindistance', angleCone='0.02')
17-
rootNode.addObject('DefaultContactManager', name='Response', response='FrictionContactConstraint')
17+
rootNode.addObject('LocalMinDistance', contactDistance='0.1', alarmDistance='2', name='localmindistance', angleCone='0.2')
18+
rootNode.addObject('CollisionResponse', name='Response', response='FrictionContactConstraint')
1819

1920
topoLines = rootNode.addChild('EdgeTopology')
20-
topoLines.addObject('WireRestShape', name='BeamRestShape',
21-
straightLength=980.0, length=1000.0,
22-
numEdges=200, youngModulus=20000,
23-
spireDiameter=25, numEdgesCollis=[50,10],
24-
printLog=True, template='Rigid3d', spireHeight=0.0,
25-
densityOfBeams=[30,5], youngModulusExtremity=20000)
21+
topoLines.addObject('RodStraightSection', name='StraightSection',
22+
length=980.0, radius=1,
23+
nbEdgesCollis=50, nbEdgesVisu=200,
24+
youngModulus=20000, massDensity=0.1, poissonRatio=0.3)
25+
26+
topoLines.addObject('RodSpireSection', name='SpireSection',
27+
length=20.0, radius=1,
28+
nbEdgesCollis=10, nbEdgesVisu=200,
29+
spireDiameter=25, spireHeight=0,
30+
youngModulus=20000, massDensity=0.1, poissonRatio=0.3)
31+
topoLines.addObject('WireRestShape', name='BeamRestShape', template="Rigid3d",
32+
wireMaterials="@StraightSection @SpireSection")
33+
2634
topoLines.addObject('EdgeSetTopologyContainer', name='meshLines')
2735
topoLines.addObject('EdgeSetTopologyModifier', name='Modifier')
2836
topoLines.addObject('EdgeSetGeometryAlgorithms', name='GeomAlgo', template='Rigid3d')
2937
topoLines.addObject('MechanicalObject', name='dofTopo2', template='Rigid3d')
3038

3139

40+
3241
BeamMechanics = rootNode.addChild('BeamModel')
3342
BeamMechanics.addObject('EulerImplicitSolver', rayleighStiffness=0.2, rayleighMass=0.1)
3443
BeamMechanics.addObject('BTDLinearSolver', verification=False, subpartSolve=False, verbose=False)
@@ -45,7 +54,7 @@ def createScene(rootNode):
4554
rotationInstrument=[0, 0, 0], step=5., speed=5.,
4655
listening=True, controlledInstrument=0)
4756
BeamMechanics.addObject('LinearSolverConstraintCorrection', wire_optimization='true', printLog=False)
48-
BeamMechanics.addObject('FixedConstraint', indices=0, name='FixedConstraint')
57+
BeamMechanics.addObject('FixedProjectiveConstraint', indices=0, name='FixedConstraint')
4958
BeamMechanics.addObject('RestShapeSpringsForceField', points='@DeployController.indexFirstNode', angularStiffness=1e8, stiffness=1e8)
5059

5160

0 commit comments

Comments
 (0)