Skip to content

Commit 9c679fd

Browse files
authored
[Examples] Fix and add old scenes (SofaDefrost#17)
* add scenes * add mesh * Rename testShell6.scn to testShell2.scn * Rename testShell6bis.scn to testShell2bis.scn * Rename testShell7.scn to testShell3.scn * Rename testShell7_small_bis.scn to testShell3_small_bis.scn
1 parent e3efac2 commit 9c679fd

21 files changed

Lines changed: 15869 additions & 1 deletion
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
def createScene(rootNode):
2+
3+
4+
rootNode.addObject('RequiredPlugin', name="Shell")
5+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Projective') # Needed to use components [FixedProjectiveConstraint]
6+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Engine.Select') # Needed to use components [BoxROI]
7+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshOBJLoader]
8+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver]
9+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mapping.Linear') # Needed to use components [IdentityMapping]
10+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass]
11+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver]
12+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject]
13+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology]
14+
rootNode.addObject('RequiredPlugin', name='Sofa.GL.Component.Rendering3D') # Needed to use components [OglModel]
15+
rootNode.addObject('RequiredPlugin', name='Sofa.GUI.Component') # Needed to use components [AttachBodyButtonSetting]
16+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.AnimationLoop') # Needed to use components [FreeMotionAnimationLoop]
17+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Correction') # Needed to use components [GenericConstraintCorrection]
18+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Solver') # Needed to use components [GenericConstraintSolver]
19+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Engine.Generate') # Needed to use components [NormalsFromPoints]
20+
rootNode.gravity = [0, -98.1, 0]
21+
rootNode.addObject('AttachBodyButtonSetting', stiffness=0.1)
22+
rootNode.addObject('FreeMotionAnimationLoop')
23+
rootNode.addObject('GenericConstraintSolver', maxIterations=1e3, tolerance=1e-3)
24+
25+
square = rootNode.addChild('Square')
26+
square.addObject('EulerImplicitSolver')
27+
square.addObject('SparseLDLSolver')
28+
square.addObject('GenericConstraintCorrection')
29+
square.addObject('MeshOBJLoader', filename='mesh/square1.obj')
30+
square.addObject('MeshTopology', src=square.MeshOBJLoader.getLinkPath())
31+
square.addObject('MechanicalObject', name="Object", template='Rigid3')
32+
square.addObject('NormalsFromPoints', name='NormalsFrom', position='@Object.position' )
33+
square.addObject('UniformMass', totalMass=0.005)
34+
square.addObject('BoxROI', box=[0, 0.9, -0.1, 1, 1, 0.1], drawBoxes=True)
35+
square.addObject('FixedProjectiveConstraint', indices=square.BoxROI.indices.getLinkPath())
36+
square.addObject('BezierTriangularBendingFEMForceField', youngModulus=1.7e3,
37+
poissonRatio=0.3, thickness=0.01, normals="@NormalsFrom.normals")
38+
39+
visu = square.addChild('Visu')
40+
visu.addObject('OglModel', src=square.MeshTopology.getLinkPath())
41+
visu.addObject('IdentityMapping')
42+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
def createScene(rootNode):
2+
3+
rootNode.addObject('RequiredPlugin', name="Shell")
4+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Projective') # Needed to use components [FixedProjectiveConstraint]
5+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Engine.Select') # Needed to use components [BoxROI]
6+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshOBJLoader]
7+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver]
8+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mapping.Linear') # Needed to use components [IdentityMapping]
9+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass]
10+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver]
11+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject]
12+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology]
13+
rootNode.addObject('RequiredPlugin', name='Sofa.GL.Component.Rendering3D') # Needed to use components [OglModel]
14+
rootNode.addObject('RequiredPlugin', name='Sofa.GUI.Component') # Needed to use components [AttachBodyButtonSetting]
15+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.AnimationLoop') # Needed to use components [FreeMotionAnimationLoop]
16+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Correction') # Needed to use components [GenericConstraintCorrection]
17+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Solver') # Needed to use components [GenericConstraintSolver]
18+
rootNode.gravity = [0, -98.1, 0]
19+
rootNode.addObject('AttachBodyButtonSetting', stiffness=0.1)
20+
rootNode.addObject('FreeMotionAnimationLoop')
21+
rootNode.addObject('GenericConstraintSolver', maxIterations=1e3, tolerance=1e-3)
22+
23+
square = rootNode.addChild('Square')
24+
square.addObject('EulerImplicitSolver')
25+
square.addObject('SparseLDLSolver')
26+
square.addObject('GenericConstraintCorrection')
27+
square.addObject('MeshOBJLoader', filename='mesh/square1.obj')
28+
square.addObject('MeshTopology', src=square.MeshOBJLoader.getLinkPath())
29+
square.addObject('MechanicalObject')
30+
square.addObject('UniformMass', totalMass=0.005)
31+
square.addObject('BoxROI', box=[0, 0.9, -0.1, 1, 1, 0.1], drawBoxes=True)
32+
square.addObject('FixedProjectiveConstraint', indices=square.BoxROI.indices.getLinkPath())
33+
square.addObject('CstFEMForceField', youngModulus=1.7e3,
34+
poissonRatio=0.3, thickness=0.01)
35+
36+
visu = square.addChild('Visu')
37+
visu.addObject('OglModel', src=square.MeshTopology.getLinkPath())
38+
visu.addObject('IdentityMapping')
39+

