Skip to content

PointsFromIndices

Find the points given a list of indices.

Vec3d

Templates:

  • Vec3d

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 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
Inputs
position Position coordinates of the degrees of freedom
indices Indices of the points
Outputs
indices_position Coordinates of the points contained in indices
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

PointsFromIndices.scn

<?xml version="1.0" ?>
<Node name="root" gravity="0 -9 1" dt="0.05">
    <RequiredPlugin name="Sofa.Component.Constraint.Projective"/> <!-- Needed to use components [FixedProjectiveConstraint] -->
    <RequiredPlugin name="Sofa.Component.Engine.Select"/> <!-- Needed to use components [BoxROI PointsFromIndices] -->
    <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.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] -->
    <VisualStyle displayFlags="showForceFields" />
    <DefaultAnimationLoop/>

    <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" name="FixedROI" box="2 9.5 -0.5 8 10.5 0.5" drawBoxes="1" position="@mecaObj.rest_position" 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" />

        <PointsFromIndices name="PFI" position="@mecaObj.position" indices="10 20 30" />

        <Node name="Selection" >
            <MechanicalObject template="Vec3" position="@../PFI.indices_position" name="SelectedDOFs" showIndices="1" showIndicesScale="0.2"  />
        </Node>

    </Node>
</Node>
def createScene(root_node):

   root = root_node.addChild('root', gravity="0 -9 1", dt="0.05")

   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.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('VisualStyle', displayFlags="showForceFields")
   root.addObject('DefaultAnimationLoop', )

   square_gravity = root.addChild('SquareGravity', gravity="0 -9.81 0")

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

   selection = SquareGravity.addChild('Selection')

   selection.addObject('MechanicalObject', template="Vec3", position="@../PFI.indices_position", name="SelectedDOFs", showIndices="1", showIndicesScale="0.2")