如何获取点数据的边界框?

时间:2013-10-21 01:13:32

标签: vtk

如何获取数据集的范围?也称为数据的边界框。使用StructuredPointsReader读取数据。

1 个答案:

答案 0 :(得分:7)

因为vtkStructuredPoints(vtkStructuredPointsReader上的GetOutput()的类型)是vtkDataSet的子类,所以可以使用vtkDataSet的GetBounds(double [6])函数。这是一个例子:

  double bounds[6];
  structuredPointsReader->Update();
  structuredPointsReader->GetOutput()->GetBounds(bounds);

  std::cout  << "xmin: " << bounds[0] << " " 
             << "xmax: " << bounds[1] << std::endl
             << "ymin: " << bounds[2] << " " 
             << "ymax: " << bounds[3] << std::endl
             << "zmin: " << bounds[4] << " " 
             << "zmax: " << bounds[5] << std::endl;