26#ifndef __vtkSlicerSegmentationsModuleLogic_h
27#define __vtkSlicerSegmentationsModuleLogic_h
31#include "vtkSlicerSegmentationsModuleLogicExport.h"
36class vtkCallbackCommand;
40class vtkGeneralTransform;
55 void PrintSelf(ostream& os, vtkIndent indent)
override;
79 bool autoOpacities =
true,
80 const char* nodeName =
nullptr,
101 bool shallowCopy =
true,
102 bool shiftImageDataExtentToZeroStart =
true);
187 const std::vector<std::string>& segmentID,
189 vtkIntArray* labelValues =
nullptr);
203 const std::vector<std::string>& segmentIDs,
221 vtkStringArray* segmentIDs,
252 std::string insertBeforeSegmentId =
"",
263 std::string baseSegmentName =
"",
264 std::string insertBeforeSegmentId =
"",
271 vtkStringArray* updatedSegmentIDs,
278 vtkStringArray* updatedSegmentIDs,
279 vtkGeneralTransform* labelmapToSegmentationTransform =
nullptr,
288 std::string terminologyContextName,
289 std::string insertBeforeSegmentId =
"",
307 vtkStringArray* segmentIds =
nullptr,
308 std::string fileFormat =
"STL",
310 double sizeScale = 1.0,
337 vtkStringArray* segmentIds =
nullptr,
338 std::string extension =
"nrrd",
339 bool useCompression =
false,
356 bool linearInterpolation =
false,
357 double backgroundColor[4] =
nullptr);
375 vtkGeneralTransform* representationToSegmentationTransform);
387 std::string segmentID,
388 std::string representationName,
389 vtkDataObject* segmentRepresentation,
390 bool applyParentTransform =
true);
403 std::string segmentID,
405 bool applyParentTransform =
true);
433 std::string segmentID,
435 const int extent[6] =
nullptr,
436 bool minimumOfAllSegments =
false,
437 const std::vector<std::string>& segmentIdsToOverwrite = {});
492 std::string sharedSegmentID,
495 std::vector<std::string>& segmentIDs,
496 int maskThreshold = 0.0,
497 bool includeInputSharedSegmentID =
false);
521 vtkStringArray* segmentIDs,
522 int extentComputationMode,
524 vtkIntArray* labelValues =
nullptr);
557 const std::vector<std::string>& segmentIDs,
563 const std::vector<std::string>& segmentIDs,
MRML node to represent discrete color information.
MRML node for representing a label map volume.
MRML node to represent a 3D surface model.
Abstract Superclass for all specific types of MRML nodes.
MRML node for representing a volume (image stack).
A set of MRML Nodes that supports serialization and undo/redo.
Parameter set node for the segment editor widget.
MRML node containing segmentations.
MRML node for segmentation storage on disk.
MRML node for representing a volume (image stack).
Image data containing orientation information.
This class encapsulates a segment that is part of a segmentation.
This class encapsulates a segmentation that can contain multiple segments and multiple representation...
@ EXTENT_UNION_OF_EFFECTIVE_SEGMENTS
Extent is computed as union of effective extent of all segments.
@ EXTENT_REFERENCE_GEOMETRY
Extent of common geometry is used as extent.
static bool ImportLabelmapToSegmentationNode(vtkMRMLLabelMapVolumeNode *labelmapNode, vtkMRMLSegmentationNode *segmentationNode, vtkStringArray *updatedSegmentIDs, vtkMRMLMessageCollection *userMessages=nullptr)
void SetDefaultSurfaceSmoothingEnabled(bool enabled)
static bool ExportAllSegmentsToModels(vtkMRMLSegmentationNode *segmentationNode, vtkIdType folderItemId)
static bool GetSharedSegmentIDsInMask(vtkMRMLSegmentationNode *segmentationNode, std::string sharedSegmentID, vtkOrientedImageData *mask, const int extent[6], std::vector< std::string > &segmentIDs, int maskThreshold=0.0, bool includeInputSharedSegmentID=false)
static vtkMRMLSegmentationNode * GetSegmentationNodeForSegmentSubjectHierarchyItem(vtkIdType segmentShItemID, vtkMRMLScene *scene)
Utility function for getting the segmentation node for a segmentation or segment subject hierarchy it...
static bool ImportModelToSegmentationNode(vtkMRMLModelNode *modelNode, vtkMRMLSegmentationNode *segmentationNode, std::string insertBeforeSegmentId="")
Import model into the segmentation as a segment.
static int DoesLabelmapContainSingleLabel(vtkMRMLLabelMapVolumeNode *labelmapVolumeNode)
static bool ExportAllSegmentsToLabelmapNode(vtkMRMLSegmentationNode *segmentationNode, vtkMRMLLabelMapVolumeNode *labelmapNode, int extentComputationMode=vtkSegmentation::EXTENT_UNION_OF_EFFECTIVE_SEGMENTS)
static bool IsSegmentationExentOutsideReferenceGeometry(vtkOrientedImageData *referenceGeometry, vtkOrientedImageData *segmentationGeometry)
static bool IsEffectiveExentOutsideReferenceVolume(vtkMRMLVolumeNode *referenceVolumeNode, vtkMRMLSegmentationNode *segmentationNode, vtkStringArray *segmentIDs=nullptr)
static const char * GetSegmentStatusAsMachineReadableString(int segmentStatus)
Get the machine readable segment status from the SegmentStatus enum value.
static vtkSegment * CreateSegmentFromModelNode(vtkMRMLModelNode *modelNode, vtkMRMLSegmentationNode *segmentationNode=nullptr)
static void SetSegmentStatus(vtkSegment *segment, int status)
static vtkMRMLSegmentationNode * GetSegmentationNodeForSegmentation(vtkMRMLScene *scene, vtkSegmentation *segmentation)
static void GetLabelValuesFromColorNode(vtkMRMLSegmentationNode *segmentationNode, vtkMRMLColorTableNode *colorTableNode, vtkStringArray *segmentIds, vtkIntArray *labelValues)
int GetDefaultOverwriteMode()
Get/Set default segmentation overwrite mode for masking options.
static bool ExportSegmentsToLabelmapNode(vtkMRMLSegmentationNode *segmentationNode, vtkStringArray *segmentIDs, vtkMRMLLabelMapVolumeNode *labelmapNode, vtkMRMLVolumeNode *referenceVolumeNode=nullptr, int extentComputationMode=vtkSegmentation::EXTENT_UNION_OF_EFFECTIVE_SEGMENTS, vtkMRMLColorTableNode *colorTableNode=nullptr)
vtkMRMLSegmentationNode * GetDefaultSegmentationNode()
Get default segmentation node. All new segmentation nodes are initialized to the content of this node...
static void CollapseBinaryLabelmaps(vtkMRMLSegmentationNode *segmentationNode, bool forceToSingleLayer)
static vtkMRMLSegmentationNode * GetSegmentationNodeForSegment(vtkMRMLScene *scene, vtkSegment *segment, std::string &segmentId)
static bool ImportLabelmapToSegmentationNode(vtkOrientedImageData *labelmapImage, vtkMRMLSegmentationNode *segmentationNode, std::string baseSegmentName="", std::string insertBeforeSegmentId="", vtkMRMLMessageCollection *userMessages=nullptr)
static bool ExportSegmentsToColorTableNode(vtkMRMLSegmentationNode *segmentationNode, const std::vector< std::string > &segmentID, vtkMRMLColorTableNode *colorTableNode, vtkIntArray *labelValues=nullptr)
static void GenerateMergedLabelmapInReferenceGeometry(vtkMRMLSegmentationNode *segmentationNode, vtkMRMLVolumeNode *referenceVolumeNode, vtkStringArray *segmentIDs, int extentComputationMode, vtkOrientedImageData *mergedLabelmap_Reference, vtkIntArray *labelValues=nullptr)
static bool ImportModelsToSegmentationNode(vtkIdType folderItemId, vtkMRMLSegmentationNode *segmentationNode, std::string insertBeforeSegmentId="")
Import models in a folder into the segmentation as segments.
static bool ExportSegmentsClosedSurfaceRepresentationToFiles(std::string destinationFolder, vtkMRMLSegmentationNode *segmentationNode, vtkStringArray *segmentIds=nullptr, std::string fileFormat="STL", bool lps=true, double sizeScale=1.0, bool merge=false)
static bool ExportSegmentToRepresentationNode(vtkSegment *segment, vtkMRMLNode *representationNode)
static int GetSegmentStatus(vtkSegment *segment)
static bool ExportSegmentsClosedSurfaceRepresentationToStlFiles(std::string destinationFolder, vtkMRMLSegmentationNode *segmentationNode, const std::vector< std::string > &segmentIDs, bool lps, double sizeScale, bool merge)
static bool ReconvertAllRepresentations(vtkMRMLSegmentationNode *segmentationNode, const std::vector< std::string > &segmentIDs={})
vtkMRMLSegmentationNode * LoadSegmentationFromFile(const char *filename, bool autoOpacities=true, const char *nodeName=nullptr, vtkMRMLColorTableNode *colorTableNode=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
static bool ExportSegmentsToLabelmapNode(vtkMRMLSegmentationNode *segmentationNode, const std::vector< std::string > &segmentIDs, vtkMRMLLabelMapVolumeNode *labelmapNode, vtkMRMLVolumeNode *referenceVolumeNode=nullptr, int extentComputationMode=vtkSegmentation::EXTENT_UNION_OF_EFFECTIVE_SEGMENTS, vtkMRMLColorTableNode *colorTableNode=nullptr)
~vtkSlicerSegmentationsModuleLogic() override
static bool GetTransformBetweenRepresentationAndSegmentation(vtkMRMLTransformableNode *representationNode, vtkMRMLSegmentationNode *segmentationNode, vtkGeneralTransform *representationToSegmentationTransform)
static bool ExportSegmentsToModels(vtkMRMLSegmentationNode *segmentationNode, const std::vector< std::string > &segmentIDs, vtkIdType folderItemId)
static bool GetSegmentClosedSurfaceRepresentation(vtkMRMLSegmentationNode *segmentationNode, std::string segmentID, vtkPolyData *polyData, bool applyParentTransform=true)
static vtkSegment * CreateSegmentFromLabelmapVolumeNode(vtkMRMLLabelMapVolumeNode *labelmapVolumeNode, vtkMRMLSegmentationNode *segmentationNode=nullptr)
static const char * GetStatusTagName()
Returns the name of the status tag.
bool ImportLabelmapToSegmentationNodeWithTerminology(vtkMRMLLabelMapVolumeNode *labelmapNode, vtkMRMLSegmentationNode *segmentationNode, std::string terminologyContextName, std::string insertBeforeSegmentId="", vtkMRMLMessageCollection *userMessages=nullptr)
static vtkMRMLColorTableNode * AddColorTableNodeForSegmentation(vtkMRMLSegmentationNode *segmentationNode)
static bool GetSegmentBinaryLabelmapRepresentation(vtkMRMLSegmentationNode *segmentationNode, std::string segmentID, vtkOrientedImageData *imageData, bool applyParentTransform=true)
void SetMRMLSceneInternal(vtkMRMLScene *newScene) override
static vtkOrientedImageData * CreateOrientedImageDataFromVolumeNode(vtkMRMLScalarVolumeNode *volumeNode, vtkMRMLTransformNode *outputParentTransformNode=nullptr)
static void OnSubjectHierarchyUIDAdded(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
static bool ExportVisibleSegmentsToLabelmapNode(vtkMRMLSegmentationNode *segmentationNode, vtkMRMLLabelMapVolumeNode *labelmapNode, vtkMRMLVolumeNode *referenceVolumeNode=nullptr, int extentComputationMode=vtkSegmentation::EXTENT_UNION_OF_EFFECTIVE_SEGMENTS)
static void GetAllLabelValues(vtkIntArray *labels, vtkImageData *labelmap)
Utility function that returns all non-empty label values in a labelmap.
void RegisterNodes() override
Register MRML Node classes to Scene. Gets called automatically when the MRMLScene is attached to this...
static vtkSegment * GetSegmentForSegmentSubjectHierarchyItem(vtkIdType segmentShItemID, vtkMRMLScene *scene)
Utility function for getting the segment object for a segment subject hierarchy item.
static bool ImportLabelmapToSegmentationNode(vtkOrientedImageData *labelmapImage, vtkMRMLSegmentationNode *segmentationNode, vtkStringArray *updatedSegmentIDs, vtkGeneralTransform *labelmapToSegmentationTransform=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
static bool SetBinaryLabelmapToSegment(vtkOrientedImageData *labelmap, vtkMRMLSegmentationNode *segmentationNode, std::string segmentID, int mergeMode=MODE_REPLACE, const int extent[6]=nullptr, bool minimumOfAllSegments=false, const std::vector< std::string > &segmentIdsToOverwrite={})
vtkMRMLSegmentEditorNode * GetDefaultSegmentEditorNode()
Get node that is used for initializing each new Segment Editor node.
bool GetDefaultSurfaceSmoothingEnabled()
Get/Set default closed surface smoothing enabled flag for new segmentation nodes.
void SetDefaultOverwriteMode(int mode)
static std::string GetSafeFileName(std::string originalName)
void PrintSelf(ostream &os, vtkIndent indent) override
static bool ExportSegmentsBinaryLabelmapRepresentationToFiles(std::string destinationFolder, vtkMRMLSegmentationNode *segmentationNode, vtkStringArray *segmentIds=nullptr, std::string extension="nrrd", bool useCompression=false, vtkMRMLVolumeNode *referenceVolumeNode=nullptr, int extentComputationMode=vtkSegmentation::EXTENT_REFERENCE_GEOMETRY, vtkMRMLColorTableNode *colorTableNode=nullptr)
static const char * GetSegmentStatusAsHumanReadableString(int segmentStatus)
Get the human readable segment status from the SegmentStatus enum value.
static bool ClearSegment(vtkMRMLSegmentationNode *segmentationNode, std::string segmentID)
Clear the contents of a single segment.
static bool ApplyParentTransformToOrientedImageData(vtkMRMLTransformableNode *transformableNode, vtkOrientedImageData *orientedImageData, bool linearInterpolation=false, double backgroundColor[4]=nullptr)
static bool CreateLabelmapVolumeFromOrientedImageData(vtkOrientedImageData *orientedImageData, vtkMRMLLabelMapVolumeNode *labelmapVolumeNode)
bool SetTerminologyToSegmentationFromLabelmapNode(vtkMRMLSegmentationNode *segmentationNode, vtkMRMLLabelMapVolumeNode *labelmapNode, std::string terminologyContextName)
static bool ExportSegmentsClosedSurfaceRepresentationToObjFile(std::string destinationFolder, vtkMRMLSegmentationNode *segmentationNode, const std::vector< std::string > &segmentIDs, bool lps, double sizeScale)
static bool ExportVisibleSegmentsToModels(vtkMRMLSegmentationNode *segmentationNode, vtkIdType folderItemId)
void OnMRMLSceneNodeAdded(vtkMRMLNode *node) override
Handle MRML node added events.
static vtkDataObject * CreateRepresentationForOneSegment(vtkSegmentation *segmentation, std::string segmentID, std::string representationName)
static bool ApplyParentTransformToPolyData(vtkMRMLTransformableNode *transformableNode, vtkPolyData *polyData)
static bool GetSegmentRepresentation(vtkMRMLSegmentationNode *segmentationNode, std::string segmentID, std::string representationName, vtkDataObject *segmentRepresentation, bool applyParentTransform=true)
static int GetSegmentStatusFromMachineReadableString(std::string statusString)
Get the enum segment status from a machine string.
vtkCallbackCommand * SubjectHierarchyUIDCallbackCommand
Command handling subject hierarchy UID added events.
static vtkSlicerSegmentationsModuleLogic * New()
vtkSlicerSegmentationsModuleLogic()
static bool ExportSegmentsToModels(vtkMRMLSegmentationNode *segmentationNode, vtkStringArray *segmentIds, vtkIdType folderItemId)
static bool CopyOrientedImageDataToVolumeNode(vtkOrientedImageData *orientedImageData, vtkMRMLVolumeNode *volumeNode, bool shallowCopy=true, bool shiftImageDataExtentToZeroStart=true)
static bool ImportLabelmapToSegmentationNode(vtkMRMLLabelMapVolumeNode *labelmapNode, vtkMRMLSegmentationNode *segmentationNode, std::string insertBeforeSegmentId="", vtkMRMLMessageCollection *userMessages=nullptr)