Skip to content

Morse-Smale Quadrangulation

Pipeline description

This example first loads a mecanical model as a 2D triangle mesh from disk. This mechanical model embeds a collection of scalar fields that corresponds to the output of the EigenField module. This module generated a family of functions that are coupled to the form of the dataset (basically, they are eigenfunctions of the laplacian matrix of the triangulation, sorted by decreasing eigenvalue magnitude).

In a pre-processing step, the 83rd EigenFunction is extracted and normalized with ScalarFieldNormalizer then simplified using PersistenceDiagram and TopologicalSimplification.

We then compute the MorseSmaleComplex of the simplified scalar field. The critical points are evenly spread onto the 2D surface and the 1-separatrices will form the base of the quadrangulation (left view on the above screenshot).

The filter MorseSmaleQuadrangulation creates a coarse quadrangulation of the input mesh using the Morse-Smale complex critical points and 1-separatrices.

This coarse quadrangulation is eventually refined with the QuadrangulationSubdivision filter (right view on the above screenshot).

ParaView

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

$ paraview --state=states/morseSmaleQuadrangulation.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
#!/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'
rockerArmvtu = XMLUnstructuredGridReader(FileName=["rockerArm.vtu"])

# create a new 'Extract Component'
extractComponent1 = ExtractComponent(Input=rockerArmvtu)
extractComponent1.InputArray = ["POINTS", "OutputEigenFunctions"]
extractComponent1.Component = 83

# create a new 'TTK ScalarFieldNormalizer'
tTKScalarFieldNormalizer1 = TTKScalarFieldNormalizer(Input=extractComponent1)
tTKScalarFieldNormalizer1.ScalarField = ["POINTS", "Result"]

# create a new 'TTK PersistenceDiagram'
tTKPersistenceDiagram1 = TTKPersistenceDiagram(Input=tTKScalarFieldNormalizer1)
tTKPersistenceDiagram1.ScalarField = ["POINTS", "Result"]
tTKPersistenceDiagram1.EmbedinDomain = 1

# create a new 'Threshold'
threshold1 = Threshold(Input=tTKPersistenceDiagram1)
threshold1.Scalars = ["CELLS", "Persistence"]
ThresholdBetween(threshold1, 0.001, 999999999)

# create a new 'TTK TopologicalSimplification'
tTKTopologicalSimplification1 = TTKTopologicalSimplification(
    Domain=tTKScalarFieldNormalizer1, Constraints=threshold1
)
tTKTopologicalSimplification1.ScalarField = ["POINTS", "Result"]

# create a new 'TTK MorseSmaleComplex'
tTKMorseSmaleComplex1 = TTKMorseSmaleComplex(Input=tTKTopologicalSimplification1)
tTKMorseSmaleComplex1.ScalarField = ["POINTS", "Result"]

# create a new 'TTK MorseSmaleQuadrangulation'
tTKMorseSmaleQuadrangulation1 = TTKMorseSmaleQuadrangulation(
    Triangulatedsurface=OutputPort(tTKMorseSmaleComplex1, 3),
    MorseSmalecriticalpoints=tTKMorseSmaleComplex1,
    MorseSmale1separatrices=OutputPort(tTKMorseSmaleComplex1, 1),
)
tTKMorseSmaleQuadrangulation1.DualQuadrangulation = 1

# create a new 'TTK QuadrangulationSubdivision'
tTKQuadrangulationSubdivision1 = TTKQuadrangulationSubdivision(
    Triangulatedsurface=OutputPort(tTKMorseSmaleComplex1, 3),
    Coarsequadrangulation=tTKMorseSmaleQuadrangulation1,
)
tTKQuadrangulationSubdivision1.Levelofsubdivisions = 3
tTKQuadrangulationSubdivision1.Numberofrelaxationiterations = 100

# save the output
SaveData("Quadrangulation.vtp", tTKQuadrangulationSubdivision1)

Inputs

  • rockerArm.vtu: a two-dimensional triangulated mechanical model.

Outputs

  • Quadrangulation.vtp: the output quadrangulated surface.

C++/Python API

EigenField

ScalarFieldNormalizer

PersistenceDiagram

TopologicalSimplification

MorseSmaleComplex

MorseSmaleQuadrangulation

QuadrangulationSubdivision