VTK/Examples/Cxx/Boneyard/GeometricObjects/WriteFile/Plane

From KitwarePublic
< VTK‎ | Examples‎ | Cxx
Jump to navigationJump to search

This example creates a plane.

Plane.cxx

#include <vtkXMLPolyDataWriter.h>
#include <vtkPlaneSource.h>
#include <vtkPolyData.h>
#include <vtkSmartPointer.h>

int main(int, char *[])
{
  vtkSmartPointer<vtkPlaneSource> plane = 
    vtkSmartPointer<vtkPlaneSource>::New();
  plane->SetCenter(1.0, 0.0, 0.0);
  plane->SetNormal(1.0, 0.0, 0.0);
  
  vtkPolyData* pdata = plane->GetOutput();
    
  //write the file
  vtkSmartPointer<vtkXMLPolyDataWriter> writer = 
    vtkSmartPointer<vtkXMLPolyDataWriter>::New();
  writer->SetInput(pdata);
  writer->SetFileName("plane.vtp");
  writer->Write();

  return EXIT_SUCCESS;
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.6)

PROJECT(Plane)

FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})

ADD_EXECUTABLE(Plane Plane.cxx)
TARGET_LINK_LIBRARIES(Plane vtkHybrid)