Skip to content

Compact Triangulation

Pipeline description

This example demonstrates how to invoke the CompactTriangulation data structure in TTK.

The example first loads a triangle mesh from disk. An elevation function along the y-axis is then computed and added on top of the mesh using the Elevation filter.

Then, the example uses TriangulationManager to initialize a clustering of the mesh vertices. The clustering information is saved into a new scalar field named ttkCompactTriangulationIndex. The number associated with each vertex by ttkCompactTriangulationIndex represents the cluster index to which the vertex belongs.

Once a scalar field named ttkCompactTriangulationIndex is defined on a dataset, any TTK plugin applied to such dataset will be executed using the CompactTriangulation data structure.

The example continues applying the ScalarFieldCriticalPoints module on the elevation function previously defined on the input mesh.

ParaView

To reproduce the above screenshot, go to your ttk-data directory and enter the following command:

paraview states/compactTriangulation.pvsm

Python code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
from paraview.simple import *

# create a new 'XML Unstructured Grid Reader'
dragonvtu = XMLUnstructuredGridReader(FileName=["dragon.vtu"])

# create a new 'Elevation'
elevation1 = Calculator(Input=dragonvtu)
elevation1.ResultArrayName = "Elevation"
elevation1.Function = "coordsY"

# create a new 'TTK TriangulationManager'
tTKTriangulationManager1 = TTKTriangulationManager(Input=elevation1)
tTKTriangulationManager1.DataArrays = ["Elevation"]

# create a new 'TTK ScalarFieldCriticalPoints'
tTKScalarFieldCriticalPoints1 = TTKScalarFieldCriticalPoints(
    Input=tTKTriangulationManager1
)
tTKScalarFieldCriticalPoints1.ScalarField = ["POINTS", "Elevation"]

# save the output
SaveData("CompactTriangulation.vtu", tTKTriangulationManager1)
SaveData("CriticalPoints.vtp", tTKScalarFieldCriticalPoints1)

To run the above Python script, go to your ttk-data directory and enter the following command:

pvpython python/compactTriangulation.py

Inputs

Outputs

  • CompactTriangulation.vtu: the input dataset in VTK file format with an additional scalar field named ttkCompactTriangulationIndex that stores the cluster index for each vertex.
  • CriticalPoints.vtp: the output critical points in VTK file format. You are free to change the vtp file extension to that of any other supported file format (e.g. csv) in the above python script.

C++/Python API

CompactTriangulation

TriangulationManager

Octree

ScalarFieldCriticalPoints