examples/sofapython3/TriangularBendingFEMForceField.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
def createScene(rootNode):
22

33
rootNode.addObject('RequiredPlugin', name="Shell")
4+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Projective') # Needed to use components [FixedProjectiveConstraint]
5+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Engine.Select') # Needed to use components [BoxROI]
6+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshOBJLoader]
7+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver]
8+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mapping.Linear') # Needed to use components [IdentityMapping]
9+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass]
10+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver]
11+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject]
12+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology]
13+
rootNode.addObject('RequiredPlugin', name='Sofa.GL.Component.Rendering3D') # Needed to use components [OglModel]
14+
rootNode.addObject('RequiredPlugin', name='Sofa.GUI.Component') # Needed to use components [AttachBodyButtonSetting]
15+
416
rootNode.gravity = [0, -98.1, 0]
517
rootNode.addObject('AttachBodyButtonSetting', stiffness=0.1)
618
rootNode.addObject('DefaultAnimationLoop')
@@ -13,7 +25,7 @@ def createScene(rootNode):
1325
square.addObject('MechanicalObject', template='Rigid3')
1426
square.addObject('UniformMass', totalMass=0.005)
1527
square.addObject('BoxROI', box=[0, 0.9, -0.1, 1, 1, 0.1], drawBoxes=True)
16-
square.addObject('FixedConstraint', indices=square.BoxROI.indices.getLinkPath())
28+
square.addObject('FixedProjectiveConstraint', indices=square.BoxROI.indices.getLinkPath())
1729
square.addObject('TriangularBendingFEMForceField', youngModulus=1.7e3,
1830
poissonRatio=0.3, thickness=0.01)
1931

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
def createScene(rootNode):
2+
3+
rootNode.addObject('RequiredPlugin', name="Shell")
4+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Projective') # Needed to use components [FixedProjectiveConstraint]
5+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Engine.Select') # Needed to use components [BoxROI]
6+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshOBJLoader]
7+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver]
8+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mapping.Linear') # Needed to use components [IdentityMapping]
9+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass]
10+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver]
11+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject]
12+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology]
13+
rootNode.addObject('RequiredPlugin', name='Sofa.GL.Component.Rendering3D') # Needed to use components [OglModel]
14+
rootNode.addObject('RequiredPlugin', name='Sofa.GUI.Component') # Needed to use components [AttachBodyButtonSetting]
15+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.AnimationLoop') # Needed to use components [FreeMotionAnimationLoop]
16+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Correction') # Needed to use components [GenericConstraintCorrection]
17+
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Solver') # Needed to use components [GenericConstraintSolver]
18+
rootNode.gravity = [0, -98.1, 0]
19+
rootNode.addObject('AttachBodyButtonSetting', stiffness=0.1)
20+
rootNode.addObject('DefaultAnimationLoop')
21+
#rootNode.addObject('FreeMotionAnimationLoop')
22+
#rootNode.addObject('GenericConstraintSolver', maxIterations=1e3, tolerance=1e-3)
23+
24+
square = rootNode.addChild('Square')
25+
square.addObject('EulerImplicitSolver')
26+
square.addObject('SparseLDLSolver')
27+
#square.addObject('GenericConstraintCorrection')
28+
square.addObject('MeshOBJLoader', filename='mesh/square1.obj')
29+
square.addObject('MeshTopology', src=square.MeshOBJLoader.getLinkPath())
30+
square.addObject('MechanicalObject', template='Rigid3', showObject=1)
31+
square.addObject('UniformMass', totalMass=0.005)
32+
square.addObject('BoxROI', box=[0, 0.9, -0.1, 1, 1, 0.1], drawBoxes=True)
33+
square.addObject('FixedProjectiveConstraint', indices=square.BoxROI.indices.getLinkPath())
34+
square.addObject('TriangularShellForceField', youngModulus=1.7e3, poissonRatio=0.3,
35+
thickness=0.05, measure="Von Mises stress", arrow_radius="0")
36+
37+
visu = square.addChild('Visu')
38+
visu.addObject('OglModel', src=square.MeshTopology.getLinkPath())
39+
visu.addObject('IdentityMapping')
40+
41+
42+
43+
#pluginList=['SofaEngine', 'SofaLoader', 'SofaSimpleFem','SofaExporter', 'SofaPython3', 'SofaShells']

