Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[examples] Update all plugins and remove DefaultVisualManagerLoop #300

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/access_compliance_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def createScene(root):
"Sofa.Component.Mapping.MappedMatrix",
"Sofa.Component.Mass",
"Sofa.Component.ODESolver.Backward",
"Sofa.Component.Topology.Container.Dynamic"])
"Sofa.Component.Topology.Container.Dynamic",
"Sofa.Component.Mapping.NonLinear",
"Sofa.Component.StateContainer"])

root.addObject("FreeMotionAnimationLoop", solveVelocityConstraintFirst=True)
constraint_solver = root.addObject("GenericConstraintSolver", tolerance=1e-9, maxIterations=1000)
Expand All @@ -27,7 +29,7 @@ def createScene(root):
root.addObject("SparseCholeskySolver")
root.addObject("GenericConstraintCorrection")

root.addObject("EdgeSetTopologyContainer", position="@loader.position", edges="@loader.edges")
root.addObject("EdgeSetTopologyContainer", name="topo", position="@loader.position", edges="@loader.edges")
root.addObject("MechanicalObject", name="defoDOF", template="Vec3d")
root.addObject("EdgeSetGeometryAlgorithms", drawEdges=True)
root.addObject("FixedConstraint", indices=[0])
Expand All @@ -36,7 +38,7 @@ def createScene(root):

ext = root.addChild("extensionsNode")
ext.addObject("MechanicalObject", template="Vec1d", name="extensionsDOF")
ext.addObject("DistanceMapping", name="distanceMapping")
ext.addObject("DistanceMapping", name="distanceMapping", topology="@../topo")
ext.addObject("UniformConstraint", template="Vec1d", iterative=True)

root.addObject(MatrixAccessController('MatrixAccessor', name='matrixAccessor', constraint_solver=constraint_solver))
Expand Down
10 changes: 10 additions & 0 deletions examples/access_mass_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ def createScene(root):
root.addObject('EulerImplicitSolver', rayleighStiffness="0.1", rayleighMass="0.1")
root.addObject('SparseLDLSolver', applyPermutation="false", template="CompressedRowSparseMatrixd")

root.addObject('RequiredPlugin', pluginName=["Sofa.Component.Constraint.Projective",
"Sofa.Component.Engine.Select",
"Sofa.Component.ODESolver.Backward",
"Sofa.Component.LinearSolver.Direct",
"Sofa.Component.SolidMechanics.FEM.Elastic",
"Sofa.Component.Mass",
"Sofa.Component.StateContainer",
"Sofa.Component.Topology.Container.Grid",
"Sofa.Component.Visual"])

root.addObject('MechanicalObject', name="DoFs")
mass = root.addObject('MeshMatrixMass', name="mass", totalMass="320")
root.addObject('RegularGridTopology', name="grid", nx="4", ny="4", nz="20", xmin="-9", xmax="-6", ymin="0", ymax="3", zmin="0", zmax="19")
Expand Down
14 changes: 9 additions & 5 deletions examples/access_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ def createScene(root):
root.addObject('DefaultAnimationLoop')
root.addObject('DefaultVisualManagerLoop')

root.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward')
root.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct')
root.addObject('RequiredPlugin', name='Sofa.Component.Engine.Select')
root.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Projective')
root.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.FEM.Elastic')
root.addObject('RequiredPlugin', pluginName=["Sofa.Component.Constraint.Projective",
"Sofa.Component.Engine.Select",
"Sofa.Component.ODESolver.Backward",
"Sofa.Component.LinearSolver.Direct",
"Sofa.Component.SolidMechanics.FEM.Elastic",
"Sofa.Component.Mass",
"Sofa.Component.StateContainer",
"Sofa.Component.Topology.Container.Grid",
"Sofa.Component.Visual"])

root.addObject('EulerImplicitSolver', rayleighStiffness="0.1", rayleighMass="0.1")
linear_solver = root.addObject('SparseLDLSolver', applyPermutation="false", template="CompressedRowSparseMatrixMat3x3d")
Expand Down
10 changes: 10 additions & 0 deletions examples/access_stiffness_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ def createScene(root):
root.addObject('DefaultAnimationLoop')
root.addObject('DefaultVisualManagerLoop')

root.addObject('RequiredPlugin', pluginName=["Sofa.Component.Constraint.Projective",
"Sofa.Component.Engine.Select",
"Sofa.Component.ODESolver.Backward",
"Sofa.Component.LinearSolver.Direct",
"Sofa.Component.SolidMechanics.FEM.Elastic",
"Sofa.Component.Mass",
"Sofa.Component.StateContainer",
"Sofa.Component.Topology.Container.Grid",
"Sofa.Component.Visual"])

root.addObject('EulerImplicitSolver', rayleighStiffness="0.1", rayleighMass="0.1")
root.addObject('SparseLDLSolver', applyPermutation="false", template="CompressedRowSparseMatrixd")

