<?xml version="1.0" ?>
<!-- See https://wiki.sofa-framework.org/wiki/TutorialSurfacesTopologicalMapping -->
<Node name="root" gravity="0 -9.81 1" dt="0.05">
    <RequiredPlugin name="Sofa.Component.Collision.Detection.Algorithm"/> <!-- Needed to use components [BVHNarrowPhase BruteForceBroadPhase CollisionPipeline] -->
    <RequiredPlugin name="Sofa.Component.Collision.Detection.Intersection"/> <!-- Needed to use components [MinProximityIntersection] -->
    <RequiredPlugin name="Sofa.Component.Collision.Geometry"/> <!-- Needed to use components [TriangleCollisionModel] -->
    <RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
    <RequiredPlugin name="Sofa.Component.Constraint.Projective"/> <!-- Needed to use components [FixedProjectiveConstraint] -->
    <RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader] -->
    <RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
    <RequiredPlugin name="Sofa.Component.Mapping.Linear"/> <!-- Needed to use components [IdentityMapping] -->
    <RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [DiagonalMass] -->
    <RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
    <RequiredPlugin name="Sofa.Component.SolidMechanics.FEM.Elastic"/> <!-- Needed to use components [TriangularFEMForceField] -->
    <RequiredPlugin name="Sofa.Component.SolidMechanics.Spring"/> <!-- Needed to use components [TriangularBendingSprings] -->
    <RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
    <RequiredPlugin name="Sofa.Component.Topology.Container.Dynamic"/> <!-- Needed to use components [QuadSetGeometryAlgorithms QuadSetTopologyContainer QuadSetTopologyModifier TriangleSetGeometryAlgorithms TriangleSetTopologyContainer TriangleSetTopologyModifier] -->
    <RequiredPlugin name="Sofa.Component.Topology.Mapping"/> <!-- Needed to use components [Quad2TriangleTopologicalMapping] -->
    <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
    <RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
    <!-- Basic Components to perform the collision detection -->
    <VisualStyle displayFlags="showBehaviorModels showVisual showWireframe" />
    <CollisionPipeline name="DefaultCollisionPipeline" depth="6" />
    <BruteForceBroadPhase/>
    <BVHNarrowPhase/>
    <MinProximityIntersection name="Proximity" alarmDistance="0.8" contactDistance="0.5" />
    <CollisionResponse name="Response" />
    <DefaultAnimationLoop/>
    
    <Node name="Quads Mesh">
        <MeshOBJLoader name="loader" filename="mesh/cubeQuad.obj" />
        <MechanicalObject src="@loader" template="Vec3" name="Quads" />
        <EulerImplicitSolver name="cg_odesolver" printLog="0"  rayleighStiffness="0.1" rayleighMass="0.1" />
        <CGLinearSolver name="linear solver" template="GraphScattered" iterations="40" tolerance="1e-09" threshold="1e-09" />
        <QuadSetTopologyContainer src="@loader" name="Container" />
        <QuadSetTopologyModifier name="Topology Modifier" />
        <QuadSetGeometryAlgorithms template="Vec3" name="GeomAlgo" />
        <!--<QuadularBendingSprings name="FEM-Bend" template="Vec3" stiffness="3000" damping="1"/>-->
        <DiagonalMass name="Mass" template="Vec3,Vec3" massDensity="0.5" />
        <FixedProjectiveConstraint name="Fixed dof" template="Vec3" indices="4 5 6 7" />
        <Node name="Visu">
            <OglModel name="Visual" color="green" />
            <IdentityMapping name="Mapping" template="Vec3,Vec3" input="@../Quads" output="@Visual" />
        </Node>
        <Node name="Triangles Mesh">
            <TriangleSetTopologyContainer name="Container" />
            <TriangleSetTopologyModifier name="Topology Modifier" />
            <TriangleSetGeometryAlgorithms name="GeomAlgo" template="Vec3" drawEdges="1" drawColorEdges="1.0 1.0 0.3" />
            <Quad2TriangleTopologicalMapping name="Topological Mapping" input="@../Container" output="@Container" />
            <TriangularFEMForceField name="FEM" template="Vec3" method="large" poissonRatio="0.3" youngModulus="1000" />
            <TriangularBendingSprings name="FEM-Bend" template="Vec3" stiffness="3000" damping="1" />
            <TriangleCollisionModel name="Models" />
        </Node>
    </Node>
</Node>