examples/xml/MeshGID.scn

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" ?>
2+
<Node name="root" dt="0.02" gravity="0 0 0">
3+
4+
<Node name="plugins">
5+
<RequiredPlugin name="Shell"/>
6+
<RequiredPlugin name="Sofa.Component.Collision.Detection.Algorithm"/> <!-- Needed to use components [BVHNarrowPhase,BruteForceBroadPhase,CollisionPipeline] -->
7+
<RequiredPlugin name="Sofa.Component.Collision.Detection.Intersection"/> <!-- Needed to use components [MinProximityIntersection] -->
8+
<RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
9+
<RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
10+
<RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
11+
<RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
12+
<RequiredPlugin name="Sofa.Component.SceneUtility"/> <!-- Needed to use components [InfoComponent] -->
13+
<RequiredPlugin name="Sofa.Component.SolidMechanics.FEM.Elastic"/> <!-- Needed to use components [TetrahedronFEMForceField] -->
14+
<RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
15+
<RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
16+
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
17+
<RequiredPlugin name="Sofa.Component.Mapping.Linear"/> <!-- Needed to use components [IdentityMapping] -->
18+
<RequiredPlugin name="Sofa.Component.Topology.Container.Constant"/> <!-- Needed to use components [MeshTopology] -->
19+
</Node>
20+
21+
<VisualStyle displayFlags ="showBehaviorModels showForceFields showVisualModels"/>
22+
<DefaultAnimationLoop/>
23+
<CollisionPipeline verbose="0"/>
24+
<BruteForceBroadPhase name="N2"/>
25+
<BVHNarrowPhase/>
26+
<CollisionResponse name="Response" response="PenaltyContactForceField"/>
27+
<MinProximityIntersection name="Proximity" alarmDistance="0.8" contactDistance="0.5"/>
28+
29+
<Node name="Meshtest" >
30+
<EulerImplicitSolver />
31+
<CGLinearSolver iterations="100" tolerance="1e-15" threshold="1e-15"/>
32+
<include href="Mesh_test.xml" filename="Mesh_test.xml" src="@tetras" />
33+
<MechanicalObject name="tetras" showIndices="false" showIndicesScale="0.0007"/>
34+
<UniformMass showAxisSizeFactor="0.00001" totalMass="1" />
35+
36+
<TetrahedronFEMForceField name="FEM" youngModulus="2870" poissonRatio="0.45" method="large" drawHeterogeneousTetra="0" />
37+
<Node name="Visual">
38+
<OglModel name="Visual" color="green"/>
39+
<IdentityMapping input="@.." output="@Visual"/>
40+
</Node>
41+
</Node>
42+
43+
44+
45+
46+
</Node>

