-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIO.tex
84 lines (64 loc) · 3.21 KB
/
IO.tex
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
\chapter{File I/O}
\label{chap:FileIO}
\index{I/O|(}
\index{file I/O|(}
Before VTK-m can be used to process data, data need to be loaded into the
system. VTK-m comes with a basic file I/O package to get started developing
very quickly. All the file I/O classes are declared under the \vtkmio{}
namespace.
\begin{didyouknow}
Files are just one of many ways to get data in and out of VTK-m. In
Part~\ref{part:Using} we explore efficient ways to define VTK-m data
structures. In particular, Section~\ref{sec:DataSets:Building} describes
how to build VTK-m data set objects and
Section~\ref{sec:ArrayHandle:Adapting} documents how to adapt data
structures defined in other libraries to be used directly in VTK-m.
\end{didyouknow}
\section{Readers}
\index{file I/O!read|(}
\index{read file|(}
All reader classes provided by VTK-m are located in the \vtkmioreader{}
namespace. The general interface for each reader class is to accept a
filename in the constructor and to provide a \textcode{ReadDataSet} method
to load the data from disk.
The data in the file are returned in a \vtkmcont{DataSet} object.
Chapter~\ref{chap:DataSets} provides much more details about the contents of
a data set object, but for now we treat \textidentifier{DataSet} as an
opaque object that can be passed around readers, writers, filters, and
rendering units.
\subsection{Legacy VTK File Reader}
Legacy VTK files are a simple open format for storing visualization data.
These files typically have a \textfilename{.vtk} extension. Legacy VTK
files are popular because they are simple to create and read and are
consequently supported by a large number of tools. The format of legacy VTK
files is well documented in \textit{The VTK User's Guide}\footnote{A free
excerpt describing the file format is available at
\url{http://www.vtk.org/Wiki/File:VTK-File-Formats.pdf}.}. Legacy VTK
files can also be read and written with tools like ParaView and VisIt.
Legacy VTK files can be read using the \vtkmioreader{VTKDataSetReader}
class. The constructor for this class takes a string containing the
filename. The \textcode{ReadDataSet} method reads the data from the
previously indicated file and returns a \vtkmcont{DataSet} object, which
can be used with filters and rendering.
\vtkmlisting{Reading a legacy VTK file.}{VTKDataSetReader.cxx}
\index{read file|)}
\index{file I/O!read|)}
\section{Writers}
\index{file I/O!write|(}
\index{write file|(}
All writer classes provided by VTK-m are located in the \vtkmiowriter{}
namespace. The general interface for each writer class is to accept a
filename in the constructor and to provide a \textcode{WriteDataSet} method
to save data to the disk. The \textcode{WriteDataSet} method takes a
\vtkmcont{DataSet} object as an argument, which contains the data to write
to the file.
\subsection{Legacy VTK File Writer}
\index{write file|)}
\index{file I/O!write|)}
Legacy VTK files can be written using the \vtkmiowriter{VTKDataSetWriter}
class. The constructor for this class takes a string containing the
filename. The \textcode{WriteDataSet} method takes a \vtkmcont{DataSet}
object and writes its data to the previously indicated file.
\vtkmlisting{Writing a legacy VTK file.}{VTKDataSetWriter.cxx}
\index{file I/O|)}
\index{I/O|)}