简体   繁体   English

VTK:高度场的基本可视化

[英]VTK: Basic visualization of heightfield

I've got a basic hello world program of libvtk working as follows: 我有一个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;
}

compile with: 编译:

$ g++ -I/usr/include/vtk-5.6 hello_vtk.cpp -lvtkInfovis -lvtkViews -lvtkFiltering

execute with: 执行:

$ ./a.out

I have two sets of data I want to visualize, both as heightfields: 我有两组要可视化的数据,都作为高度字段:

The first is of the form: 第一种形式为:

double x1[N*M];

representing an N x M heightfield where height at (i, j) is x[N*j + i] 表示一个N x M高度场,其中(i,j)处的高度为x [N * j + i]

The second is of the form: 第二种形式:

map<pair<double, double>, double> x2;

where there is a sample of a continuous surface from (i,j) of height h represented by: 其中有一个高度为(h,i)的(i,j)连续表面的样本,表示为:

x2[make_pair(i,j)] = h

Clearly an instance of x2 could be interpolated if necessary into an x1. 显然,如有必要,可以将x2的实例插值到x1中。

My question is which classes should be used and what is a sketch of the implementation necessary to visualize x1 and/or x2 in VTK? 我的问题是应该使用哪些类,以及在VTK中可视化x1和/或x2所需的实现草图?

(Is there any top down documentation of VTK? It seems to be an extremely large library and the only reference I could find is the doxygene which requires linear time searching to find what you are looking for) (是否有任何有关VTK的自上而下的文档?这似乎是一个很大的库,我唯一能找到的参考文献是doxygene,它需要线性时间搜索才能找到所需的内容)

You have to get your data into a VTK data structure (probably a vtkImageData or vtkStructuredGrid). 您必须将数据放入VTK数据结构(可能是vtkImageData或vtkStructuredGrid)。 You can check out this example: http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/Color_a_mesh_by_height that should have a lot of elements you need to do this. 您可以查看以下示例: http : //www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/Color_a_mesh_by_height ,其中应该包含很多元素。

Note: the example uses a vtkPolyData data structure, but this is probably overkill for this type of regular/grid data. 注意:该示例使用vtkPolyData数据结构,但是对于这种类型的常规/网格数据而言,这可能是过大的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM