Geometry Approximation
Pipeline description
This example first loads the geometry of a stone.
A fake shadow is put on the stone mesh to give the mesh depth values. The stone object is placed within a sphere using IcosphereFromObject. The object and the icosphere is then given to the CinemaImaging filter. It generates multiple images of the stone object, and the images are taken from cameras placed on the vertices of the icosphere.
An approximation of the geometry is calculated from the images using DepthImageBasedGeometryApproximation. The approximated geometry can be extracted using the Threshold
filter.
ParaView
To reproduce the above screenshot, go to your ttk-data directory and enter the following command:
paraview states/geometryApproximation.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 | #!/usr/bin/env python
from paraview.simple import *
# create a new 'XML PolyData Reader'
stonevtp = XMLPolyDataReader(FileName=["GroundWater.cdb/stone.vtp"])
# create a new 'Elevation'
fakeShadow = Elevation(Input=stonevtp)
fakeShadow.LowPoint = [0.13294358695786565, 0.08882809227819845, -0.018024881743751362]
fakeShadow.HighPoint = [0.06742407365289238, 0.018398674549435334, 0.138207120609427]
# create a new 'TTK IcosphereFromObject'
tTKIcosphereFromObject1 = TTKIcosphereFromObject(Object=stonevtp)
# create a new 'TTK CinemaImaging'
tTKCinemaImaging1 = TTKCinemaImaging(
Dataset=fakeShadow, SamplingGrid=tTKIcosphereFromObject1
)
# create a new 'TTK DepthImageBasedGeometryApproximation'
tTKDepthImageBasedGeometryApproximation1 = TTKDepthImageBasedGeometryApproximation(
Input=tTKCinemaImaging1
)
tTKDepthImageBasedGeometryApproximation1.DepthArray = ["POINTS", "Depth"]
# create a new 'Threshold'
threshold1 = Threshold(Input=tTKDepthImageBasedGeometryApproximation1)
threshold1.Scalars = ["CELLS", "TriangleDistortion"]
threshold1.ThresholdMethod = "Between"
threshold1.LowerThreshold = -999999999
threshold1.UpperThreshold = 0.02
SaveData("CinemaImages.vtm", tTKCinemaImaging1)
SaveData("GeometryApproximatedStone.vtm", threshold1)
|
To run the above Python script, go to your ttk-data directory and enter the following command:
pvpython python/geometryApproximation.py
- stone.vtp: a mesh of the stone around the ground water.
Outputs
CinemaImages.vtm
: the images from the cameras given in a multiblock.
GeometryApproximatedStone.vtm
: the reconstructed objected as a multiblock of meshes.
C++/Python API
IcosphereFromObject
CinemaImaging
DepthImageBasedGeometryApproximation