Skip to content

TopologyBoundingTrasher

Component removing all elements going outside from the given bounding box.

Vec3d

Templates:

  • Vec3d

Target: Sofa.Component.Topology.Utility

namespace: sofa::component::topology::utility

parents:

  • BaseObject

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
position position coordinates of the topology object to interact with.
box List of boxes defined by xmin,ymin,zmin, xmax,ymax,zmax -1000 -1000 -1000 1000 1000 1000
Visualization
drawBox Draw bounding box (default = false) 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
topology link to the topology container BaseMeshTopology

Examples

TopologyBoundingTrasher.scn

<!-- Mechanical MassSpring Group Basic Example -->
<Node name="root" dt="0.01" showBoundingTree="0" gravity="0 -1 0">
    <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.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 [SpringForceField 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.Topology.Utility"/> <!-- Needed to use components [TopologyBoundingTrasher] -->
    <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
    <RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->

    <VisualStyle displayFlags="showBehaviorModels showVisual" />
    <CollisionPipeline verbose="0" />
    <BruteForceBroadPhase/>
    <BVHNarrowPhase/>
    <CollisionResponse response="PenalityContactForceField" />
    <MinProximityIntersection name="Proximity" alarmDistance="0.8" contactDistance="0.5" />
    <DefaultAnimationLoop/>

    <Node name="SquareGravity">
        <CGImplicit iterations="40" tolerance="1e-6" threshold="1e-10" />
        <MeshGmshLoader name="loader" filename="mesh/square3.msh" createSubelements="true" />
        <MechanicalObject name="Volume" src="@loader" scale="10" />
        <TriangleSetTopologyContainer  name="Container" src="@loader" />
        <TriangleSetTopologyModifier   name="Modifier" />
        <TriangleSetGeometryAlgorithms name="GeomAlgo" template="Vec3" />
        <DiagonalMass massDensity="1" />
        <SpringForceField name="FF" />
        <TriangularFEMForceField name="FEM" youngModulus="60" poissonRatio="0.3" method="large" />
        <TriangularBendingSprings name="FEM-Bend" stiffness="300" damping="1.0" />

        <TopologyBoundingTrasher box="-10 -10 -10 11 11 11" topology="@Container" drawBox="1" position="@Volume.position"/>
        <Node >
            <OglModel name="Visual" color="red" />
            <IdentityMapping input="@.." output="@Visual" />
        </Node>
    </Node>
</Node>
def createScene(root_node):

   root = root_node.addChild('root', dt="0.01", showBoundingTree="0", gravity="0 -1 0")

   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.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.Topology.Utility")
   root.addObject('RequiredPlugin', name="Sofa.Component.Visual")
   root.addObject('RequiredPlugin', name="Sofa.GL.Component.Rendering3D")
   root.addObject('VisualStyle', displayFlags="showBehaviorModels showVisual")
   root.addObject('CollisionPipeline', verbose="0")
   root.addObject('BruteForceBroadPhase', )
   root.addObject('BVHNarrowPhase', )
   root.addObject('CollisionResponse', response="PenalityContactForceField")
   root.addObject('MinProximityIntersection', name="Proximity", alarmDistance="0.8", contactDistance="0.5")
   root.addObject('DefaultAnimationLoop', )

   square_gravity = root.addChild('SquareGravity')

   square_gravity.addObject('CGImplicit', iterations="40", tolerance="1e-6", threshold="1e-10")
   square_gravity.addObject('MeshGmshLoader', name="loader", filename="mesh/square3.msh", createSubelements="true")
   square_gravity.addObject('MechanicalObject', name="Volume", src="@loader", scale="10")
   square_gravity.addObject('TriangleSetTopologyContainer', name="Container", src="@loader")
   square_gravity.addObject('TriangleSetTopologyModifier', name="Modifier")
   square_gravity.addObject('TriangleSetGeometryAlgorithms', name="GeomAlgo", template="Vec3")
   square_gravity.addObject('DiagonalMass', massDensity="1")
   square_gravity.addObject('SpringForceField', name="FF")
   square_gravity.addObject('TriangularFEMForceField', name="FEM", youngModulus="60", poissonRatio="0.3", method="large")
   square_gravity.addObject('TriangularBendingSprings', name="FEM-Bend", stiffness="300", damping="1.0")
   square_gravity.addObject('TopologyBoundingTrasher', box="-10 -10 -10 11 11 11", topology="@Container", drawBox="1", position="@Volume.position")

   node = SquareGravity.addChild('node')

   node.addObject('OglModel', name="Visual", color="red")
   node.addObject('IdentityMapping', input="@..", output="@Visual")