Skip to content

Commit e61f01b

Browse files
authored
[examples] Fix all example warnings and add all files to the release (#355)
* add all examples to the release * fix all scene warnings for v23.06
1 parent 36682dd commit e61f01b

23 files changed

Lines changed: 195 additions & 57 deletions

examples/CMakeLists.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
project(Examples)
22

33
set(EXAMPLES_FILES
4-
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
4+
5+
${CMAKE_CURRENT_SOURCE_DIR}/access_compliance_matrix.py
6+
${CMAKE_CURRENT_SOURCE_DIR}/access_mass_matrix.py
7+
${CMAKE_CURRENT_SOURCE_DIR}/access_matrix.py
8+
${CMAKE_CURRENT_SOURCE_DIR}/access_stiffness_matrix.py
9+
${CMAKE_CURRENT_SOURCE_DIR}/additional-examples/ControllerScene.py
510
${CMAKE_CURRENT_SOURCE_DIR}/advanced_timer.py
6-
${CMAKE_CURRENT_SOURCE_DIR}/basic.py
711
${CMAKE_CURRENT_SOURCE_DIR}/basic-addGUI.py
12+
${CMAKE_CURRENT_SOURCE_DIR}/basic.py
13+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
814
${CMAKE_CURRENT_SOURCE_DIR}/emptyController.py
915
${CMAKE_CURRENT_SOURCE_DIR}/emptyDataEngine.py
1016
${CMAKE_CURRENT_SOURCE_DIR}/emptyForceField.py
1117
${CMAKE_CURRENT_SOURCE_DIR}/example-forcefield.py
1218
${CMAKE_CURRENT_SOURCE_DIR}/example-scriptcontroller.py
1319
${CMAKE_CURRENT_SOURCE_DIR}/keyEvents.py
1420
${CMAKE_CURRENT_SOURCE_DIR}/liver.py
21+
${CMAKE_CURRENT_SOURCE_DIR}/liver-scriptcontroller.py
1522
${CMAKE_CURRENT_SOURCE_DIR}/loadXMLfromPython.py
23+
${CMAKE_CURRENT_SOURCE_DIR}/pointSetTopologyModifier.py
1624
${CMAKE_CURRENT_SOURCE_DIR}/ReadTheDocs_Example.py
17-
${CMAKE_CURRENT_SOURCE_DIR}/additional-examples/ControllerScene.py
25+
${CMAKE_CURRENT_SOURCE_DIR}/springForceField.py
26+
1827
)
1928

2029
add_custom_target(${PROJECT_NAME} SOURCES ${EXAMPLES_FILES})

examples/ReadTheDocs_Example.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,27 @@
1212
SofaRuntime.importPlugin("Sofa.GL.Component")
1313

1414
def createScene(rootNode):
15+
16+
rootNode.bbox = [[-1, -1, -1],[1,1,1]]
17+
18+
rootNode.addObject("RequiredPlugin", pluginName=[ 'Sofa.Component.AnimationLoop',
19+
'Sofa.Component.Collision.Detection.Algorithm',
20+
'Sofa.Component.Collision.Detection.Intersection',
21+
'Sofa.Component.Collision.Geometry',
22+
'Sofa.Component.Collision.Response.Contact',
23+
'Sofa.Component.Constraint.Lagrangian.Correction',
24+
'Sofa.Component.Constraint.Lagrangian.Solver',
25+
'Sofa.Component.IO.Mesh',
26+
'Sofa.Component.LinearSolver.Iterative',
27+
'Sofa.Component.Mapping.NonLinear',
28+
'Sofa.Component.Mass',
29+
'Sofa.Component.ODESolver.Backward',
30+
'Sofa.Component.StateContainer',
31+
'Sofa.Component.Topology.Container.Constant',
32+
'Sofa.Component.Visual',
33+
'Sofa.GL.Component.Rendering3D'
34+
])
35+
1536
rootNode.addObject("VisualGrid", nbSubdiv=10, size=1000)
1637

1738
rootNode.findData('gravity').value=[0.0,-981.0,0.0];
@@ -24,12 +45,12 @@ def createScene(rootNode):
2445

2546
#Collision function
2647

27-
rootNode.addObject('DefaultPipeline')
48+
rootNode.addObject('CollisionPipeline')
2849
rootNode.addObject('FreeMotionAnimationLoop')
2950
rootNode.addObject('GenericConstraintSolver', tolerance="1e-6", maxIterations="1000")
30-
rootNode.addObject('BruteForceDetection')
31-
rootNode.addObject('RuleBasedContactManager', responseParams="mu="+str(0.0), name='Response',
32-
response='FrictionContactConstraint')
51+
rootNode.addObject('BruteForceBroadPhase', name="BroadPhase")
52+
rootNode.addObject('BVHNarrowPhase', name="NarrowPhase")
53+
rootNode.addObject('RuleBasedContactManager', responseParams="mu="+str(0.0), name='Response', response='FrictionContactConstraint')
3354
rootNode.addObject('LocalMinDistance', alarmDistance=10, contactDistance=5, angleCone=0.01)
3455

3556
### Mechanical model
@@ -46,7 +67,7 @@ def createScene(rootNode):
4667

4768
floor.addObject('UniformMass', name="mass", vertexMass=[totalMass, volume, inertiaMatrix[:]])
4869
floorCollis = floor.addChild('collision')
49-
floorCollis.addObject('MeshObjLoader', name="loader", filename="mesh/floor.obj",
70+
floorCollis.addObject('MeshOBJLoader', name="loader", filename="mesh/floor.obj",
5071
triangulate="true", scale=5.0)
5172
floorCollis.addObject('MeshTopology', src="@loader")
5273
floorCollis.addObject('MechanicalObject')
@@ -58,7 +79,7 @@ def createScene(rootNode):
5879

5980
#### visualization
6081
floorVisu = floor.addChild("VisualModel")
61-
floorVisu.loader = floorVisu.addObject('MeshObjLoader', name="loader",
82+
floorVisu.loader = floorVisu.addObject('MeshOBJLoader', name="loader",
6283
filename="mesh/floor.obj")
6384
floorVisu.addObject('OglModel', name="model", src="@loader", scale3d=[5.0]*3,
6485
color=[1., 1., 0.], updateNormals=False)
@@ -75,7 +96,7 @@ def createScene(rootNode):
7596
sphere.addObject('CGLinearSolver', name='Solver', iterations=25, tolerance=1e-5, threshold=1e-5)
7697

7798
collision = sphere.addChild('collision')
78-
collision.addObject('MeshObjLoader', name="loader", filename="mesh/ball.obj",
99+
collision.addObject('MeshOBJLoader', name="loader", filename="mesh/ball.obj",
79100
triangulate="true", scale=45.0)
80101

81102
collision.addObject('MeshTopology', src="@loader")
@@ -89,7 +110,7 @@ def createScene(rootNode):
89110

90111
#### visualization
91112
sphereVisu = sphere.addChild("VisualModel")
92-
sphereVisu.loader = sphereVisu.addObject('MeshObjLoader', name="loader",
113+
sphereVisu.loader = sphereVisu.addObject('MeshOBJLoader', name="loader",
93114
filename="mesh/ball.obj")
94115
sphereVisu.addObject('OglModel', name="model", src="@loader", scale3d=[50]*3,
95116
color=[0., 1., 0.], updateNormals=False)

examples/access_compliance_matrix.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ def createScene(root):
1717
"Sofa.Component.Mapping.MappedMatrix",
1818
"Sofa.Component.Mass",
1919
"Sofa.Component.ODESolver.Backward",
20-
"Sofa.Component.Topology.Container.Dynamic"])
20+
"Sofa.Component.Topology.Container.Dynamic",
21+
"Sofa.Component.Mapping.NonLinear",
22+
"Sofa.Component.StateContainer"
23+
])
2124

2225
root.addObject("FreeMotionAnimationLoop", solveVelocityConstraintFirst=True)
2326
constraint_solver = root.addObject("GenericConstraintSolver", tolerance=1e-9, maxIterations=1000)
@@ -27,15 +30,15 @@ def createScene(root):
2730
root.addObject("SparseCholeskySolver")
2831
root.addObject("GenericConstraintCorrection")
2932

30-
root.addObject("EdgeSetTopologyContainer", position="@loader.position", edges="@loader.edges")
33+
root.addObject("EdgeSetTopologyContainer", name="topo", position="@loader.position", edges="@loader.edges")
3134
root.addObject("MechanicalObject", name="defoDOF", template="Vec3d")
3235
root.addObject("EdgeSetGeometryAlgorithms", drawEdges=True)
3336
root.addObject("FixedConstraint", indices=[0])
3437
root.addObject("DiagonalMass", name="mass", totalMass="1e-3")
3538

3639
ext = root.addChild("extensionsNode")
3740
ext.addObject("MechanicalObject", template="Vec1d", name="extensionsDOF")
38-
ext.addObject("DistanceMapping", name="distanceMapping")
41+
ext.addObject("DistanceMapping", name="distanceMapping", topology="@topo")
3942
ext.addObject("UniformConstraint", template="Vec1d", iterative=True)
4043

4144
root.addObject(MatrixAccessController('MatrixAccessor', name='matrixAccessor', constraint_solver=constraint_solver))

examples/access_mass_matrix.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ def createScene(root):
1414

1515
root.addObject('VisualStyle', displayFlags="showBehaviorModels showForceFields")
1616

17+
root.addObject("RequiredPlugin", pluginName=['Sofa.Component.Constraint.Projective',
18+
'Sofa.Component.Engine.Select',
19+
'Sofa.Component.LinearSolver.Direct',
20+
'Sofa.Component.Mass',
21+
'Sofa.Component.ODESolver.Backward',
22+
'Sofa.Component.SolidMechanics.FEM.Elastic',
23+
'Sofa.Component.StateContainer',
24+
'Sofa.Component.Topology.Container.Grid',
25+
'Sofa.Component.Visual'
26+
])
27+
1728
root.addObject('DefaultAnimationLoop')
1829
root.addObject('DefaultVisualManagerLoop')
1930

examples/access_matrix.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ def createScene(root):
99

1010
root.addObject('VisualStyle', displayFlags="showBehaviorModels showForceFields")
1111

12+
root.addObject("RequiredPlugin", pluginName=['Sofa.Component.Mass',
13+
'Sofa.Component.StateContainer',
14+
'Sofa.Component.Topology.Container.Grid',
15+
'Sofa.Component.Visual'
16+
])
17+
1218
root.addObject('DefaultAnimationLoop')
1319
root.addObject('DefaultVisualManagerLoop')
1420

examples/access_stiffness_matrix.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ def createScene(root):
1414

1515
root.addObject('VisualStyle', displayFlags="showBehaviorModels showForceFields")
1616

17+
root.addObject("RequiredPlugin", pluginName=['Sofa.Component.Constraint.Projective',
18+
'Sofa.Component.Engine.Select',
19+
'Sofa.Component.LinearSolver.Direct',
20+
'Sofa.Component.Mass',
21+
'Sofa.Component.ODESolver.Backward',
22+
'Sofa.Component.SolidMechanics.FEM.Elastic',
23+
'Sofa.Component.StateContainer',
24+
'Sofa.Component.Topology.Container.Grid',
25+
'Sofa.Component.Visual'
26+
])
27+
1728
root.addObject('DefaultAnimationLoop')
1829
root.addObject('DefaultVisualManagerLoop')
1930

examples/additional-examples/ControllerScene.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def createScene(root):
9090
root.name = 'root'
9191
root.gravity = [0.0, 9.8, 0.0]
9292

93-
loader = root.addObject('MeshObjLoader', name='loader',
93+
loader = root.addObject('MeshOBJLoader', name='loader',
9494
filename="mesh/liver.obj")
9595
te = root.addObject("TransformEngine", name="te",
9696
input_position=loader.position.getLinkPath(), rotation=[0,0,0])

examples/additional-examples/pygame_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def createScene(root):
7474
root.addObject("VisualStyle", displayFlags="showAll")
7575
root.addObject("MeshGmshLoader", name="meshLoaderCoarse",
7676
filename="mesh/liver.msh")
77-
root.addObject("MeshObjLoader", name="meshLoaderFine",
77+
root.addObject("MeshOBJLoader", name="meshLoaderFine",
7878
filename="mesh/liver-smooth.obj")
7979

8080
root.addObject("EulerImplicitSolver")
@@ -97,7 +97,7 @@ def createScene(root):
9797
liver.addObject("MeshMatrixMass", massDensity="1")
9898
liver.addObject("FixedConstraint", indices="2 3 50")
9999
visual = liver.addChild("visual")
100-
visual.addObject('MeshObjLoader', name="meshLoader_0", filename="mesh/liver-smooth.obj", handleSeams="1")
100+
visual.addObject('MeshOBJLoader', name="meshLoader_0", filename="mesh/liver-smooth.obj", handleSeams="1")
101101
visual.addObject('OglModel', name="VisualModel", src="@meshLoader_0", color='red')
102102
visual.addObject('BarycentricMapping', input="@..", output="@VisualModel", name="visual mapping")
103103

examples/additional-examples/pyqt_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def __init__(self):
110110
root.addObject("VisualStyle", displayFlags="showBehaviorModels showAll")
111111
root.addObject("MeshGmshLoader", name="meshLoaderCoarse",
112112
filename="mesh/liver.msh")
113-
root.addObject("MeshObjLoader", name="meshLoaderFine",
113+
root.addObject("MeshOBJLoader", name="meshLoaderFine",
114114
filename="mesh/liver-smooth.obj")
115115

116116
root.addObject("EulerImplicitSolver")
@@ -134,7 +134,7 @@ def __init__(self):
134134
liver.addObject("FixedConstraint", indices="2 3 50")
135135

136136
visual = liver.addChild("visual")
137-
visual.addObject('MeshObjLoader', name="meshLoader_0", filename="mesh/liver-smooth.obj", handleSeams="1")
137+
visual.addObject('MeshOBJLoader', name="meshLoader_0", filename="mesh/liver-smooth.obj", handleSeams="1")
138138
visual.addObject('OglModel', name="VisualModel", src="@meshLoader_0", color='red')
139139
visual.addObject('BarycentricMapping', input="@..", output="@VisualModel", name="visual mapping")
140140

examples/advanced_timer.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,21 @@ def createScene(root):
4343
root.dt = 0.01
4444

4545
# List of required plugins
46-
root.addObject('RequiredPlugin', name='Sofa.Component')
46+
root.addObject("RequiredPlugin", pluginName=['Sofa.Component.Constraint.Projective',
47+
'Sofa.Component.Engine.Select',
48+
'Sofa.Component.LinearSolver.Iterative',
49+
'Sofa.Component.MechanicalLoad',
50+
'Sofa.Component.ODESolver.Backward',
51+
'Sofa.Component.SolidMechanics.FEM.Elastic',
52+
'Sofa.Component.StateContainer',
53+
'Sofa.Component.Topology.Container.Dynamic',
54+
'Sofa.Component.Topology.Container.Grid',
55+
'Sofa.Component.Visual'
56+
])
57+
58+
59+
# AnimationLoop
60+
root.addObject('DefaultAnimationLoop')
4761

4862
# Visual style
4963
root.addObject('VisualStyle', displayFlags='showBehaviorModels showForceFields')

0 commit comments

Comments
 (0)