本文由Markdown编辑器编辑而成。
1. 前言:
最近的工作任务,主要围绕创建VTK的filter,及其将filter植入到ParaView的源代码中,为ParaView增加新的filter。
为了完成这个工作,首先必须了解VTK管道机制的工作原理。为此有必要阅读vtk的关于Pipeline的官方文档。经查阅,该文档的链接为:http://www.vtk.org/Wiki/VTK/Tutorials/New_Pipeline。
通过阅读文档,为之后阅读和理解vtk中的filter源码以及创建自己的filter都有很大的帮助。
以下是相关文档中主要部分的翻译:
2. VTK管道机制
This section will introduce the classes and concepts used in the new VTK pipeline. You should be familiar with the very basic design of the old pipeline before delving into this. The new pipeline was designed to reduce complexity while at the same time provide more flexibility. In the old pipeline the pipeline functionality and mechanics were contained in the data object and filters. In the new pipeline this functionality is contained in a new class (and its subclasses) called vtkExecutive.
本部分将主要介绍在vtk新的管道机制中会被用到的类和概念。在深入钻研这部分前,你应该熟悉在旧的管道机制中最基本的设计。新的管道机制是为了降低复杂度,同时提供更多的灵活性。在旧的管道机制中,管道的功能和机制被包含在数据体和滤波器中。在新的管道中,这个功能被包含在一个新的名为vtkExecutive的类(和它的子类)中。
Contents:
Introduction
Typical Pipeline Execution
Request Information
Request Update Extent
Request DataExecutives
vtkExecutive
vtkDemandDrivenPipeline
vtkStreamingDemanDrivenPipeline
vtkCompositeDataPipelineConverting an Existing Filter to the New Pipeline
2.1 Introduction
There are four key classes that make up the new pipeline. They are:
新的管道是由四个关键的类构成的,这四个类分别是:
vtkInformation,vtkDataObject,vtkAlgorithm和vtkExecutive.
vtkInformation:
provides the flexibility to grow. Most of the methods and Meta information storage make use of this class. vtkInformation is a map-based data structure that supports heterogeneous key-value operations with compile time type checking. There is also a vtkInformationVector class for storing vectors of information objects. When passing information up or down the pipeline (or from the executive to the algorithm) this is the class to use.
vtkDataObject:
in the past this class both stored data and handled some of the pipeline logic. In the new pipeline this class is only supposed to store data. In practice there are some pipeline methods in the class for backwards compatibility so that all of VTK doesn’t break,but the goal is that vtkDataObject should only be about storing data. vtkDataObject has an instance of vtkInformation that can be used to store key-value pairs in. For example the current extent of the data object is stored in there but the whole extent is not,because that is a pipeline attribute containing information about a specific pipeline topology .
vtkAlgorithm:
an algorithm is the new superclass for all filters/sources/sinks in VTK. It is basically the replacement for vtkSource. Like vtkDataObject,vtkAlgorithm should know nothing about the pipeline and should only be an algorithm/function/filter. Call it with the correct arguments and it will produce results. It also has a vtkInformation instance that describes the properties of the algorithm and it has information objects that describe its input and output port characteristics. The main method of an algorithm is ProcessRequest.
vtkExecutive:
contains the logic of how to connect and execute a pipeline. This class is the superclass of all executives. Executives are distributed (as opposed to centralized) and each filter/algorithm has its own executive that communicates with other executives. vtkExecutive has a subclass called vtkDemandDrivenPipeline which in turn has a subclass called vtkStreamingDemandDrivenPipeline. vtkStreamingDemandDrivenPipeline provides most of the functionality that was found in the old VTK pipeline and is the default executive for all algorithms if you do not specify one.