Skip to content

MeshGenerationFromImage

Generate tetrahedral mesh from image

Vec3d,ImageUC

Templates:

  • Vec3d,ImageUC

Target: CGALPlugin

namespace: cgal

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
filename Image file
image image input 0 0 0 0 0
transform 12-param vector for trans, rot, scale, ...
features features (1D) that will be preserved in the mesh
outputPoints New Rest position coordinates from the tetrahedral generation
outputTetras List of tetrahedra
outputTetrasDomains domain of each tetrahedron
outputCellData Output cell data
frozen true to prohibit recomputations of the mesh 0
edgeSize Edge size criterium (needed for polyline features 2
facetAngle Lower bound for the angle in degrees of the surface mesh facets 25
facetSize Uniform upper bound for the radius of the surface Delaunay balls 0.15
facetApproximation Upper bound for the center-center distances of the surface mesh facets 0.008
cellRatio Upper bound for the radius-edge ratio of the tetrahedra 4
cellSize Uniform upper bound for the circumradii of the tetrahedra in the mesh 1
label label to be resized to a specific cellSize
labelCellSize Uniform upper bound for the circumradii of the tetrahedra in the mesh by label
labelCellData 1D cell data by label
odt activate odt optimization 0
lloyd activate lloyd optimization 0
perturb activate perturb optimization 0
exude activate exude optimization 0
odt_max_it odt max iteration number 200
lloyd_max_it lloyd max iteration number 200
perturb_max_time perturb maxtime 20
exude_max_time exude max time 20
ordering Output points and elements ordering (0 = none, 1 = longest bbox axis) 0
Visualization
drawTetras display generated tetra mesh 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

Examples

MeshGenerationFromImage.scn

<?xml version="1.0"?>
<Node name="root" gravity="0 0 0" dt="1"  >
    <RequiredPlugin pluginName="CGALPlugin"/>
    <RequiredPlugin pluginName="image"/>
    <RequiredPlugin pluginName='SofaOpenglVisual'/>

    <BackgroundSetting color="0 0.16862745098 0.21176470588"/>
    <VisualStyle displayFlags="showVisual" />
    <VisualGrid/>
    <OglSceneFrame/>
    <LineAxis/>

    <ImageContainer name="image" template="ImageUC" filename="data/image/image-cube.inr"/>
    <!-- <ImageViewer template="ImageUC" src="@image"/> -->

    <MeshGenerationFromImage template="Vec3d,ImageUC" name="generator" printLog="0" drawTetras="true"
    image="@image.image" transform="@image.transform"
    cellSize="0.5" facetAngle="30" facetSize="1" cellRatio="3" facetApproximation="1" ordering="0"
    label="1 2 3" labelCellSize="0.2 0.5 0.1" labelCellData="100 200 300"/>

    <MeshTopology name="volume" points="@generator.outputPoints"    tetras="@generator.outputTetras"/> 
    <!--<VTKExporter name="exporter" filename="data/output.vtu"  XMLformat="1" edges="0" tetras="1"  listening="true" exportAtBegin="true" cellsDataFields="generator.outputCellData" overwrite="true"/>-->
</Node>
def createScene(root_node):

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

   root.addObject('RequiredPlugin', pluginName="CGALPlugin")
   root.addObject('RequiredPlugin', pluginName="image")
   root.addObject('RequiredPlugin', pluginName="SofaOpenglVisual")
   root.addObject('BackgroundSetting', color="0 0.16862745098 0.21176470588")
   root.addObject('VisualStyle', displayFlags="showVisual")
   root.addObject('VisualGrid', )
   root.addObject('OglSceneFrame', )
   root.addObject('LineAxis', )
   root.addObject('ImageContainer', name="image", template="ImageUC", filename="data/image/image-cube.inr")
   root.addObject('MeshGenerationFromImage', template="Vec3d,ImageUC", name="generator", printLog="0", drawTetras="true", image="@image.image", transform="@image.transform", cellSize="0.5", facetAngle="30", facetSize="1", cellRatio="3", facetApproximation="1", ordering="0", label="1 2 3", labelCellSize="0.2 0.5 0.1", labelCellData="100 200 300")
   root.addObject('MeshTopology', name="volume", points="@generator.outputPoints", tetras="@generator.outputTetras")

MeshGenerationFromImageWithFeatures.scn

<?xml version="1.0"?>
<Node name="root" gravity="0 0 0" dt="1"  >
    <RequiredPlugin pluginName="CGALPlugin"/>
    <RequiredPlugin pluginName="image"/>

    <MeshVTKLoader name="loader" filename="data/edgePoints.vtk" scale3d="1.0 1.0 1.0"/>
    <ImageContainer name="image" template="ImageUC" filename="data/image/image-cube.inr"/>
    <ImageViewer template="ImageUC" src="@image" plane="0 0 0"/>

    <MeshGenerationFromImage template="Vec3d,ImageUC" name="generator" printLog="0" drawTetras="true"
            image="@image.image" transform="@image.transform"  features="@loader.position"
            cellSize="5" edgeSize="5"  facetSize="5" facetApproximation="0.1"  facetAngle="30" cellRatio="3"  ordering="0"
            label="1 2 3" labelCellSize="0.15 0.15 0.15" labelCellData="100 200 300"/>/> 

    <MeshTopology name="generatedMesh" points="@generator.outputPoints"     tetras="@generator.outputTetras"/>  
    <!--<VTKExporter name="exporter" filename="cubeWithFeatures.vtk"  XMLformat="0" edges="0" tetras="1" exportAtBegin="1" cellsDataFields="generator.outputCellData"/>-->
</Node>
def createScene(root_node):

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

   root.addObject('RequiredPlugin', pluginName="CGALPlugin")
   root.addObject('RequiredPlugin', pluginName="image")
   root.addObject('MeshVTKLoader', name="loader", filename="data/edgePoints.vtk", scale3d="1.0 1.0 1.0")
   root.addObject('ImageContainer', name="image", template="ImageUC", filename="data/image/image-cube.inr")
   root.addObject('ImageViewer', template="ImageUC", src="@image", plane="0 0 0")
   root.addObject('MeshGenerationFromImage', template="Vec3d,ImageUC", name="generator", printLog="0", drawTetras="true", image="@image.image", transform="@image.transform", features="@loader.position", cellSize="5", edgeSize="5", facetSize="5", facetApproximation="0.1", facetAngle="30", cellRatio="3", ordering="0", label="1 2 3", labelCellSize="0.15 0.15 0.15", labelCellData="100 200 300")
   root.addObject('MeshTopology', name="generatedMesh", points="@generator.outputPoints", tetras="@generator.outputTetras")