I am creating a 3D model from a series of dicom images. The workflow that I am using is as follows:
If it is ok to move the model, then you can define the center of the model, and transform it to the global origin, then save the transformed model as a PLY file.
First, you want to define the center of the model. A quick and dirty way could be to get the center of mass:
centerFilter = vtk.vtkCenterOfMass() centerFilter.SetInputData(polydata) centerFilter.SetUseScalarsAsWeights(False) centerFilter.Update() center = centerFilter.GetCenter()
Then you want to transform your model:
transform = vtk.vtkTransform() transform.Translate(-center, -center, -center) transformFilter = vtk.vtkTransformPolyDataFilter() transformFilter.SetInputData(polydata) transformFilter.SetTransform(transform) transformFilter.Update() centeredPolydata = transformFilter.GetOutput()
Then write the output PLY file with centeredPolydata.
Note: this will make it more difficult to relate the centered model to the image data.