Difference between revisions of "VTK/Examples/Cxx/PolyData/DataBounds"

From KitwarePublic
< VTK‎ | Examples‎ | Cxx
Jump to: navigation, search
 
Line 1: Line 1:
This examples gets the bounds of a dataset. Note that Update() must be applied to create the output of the filter.
+
= '''See [https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/DataBounds DataBounds] on the new [https://lorensen.github.io/VTKExamples/site/ VTKExamples website].''' =
 
 
==DataBounds.cxx==
 
<source lang="cpp">
 
#include <vtkSphereSource.h>
 
#include <vtkSmartPointer.h>
 
#include <vtkPolyData.h>
 
#include <vtkXMLPolyDataReader.h>
 
 
 
int main(int argc, char *argv[])
 
{
 
  vtkSmartPointer<vtkPolyData> polyData =
 
    vtkSmartPointer<vtkPolyData>::New();
 
 
 
  if (argc > 1)
 
    {
 
    vtkSmartPointer<vtkXMLPolyDataReader> reader =
 
      vtkSmartPointer<vtkXMLPolyDataReader>::New();
 
    reader->SetFileName ( argv[1] );
 
    reader->Update();
 
    polyData = reader->GetOutput();
 
    }
 
  else
 
    {
 
    vtkSmartPointer<vtkSphereSource> modelSource =
 
      vtkSmartPointer<vtkSphereSource>::New();
 
    modelSource->Update();
 
    polyData = modelSource->GetOutput();
 
    }
 
 
 
  double bounds[6];
 
  polyData->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;
 
 
  return EXIT_SUCCESS;
 
}
 
 
 
</source>
 
 
 
{{VTKCMakeLists|{{SUBPAGENAME}}}}
 
 
 
[[Category:VTKNoVizRequired]]
 

Latest revision as of 17:10, 9 September 2019

See DataBounds on the new VTKExamples website.