Expand Down
6 changes: 1 addition & 5 deletions examples/basic-addGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
def main():
import SofaRuntime
import Sofa.Gui
# Make sure to load all SOFA libraries
SofaRuntime.importPlugin("Sofa.Component.StateContainer")
SofaRuntime.importPlugin("SofaOpenglVisual")

#Create the root node
root = Sofa.Core.Node("root")
Expand Down Expand Up @@ -39,8 +36,7 @@ def main():

# Function called when the scene graph is being created
def createScene(root):
# Scene must now include a VisualLoop
root.addObject('DefaultVisualManagerLoop')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing the DefaultVisualManagerLoop ? Isn't it better to have it explicit

root.addObject("RequiredPlugin", pluginName=["Sofa.Component.StateContainer"])

# Scene must now include a AnimationLoop
root.addObject('DefaultAnimationLoop')
Expand Down
3 changes: 3 additions & 0 deletions examples/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def createScene(root):
node1 = root.addChild("Node1")
node2 = root.addChild("Node2")

root.addObject("RequiredPlugin", pluginName=["Sofa.Component.StateContainer"])
root.addObject('DefaultAnimationLoop')

node1.addObject("MechanicalObject", template="Rigid3d", position="0 0 0 0 0 0 1", showObject="1")

node2.addObject("MechanicalObject", template="Rigid3d", position="1 1 1 0 0 0 1", showObject="1")
Expand Down
1 change: 0 additions & 1 deletion examples/emptyController.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def createScene(root):
def main():
import SofaRuntime
import Sofa.Gui
SofaRuntime.importPlugin("SofaOpenglVisual")
root=Sofa.Core.Node("root")
createScene(root)

Expand Down
5 changes: 3 additions & 2 deletions examples/emptyDataEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def update():

def createScene(root):
root.dt = 0.01
root.addObject('DefaultVisualManagerLoop')
root.bbox = [[0, 0, 0],[1,1,1]]

root.addObject('DefaultAnimationLoop')

# Add our python forcefield in the scene
root.addObject( EmptyDataEngine(name="MyEmptyDataEngine") )
Expand All @@ -31,7 +33,6 @@ def createScene(root):
def main():
import Sofa.Gui
import SofaRuntime
SofaRuntime.importPlugin("SofaOpenglVisual")
root=Sofa.Core.Node("root")
createScene(root)
Sofa.Simulation.init(root)
Expand Down
5 changes: 4 additions & 1 deletion examples/emptyForceField.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def addKToMatrix(self, mparams, nNodes, nDofs):

def createScene(root):
root.dt = 0.01
root.addObject('DefaultVisualManagerLoop')
root.bbox = [[0, 0, 0],[1,1,1]]

root.addObject("RequiredPlugin", pluginName=["Sofa.Component.LinearSolver.Iterative", "Sofa.Component.ODESolver.Backward",
"Sofa.Component.StateContainer"])
root.addObject('DefaultAnimationLoop')

node1 = root.addChild("Node1")
Expand Down
17 changes: 10 additions & 7 deletions examples/example-forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ def addDForce(self, df, dx, params):


def createScene(node):
node.addObject("RequiredPlugin", name="Sofa.GL.Component")
node.addObject("RequiredPlugin", name="Sofa.Component.LinearSolver.Direct")
node.addObject("RequiredPlugin", name="Sofa.Component.ODESolver.Backward")
node.addObject("OglLineAxis")
node.addObject("RequiredPlugin", pluginName=["Sofa.GL.Component",
"Sofa.Component.LinearSolver.Direct",
"Sofa.Component.LinearSolver.Iterative",
"Sofa.Component.ODESolver.Backward",
"Sofa.Component.LinearSolver.Iterative",
"Sofa.Component.Mass",
"Sofa.Component.StateContainer",
"Sofa.Component.Visual"])

node.addObject("LineAxis")
node.addObject("DefaultAnimationLoop", name="loop")
node.addObject("EulerImplicitSolver")
node.addObject("CGLinearSolver", tolerance=1e-12, threshold=1e-12, iterations=25)
Expand All @@ -53,9 +59,6 @@ def createScene(node):
def main():
import SofaRuntime
import Sofa.Gui
SofaRuntime.importPlugin("SofaOpenglVisual")
SofaRuntime.importPlugin("Sofa.Component.StateContainer")
SofaRuntime.importPlugin("SofaImplicitOdeSolver")

root=Sofa.Core.Node("root")
createScene(root)
Expand Down
25 changes: 21 additions & 4 deletions examples/liver-scriptcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,34 @@ def createScene(root):
root.gravity=[0, -9.81, 0]
root.dt=0.02

