示例#1
0
  def test_CropVolumeSelfTest(self):
    """
    Replicate the crashe in issue 3117
    """

    print("Running CropVolumeSelfTest Test case:")

    import SampleData

    vol = SampleData.downloadSample("MRHead")
    roi = slicer.vtkMRMLMarkupsROINode()

    mainWindow = slicer.util.mainWindow()
    mainWindow.moduleSelector().selectModule('CropVolume')

    cropVolumeNode = slicer.vtkMRMLCropVolumeParametersNode()
    cropVolumeNode.SetScene(slicer.mrmlScene)
    cropVolumeNode.SetName('ChangeTracker_CropVolume_node')
    cropVolumeNode.SetIsotropicResampling(True)
    cropVolumeNode.SetSpacingScalingConst(0.5)
    slicer.mrmlScene.AddNode(cropVolumeNode)

    cropVolumeNode.SetInputVolumeNodeID(vol.GetID())
    cropVolumeNode.SetROINodeID(roi.GetID())

    cropVolumeLogic = slicer.modules.cropvolume.logic()
    cropVolumeLogic.Apply(cropVolumeNode)

    self.delayDisplay('First test passed, closing the scene and running again')
    # test clearing the scene and running a second time
    slicer.mrmlScene.Clear(0)
    # the module will re-add the removed parameters node
    mainWindow.moduleSelector().selectModule('Transforms')
    mainWindow.moduleSelector().selectModule('CropVolume')
    cropVolumeNode = slicer.mrmlScene.GetNodeByID('vtkMRMLCropVolumeParametersNode1')
    vol = SampleData.downloadSample("MRHead")
    roi = slicer.vtkMRMLMarkupsROINode()
    cropVolumeNode.SetInputVolumeNodeID(vol.GetID())
    cropVolumeNode.SetROINodeID(roi.GetID())
    cropVolumeLogic.Apply(cropVolumeNode)

    self.delayDisplay('Test passed')
 def markupsNodes(self):
   return {
     slicer.vtkMRMLMarkupsAngleNode(): slicer.vtkSlicerAngleWidget(),
     slicer.vtkMRMLMarkupsClosedCurveNode(): slicer.vtkSlicerCurveWidget(),
     slicer.vtkMRMLMarkupsCurveNode(): slicer.vtkSlicerCurveWidget(),
     slicer.vtkMRMLMarkupsFiducialNode(): slicer.vtkSlicerPointsWidget(),
     slicer.vtkMRMLMarkupsLineNode(): slicer.vtkSlicerLineWidget(),
     slicer.vtkMRMLMarkupsPlaneNode(): slicer.vtkSlicerPlaneWidget(),
     slicer.vtkMRMLMarkupsROINode(): slicer.vtkSlicerROIWidget(),
     slicer.vtkMRMLMarkupsTestLineNode(): slicer.vtkSlicerTestLineWidget()
   }