我有一个libvtk的基本hello world程序,如下所示:
#include "vtkGraphLayoutView.h"
#include "vtkRandomGraphSource.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
int main(int, char*[])
{
vtkRandomGraphSource* source = vtkRandomGraphSource::New();
vtkGraphLayoutView* view = vtkGraphLayoutView::New();
view->SetRepresentationFromInputConnection(source->GetOutputPort());
view->ResetCamera();
view->Render();
view->GetInteractor()->Start();
source->Delete();
view->Delete();
return 0;
}
编译:
$ g++ -I/usr/include/vtk-5.6 hello_vtk.cpp -lvtkInfovis -lvtkViews -lvtkFiltering
执行:
$ ./a.out
我想要显示两组数据,两者都是高度字段:
第一种形式是:
double x1[N*M];
表示N x M高度场,其中(i,j)处的高度为x [N * j + i]
第二种形式为:
map<pair<double, double>, double> x2;
其中有一个高度为(i,j)的连续曲面样本,由下式表示:
x2[make_pair(i,j)] = h
显然,如果需要,可以将x2的实例插入到x1中。
我的问题是应该使用哪些类,以及在VTK中可视化x1和/或x2所需的实现草图是什么?
(有没有自上而下的VTK文档?它似乎是一个非常大的库,我唯一能找到的参考是doxygene,需要线性时间搜索才能找到你要找的东西)
答案 0 :(得分:1)
您必须将数据放入VTK数据结构(可能是vtkImageData或vtkStructuredGrid)。您可以查看以下示例:http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/Color_a_mesh_by_height,您应该拥有执行此操作所需的大量元素。
注意:该示例使用vtkPolyData数据结构,但这对于此类常规/网格数据可能有点过分。