root.addObject('DefaultVisualManagerLoop')
root.addObject("RequiredPlugin", pluginName=["Sofa.Component.Collision.Detection.Intersection",
"Sofa.Component.Collision.Detection.Algorithm",
"Sofa.Component.AnimationLoop",
"Sofa.Component.Collision.Geometry",
"Sofa.Component.Collision.Response.Contact",
"Sofa.Component.Constraint.Projective",
"Sofa.Component.IO.Mesh",
"Sofa.Component.LinearSolver.Iterative",
"Sofa.Component.Mass",
"Sofa.Component.ODESolver.Backward",
"Sofa.Component.StateContainer",
"Sofa.Component.Mapping.Linear",
"Sofa.Component.SolidMechanics.FEM.Elastic",
"Sofa.Component.Visual",
"Sofa.GL.Component.Rendering3D",
"Sofa.Component.Topology.Container.Dynamic"])

root.addObject('DefaultAnimationLoop')


root.addObject('VisualStyle', displayFlags="showCollisionModels hideVisualModels showForceFields")
root.addObject('RequiredPlugin', pluginName="SofaImplicitOdeSolver SofaLoader SofaOpenglVisual SofaBoundaryCondition SofaGeneralLoader SofaGeneralSimpleFem")
root.addObject('DefaultPipeline', name="CollisionPipeline")
root.addObject('BruteForceDetection', name="N2")
root.addObject('BruteForceBroadPhase', name="BruteForce")
root.addObject('BVHNarrowPhase', name="BVHNarrow")
root.addObject('DefaultContactManager', name="CollisionResponse", response="PenalityContactForceField")
root.addObject('DiscreteIntersection')

root.addObject('MeshObjLoader', name="LiverSurface", filename="mesh/liver-smooth.obj")
root.addObject('MeshOBJLoader', name="LiverSurface", filename="mesh/liver-smooth.obj")

liver = root.addChild('Liver')
liver.addObject('EulerImplicitSolver', name="cg_odesolver", rayleighStiffness=0.1, rayleighMass=0.1)
Expand Down
20 changes: 17 additions & 3 deletions examples/liver.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,32 @@ def createScene(root):
root.gravity=[0, -9.81, 0]
root.dt=0.02

root.addObject('DefaultVisualManagerLoop')
root.addObject('DefaultAnimationLoop')

root.addObject("RequiredPlugin", pluginName=["Sofa.Component.Collision.Detection.Intersection",
"Sofa.Component.Collision.Detection.Algorithm",
"Sofa.Component.Collision.Geometry",
"Sofa.Component.Collision.Response.Contact",
"Sofa.Component.Constraint.Projective",
"Sofa.Component.IO.Mesh",
"Sofa.Component.LinearSolver.Iterative",
"Sofa.Component.Mass",
"Sofa.Component.ODESolver.Backward",
"Sofa.Component.StateContainer",
"Sofa.Component.Mapping.Linear",
"Sofa.Component.SolidMechanics.FEM.Elastic",
"Sofa.Component.Visual",
"Sofa.GL.Component.Rendering3D",
"Sofa.Component.Topology.Container.Dynamic"])

root.addObject('VisualStyle', displayFlags="showCollisionModels")
root.addObject('RequiredPlugin', pluginName="Sofa.Component")
root.addObject('DefaultPipeline', name="CollisionPipeline")
root.addObject('BruteForceBroadPhase', name="BroadPhase")
root.addObject('BVHNarrowPhase', name="NarrowPhase")
root.addObject('DefaultContactManager', name="CollisionResponse", response="PenalityContactForceField")
root.addObject('DiscreteIntersection')

root.addObject('MeshObjLoader', name="LiverSurface", filename="mesh/liver-smooth.obj")
root.addObject('MeshOBJLoader', name="LiverSurface", filename="mesh/liver-smooth.obj")

liver = root.addChild('Liver')
liver.addObject('EulerImplicitSolver', name="cg_odesolver", rayleighStiffness="0.1", rayleighMass="0.1")
Expand Down
3 changes: 1 addition & 2 deletions examples/loadXMLfromPython.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ def createScene(root):
# Call the above function to create the scene graph
scene="""
<Node dt="0.005" gravity="0 0 0">
<RequiredPlugin name="SofaOpenglVisual" />
<DefaultVisualManagerLoop/>
<RequiredPlugin name="Sofa.Component.StateContainer"/>
<DefaultAnimationLoop/>

<Node name="child1">
Expand Down
7 changes: 6 additions & 1 deletion examples/springForceField.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@

def createScene(root):
root.gravity = [0, -9.81, 0]
root.bbox = [[0, 0, 0],[1,1,1]]

root.addObject('DefaultAnimationLoop')
root.addObject('DefaultVisualManagerLoop')
root.addObject("RequiredPlugin", pluginName=["Sofa.Component.IO.Mesh", "Sofa.Component.Mass",
"Sofa.Component.LinearSolver.Iterative", "Sofa.Component.MechanicalLoad",
"Sofa.Component.Mapping.NonLinear", "Sofa.Component.ODESolver.Backward",
"Sofa.Component.SolidMechanics.Spring", "Sofa.Component.StateContainer",
"Sofa.GL.Component.Rendering3D"])

surface_node = root.addChild('Surface')
surface_loader = surface_node.addObject('MeshOBJLoader', name='surface_loader', filename='mesh/ball.obj')
Expand Down