Difference between revisions of "Documentation/Nightly/Developers/FAQ/MRML"
From Slicer Wiki
m |
|||
Line 8: | Line 8: | ||
* Generic pattern | * Generic pattern | ||
− | < | + | <pre> |
− | + | vtkNew<vtkMRML???Node> nodeToAdd; | |
− | + | ... | |
− | + | mrmlScene->AddNode(nodeToAdd.GetPointer()); | |
− | </ | + | </pre> |
* Add a polydata to the scene | * Add a polydata to the scene | ||
− | < | + | <pre> |
− | + | vtkNew<vtkMRMLModelNode> modelNode; | |
− | + | modelNode->SetPolyData(polyData); | |
− | + | mrmlScene->AddNode(modelNode.GetPointer()); | |
− | </ | + | </pre> |
* Load a polyData from file | * Load a polyData from file | ||
− | < | + | <pre> |
− | + | vtkSlicerModelsLogic* modelsLogic = ...; | |
− | + | //modelsLogic->SetMRMLScene(mrmlScene); | |
− | + | modelsLogic->AddModel(polyDataFileName); | |
− | </ | + | </pre> |
== What to do if you get 'No LookupTable was set but number of components in input doesn't match OutputFormat' when loading a MRML scene ? == | == What to do if you get 'No LookupTable was set but number of components in input doesn't match OutputFormat' when loading a MRML scene ? == |
Revision as of 16:01, 8 June 2016
Home < Documentation < Nightly < Developers < FAQ < MRML
For the latest Slicer documentation, visit the read-the-docs. |
Contents
MRML
How to add a MRML node into the scene ?
- Generic pattern
vtkNew<vtkMRML???Node> nodeToAdd; ... mrmlScene->AddNode(nodeToAdd.GetPointer());
- Add a polydata to the scene
vtkNew<vtkMRMLModelNode> modelNode; modelNode->SetPolyData(polyData); mrmlScene->AddNode(modelNode.GetPointer());
- Load a polyData from file
vtkSlicerModelsLogic* modelsLogic = ...; //modelsLogic->SetMRMLScene(mrmlScene); modelsLogic->AddModel(polyDataFileName);
What to do if you get 'No LookupTable was set but number of components in input doesn't match OutputFormat' when loading a MRML scene ?
If you get the following error messages:
ERROR: In /path/to/VTK/Imaging/vtkImageMapToColors.cxx, line 153 vtkImageMapToColors (0x268f190): RequestInformation: No LookupTable was set but number of components in input doesn't match OutputFormat, therefore input can't be passed through! ERROR: In /path/to/VTK/Imaging/vtkImageExtractComponents.cxx, line 239 vtkImageExtractComponents (0x26947e0): Execute: Component 1 is not in input. ERROR: In /path/to/VTK/Imaging/vtkImageExtractComponents.cxx, line 239 vtkImageExtractComponents (0x26947e0): Execute: Component 1 is not in input. [...]
Make sure the colorNodeRef
attribute is set on each VolumeDisplay
node.
How to change the volumes in the 2D views ?
appLogic = slicer.app.applicationLogic()
selectionNode = appLogic.GetSelectionNode()
selectionNode.SetReferenceActiveVolumeID(bg)
selectionNode.SetReferenceSecondaryVolumeID(fg)
appLogic.PropagateVolumeSelection()
Source: https://github.com/fedorov/ChangeTrackerPy/blob/master/Wizard/Helper.py#L82