Skip to content

SparseGridMultipleTopology

Sparse grid in 3D.

Target: Sofa.Component.Topology.Container.Grid

namespace: sofa::component::topology::container::grid

parents:

  • SparseGridRamificationTopology

Data

Name Description Default value
name object name unnamed
printLog if true, emits extra messages at runtime. 0
tags list of the subsets the object belongs to
bbox this object bounding box
componentState The state of the component among (Dirty, Valid, Undefined, Loading, Invalid). Undefined
listening if true, handle the events, otherwise ignore the events 0
filename Filename of the mesh
position List of point positions
edges List of edge indices
triangles List of triangle indices
quads List of quad indices
tetrahedra List of tetrahedron indices
hexahedra List of hexahedron indices
uv List of uv coordinates
fillWeighted Is quantity of matter inside a cell taken into account? (.5 for boundary, 1 for inside) 1
onlyInsideCells Select only inside cells (exclude boundary cells) 0
n grid resolution 2 2 2
min Min 0 0 0
max Max 0 0 0
cellWidth if > 0 : dimension of each cell in the created grid 0
nbVirtualFinerLevels create virtual (not in the animation tree) finer sparse grids in order to dispose of finest information (useful to compute better mechanical properties for example) 0
dataResolution Dimension of the voxel File 0 0 0
voxelSize Dimension of one voxel 1 1 1
marchingCubeStep Step of the Marching Cube algorithm 1
convolutionSize Dimension of the convolution kernel to smooth the voxels. 0 if no smoothing is required. 0
facets Input mesh facets
finestConnectivity Test for connectivity at the finest level? (more precise but slower by testing all intersections between the model mesh and the faces between boundary cubes) 1
fileTopologies All topology filenames []
stiffnessCoefs A stiffness coefficient for each topology filename
massCoefs A mass coefficient for each topology filename
computeRamifications Are ramifications wanted? 1
erasePreviousCoef Does a new stiffness/mass coefficient replace the previous or blend half/half with it? 0
Visualization
drawEdges if true, draw the topology Edges 0
drawTriangles if true, draw the topology Triangles 0
drawQuads if true, draw the topology Quads 0
drawTetrahedra if true, draw the topology Tetrahedra 0
drawHexahedra if true, draw the topology hexahedra 0
Name Description Destination type name
context Graph Node containing this object (or BaseContext::getDefault() if no graph is used) BaseContext
slaves Sub-objects used internally by this object BaseObject
master nullptr for regular objects, or master object for which this object is one sub-objects BaseObject

Examples

SparseGridMultipleTopology.scn

<Node name="root" gravity="0 0 0" dt="0.02">
    <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 [LineCollisionModel PointCollisionModel TriangleCollisionModel] -->
    <RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
    <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 [BarycentricMapping] -->
    <RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
    <RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
    <RequiredPlugin name="Sofa.Component.SolidMechanics.FEM.Elastic"/> <!-- Needed to use components [HexahedronFEMForceField] -->
    <RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
    <RequiredPlugin name="Sofa.Component.Topology.Container.Constant"/> <!-- Needed to use components [MeshTopology] -->
    <RequiredPlugin name="Sofa.Component.Topology.Container.Grid"/> <!-- Needed to use components [SparseGridMultipleTopology] -->
    <RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
    <CollisionPipeline depth="6" verbose="0" draw="0" />
    <BruteForceBroadPhase/>
    <BVHNarrowPhase/>
    <MinProximityIntersection name="Proximity" alarmDistance="0.5" contactDistance="0.3" />
    <CollisionResponse name="Response" response="PenalityContactForceField" />
    <DefaultAnimationLoop/>

    <Node name="frog with several stiffnesses">
        <SparseGridMultipleTopology n="9 9 7" fileTopology="mesh/frog_body.obj" fileTopologies="mesh/frog_body.obj mesh/frog_eyes.obj mesh/frog_eyebrows.obj mesh/frog_lips.obj" stiffnessCoefs="10 100 100 .2" massCoefs="1 1 1 1" nbVirtualFinerLevels="1" />
        <!-- body=soft, lips=very soft, eyes=very stiff-->
        <!-- the order is important: included elements must appear after (lips is included in boby so it appears after)-->
        <EulerImplicitSolver  rayleighStiffness="0.1" rayleighMass="0.1" />
        <CGLinearSolver iterations="10" tolerance="1e-5" threshold="1e-5"/>
        <MechanicalObject />
        <UniformMass vertexMass="1" />
        <HexahedronFEMForceField youngModulus="3000" poissonRatio="0.3" method="large" updateStiffnessMatrix="false" printLog="0" />
        <Node name="Visu1">
            <MeshOBJLoader name="meshLoader_0" filename="mesh/frog_body.obj" handleSeams="1" />
            <OglModel name="VisualBody" src="@meshLoader_0" normals="0" color="0.17 0.70 0.05" />
            <BarycentricMapping input="@.." output="@VisualBody" />
        </Node>
        <Node name="Visu2">
            <MeshOBJLoader name="meshLoader_2" filename="mesh/frog_eyes.obj" handleSeams="1" />
            <OglModel name="VisualEyes" src="@meshLoader_2" normals="0" color="0.04 0.19 0.52" />
            <BarycentricMapping input="@.." output="@VisualEyes" />
        </Node>
        <Node name="Visu3">
            <MeshOBJLoader name="meshLoader_3" filename="mesh/frog_eyebrows.obj" handleSeams="1" />
            <OglModel name="VisualEyebrows" src="@meshLoader_3" normals="0" color="0.44 0.43 0.00" />
            <BarycentricMapping input="@.." output="@VisualEyebrows" />
        </Node>
        <Node name="Visu4">
            <MeshOBJLoader name="meshLoader_1" filename="mesh/frog_lips.obj" handleSeams="1" />
            <OglModel name="VisualLips" src="@meshLoader_1" normals="0" color="0.47 0.25 0.03" />
            <BarycentricMapping input="@.." output="@VisualLips" />
        </Node>
        <Node name="Surf">
            <MeshOBJLoader name="loader" filename="mesh/frog-push25.obj" />
            <MeshTopology src="@loader" />
            <MechanicalObject src="@loader" />
            <TriangleCollisionModel />
            <LineCollisionModel />
            <PointCollisionModel />
            <BarycentricMapping />
        </Node>
    </Node>
