Skip to content

BoxROI

Find the primitives (vertex/edge/triangle/quad/tetrahedron/hexahedron) inside given boxes Supports GPU-side computations using CUDA

Templates:

  • Rigid3d
  • Vec1d
  • Vec2d
  • Vec3d
  • Vec6d

Target: Sofa.Component.Engine.Select

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

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. (default = true) 1
computeTriangles If true, will compute triangle list and index list inside the ROI. (default = true) 1
computeTetrahedra If true, will compute tetrahedra list and index list inside the ROI. (default = true) 1
computeHexahedra If true, will compute hexahedra list and index list inside the ROI. (default = true) 1
computeQuad If true, will compute quad list and index list inside the ROI. (default = true) 1
strict If true, an element is inside the box iif all of its nodes are inside. If False, only the center point of the element is checked. (default = true) 1
doUpdate If true, updates the selection at the beginning of simulation steps. (default = true) 1
Inputs
box List of boxes defined by xmin,ymin,zmin, xmax,ymax,zmax
orientedBox List of boxes defined by 3 points (p0, p1, p2) and a depth distance A parallelogram will be defined by (p0, p1, p2, p3 = p0 + (p2-p1)). The box will finaly correspond to the parallelogram extrusion of depth/2 along its normal and depth/2 in the opposite direction.
position Rest position coordinates of the degrees of freedom. If empty the positions from a MechanicalObject then a MeshLoader are searched in the current context. If none are found the parent's context is searched for MechanicalObject.
edges Edge Topology
triangles Triangle Topology
tetrahedra Tetrahedron Topology
hexahedra Hexahedron Topology
quad Quad Topology
Outputs
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
hexahedronIndices Indices of the hexahedra contained in the ROI
quadIndices Indices of the quad 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
hexahedraInROI Hexahedra contained in the ROI
quadInROI Quad contained in the ROI
nbIndices Number of selected indices
Visualization
drawBoxes Draw Boxes. (default = false) 0
drawPoints Draw Points. (default = false) 0
drawEdges Draw Edges. (default = false) 0
drawTriangles Draw Triangles. (default = false) 0
drawTetrahedra Draw Tetrahedra. (default = false) 0
drawHexahedra Draw Tetrahedra. (default = false) 0
drawQuads Draw Quads. (default = false) 0
drawSize rendering size for box and topological elements 1

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/BoxROI.scn

