def GenerateEvolutionModel(self, resultContainer): matrix = slicer.vtkMatrix4x4() image = resultContainer.GetNode().GetImageData() resultContainer.GetNode().GetIJKToRASMatrix(matrix) threshold = 0.0 polyData = slicer.vtkPolyData() if image.GetPointData().GetScalars(): # marching Cubes, only if image has content polyData.DeepCopy(self._mainGUIClass.GetMyLogic().MarchingCubes( image, matrix, threshold)) scene = self._mainGUIClass.GetLogic().GetMRMLScene() if self._mainGUIClass._outEvolModel == None: # no node so far self._mainGUIClass._outEvolModel = slicer.vtkMRMLModelNode() self._mainGUIClass._outEvolModel.SetName( "VMTK Level-Set Evolution Output Model") self._mainGUIClass._outEvolModel.SetAndObservePolyData( slicer.vtkPolyData()) self._mainGUIClass._outEvolModel.SetScene(scene) scene.AddNode(self._mainGUIClass._outEvolModel) self._mainGUIClass._outEvolModelDisplay = slicer.vtkMRMLModelDisplayNode( ) self._mainGUIClass._outEvolModelDisplay.SetColor(0.0, 0.0, 0.8) self._mainGUIClass._outEvolModelDisplay.SetPolyData( slicer.vtkPolyData()) self._mainGUIClass._outEvolModelDisplay.SetVisibility(1) self._mainGUIClass._outEvolModelDisplay.SetOpacity(0.5) self._mainGUIClass._outEvolModelDisplay.SetSliceIntersectionVisibility( 1) self._mainGUIClass._outEvolModel.SetAndObservePolyData(polyData) self._mainGUIClass._outEvolModel.SetModifiedSinceRead(1) self._mainGUIClass._outEvolModelDisplay.SetPolyData( self._mainGUIClass._outEvolModel.GetPolyData()) self._mainGUIClass._outEvolModelDisplay.SetSliceIntersectionVisibility( 1) self._mainGUIClass._outEvolModelDisplay.SetVisibility(1) self._mainGUIClass._outEvolModelDisplay.SetOpacity(0.5) scene.AddNode(self._mainGUIClass._outEvolModelDisplay) self._mainGUIClass._outEvolModel.SetAndObserveDisplayNodeID( self._mainGUIClass._outEvolModelDisplay.GetID()) self._mainGUIClass._outEvolModelDisplay.SetSliceIntersectionVisibility( 1) self._mainGUIClass._outEvolModelDisplay.SetVisibility(1) self._mainGUIClass._outEvolModelDisplay.SetOpacity(0.5)
def GenerateModel(self, volumeNode, color): if color == 'red': r = 0.8 g = 0.0 b = 0.0 name = "VMTK Initialization Model" registerModel = 1 elif color == 'blue': r = 1.0 g = 1.0 b = 0.0 name = "VMTK Evolution Model" registerModel = 0 matrix = slicer.vtkMatrix4x4() image = volumeNode.GetImageData() volumeNode.GetIJKToRASMatrix(matrix) polyData = slicer.vtkPolyData() if image.GetPointData().GetScalars(): # marching Cubes, only if image has content polyData.DeepCopy(self._parentClass.GetMyLogic().MarchingCubes( image, matrix, 0.0)) scene = self._parentClass.GetLogic().GetMRMLScene() newModel = slicer.vtkMRMLModelNode() newModel.SetName(name) newModel.SetScene(scene) newModel.SetAndObservePolyData(polyData) scene.AddNode(newModel) newModelDisplay = slicer.vtkMRMLModelDisplayNode() newModelDisplay.SetPolyData(newModel.GetPolyData()) newModelDisplay.SetColor(r, g, b) newModelDisplay.SetBackfaceCulling(0) newModelDisplay.SetSliceIntersectionVisibility(1) newModelDisplay.SetVisibility(1) newModelDisplay.SetOpacity(1.0) scene.AddNode(newModelDisplay) newModel.SetAndObserveDisplayNodeID(newModelDisplay.GetID()) if registerModel: self._parentClass.SetOutInitModelDisplay(newModelDisplay)
def GenerateModel(self, volumeNode, color): if color == "red": r = 0.8 g = 0.0 b = 0.0 name = "VMTK Initialization Model" registerModel = 1 elif color == "blue": r = 1.0 g = 1.0 b = 0.0 name = "VMTK Evolution Model" registerModel = 0 matrix = slicer.vtkMatrix4x4() image = volumeNode.GetImageData() volumeNode.GetIJKToRASMatrix(matrix) polyData = slicer.vtkPolyData() if image.GetPointData().GetScalars(): # marching Cubes, only if image has content polyData.DeepCopy(self._parentClass.GetMyLogic().MarchingCubes(image, matrix, 0.0)) scene = self._parentClass.GetLogic().GetMRMLScene() newModel = slicer.vtkMRMLModelNode() newModel.SetName(name) newModel.SetScene(scene) newModel.SetAndObservePolyData(polyData) scene.AddNode(newModel) newModelDisplay = slicer.vtkMRMLModelDisplayNode() newModelDisplay.SetPolyData(newModel.GetPolyData()) newModelDisplay.SetColor(r, g, b) newModelDisplay.SetBackfaceCulling(0) newModelDisplay.SetSliceIntersectionVisibility(1) newModelDisplay.SetVisibility(1) newModelDisplay.SetOpacity(1.0) scene.AddNode(newModelDisplay) newModel.SetAndObserveDisplayNodeID(newModelDisplay.GetID()) if registerModel: self._parentClass.SetOutInitModelDisplay(newModelDisplay)
def GenerateEvolutionModel(self,resultContainer): matrix = slicer.vtkMatrix4x4() image = resultContainer.GetNode().GetImageData() resultContainer.GetNode().GetIJKToRASMatrix(matrix) threshold = 0.0 polyData = slicer.vtkPolyData() if image.GetPointData().GetScalars(): # marching Cubes, only if image has content polyData.DeepCopy(self._mainGUIClass.GetMyLogic().MarchingCubes(image,matrix,threshold)) scene = self._mainGUIClass.GetLogic().GetMRMLScene() if self._mainGUIClass._outEvolModel == None: # no node so far self._mainGUIClass._outEvolModel = slicer.vtkMRMLModelNode() self._mainGUIClass._outEvolModel.SetName("VMTK Level-Set Evolution Output Model") self._mainGUIClass._outEvolModel.SetAndObservePolyData(slicer.vtkPolyData()) self._mainGUIClass._outEvolModel.SetScene(scene) scene.AddNode(self._mainGUIClass._outEvolModel) self._mainGUIClass._outEvolModelDisplay = slicer.vtkMRMLModelDisplayNode() self._mainGUIClass._outEvolModelDisplay.SetColor(0.0, 0.0, 0.8) self._mainGUIClass._outEvolModelDisplay.SetPolyData(slicer.vtkPolyData()) self._mainGUIClass._outEvolModelDisplay.SetVisibility(1) self._mainGUIClass._outEvolModelDisplay.SetOpacity(0.5) self._mainGUIClass._outEvolModelDisplay.SetSliceIntersectionVisibility(1) self._mainGUIClass._outEvolModel.SetAndObservePolyData(polyData) self._mainGUIClass._outEvolModel.SetModifiedSinceRead(1) self._mainGUIClass._outEvolModelDisplay.SetPolyData(self._mainGUIClass._outEvolModel.GetPolyData()) self._mainGUIClass._outEvolModelDisplay.SetSliceIntersectionVisibility(1) self._mainGUIClass._outEvolModelDisplay.SetVisibility(1) self._mainGUIClass._outEvolModelDisplay.SetOpacity(0.5) scene.AddNode(self._mainGUIClass._outEvolModelDisplay) self._mainGUIClass._outEvolModel.SetAndObserveDisplayNodeID(self._mainGUIClass._outEvolModelDisplay.GetID()) self._mainGUIClass._outEvolModelDisplay.SetSliceIntersectionVisibility(1) self._mainGUIClass._outEvolModelDisplay.SetVisibility(1) self._mainGUIClass._outEvolModelDisplay.SetOpacity(0.5)
def Splitting(self): inCeLine = self._inCenterLineSelector.GetSelected() inModel = self._inModelSelector.GetSelected() outModel = self._outModelSelector.GetSelected() split = self._checkButton.GetSelectedState() vmtkFound = self.CheckForVmtkLibrary() if inCeLine and inModel and outModel and vmtkFound: result = slicer.vtkPolyData() r = self._logic.branchSplitting(inCeLine.GetPolyData(), inModel.GetPolyData()) result.DeepCopy(r) result.Update() outModel.SetAndObservePolyData(result) outModel.SetModifiedSinceRead(1) displayNode = outModel.GetModelDisplayNode() if not displayNode: displayNode = slicer.vtkMRMLModelDisplayNode() displayNode.SetPolyData(outModel.GetPolyData()) displayNode.SetColor(1, 0, 0) displayNode.SetScalarVisibility(1) displayNode.SetActiveScalarName(self._logic._GroupIdsArrayName) displayNode.SetAndObserveColorNodeID( self.GetLogic().GetMRMLScene().GetNodesByName( "Labels").GetItemAsObject(0).GetID()) displayNode.SetVisibility(1) displayNode.SetOpacity(1.0) self.GetLogic().GetMRMLScene().AddNode(displayNode) outModel.SetAndObserveDisplayNodeID(displayNode.GetID()) dNode = inModel.GetModelDisplayNode() dNode.SetOpacity(0.0) inModel.SetAndObserveDisplayNodeID(dNode.GetID()) if split == 1: ctr = 0 newPdList = self._logic.splitModels(result) for i in newPdList: if i.GetNumberOfCells() == 0: continue self._helper.debug("Number of Cells are: " + str(i.GetNumberOfCells())) ctr += 1 scene = self.GetLogic().GetMRMLScene() newNode = slicer.vtkMRMLModelNode() newNode.SetName("VMTKBranchSplittingOut_Branch" + str(ctr)) newNode.SetScene(scene) newNode.SetAndObservePolyData(i) scene.AddNode(newNode) dn = slicer.vtkMRMLModelDisplayNode() dn.SetPolyData(newNode.GetPolyData()) dn.SetColor(random.random(), random.random(), random.random()) dn.SetBackfaceCulling(0) dn.SetSliceIntersectionVisibility(1) dn.SetVisibility(1) dn.SetOpacity(1.0) scene.AddNode(dn) newNode.SetAndObserveDisplayNodeID(dn.GetName())
def Splitting(self): inCeLine = self._inCenterLineSelector.GetSelected() inModel = self._inModelSelector.GetSelected() outModel = self._outModelSelector.GetSelected() split = self._checkButton.GetSelectedState() vmtkFound=self.CheckForVmtkLibrary() if inCeLine and inModel and outModel and vmtkFound: result = slicer.vtkPolyData() r=self._logic.branchSplitting(inCeLine.GetPolyData(),inModel.GetPolyData()) result.DeepCopy(r) result.Update() outModel.SetAndObservePolyData(result) outModel.SetModifiedSinceRead(1) displayNode = outModel.GetModelDisplayNode() if not displayNode: displayNode = slicer.vtkMRMLModelDisplayNode() displayNode.SetPolyData(outModel.GetPolyData()) displayNode.SetColor(1, 0, 0) displayNode.SetScalarVisibility(1) displayNode.SetActiveScalarName(self._logic._GroupIdsArrayName) displayNode.SetAndObserveColorNodeID(self.GetLogic().GetMRMLScene().GetNodesByName("Labels").GetItemAsObject(0).GetID()) displayNode.SetVisibility(1) displayNode.SetOpacity(1.0) self.GetLogic().GetMRMLScene().AddNode(displayNode) outModel.SetAndObserveDisplayNodeID(displayNode.GetID()) dNode = inModel.GetModelDisplayNode() dNode.SetOpacity(0.0) inModel.SetAndObserveDisplayNodeID(dNode.GetID()) if split == 1: ctr=0 newPdList=self._logic.splitModels(result) for i in newPdList: if i.GetNumberOfCells() == 0: continue self._helper.debug("Number of Cells are: "+str(i.GetNumberOfCells())) ctr+=1 scene=self.GetLogic().GetMRMLScene() newNode=slicer.vtkMRMLModelNode() newNode.SetName("VMTKBranchSplittingOut_Branch"+str(ctr)) newNode.SetScene(scene) newNode.SetAndObservePolyData(i) scene.AddNode(newNode) dn=slicer.vtkMRMLModelDisplayNode() dn.SetPolyData(newNode.GetPolyData()) dn.SetColor(random.random() ,random.random() ,random.random() ) dn.SetBackfaceCulling(0) dn.SetSliceIntersectionVisibility(1) dn.SetVisibility(1) dn.SetOpacity(1.0) scene.AddNode(dn) newNode.SetAndObserveDisplayNodeID(dn.GetName())