Write a sphere to a VTP file

From KitwarePublic
Jump to navigationJump to search
#include <vtkSphereSource.h>
void WriteSphere(const string &OutputFilename)
{
	vtkSmartPointer<vtkSphereSource> sphere = vtkSmartPointer<vtkSphereSource>::New();
	sphere->SetCenter(0.0, 0.0, 0.0);
	sphere->SetRadius(5.0);
	
	vtkSmartPointer<vtkPolyData> pdata = sphere->GetOutput();
		
	//write the file
	vtkSmartPointer<vtkXMLPolyDataWriter> writer = vtkSmartPointer<vtkXMLPolyDataWriter>::New();
	writer->SetInput(pdata);

	writer->SetFileName(OutputFilename.c_str());
	writer->Write();

}