VES/KiwiViewer Scene File: Difference between revisions

From KitwarePublic
< VES
Jump to navigationJump to search
No edit summary
Line 13: Line 13:
===Bundled Examples===
===Bundled Examples===


KiwiViewer is bundled with sample datasets that demonstrate how to do <b>animations, custom color maps, and textured meshes</b>.  The sample datasets that have a .zip file extension will extract into folders that contain data files and a kiwi scene file with the <i>.kiwi</i> file extension.  You can copy the extracted folders to your computer using iTunes file sharing in order to read and modify them.
KiwiViewer is bundled with sample datasets that demonstrate how to do <b>animations, custom color maps, and textured meshes</b>.  The sample datasets that have a .zip file extension will extract into folders that contain data files and a kiwi scene file with the <i>.kiwi</i> file extension.  You can download the sample datasets [https://midas3.kitware.com/midas/folder/9479 from Midas].


===ParaView Exporter===
===ParaView Exporter===

Revision as of 12:42, 5 March 2013

Introduction

KiwiViewer can load scene files that describe a scene consisting of one or more data files. KiwiViewer v2.0 uses a scene file in the JSON format. KiwiViewer v1.0 for Android used a CSV format. A scene file can be added to a folder with data files and zipped up for KiwiViewer to read.

JSON scene file for KiwiViewer v2.0

KiwiViewer v2.0 is available for iOS in the App Store. An experimental version for Android can be downloaded from the KiwiViewer packages page.

Examples

The best way to get started with kiwi scene files in the JSON format is to look at examples. There are two ways to get examples. You can use the paraview_to_kiwi macro, described in the following section, to automatically create scene files. Or, you can look at the examples that are bundled with the KiwiViewer v2.0 app.

Bundled Examples

KiwiViewer is bundled with sample datasets that demonstrate how to do animations, custom color maps, and textured meshes. The sample datasets that have a .zip file extension will extract into folders that contain data files and a kiwi scene file with the .kiwi file extension. You can download the sample datasets from Midas.

ParaView Exporter

You can download the paraview_to_kiwi.py python script and add it to ParaView as a python macro. In ParaView, go to the Macros menu and choose Add new macro. Select the paraview_to_kiwi.py script and it will become a macro in ParaView. ParaView macros are accessible from the Macros menu or the Macros toolbar (enable the Macros toolbar using the View menu).

When you run the paraview_to_kiwi macro, the current scene will be exported to a zip file on your desktop. If the export operation fails, you can open the Python Console from the Tools menu, error messages will be displayed in the console. If you are unable to resolve the error, please ask for help on the ParaView User's mailing list.

You can use iTunes file sharing to copy the zip file into KiwiViewer. Or, place the zip file into your Dropbox folder, or upload it to Midas where KiwiViewer can access it. If you read the paraview_to_kiwi.py script.

Scene file from exported ParaView animation

You can use ParaView to export an animation using the Save Geometry option in the File menu. ParaView will export the animation into a directory, and that directory will contain a subdirectory for each frame of the animation. The subdirectories will contain the data files for each frame of the animation. For this example, we assume that each subdirectory contains just one vtp file. You can open a terminal and cd to the exported animation directory. Running ls */*.vtp should list all the data files. Run python and paste this code into the interactive prompt:


import glob
import json

filenames = glob.glob('*/*.vtp')
object = dict(filenames=filenames)
scene = dict(objects=[object])
open('scene.kiwi', 'w').write(json.dumps(scene, indent=2))

Now you will have a .kiwi scene file inside the exported animation directory. At this point, you can zip the whole directory and open it with KiwiViewer.

Old style Kiwi CSV scene file for KiwiViewer v1.0

KiwiViewer v1.0 for Android supports a scene file that uses a simple comma-separated-value format. This format is not used in newer versions of KiwiViewer, it has been replaced with the JSON format scene file described above.

File extension

The scene description file extension should be .kiwi.

Separators

Each field should be separated by a comma without leading or trailing spaces. Fields are not quoted.

Headers

The first row of the file contains text column headers, separated by comma. The order of the columns does not matter. The file may contain extra columns, they will be ignored. The only required header is filename. The available headers are: filename, url, r, g, b, a. The r, g, b columns specify the dataset color. The a column specifies alpha (transparency). Color and alpha are specified using decimal numbers between 0.0 and 1.0. If color is not specified, it will default to white. If alpha is not specified, it defaults to 1.

Example Files

This file specifies two datasets:

filename
foo.vtk
bar.vtk

This file specifies two datasets. The datasets will be downloaded from URLs and saved to local storage.

filename,url
foo.vtk,http://example.com/foo.vtk
bar.vtk,http://example.com/bar.vtk

This file specifies one dataset that will be green and translucent.

filename,r,g,b,a
foo.vtk,0,1,0,0.5

Specifying a URL

You can specify a url column to download datasets. The file must still have the filename column. The dataset will be downloaded from the URL and saved to local storage using the value specified in the filename column. If the scene file is loaded again in the future, and the file still exists on local storage, it will not be downloaded again.

Specifying a filename

The filename specified is relative to the .kiwi scene file. For example, loading the scene file /sdcard/Documents/test.kiwi that specifies a filename models/foo.vtk will open the file /sdcard/Documents/models/foo.vtk. If a dataset is downloaded from a URL and saved to local storage, subdirectories will be created if they are specified in the filename field.