MeshSTLLoader
This component belongs to the category of the MeshLoaders.
The MeshSTLLoader loads a mesh from a file under the format *.stl. Such a mesh file only supports surface meshes. The *.stl format is widely spread and such meshes can be generated using softwares like MeshLab or Paraview among many other solutions.
Usage
No pre-requisite in your scene to use a MeshLoader.
Example
This component is used as follows in XML format:
<MeshSTLLoader name="STLLoader" filename="mesh/circle_knot_ascii.stl" printLog="true" flipNormals="0" />
or using SofaPython3:
node.addObject('MeshSTLLoader', name="STLLoader", filename="mesh/circle_knot_ascii.stl", flipNormals="0")
An example scene involving a MeshSTLLoader is available in examples/Component/IO/Mesh/MeshSTLLoader.scn
Target: Sofa.Component.IO.Mesh
namespace: sofa::component::io::mesh
parents:
MeshLoader
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 |
filename | Filename of the object | |
flipNormals | Flip Normals | 0 |
triangulate | Divide all polygons into triangles | 0 |
createSubelements | Divide all n-D elements into their (n-1)-D boundary elements (e.g. tetrahedra to triangles) | 0 |
onlyAttachedPoints | Only keep points attached to elements of the mesh | 0 |
translation | Translation of the DOFs | 0 0 0 |
rotation | Rotation of the DOFs | 0 0 0 |
scale3d | Scale of the DOFs in 3 dimensions | 1 1 1 |
transformation | 4x4 Homogeneous matrix to transform the DOFs (when present replace any) | [1 0 0 0,0 1 0 0,0 0 1 0,0 0 0 1] |
headerSize | Size of the header binary file (just before the number of facet). | 80 |
forceBinary | Force reading in binary mode. Even in first keyword of the file is solid. | 0 |
mergePositionUsingMap | Since positions are duplicated in a STL, they have to be merged. Using a map to do so will temporarily duplicate memory but should be more efficient. Disable it if memory is really an issue. | 1 |
Groups | ||
edgesGroups | Groups of Edges | |
trianglesGroups | Groups of Triangles | |
quadsGroups | Groups of Quads | |
polygonsGroups | Groups of Polygons | |
tetrahedraGroups | Groups of Tetrahedra | |
hexahedraGroups | Groups of Hexahedra | |
pentahedraGroups | Groups of Pentahedra | |
pyramidsGroups | Groups of Pyramids | |
Vectors | ||
position | Vertices of the mesh loaded | |
polylines | Polylines of the mesh loaded | |
edges | Edges of the mesh loaded | |
triangles | Triangles of the mesh loaded | |
quads | Quads of the mesh loaded | |
polygons | Polygons of the mesh loaded | |
highOrderEdgePositions | High order edge points of the mesh loaded | |
highOrderTrianglePositions | High order triangle points of the mesh loaded | |
highOrderQuadPositions | High order quad points of the mesh loaded | |
tetrahedra | Tetrahedra of the mesh loaded | |
hexahedra | Hexahedra of the mesh loaded | |
pentahedra | Pentahedra of the mesh loaded | |
highOrderTetrahedronPositions | High order tetrahedron points of the mesh loaded | |
highOrderHexahedronPositions | High order hexahedron points of the mesh loaded | |
pyramids | Pyramids of the mesh loaded | |
normals | Normals of the mesh loaded |
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/IO/Mesh/MeshSTLLoader.scn
<!-- For more details see: https://wiki.sofa-framework.org/tdev/wiki/Notes/NewLoaderArchitecture -->
<Node>
<RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshSTLLoader] -->
<RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
<VisualStyle displayFlags="showVisual" />
<DefaultAnimationLoop/>
<MeshSTLLoader name="STLLoader" filename="mesh/circle_knot_ascii.stl" printLog="true" flipNormals="0" />
<OglModel src="@STLLoader" name="VisualModel" color="red" />
</Node>
def createScene(rootNode):
rootNode = rootNode.addChild('rootNode')
rootNode.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
rootNode.addObject('RequiredPlugin', name="Sofa.Component.Visual")
rootNode.addObject('RequiredPlugin', name="Sofa.GL.Component.Rendering3D")
rootNode.addObject('VisualStyle', displayFlags="showVisual")
rootNode.addObject('DefaultAnimationLoop')
rootNode.addObject('MeshSTLLoader', name="STLLoader", filename="mesh/circle_knot_ascii.stl", printLog="true", flipNormals="0")
rootNode.addObject('OglModel', src="@STLLoader", name="VisualModel", color="red")
Component/IO/Mesh/MeshSTLLoader_binary.scn
<!-- For more details see: https://wiki.sofa-framework.org/tdev/wiki/Notes/NewLoaderArchitecture -->
<Node>
<RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshSTLLoader] -->
<RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
<VisualStyle displayFlags="showVisual" />
<DefaultAnimationLoop/>
<MeshSTLLoader name="STLLoader" filename="mesh/pliers_binary.stl" printLog="true" />
<OglModel src="@STLLoader" name="VisualModel" color="red" />
</Node>
def createScene(rootNode):
rootNode = rootNode.addChild('rootNode')
rootNode.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
rootNode.addObject('RequiredPlugin', name="Sofa.Component.Visual")
rootNode.addObject('RequiredPlugin', name="Sofa.GL.Component.Rendering3D")
rootNode.addObject('VisualStyle', displayFlags="showVisual")
rootNode.addObject('DefaultAnimationLoop')
rootNode.addObject('MeshSTLLoader', name="STLLoader", filename="mesh/pliers_binary.stl", printLog="true")
rootNode.addObject('OglModel', src="@STLLoader", name="VisualModel", color="red")