Skip to content

Dragon

Pipeline description

This example first loads a triangle mesh from disk. In a pre-processing, the mesh is smoothed and an elevation function is computed on top of it. The elevation function will be considered as the input scalar data in the remainder.

Then, the PersistenceDiagram is computed and thresholds are applied base on persistence to maintain only the most persistent features. This results in a simplified persistence diagram (bottom right view in the above screenshot).

The PersistenceCurve is also computed (top right view in the above screenshot).

The simplified persistence diagram is then used as a constraint for the TopologicalSimplification of the input scalar data.

This simplified data is then used as the input of the computation of ScalarFieldCriticalPoints (top left view, above screenshot) and the ContourTree (FTM) (bottom left view, above screenshot).

ParaView

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

$ paraview --state=states/dragon.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python

from paraview.simple import *

# paraview 5.9 VS 5.10 compatibility ===========================================
def ThresholdBetween(threshold, lower, upper):
    try:
        # paraview 5.9
        threshold.ThresholdRange = [lower, upper]
    except:
        # paraview 5.10
        threshold.ThresholdMethod = "Between"
        threshold.LowerThreshold = lower
        threshold.UpperThreshold = upper
# end of comphatibility ========================================================

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

# create a new 'TTK GeometrySmoother'
tTKGeometrySmoother1 = TTKGeometrySmoother(Input=dragonvtu)

# create a new 'Calculator'
elevation = Calculator(Input=tTKGeometrySmoother1)
elevation.ResultArrayName = 'Elevation'
elevation.Function = 'coordsY'

# create a new 'TTK PersistenceCurve'
tTKPersistenceCurve1 = TTKPersistenceCurve(Input=elevation)
tTKPersistenceCurve1.ScalarField = ['POINTS', 'Elevation']

# create a new 'TTK PersistenceDiagram'
tTKPersistenceDiagram1 = TTKPersistenceDiagram(Input=elevation)
tTKPersistenceDiagram1.ScalarField = ['POINTS', 'Elevation']

# create a new 'Threshold'
pairs = Threshold(Input=tTKPersistenceDiagram1)
pairs.Scalars = ['CELLS', 'PairIdentifier']
ThresholdBetween(pairs, 0.0, 999999999)

# create a new 'Threshold'
persistenceThreshold = Threshold(Input=pairs)
persistenceThreshold.Scalars = ['CELLS', 'Persistence']
ThresholdBetween(persistenceThreshold, 5.0, 999999999)

# create a new 'TTK TopologicalSimplification'
tTKTopologicalSimplification1 = TTKTopologicalSimplification(Domain=elevation,
    Constraints=persistenceThreshold)
tTKTopologicalSimplification1.ScalarField = ['POINTS', 'Elevation']

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

# create a new 'TTK Merge and Contour Tree (FTM)'
tTKContourTree1 = TTKMergeandContourTreeFTM(Input=tTKTopologicalSimplification1)
tTKContourTree1.ScalarField = ['POINTS', 'Elevation']
tTKContourTree1.ArcSampling = 30

# create a new 'TTK GeometrySmoother'
tTKGeometrySmoother2 = TTKGeometrySmoother(Input=OutputPort(tTKContourTree1,1))
tTKGeometrySmoother2.IterationNumber = 40

# create a new 'Extract Surface'
extractSurface4 = ExtractSurface(Input=tTKGeometrySmoother2)

# create a new 'Tube'
tube4 = Tube(Input=extractSurface4)
tube4.NumberofSides = 12
tube4.Radius = 0.75

# create a new 'TTK IcospheresFromPoints'
tTKIcospheresFromPoints4 = TTKIcospheresFromPoints(Input=tTKContourTree1)
tTKIcospheresFromPoints4.Radius = 2.0

# save the output
SaveData('PersistenceDiagram.vtu', tTKPersistenceDiagram1)
SaveData('PersistenceCurve.csv', OutputPort(tTKPersistenceCurve1, 3))
SaveData('CriticalPoints.vtp', tTKScalarFieldCriticalPoints1)
SaveData('ContourTreeNodes.vtp', tTKIcospheresFromPoints4)
SaveData('ContourTreeArcs.vtp', tube4)

Inputs

Outputs

  • PersistenceDiagram.vtu: the output persistence diagram in VTK file format (bottom right view, above screenshot). You are free to change the vtu file extension to that of any other supported file format (e.g. csv) in the above python script.
  • PersistenceCurve.csv: the output persistence curve.
  • CriticalPoints.vtp: the output critical points in VTK file format (bottom right view, above screenshot). 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.
  • ContourTreeNode.vtp: spheres, representing the nodes of the output contour tree in VTK file format (bottom right view, above screenshot). 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.
  • ContourTreeArcs.vtp: cylinders, representing the arcs of the output contour tree in VTK file format (bottom right view, above screenshot). 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

ContourTree (FTM)

GeometrySmoother

IcospheresFromPoints

PersistenceCurve

PersistenceDiagram

ScalarFieldCriticalPoints

TopologicalSimplification