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).
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).
#!/usr/bin/env pythonfromparaview.simpleimport*# 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=1tTKPersistenceDiagram1.IgnoreBoundary=False# create a new 'Threshold'threshold1=Threshold(Input=tTKPersistenceDiagram1)threshold1.Scalars=["CELLS","Persistence"]threshold1.ThresholdMethod="Between"threshold1.LowerThreshold=0.001threshold1.UpperThreshold=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=3tTKQuadrangulationSubdivision1.Numberofrelaxationiterations=100# save the outputSaveData("Quadrangulation.vtp",tTKQuadrangulationSubdivision1)
To run the above Python script, go to your ttk-data directory and enter the following command: