Skip to content

MeshROI

Find the primitives (vertex/edge/triangle/tetrahedron) inside a given mesh

Templates:

  • Rigid3d
  • Vec3d
  • Vec6d

Target: Sofa.Component.Engine.Select

namespace: sofa::component::engine::select

parents:

  • DataEngine

Data:

Name Description Default value
name object name unnamed
printLog if true, emits extra messages at runtime. 0
tags list of the subsets the objet 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
computeEdges If true, will compute edge list and index list inside the ROI. 1
computeTriangles If true, will compute triangle list and index list inside the ROI. 1
computeTetrahedra If true, will compute tetrahedra list and index list inside the ROI. 1
computeMeshROI Compute with the mesh (not only bounding box) 1
doUpdate Update the computation (not only at the init) 0
Inputs
position Rest position coordinates of the degrees of freedom
edges Edge Topology
triangles Triangle Topology
tetrahedra Tetrahedron Topology
ROIposition ROI position coordinates of the degrees of freedom
ROIedges ROI Edge Topology
ROItriangles ROI Triangle Topology
Outputs
box Bounding box defined by xmin,ymin,zmin, xmax,ymax,zmax
indices Indices of the points contained in the ROI
edgeIndices Indices of the edges contained in the ROI
triangleIndices Indices of the triangles contained in the ROI
tetrahedronIndices Indices of the tetrahedra contained in the ROI
pointsInROI Points contained in the ROI
edgesInROI Edges contained in the ROI
trianglesInROI Triangles contained in the ROI
tetrahedraInROI Tetrahedra contained in the ROI
pointsOutROI Points not contained in the ROI
edgesOutROI Edges not contained in the ROI
trianglesOutROI Triangles not contained in the ROI
tetrahedraOutROI Tetrahedra not contained in the ROI
indicesOut Indices of the points not contained in the ROI
edgeOutIndices Indices of the edges not contained in the ROI
triangleOutIndices Indices of the triangles not contained in the ROI
tetrahedronOutIndices Indices of the tetrahedra not contained in the ROI
Visualization
drawOut Draw the data not contained in the ROI 0
drawMesh Draw Mesh used for the ROI 0
drawBox Draw the Bounding box around the mesh used for the ROI 0
drawPoints Draw Points 0
drawEdges Draw Edges 0
drawTriangles Draw Triangles 0
drawTetrahedra Draw Tetrahedra 0
drawSize rendering size for mesh and topological elements 0

Links:

Name Description
context Graph Node containing this object (or BaseContext::getDefault() if no graph is used)
slaves Sub-objects used internally by this object
master nullptr for regular objects, or master object for which this object is one sub-objects

Examples

Component/Engine/Select/MeshROI.scn

