parameters: (self)
docstring: make models of current merge volume
docstring_summary: make models of current merge volume
docstring_tokens: make models of current merge volume
function: def build(self):
      """make models of current merge volume"""
  
      #
      # get the image data for the label layer
      #
  
      self.statusText( "Building..." )
      merge = self.merge
      if not merge:
        return
  
      #
      # create a model using the command line module
      # based on the current editor parameters
      #
  
      parameters = {}
      parameters["InputVolume"] = merge.GetID()
      parameters['FilterType'] = "Sinc"
      parameters['GenerateAll'] = True
  
      # not needed: setting StartLabel and EndLabel instead
      #parameters['Labels'] = self.getPaintLabel()
  
      parameters["JointSmoothing"] = True
      parameters["SplitNormals"] = True
      parameters["PointNormals"] = True
      parameters["SkipUnNamed"] = True
  
      # create models for all labels
      parameters["StartLabel"] = -1
      parameters["EndLabel"] = -1
  
      parameters["Decimate"] = 0.25
      parameters["Smooth"] = 10
  
      #
      # output
      # - make a new hierarchy node if needed
      #
      numNodes = slicer.mrmlScene.GetNumberOfNodesByClass( "vtkMRMLModelHierarchyNode" )
      outHierarchy = None
      for n in range(numNodes):
        node = slicer.mrmlScene.GetNthNodeByClass( n, "vtkMRMLModelHierarchyNode" )
        if node.GetName() == "Editor Models":
          outHierarchy = node
          break
  
      if outHierarchy and self.replaceModels.checked and numNodes > 0:
        # user wants to delete any existing models, so take down hierarchy and
        # delete the model nodes
        rr = list(range(numNodes))
        rr.reverse()
        for n in rr:
          node = slicer.mrmlScene.GetNthNodeByClass( n, "vtkMRMLModelHierarchyNode" )
          if node.GetParentNodeID() == outHierarchy.GetID():
            slicer.mrmlScene.RemoveNode( node.GetModelNode() )
            slicer.mrmlScene.RemoveNode( node )
  
      if not outHierarchy:
        outHierarchy = slicer.vtkMRMLModelHierarchyNode()
        outHierarchy.SetScene( slicer.mrmlScene )
        outHierarchy.SetName( "Editor Models" )
        slicer.mrmlScene.AddNode( outHierarchy )
  
      parameters["ModelSceneFile"] = outHierarchy
  
      try:
        modelMaker = slicer.modules.modelmaker
        #
        # run the task (in the background)
        # - use the GUI to provide progress feedback
        # - use the GUI's Logic to invoke the task
        # - model will show up when the processing is finished
        #
        self.CLINode = slicer.cli.run(modelMaker, self.CLINode, parameters)
        self.statusText( "Model Making Started..." )
      except AttributeError:
        slicer.util.errorDisplay('The ModelMaker module is not available<p>Perhaps it was disabled in the application '
                                 'settings or did not load correctly.', windowTitle='Editor')
function_tokens: def build ( self ) : # # get the image data for the label layer # self . statusText ( "Building..." ) merge = self . merge if not merge : return # # create a model using the command line module # based on the current editor parameters # parameters = { } parameters [ "InputVolume" ] = merge . GetID ( ) parameters [ 'FilterType' ] = "Sinc" parameters [ 'GenerateAll' ] = True # not needed: setting StartLabel and EndLabel instead #parameters['Labels'] = self.getPaintLabel() parameters [ "JointSmoothing" ] = True parameters [ "SplitNormals" ] = True parameters [ "PointNormals" ] = True parameters [ "SkipUnNamed" ] = True # create models for all labels parameters [ "StartLabel" ] = - 1 parameters [ "EndLabel" ] = - 1 parameters [ "Decimate" ] = 0.25 parameters [ "Smooth" ] = 10 # # output # - make a new hierarchy node if needed # numNodes = slicer . mrmlScene . GetNumberOfNodesByClass ( "vtkMRMLModelHierarchyNode" ) outHierarchy = None for n in range ( numNodes ) : node = slicer . mrmlScene . GetNthNodeByClass ( n , "vtkMRMLModelHierarchyNode" ) if node . GetName ( ) == "Editor Models" : outHierarchy = node break if outHierarchy and self . replaceModels . checked and numNodes > 0 : # user wants to delete any existing models, so take down hierarchy and # delete the model nodes rr = list ( range ( numNodes ) ) rr . reverse ( ) for n in rr : node = slicer . mrmlScene . GetNthNodeByClass ( n , "vtkMRMLModelHierarchyNode" ) if node . GetParentNodeID ( ) == outHierarchy . GetID ( ) : slicer . mrmlScene . RemoveNode ( node . GetModelNode ( ) ) slicer . mrmlScene . RemoveNode ( node ) if not outHierarchy : outHierarchy = slicer . vtkMRMLModelHierarchyNode ( ) outHierarchy . SetScene ( slicer . mrmlScene ) outHierarchy . SetName ( "Editor Models" ) slicer . mrmlScene . AddNode ( outHierarchy ) parameters [ "ModelSceneFile" ] = outHierarchy try : modelMaker = slicer . modules . modelmaker # # run the task (in the background) # - use the GUI to provide progress feedback # - use the GUI's Logic to invoke the task # - model will show up when the processing is finished # self . CLINode = slicer . cli . run ( modelMaker , self . CLINode , parameters ) self . statusText ( "Model Making Started..." ) except AttributeError : slicer . util . errorDisplay ( 'The ModelMaker module is not available<p>Perhaps it was disabled in the application ' 'settings or did not load correctly.' , windowTitle = 'Editor' )