<?xml version="1.0" ?>
<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.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.Engine.Select"/> <!-- Needed to use components [BoxROI] -->
    <RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshGmshLoader] -->
    <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 [TriangleSetGeometryAlgorithms TriangleSetTopologyContainer 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 name="default0" verbose="0" />
    <BruteForceBroadPhase/>
    <BVHNarrowPhase/>
    <CollisionResponse name="default1" response="PenalityContactForceField" />
    <MinProximityIntersection name="Proximity" alarmDistance="0.8" contactDistance="0.5" />
    <Node name="SquareGravity" gravity="0 -9.81 0">
        <EulerImplicitSolver name="cg_odesolver" printLog="false"  rayleighStiffness="0.1" rayleighMass="0.1" />
        <CGLinearSolver iterations="25" name="linear solver" tolerance="1.0e-9" threshold="1.0e-9" />
        <MeshGmshLoader name="loader" filename="mesh/square3.msh" createSubelements="true"/>
        <MechanicalObject src="@loader" template="Vec3" name="mecaObj" scale3d="10 10 10" restScale="1" />
        <TriangleSetTopologyContainer src="@loader" name="Container" />
        <TriangleSetTopologyModifier name="Modifier" />
        <TriangleSetGeometryAlgorithms template="Vec3" name="GeomAlgo" />
        <DiagonalMass name="default5" massDensity="0.15" />
        <BoxROI template="Vec3" box="2 9.5 -0.5 8 10.5 0.5" drawBoxes="1" position="@mecaObj.rest_position" name="FixedROI" computeTriangles="0" computeTetrahedra="0" computeEdges="0" />
        <FixedProjectiveConstraint template="Vec3" name="default6" indices="@FixedROI.indices" />
        <TriangularFEMForceField template="Vec3" name="FEM" method="large" poissonRatio="0.3" youngModulus="60" />
        <TriangularBendingSprings template="Vec3" name="FEM-Bend" stiffness="300" damping="1" />
        <TriangleCollisionModel template="Vec3" name="default7" />
        <BoxROI template="Vec3" box="3 3 0 6 6 1" orientedBox="3 9 0 6 7 0 3 7 0 1   8 3 0 9 5.5 0 8 6 0 1" drawBoxes="1" position="@mecaObj.position" drawTriangles="1" triangles="@Container.triangles" name="boxROI" />
        <Node name="visu">
            <OglModel template="Vec3" name="Visual" material="Default Diffuse 1 1 0 0 0.6 Ambient 1 0.2 0 0 1 Specular 0 1 0 0 1 Emissive 0 1 0 0 1 Shininess 0 45" />
            <IdentityMapping template="Vec3,Vec3" name="default8" input="@.." output="@Visual" />
        </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.Geometry")
    root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Response.Contact")
    root.addObject('RequiredPlugin', name="Sofa.Component.Constraint.Projective")
    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.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.SolidMechanics.Spring")
    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', name="default0", verbose="0")
    root.addObject('BruteForceBroadPhase')
    root.addObject('BVHNarrowPhase')
    root.addObject('CollisionResponse', name="default1", response="PenalityContactForceField")
    root.addObject('MinProximityIntersection', name="Proximity", alarmDistance="0.8", contactDistance="0.5")

    SquareGravity = root.addChild('SquareGravity', gravity="0 -9.81 0")
    SquareGravity.addObject('EulerImplicitSolver', name="cg_odesolver", printLog="false", rayleighStiffness="0.1", rayleighMass="0.1")
    SquareGravity.addObject('CGLinearSolver', iterations="25", name="linear solver", tolerance="1.0e-9", threshold="1.0e-9")
    SquareGravity.addObject('MeshGmshLoader', name="loader", filename="mesh/square3.msh", createSubelements="true")
    SquareGravity.addObject('MechanicalObject', src="@loader", template="Vec3", name="mecaObj", scale3d="10 10 10", restScale="1")
    SquareGravity.addObject('TriangleSetTopologyContainer', src="@loader", name="Container")
    SquareGravity.addObject('TriangleSetTopologyModifier', name="Modifier")
    SquareGravity.addObject('TriangleSetGeometryAlgorithms', template="Vec3", name="GeomAlgo")
    SquareGravity.addObject('DiagonalMass', name="default5", massDensity="0.15")
    SquareGravity.addObject('BoxROI', template="Vec3", box="2 9.5 -0.5 8 10.5 0.5", drawBoxes="1", position="@mecaObj.rest_position", name="FixedROI", computeTriangles="0", computeTetrahedra="0", computeEdges="0")
    SquareGravity.addObject('FixedProjectiveConstraint', template="Vec3", name="default6", indices="@FixedROI.indices")
    SquareGravity.addObject('TriangularFEMForceField', template="Vec3", name="FEM", method="large", poissonRatio="0.3", youngModulus="60")
    SquareGravity.addObject('TriangularBendingSprings', template="Vec3", name="FEM-Bend", stiffness="300", damping="1")
    SquareGravity.addObject('TriangleCollisionModel', template="Vec3", name="default7")
    SquareGravity.addObject('BoxROI', template="Vec3", box="3 3 0 6 6 1", orientedBox="3 9 0 6 7 0 3 7 0 1   8 3 0 9 5.5 0 8 6 0 1", drawBoxes="1", position="@mecaObj.position", drawTriangles="1", triangles="@Container.triangles", name="boxROI")

    visu = SquareGravity.addChild('visu')
    visu.addObject('OglModel', template="Vec3", name="Visual", material="Default Diffuse 1 1 0 0 0.6 Ambient 1 0.2 0 0 1 Specular 0 1 0 0 1 Emissive 0 1 0 0 1 Shininess 0 45")
    visu.addObject('IdentityMapping', template="Vec3,Vec3", name="default8", input="@..", output="@Visual")

Component/Engine/Select/BoxROI_2d.scn

<?xml version="1.0" ?>
<Node name="root" gravity="0 -9.81 1" dt="0.02">
    <RequiredPlugin name="Sofa.Component.Constraint.Projective"/> <!-- Needed to use components [FixedProjectiveConstraint] -->
    <RequiredPlugin name="Sofa.Component.Engine.Select"/> <!-- Needed to use components [BoxROI] -->
    <RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
    <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.Spring"/> <!-- Needed to use components [MeshSpringForceField] -->
    <RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
    <RequiredPlugin name="Sofa.Component.Topology.Container.Grid"/> <!-- Needed to use components [RegularGridTopology] -->
    <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->

    <VisualStyle displayFlags="showBehaviorModels showForceFields" />

    <DefaultAnimationLoop/>
    <DefaultVisualManagerLoop/>

    <Node name="M1">
        <EulerImplicitSolver name="odesolver" rayleighStiffness="0.1" rayleighMass="0.1" />
        <CGLinearSolver template="CompressedRowSparseMatrix" iterations="1000" threshold="1e-9" tolerance="1e-9"/>
        <MechanicalObject template="Vec2"/>
        <UniformMass vertexMass="1" />
        <RegularGridTopology nx="21" ny="5" nz="1" xmin="0" xmax="20" ymin="0" ymax="4" zmin="0" zmax="0"/>
        <BoxROI name="box" box="-0.1 -0.1 -1e4  0.1 4.1 1e4"/>
        <FixedProjectiveConstraint indices="@box.indices" />
        <MeshSpringForceField stiffness="10000"/>
    </Node>
</Node>
def createScene(rootNode):

    root = rootNode.addChild('root', gravity="0 -9.81 1", dt="0.02")
    root.addObject('RequiredPlugin', name="Sofa.Component.Constraint.Projective")
    root.addObject('RequiredPlugin', name="Sofa.Component.Engine.Select")
    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.Spring")
    root.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
    root.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Grid")
    root.addObject('RequiredPlugin', name="Sofa.Component.Visual")
    root.addObject('VisualStyle', displayFlags="showBehaviorModels showForceFields")
    root.addObject('DefaultAnimationLoop')
    root.addObject('DefaultVisualManagerLoop')

    M1 = root.addChild('M1')
    M1.addObject('EulerImplicitSolver', name="odesolver", rayleighStiffness="0.1", rayleighMass="0.1")
    M1.addObject('CGLinearSolver', template="CompressedRowSparseMatrix", iterations="1000", threshold="1e-9", tolerance="1e-9")
    M1.addObject('MechanicalObject', template="Vec2")
    M1.addObject('UniformMass', vertexMass="1")
    M1.addObject('RegularGridTopology', nx="21", ny="5", nz="1", xmin="0", xmax="20", ymin="0", ymax="4", zmin="0", zmax="0")
    M1.addObject('BoxROI', name="box", box="-0.1 -0.1 -1e4  0.1 4.1 1e4")
    M1.addObject('FixedProjectiveConstraint', indices="@box.indices")
    M1.addObject('MeshSpringForceField', stiffness="10000")

Component/Engine/Select/BoxROI_1d.scn

<?xml version="1.0" ?>
<Node name="root" gravity="9.81 0 0" dt="0.02">
    <RequiredPlugin name="Sofa.Component.Constraint.Projective"/> <!-- Needed to use components [FixedProjectiveConstraint] -->
    <RequiredPlugin name="Sofa.Component.Engine.Select"/> <!-- Needed to use components [BoxROI] -->
    <RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
    <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.Spring"/> <!-- Needed to use components [MeshSpringForceField] -->
    <RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
    <RequiredPlugin name="Sofa.Component.Topology.Container.Grid"/> <!-- Needed to use components [RegularGridTopology] -->
    <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->

    <VisualStyle displayFlags="showBehaviorModels showForceFields" />

    <DefaultAnimationLoop/>
    <DefaultVisualManagerLoop/>

    <Node name="M1">
        <EulerImplicitSolver name="odesolver" rayleighStiffness="0.1" rayleighMass="0.1" />
        <CGLinearSolver template="CompressedRowSparseMatrix" iterations="1000" threshold="1e-9" tolerance="1e-9"/>
        <MechanicalObject template="Vec1" showObject="true" showObjectScale="10"/>
        <UniformMass vertexMass="1" />
        <RegularGridTopology nx="21" ny="1" nz="1" xmin="0" xmax="20" ymin="0" ymax="0" zmin="0" zmax="0"/>
        <BoxROI name="box" box="-0.1 -1e4 -1e4  0.1 1e4 1e4"/>
        <FixedProjectiveConstraint indices="@box.indices" />
        <MeshSpringForceField stiffness="500"/>
    </Node>
</Node>
def createScene(rootNode):

    root = rootNode.addChild('root', gravity="9.81 0 0", dt="0.02")
    root.addObject('RequiredPlugin', name="Sofa.Component.Constraint.Projective")
    root.addObject('RequiredPlugin', name="Sofa.Component.Engine.Select")
    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.Spring")
    root.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
    root.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Grid")
    root.addObject('RequiredPlugin', name="Sofa.Component.Visual")
    root.addObject('VisualStyle', displayFlags="showBehaviorModels showForceFields")
    root.addObject('DefaultAnimationLoop')
    root.addObject('DefaultVisualManagerLoop')

    M1 = root.addChild('M1')
    M1.addObject('EulerImplicitSolver', name="odesolver", rayleighStiffness="0.1", rayleighMass="0.1")
    M1.addObject('CGLinearSolver', template="CompressedRowSparseMatrix", iterations="1000", threshold="1e-9", tolerance="1e-9")
    M1.addObject('MechanicalObject', template="Vec1", showObject="true", showObjectScale="10")
    M1.addObject('UniformMass', vertexMass="1")
    M1.addObject('RegularGridTopology', nx="21", ny="1", nz="1", xmin="0", xmax="20", ymin="0", ymax="0", zmin="0", zmax="0")
    M1.addObject('BoxROI', name="box", box="-0.1 -1e4 -1e4  0.1 1e4 1e4")
    M1.addObject('FixedProjectiveConstraint', indices="@box.indices")
    M1.addObject('MeshSpringForceField', stiffness="500")