</Node>
def createScene(root_node):

   root = root_node.addChild('root', gravity="0 0 0", dt="0.02")

   root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Detection.Algorithm")
   root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Detection.Intersection")
   root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Geometry")
   root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Response.Contact")
   root.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
   root.addObject('RequiredPlugin', name="Sofa.Component.LinearSolver.Iterative")
   root.addObject('RequiredPlugin', name="Sofa.Component.Mapping.Linear")
   root.addObject('RequiredPlugin', name="Sofa.Component.Mass")
   root.addObject('RequiredPlugin', name="Sofa.Component.ODESolver.Backward")
   root.addObject('RequiredPlugin', name="Sofa.Component.SolidMechanics.FEM.Elastic")
   root.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
   root.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Constant")
   root.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Grid")
   root.addObject('RequiredPlugin', name="Sofa.GL.Component.Rendering3D")
   root.addObject('CollisionPipeline', depth="6", verbose="0", draw="0")
   root.addObject('BruteForceBroadPhase', )
   root.addObject('BVHNarrowPhase', )
   root.addObject('MinProximityIntersection', name="Proximity", alarmDistance="0.5", contactDistance="0.3")
   root.addObject('CollisionResponse', name="Response", response="PenalityContactForceField")
   root.addObject('DefaultAnimationLoop', )

   frog_with_several_stiffnesses = root.addChild('frog with several stiffnesses')

   frog_with_several_stiffnesses.addObject('SparseGridMultipleTopology', n="9 9 7", fileTopology="mesh/frog_body.obj", fileTopologies="mesh/frog_body.obj mesh/frog_eyes.obj mesh/frog_eyebrows.obj mesh/frog_lips.obj", stiffnessCoefs="10 100 100 .2", massCoefs="1 1 1 1", nbVirtualFinerLevels="1")
   frog_with_several_stiffnesses.addObject('EulerImplicitSolver', rayleighStiffness="0.1", rayleighMass="0.1")
   frog_with_several_stiffnesses.addObject('CGLinearSolver', iterations="10", tolerance="1e-5", threshold="1e-5")
   frog_with_several_stiffnesses.addObject('MechanicalObject', )
   frog_with_several_stiffnesses.addObject('UniformMass', vertexMass="1")
   frog_with_several_stiffnesses.addObject('HexahedronFEMForceField', youngModulus="3000", poissonRatio="0.3", method="large", updateStiffnessMatrix="false", printLog="0")

   visu1 = frog with several stiffnesses.addChild('Visu1')

   visu1.addObject('MeshOBJLoader', name="meshLoader_0", filename="mesh/frog_body.obj", handleSeams="1")
   visu1.addObject('OglModel', name="VisualBody", src="@meshLoader_0", normals="0", color="0.17 0.70 0.05")
   visu1.addObject('BarycentricMapping', input="@..", output="@VisualBody")

   visu2 = frog with several stiffnesses.addChild('Visu2')

   visu2.addObject('MeshOBJLoader', name="meshLoader_2", filename="mesh/frog_eyes.obj", handleSeams="1")
   visu2.addObject('OglModel', name="VisualEyes", src="@meshLoader_2", normals="0", color="0.04 0.19 0.52")
   visu2.addObject('BarycentricMapping', input="@..", output="@VisualEyes")

   visu3 = frog with several stiffnesses.addChild('Visu3')

   visu3.addObject('MeshOBJLoader', name="meshLoader_3", filename="mesh/frog_eyebrows.obj", handleSeams="1")
   visu3.addObject('OglModel', name="VisualEyebrows", src="@meshLoader_3", normals="0", color="0.44 0.43 0.00")
   visu3.addObject('BarycentricMapping', input="@..", output="@VisualEyebrows")

   visu4 = frog with several stiffnesses.addChild('Visu4')

   visu4.addObject('MeshOBJLoader', name="meshLoader_1", filename="mesh/frog_lips.obj", handleSeams="1")
   visu4.addObject('OglModel', name="VisualLips", src="@meshLoader_1", normals="0", color="0.47 0.25 0.03")
   visu4.addObject('BarycentricMapping', input="@..", output="@VisualLips")

   surf = frog with several stiffnesses.addChild('Surf')

   surf.addObject('MeshOBJLoader', name="loader", filename="mesh/frog-push25.obj")
   surf.addObject('MeshTopology', src="@loader")
   surf.addObject('MechanicalObject', src="@loader")
   surf.addObject('TriangleCollisionModel', )
   surf.addObject('LineCollisionModel', )
   surf.addObject('PointCollisionModel', )
   surf.addObject('BarycentricMapping', )