<Node name="root" gravity="0 -9 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.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
    <RequiredPlugin name="Sofa.Component.Engine.Select"/> <!-- Needed to use components [MeshROI] -->
    <RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader MeshVTKLoader] -->
    <RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
    <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 [TetrahedralCorotationalFEMForceField] -->
    <RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
    <RequiredPlugin name="Sofa.Component.Topology.Container.Dynamic"/> <!-- Needed to use components [TetrahedronSetGeometryAlgorithms TetrahedronSetTopologyContainer TetrahedronSetTopologyModifier TriangleSetTopologyModifier] -->
    <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
    <RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->

    <DefaultAnimationLoop/>
    <VisualStyle displayFlags="showBehaviorModels showWireframe" />
    <CollisionPipeline />
    <BruteForceBroadPhase/>
    <BVHNarrowPhase/>
    <CollisionResponse response="PenalityContactForceField" />
    <MinProximityIntersection  alarmDistance="0.8" contactDistance="0.5" />
    <Node >
        <EulerImplicitSolver   rayleighStiffness="0.1" rayleighMass="0.1" />
        <CGLinearSolver iterations="25" tolerance="1e-05" threshold="1e-05" />
        <MeshVTKLoader name="loader" filename="mesh/Ossicles.vtu" />
        <MechanicalObject src="@loader"  name="mecaObj" scale3d="1 1 1" restScale="1" />


        <TetrahedronSetTopologyContainer name="Container"  src="@loader"/>
        <TriangleSetTopologyModifier name="ModifierTri" />
        <TetrahedronSetTopologyModifier name="ModifierTetra"/>
        <TetrahedronSetGeometryAlgorithms  name="GeomAlgo"/>
        <DiagonalMass  massDensity="0.15" />

        <TetrahedralCorotationalFEMForceField name="FEM" youngModulus="1e10" poissonRatio="0.3" method="large" />

        <Node name="MeshROI"  >
            <MeshOBJLoader name="ROIloader" filename="mesh/malleus.obj" scale3d="1 1 1" translation="0 0 0" rotation="0 0 0"/>
            <OglModel />
            <MeshROI name="ROIm"  drawMesh="0" drawBox="0" drawEdges="0" drawTriangles="1" drawTetrahedra="1" drawOut="0" computeMeshROI="1"  doUpdate="0"
               position="@../mecaObj.position" tetrahedra="@../loader.tetrahedra" ROIposition="@ROIloader.position" ROItriangles="@ROIloader.triangles" />
        </Node>
    </Node>
</Node>
def createScene(rootNode):

    root = rootNode.addChild('root', gravity="0 -9 1", dt="0.05")
    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.Response.Contact")
    root.addObject('RequiredPlugin', name="Sofa.Component.Engine.Select")
    root.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
    root.addObject('RequiredPlugin', name="Sofa.Component.LinearSolver.Iterative")
    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.Dynamic")
    root.addObject('RequiredPlugin', name="Sofa.Component.Visual")
    root.addObject('RequiredPlugin', name="Sofa.GL.Component.Rendering3D")
    root.addObject('DefaultAnimationLoop')
    root.addObject('VisualStyle', displayFlags="showBehaviorModels showWireframe")
    root.addObject('CollisionPipeline')
    root.addObject('BruteForceBroadPhase')
    root.addObject('BVHNarrowPhase')
    root.addObject('CollisionResponse', response="PenalityContactForceField")
    root.addObject('MinProximityIntersection', alarmDistance="0.8", contactDistance="0.5")

    root = root.addChild('root')
    root.addObject('EulerImplicitSolver', rayleighStiffness="0.1", rayleighMass="0.1")
    root.addObject('CGLinearSolver', iterations="25", tolerance="1e-05", threshold="1e-05")
    root.addObject('MeshVTKLoader', name="loader", filename="mesh/Ossicles.vtu")
    root.addObject('MechanicalObject', src="@loader", name="mecaObj", scale3d="1 1 1", restScale="1")
    root.addObject('TetrahedronSetTopologyContainer', name="Container", src="@loader")
    root.addObject('TriangleSetTopologyModifier', name="ModifierTri")
    root.addObject('TetrahedronSetTopologyModifier', name="ModifierTetra")
    root.addObject('TetrahedronSetGeometryAlgorithms', name="GeomAlgo")
    root.addObject('DiagonalMass', massDensity="0.15")
    root.addObject('TetrahedralCorotationalFEMForceField', name="FEM", youngModulus="1e10", poissonRatio="0.3", method="large")

    MeshROI = root.addChild('MeshROI')
    MeshROI.addObject('MeshOBJLoader', name="ROIloader", filename="mesh/malleus.obj", scale3d="1 1 1", translation="0 0 0", rotation="0 0 0")
    MeshROI.addObject('OglModel')
    MeshROI.addObject('MeshROI', name="ROIm", drawMesh="0", drawBox="0", drawEdges="0", drawTriangles="1", drawTetrahedra="1", drawOut="0", computeMeshROI="1", doUpdate="0", position="@../mecaObj.position", tetrahedra="@../loader.tetrahedra", ROIposition="@ROIloader.position", ROItriangles="@ROIloader.triangles")