examples/xml/MeshInterpolator.scn

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0"?>
2+
<Node name="root" dt="0.02" gravity="0 0 0">
3+
<Node name="plugins">
4+
<RequiredPlugin name="Shell"/>
5+
<RequiredPlugin name="Sofa.Component.Collision.Detection.Algorithm"/> <!-- Needed to use components [BVHNarrowPhase,BruteForceBroadPhase,CollisionPipeline] -->
6+
<RequiredPlugin name="Sofa.Component.Collision.Detection.Intersection"/> <!-- Needed to use components [MinProximityIntersection] -->
7+
<RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
8+
<RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader] -->
9+
<RequiredPlugin name="Sofa.Component.Mapping.Linear"/> <!-- Needed to use components [IdentityMapping] -->
10+
<RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
11+
<RequiredPlugin name="Sofa.Component.Topology.Container.Dynamic"/> <!-- Needed to use components [TriangleSetGeometryAlgorithms,TriangleSetTopologyContainer] -->
12+
<RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
13+
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
14+
15+
</Node>
16+
17+
<VisualStyle displayFlags ="showBehaviorModels showForceFields showVisualModels"/>
18+
<DefaultAnimationLoop/>
19+
<CollisionPipeline verbose="0"/>
20+
<BruteForceBroadPhase name="N2"/>
21+
<BVHNarrowPhase/>
22+
<CollisionResponse name="Response" response="PenaltyContactForceField"/>
23+
<MinProximityIntersection name="Proximity" alarmDistance="0.8" contactDistance="0.5"/>
24+
25+
26+
27+
<Node name="MeshInterpolator">
28+
<!-- Starting mesh -->
29+
<Node name="m1">
30+
<MeshOBJLoader name="m1" filename="../../../Shell/mesh/transform-cube.obj" />
31+
<!-- Visualisation -->
32+
<TriangleSetTopologyContainer src="@m1" />
33+
<MechanicalObject />
34+
<TriangleSetGeometryAlgorithms drawEdges="true" drawColorEdges="0.2 0.2 0.2" />
35+
</Node>
36+
37+
<!-- Final mesh -->
38+
<Node name="m2">
39+
<MeshOBJLoader name="m2" filename="../../../Shell/mesh/transform-sphere.obj" />
40+
<!-- Visualisation -->
41+
<TriangleSetTopologyContainer src="@m2" />
42+
<MechanicalObject />
43+
<TriangleSetGeometryAlgorithms drawEdges="true" drawColorEdges="0.2 0.2 0.2" />
44+
</Node>
45+
46+
<Node name="simluation" >
47+
48+
<MeshInterpolator name="interp" startPosition="@m1/m1.position" endPosition="@m2/m2.position"
49+
listening="true" startTime="0" nbSteps="10" increment="0.01" />
50+
51+
<TriangleSetTopologyContainer triangles="@m1/m1.triangles" position="@interp.position" />
52+
<MechanicalObject position="@interp.position" />
53+
54+
<!-- Visualisation -->
55+
<Node name="Visual">
56+
<OglModel name="Visual" color="green"/>
57+
<IdentityMapping input="@.." output="@Visual"/>
58+
</Node>
59+
60+
</Node>
61+
62+
</Node>
63+
</Node>

0 commit comments

Comments
 (0)