天天看點

VTK VTK體系結構2

1.前言

the visualization pipeline in vtk can be used to read or create data, analyze and create derivative version of this data, and write the data to disk or pass it along to the rendering engine for display. for example, you may read a 3d volume of data from disk, process it to create a set of triangles representing an isovalued surface through the volume, then write this geometric object back out to disk. or, you may create a set of spheres and cylinders to represent atoms and bonds, then pass these off to the rendering engine for display. vtk的pipeline主要用于讀取和創造資料,以及對現有資料進行分析和更改、把資料寫到磁盤或者通過這個“管道”把資料送到渲染引擎中進行顯示。例如,你可以從磁盤中讀取一個三維資料、處理資料、進行繪制、寫回磁盤。pipeline一般都是在為render engine做準備工作。 the visualization toolkit uses a data flow approach to transform information into graphical data. there are two basic types of objects involved in this approach. vtk才用資料流的方法将資料資訊轉換為圖形資料,主要有兩個類型的對象參與了這個過程: vtkdataobject  vtkalgorithm。

2.vtkdataobject & vtkalgorithm 資料對象和算法

the attribute data can be associated with the points or cells of the dataset. cells are topological organizations of points; cells form the atoms of the dataset and are used to interpolate information between points。 下圖顯示了vtk支援的屬性資料:
VTK VTK體系結構2
algorithms, also referred to generally as filters, operate on data objects to produce new dataobjects. algorithms and data objects are connected together to form visualization pipelines。 算法,其實就是濾波器啦~把它作用在原始資料上可以生成新的資料對象。算法和資料對象聯系在一起就形成了本節我們要學的“可視化管道技術”。 下圖是對可視化管道技術的一個描述:
VTK VTK體系結構2
this figure together with  next figure  illustrate some important visualization concepts. source algorithms produce data by reading (reader objects) or constructing one or more data objects (procedural source objects). filters ingest one or more data objects and generate one or more data objects on output. mappers take the data and convert it into a visual representation that is displayed by the rendering engine. a writer can be thought of as a type of mapper that writes data to a file or stream. 這張圖像和下圖搭配在一起解釋了一些重要的概念。源算法通過通過讀取過建構資料産生資料;濾波器通過攝取一個或多個資料對象,生成一個或多個資料對象,輸出。映射器得到這些資料,利用渲染引擎進行可視化顯示。
VTK VTK體系結構2

3.several important issues regarding the construction of the visualization pipeline

first, pipeline topology is constructed using variations of the methods which sets the input to the filter afilter to the output of the filter anotherfilter. (filters with multiple inputs and outputs have similar methods.) 
we only want to execute those portions of the pipeline necessary to bring the output up to date. the visualization toolkit uses a lazy evaluation scheme (executes only when the data is requested) based on an internal modification time of each object.  third, the assembly of the pipeline requires that only those objects compatible with one another can fit together with the setinputconnection() and getoutputport() methods. vtk produces errors at run-time if the data object types are incompatible.  finally, we must decide whether to cache, or retain, the data objects once the pipeline has executed. since visualization datasets are typically quite large, this is important to the successful application of visualization tools. vtk offers methods to turn data caching on and off, use of reference counting to avoid copying data, and methods to stream data in pieces if an entire dataset cannot be held in memory. 

4. image processing 圖像處理

vtk supports an extensive set of image processing and volume rendering functionality. in vtk, both 2d (image) and 3d (volume) data are referred to as vtkimagedata. an image dataset in vtk is one in which the data is arranged in a regular, axis-aligned array. images, pixmaps, and bitmaps are examples of 2d image datasets; volumes (a stack of 2d images) is a 3d image dataset. algorithms in the imaging pipeline always input and output image data objects. because of the regular and simple nature of the data, the imaging pipeline has other important features. volume rendering (體繪制)is used to visualize 3d vtkimagedata , and special image viewers are used to view 2d vtkimagedata. almost all algorithms in the imaging pipeline are multithreaded(圖像管道中的所有的算法都是多線程的) and are capable of streaming data in pieces to satisfy a user-specified memory limit.filters automatically sense the number of cores and processors available on the system and create that number of threads during execution as well as automatically separating data into pieces that are streamed through the pipeline.