Created
June 3, 2022 20:57
-
-
Save pieper/e4ca5e4c753c5ed6c61656d25b93402c to your computer and use it in GitHub Desktop.
Load a ply point cloud in Slicer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
filePath = "/Users/pieper/slicer/latest/SlicerMorph/loadPointCloud.py" | |
modelPath = "/opt/tmp/georeferenced_model.vtk" | |
exec(open(filePath).read()) | |
""" | |
modelNode = slicer.util.loadModel(modelPath) | |
modelArray = slicer.util.arrayFromModelPoints(modelNode) | |
pointSource = vtk.vtkPointSource() | |
pointSource.SetNumberOfPoints(len(modelArray)) | |
pointSource.Update() | |
pointPolyData = pointSource.GetOutputDataObject(0) | |
modelPolyData = modelNode.GetPolyData() | |
pointPolyData.GetPoints().DeepCopy(modelPolyData.GetPoints()) | |
pointPolyData.GetPointData().DeepCopy(modelPolyData.GetPointData()) | |
modelNode.SetAndObservePolyData(pointPolyData) | |
modelDisplayNode = modelNode.GetDisplayNode() | |
modelDisplayNode.SetRepresentation(modelDisplayNode.PointsRepresentation) | |
modelDisplayNode.SetPointSize(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment