21 #ifndef __vtkSegmentation_h 22 #define __vtkSegmentation_h 25 #include <vtkObject.h> 26 #include <vtkSmartPointer.h> 38 #include "vtkSegmentationCoreConfigure.h" 40 class vtkAbstractTransform;
41 class vtkCallbackCommand;
99 MasterRepresentationModified = 62100,
128 EXTENT_UNION_OF_EFFECTIVE_SEGMENTS_AND_REFERENCE_GEOMETRY
132 typedef std::map<std::string, vtkSmartPointer<vtkSegment> >
SegmentMap;
137 void PrintSelf(ostream& os, vtkIndent indent)
override;
140 virtual void ReadXMLAttributes(
const char** atts);
143 virtual void WriteXML(ostream& of,
int indent);
152 virtual void GetBounds(
double bounds[6]);
156 virtual void ApplyLinearTransform(vtkAbstractTransform* transform);
160 virtual void ApplyNonLinearTransform(vtkAbstractTransform* transform);
163 std::string DetermineCommonLabelmapGeometry(
int extentComputationMode = EXTENT_UNION_OF_SEGMENTS,
const std::vector<std::string>& segmentIDs = std::vector<std::string>());
178 void DetermineCommonLabelmapExtent(
int commonGeometryExtent[6],
vtkOrientedImageData* commonGeometryImage,
179 const std::vector<std::string>& segmentIDs = std::vector<std::string>(),
bool computeEffectiveExtent=
false,
bool addPadding=
false);
180 #endif // __VTK_WRAP__ 183 std::string DetermineCommonLabelmapGeometry(
int extentComputationMode, vtkStringArray* segmentIds);
186 void DetermineCommonLabelmapExtent(
int commonGeometryExtent[6],
vtkOrientedImageData* commonGeometryImage,
187 vtkStringArray* segmentIds,
bool computeEffectiveExtent=
false,
bool addPadding=
false);
191 bool SetImageGeometryFromCommonLabelmapGeometry(
vtkOrientedImageData* imageData, vtkStringArray* segmentIDs =
nullptr,
208 bool AddSegment(
vtkSegment* segment, std::string segmentId =
"", std::string insertBeforeSegmentId =
"");
213 std::string GenerateUniqueSegmentID(std::string
id);
217 void RemoveSegment(std::string segmentId);
224 void RemoveAllSegments();
228 vtkSegment* GetSegment(std::string segmentId);
231 void GetSegmentIDs(std::vector<std::string> &segmentIds);
234 void GetSegmentIDs(vtkStringArray* segmentIds);
237 std::vector<std::string> GetSegmentIDs();
240 int GetNumberOfSegments()
const;
243 vtkSegment* GetNthSegment(
unsigned int index)
const;
246 std::string GetNthSegmentID(
unsigned int index)
const;
251 int GetSegmentIndex(
const std::string& segmentId);
256 bool SetSegmentIndex(
const std::string& segmentId,
unsigned int newIndex);
262 void ReorderSegments(std::vector<std::string> segmentIdsToMove, std::string insertBeforeSegmentId =
"");
266 std::string GetSegmentIdBySegment(
vtkSegment* segment);
271 std::string GetSegmentIdBySegmentName(std::string name);
277 std::vector<vtkSegment*> GetSegmentsByTag(std::string tag, std::string value=
"");
280 vtkDataObject* GetSegmentRepresentation(std::string segmentId, std::string representationName);
288 bool CopySegmentFromSegmentation(
vtkSegmentation* fromSegmentation, std::string segmentId,
bool removeFromSource=
false);
295 void GetContainedRepresentationNames(std::vector<std::string>& representationNames);
300 bool ContainsRepresentation(std::string representationName);
303 bool IsMasterRepresentationPolyData();
306 bool IsMasterRepresentationImageData();
312 void InvalidateNonMasterRepresentations();
330 const std::vector<std::string>& segmentIDs = std::vector<std::string>(), vtkIntArray* labelValues =
nullptr);
331 #endif // __VTK_WRAP__ 336 bool IsSharedBinaryLabelmap(std::string segmentID);
343 void GetSegmentIDsSharingRepresentation(std::string originalSegmentId, std::string representationName,
344 std::vector<std::string>& sharedSegmentIds,
bool includeOriginalSegmentId=
true);
350 void GetSegmentIDsSharingBinaryLabelmapRepresentation(std::string originalSegmentId, std::vector<std::string> &sharedSegmentIds,
351 bool includeOriginalSegmentId=
true);
356 int GetUniqueLabelValueForSharedLabelmap(std::string segmentId);
366 void MergeSegmentLabelmaps(std::vector<std::string> mergeSegmentIds);
369 void SeparateSegmentLabelmap(std::string segmentId);
374 void ClearSegment(std::string segmentId);
380 int GetNumberOfLayers(std::string representationName=
"");
384 int GetLayerIndex(std::string segmentId, std::string representationName=
"");
388 vtkDataObject* GetLayerDataObject(
int layer, std::string representationName=
"");
392 void GetLayerObjects(vtkCollection* layerObjects, std::string representationName =
"");
396 std::vector<std::string> GetSegmentIDsForLayer(
int layer, std::string representationName =
"");
400 std::vector<std::string> GetSegmentIDsForDataObject(vtkDataObject* dataObject, std::string representationName =
"");
405 void CollapseBinaryLabelmaps(
bool forceToSingleLayer=
false);
419 bool CreateRepresentation(
const std::string& targetRepresentationName,
bool alwaysConvert=
false);
430 void RemoveRepresentation(
const std::string& representationName);
436 bool CanAcceptRepresentation(std::string representationName);
447 std::string AddEmptySegment(std::string segmentId=
"", std::string segmentName=
"",
double color[3]=
nullptr);
450 void GetPossibleConversions(
const std::string& targetRepresentationName,
454 void SetConversionParameter(
const std::string& name,
const std::string& value) { this->Converter->SetConversionParameter(name, value); };
466 std::string SerializeAllConversionParameters();
470 void DeserializeConversionParameters(std::string conversionParametersString);
475 vtkGetMacro(MasterRepresentationName, std::string);
479 virtual void SetMasterRepresentationName(
const std::string& representationName);
484 std::map<vtkDataObject*, vtkDataObject*>& cachedRepresentations);
498 bool ConvertSingleSegment(std::string segmentId, std::string targetRepresentationName);
502 void RemoveSegment(SegmentMap::iterator segmentIt);
508 bool SetMasterRepresentationModifiedEnabled(
bool enabled);
514 bool SetSegmentModifiedEnabled(
bool enabled);
519 static void OnSegmentModified(vtkObject* caller,
unsigned long eid,
void* clientData,
void* callData);
523 static void OnMasterRepresentationModified(vtkObject* caller,
unsigned long eid,
void* clientData,
void* callData);
527 void UpdateMasterRepresentationObservers();
572 friend class qMRMLSegmentEditorWidgetPrivate;
579 #endif // __vtkSegmentation_h Invoked if a representation is created or removed in the segments (e.g., created by conversion from m...
This class encapsulates a segment that is part of a segmentation.
void GetAvailableRepresentationNames(std::set< std::string > &representationNames)
Get all representations supported by the converter.
int SegmentIdAutogeneratorIndex
Extent is computed as union of extent of all segments, with a single-voxel padding added on each side...
std::set< vtkSmartPointer< vtkDataObject > > MasterRepresentationCache
bool MasterRepresentationModifiedEnabled
Modified events of master representations are observed.
Image data containing orientation information.
vtkCallbackCommand * MasterRepresentationCallbackCommand
Command handling master representation modified events.
std::deque< std::string > SegmentIds
Invoked if new segment is added.
vtkCallbackCommand * SegmentCallbackCommand
Command handling segment modified events.
bool SegmentModifiedEnabled
Modified events of segments are observed.
Invoked if segment IDs order is changed. Not called when a segment is added or removed.
This class encapsulates a segmentation that can contain multiple segments and multiple representation...
Store a list of conversion parameters.
Store multiple segmentation conversion paths.
std::string MasterRepresentationName
std::string GetConversionParameter(const std::string &name)
Extent is computed as union of extent of all segments.
Extent is computed as union of effective extent of all segments.
Invoked when content of any representation (including the master representation) in a segment is chan...
Extent is computed as union of effective extent of all segments, with a single-voxel padding added on...
Store a segmentation conversion path.
Invoked if a segment is removed.
void SetConversionParameter(const std::string &name, const std::string &value)
Set a conversion parameter to all rules having this parameter.
void GetConversionParametersForPath(vtkSegmentationConversionParameters *conversionParameters, vtkSegmentationConversionPath *path)
Get names of all conversion parameters used by the selected conversion path.
Utility functions for resampling oriented image data.
vtkSegmentationConverter * Converter
Converter instance.
std::map< std::string, vtkSmartPointer< vtkSegment > > SegmentMap
Container type for segments. Maps segment IDs to segment objects.
SegmentMap Segments
Container of segments that belong to this segmentation.
Extent of common geometry is used as extent.
MRML node containing segmentationsSegmentation node stores a set of segments (also known as contours ...
Class that can convert between different representations of a segment.