Skip to content

CinemaIO

Pipeline description

This example first loads a cinema database of a simulation from disk, consisting of three dimensional image files, using the CinemaReader. This outputs a vtkTable.

The database is queried for a selection of images, using CinemaQuery, which supports SQL queries on vtkTables (bottom view shows query result in a spreadsheet view).

Each selected entry in the database is read by the CinemaProductReader, which outputs a vtkMultiBlock of the images.

The images are sliced with a plane, and each slice is visualized side-by-side using the GridLayout (top view in screenshot).

ForEach is used to loop through all slices, and then the ArrayEditor is used to add a FieldData value to each slice. In this case, we add the interval SampleInterval between each queried entry. Each slice is then written to a new cinema database with the CinemaWriter. Finally, the for-loop is terminated using EndFor.

ParaView

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

paraview states/cinemaIO.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
#!/usr/bin/env python

from paraview.simple import *

# create a new 'TTK CinemaReader'
viscousFingerscdb = TTKCinemaReader(DatabasePath="ViscousFingers.cdb")

# create a new 'TTK CinemaQuery'
tTKCinemaQuery1 = TTKCinemaQuery(InputTable=viscousFingerscdb)
tTKCinemaQuery1.SQLStatement = """SELECT * FROM InputTable0
WHERE Sim='run01' AND Time%10=0
ORDER BY Time
LIMIT 8 OFFSET 1"""

# create a new 'TTK CinemaProductReader'
tTKCinemaProductReader1 = TTKCinemaProductReader(Input=tTKCinemaQuery1)

# create a new 'Slice'
slice1 = Slice(Input=tTKCinemaProductReader1)
slice1.SliceType = "Plane"
slice1.HyperTreeGridSlicer = "Plane"
slice1.SliceOffsetValues = [0.0]

# init the 'Plane' selected for 'SliceType'
slice1.SliceType.Origin = [31.5, 31.5, 31.5]

# create a new 'TTK GridLayout'
tTKGridLayout1 = TTKGridLayout(Input=slice1)
tTKGridLayout1.ColumnAxis = "Y"
tTKGridLayout1.ColumnGap = 8.0
tTKGridLayout1.RowAxis = "Z"
tTKGridLayout1.NumberofRows = 1

# create a new 'TTK ForEach'
tTKForEach1 = TTKForEach(Input=tTKGridLayout1)
tTKForEach1.IterationMode = "Block"
tTKForEach1.InputArray = ["POINTS", "ImageFile"]
tTKForEach1.OutputType = "vtkPolyData"

# create a new 'TTK ArrayEditor'
tTKArrayEditor1 = TTKArrayEditor(Target=tTKForEach1, Source=None)
tTKArrayEditor1.TargetAttributeType = "Field Data"
tTKArrayEditor1.DataString = "SampleInterval, 10"
tTKArrayEditor1.TargetArray = ["POINTS", "ImageFile"]

# create a new 'TTK CinemaWriter'
tTKCinemaWriter1 = TTKCinemaWriter(
    Input=tTKArrayEditor1, DatabasePath="ViscousFingersSampled.cdb"
)
tTKCinemaWriter1.ScalarField = ["POINTS", "ImageFile"]

# create a new 'TTK EndFor'
tTKEndFor1 = TTKEndFor(Data=tTKCinemaWriter1, For=tTKForEach1)

UpdatePipeline()

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

pvpython python/cinemaIO.py

Inputs

Outputs

  • ViscousFingersSampled.cdb: a cinema database containing the sampled slices of the input cinema database.

C++/Python API

ArrayEditor

CinemaProductReader

CinemaQuery

CinemaReader

CinemaWriter

EndFor

ForEach

GridLayout