vtkAlgorithm
NAME
vtkAlgorithm - 在VTK中所有源代码、滤波器、槽的父类。 (Superclass for all sources, filters, and sinks in VTK.)
Mappers 接收数据并将其转换为可被渲染引擎绘制的可视化表达;Sources 通过读取(Reader 对象)或者创建数据对象(程序源对象)两种方式来产生数据;
Filters 处理输入数据并产生新的数据对象;
sinks []
Introduction
vtkAlgorithm 只能是一个算法、函数、滤波器。它的实例: 描述算法属性; 有 information 对象(vtkInformation)来描述输入、输出端的特性,这个算法主要的方法是 ProcessRequest().
【它的子类重要的就是改写 ProRequest() 这个方法】
SECTION Description
它定义了一个通用的接口来处理算法中的数据,包括可视化管线连接的输入、输出数据, 她们的类型是无关的。
可视化关系那楼是被 vtkExecutive 的实例控制的(Pipelines are controlled by instances of vtkExecutive)。
当 vtkAlgorithm 的实例被用在管线流程时,都会自动关联一个 vtkExecutive 的实例, vtkExecutive 主要控制数据流。
协作图
vtkFeatureEdges
示例:
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main(int, char *[])
{
vtkSmartPointer diskSource = vtkSmartPointer::New();
diskSource->Update();
vtkSmartPointer featureEdges = vtkSmartPointer::New();
featureEdges->SetInputConnection(diskSource->GetOutputPort());
featureEdges->BoundaryEdgesOn();
featureEdges->FeatureEdgesOff();
featureEdges->ManifoldEdgesOff();
featureEdges->NonManifoldEdgesOff();
featureEdges->SetBoundaryEdges(100);
featureEdges->Update();
// Visualize
vtkSmartPointer edgeMapper = vtkSmartPointer::New();
edgeMapper->SetInputConnection(featureEdges->GetOutputPort());
vtkSmartPointer edgeActor = vtkSmartPointer::New();
edgeActor->SetMapper(edgeMapper);
vtkSmartPointer diskMapper = vtkSmartPointer::New();
diskMapper->SetInputConnection(diskSource->GetOutputPort());
vtkSmartPointer diskActor = vtkSmartPointer::New();
diskActor->SetMapper(diskMapper);
// Create a renderer, render window, and interactor
vtkSmartPointer renderer = vtkSmartPointer::New();
vtkSmartPointer renderWindow = vtkSmartPointer::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer renderWindowInteractor = vtkSmartPointer::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
renderer->AddActor(edgeActor);
renderer->AddActor(diskActor);
renderer->SetBackground(.3, .6, .3); // Background color green
renderWindow->Render();
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}
执行过程中结合 F11 和 F10 分析上述代码。
在执行 vtkAlgorithm::Update() 时,会调用
vtkPolyDataAlgorithm 是 vtkAlgorithm 的子类重写 ProcessRequest(), 该函数中调用 RequestData(), 而 vtkFeatureEdges 是vtkPolyDataAlgorithm 子类vtkFeatureEdges重写了 RequestData() 这个函数
vtkExecutive
是所有管线指向的父类 (Superclass for all pipeline executives in VTK.)
包含了如果连接管线和执行管线的逻辑,这个类是所有 执行程序 executive 的父类。可执行程序是分布式的(相对集中),每一个滤波或者算法都有自己的可执行程序和其他可执行程序联系。
子类 vtkDemandDrivenPipeline, 这个类也有一个子类 vtkStreamingDemandDrivenPipeline。
vtkStreamingDemandDrivenPipeline 为旧版的 VTK管线提供了大部分的功能, 对于很多 algorithm 是默认执行的。
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.