Skip to content

RandomPointDistributionInSurface

Engine distributing points over a surface randomly.

Vec3d

Templates:

  • Vec3d

Target: Sofa.Component.Engine.Generate

namespace: sofa::component::engine::generate

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
randomSeed Set a specified seed for random generation (0 for "true pseudo-randomness" 0
isVisible is Visible ? 1
minDistanceBetweenPoints Min Distance between 2 points (-1 for true randomness) 0.1
numberOfInPoints Number of points inside 10
numberOfTests Number of tests to find if the point is inside or not (odd number) 5
outPoints Points outside the surface
Visualization
drawOutputPoints Output points visible ? 0
Inputs
vertices Vertices
triangles Triangles indices
Outputs
inPoints Points inside the surface
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

RandomPointDistributionInSurface.scn

<?xml version="1.0"?>
<Node name="root" dt="0.02">
    <RequiredPlugin name="Sofa.Component.Engine.Generate"/> <!-- Needed to use components [RandomPointDistributionInSurface] -->
    <RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader] -->
    <RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
    <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
    <RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
    <VisualStyle displayFlags="showBehaviorModels" />
    <DefaultAnimationLoop/>

    <Node name="Random">
        <MeshOBJLoader name="meshLoader" filename="mesh/liver.obj" />
        <MechanicalObject src="@meshLoader"/>
        <RandomPointDistributionInSurface template="Vec3" drawOutputPoints="true"
            vertices="@meshLoader.position" triangles="@meshLoader.triangles" numberOfInPoints="100" numberOfTests="3" minDistanceBetweenPoints="0.1" 
        />
    </Node>
    <Node name="Visu">
        <VisualStyle displayFlags="showWireframe" />
        <MeshOBJLoader name='myLoader' filename='mesh/liver.obj'/>  
        <OglModel src='@myLoader'/>
    </Node>
</Node>
def createScene(root_node):

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

   root.addObject('RequiredPlugin', name="Sofa.Component.Engine.Generate")
   root.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
   root.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
   root.addObject('RequiredPlugin', name="Sofa.Component.Visual")
   root.addObject('RequiredPlugin', name="Sofa.GL.Component.Rendering3D")
   root.addObject('VisualStyle', displayFlags="showBehaviorModels")
   root.addObject('DefaultAnimationLoop', )

   random = root.addChild('Random')

   random.addObject('MeshOBJLoader', name="meshLoader", filename="mesh/liver.obj")
   random.addObject('MechanicalObject', src="@meshLoader")
   random.addObject('RandomPointDistributionInSurface', template="Vec3", drawOutputPoints="true", vertices="@meshLoader.position", triangles="@meshLoader.triangles", numberOfInPoints="100", numberOfTests="3", minDistanceBetweenPoints="0.1")

   visu = root.addChild('Visu')

   visu.addObject('VisualStyle', displayFlags="showWireframe")
   visu.addObject('MeshOBJLoader', name="myLoader", filename="mesh/liver.obj")
   visu.addObject('OglModel', src="@myLoader")