21 #ifndef __vtkSegmentation_h 22 #define __vtkSegmentation_h 25 #include <vtkObject.h> 26 #include <vtkSmartPointer.h> 37 #include "vtkSegmentationCoreConfigure.h" 39 class vtkAbstractTransform;
40 class vtkCallbackCommand;
93 MasterRepresentationModified = 62100,
106 SegmentsOrderModified
120 EXTENT_UNION_OF_EFFECTIVE_SEGMENTS_PADDED
124 typedef std::map<std::string, vtkSmartPointer<vtkSegment> >
SegmentMap;
129 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
132 virtual void ReadXMLAttributes(
const char** atts);
135 virtual void WriteXML(ostream& of,
int indent);
144 virtual void GetBounds(
double bounds[6]);
148 virtual void ApplyLinearTransform(vtkAbstractTransform* transform);
152 virtual void ApplyNonLinearTransform(vtkAbstractTransform* transform);
164 std::string DetermineCommonLabelmapGeometry(
int extentComputationMode = EXTENT_UNION_OF_SEGMENTS,
const std::vector<std::string>& segmentIDs = std::vector<std::string>());
171 void DetermineCommonLabelmapExtent(
int commonGeometryExtent[6],
vtkOrientedImageData* commonGeometryImage,
172 const std::vector<std::string>& segmentIDs = std::vector<std::string>(),
bool computeEffectiveExtent=
false,
bool addPadding=
false);
174 #endif // __VTK_WRAP__ 177 std::string DetermineCommonLabelmapGeometry(
int extentComputationMode, vtkStringArray* segmentIds);
180 void DetermineCommonLabelmapExtent(
int commonGeometryExtent[6],
vtkOrientedImageData* commonGeometryImage,
181 vtkStringArray* segmentIds,
bool computeEffectiveExtent=
false,
bool addPadding=
false);
185 bool SetImageGeometryFromCommonLabelmapGeometry(
vtkOrientedImageData* imageData, vtkStringArray* segmentIDs = NULL,
202 bool AddSegment(
vtkSegment* segment, std::string segmentId =
"", std::string insertBeforeSegmentId =
"");
207 std::string GenerateUniqueSegmentID(std::string
id);
211 void RemoveSegment(std::string segmentId);
218 void RemoveAllSegments();
222 vtkSegment* GetSegment(std::string segmentId);
225 void GetSegmentIDs(std::vector<std::string> &segmentIds);
228 void GetSegmentIDs(vtkStringArray* segmentIds);
231 int GetNumberOfSegments()
const;
234 vtkSegment* GetNthSegment(
unsigned int index)
const;
237 std::string GetNthSegmentID(
unsigned int index)
const;
242 int GetSegmentIndex(
const std::string& segmentId);
247 bool SetSegmentIndex(
const std::string& segmentId,
unsigned int newIndex);
253 void ReorderSegments(std::vector<std::string> segmentIdsToMove, std::string insertBeforeSegmentId =
"");
257 std::string GetSegmentIdBySegment(
vtkSegment* segment);
262 std::string GetSegmentIdBySegmentName(std::string name);
268 std::vector<vtkSegment*> GetSegmentsByTag(std::string tag, std::string value=
"");
271 vtkDataObject* GetSegmentRepresentation(std::string segmentId, std::string representationName);
279 bool CopySegmentFromSegmentation(
vtkSegmentation* fromSegmentation, std::string segmentId,
bool removeFromSource=
false);
286 void GetContainedRepresentationNames(std::vector<std::string>& representationNames);
291 bool ContainsRepresentation(std::string representationName);
294 bool IsMasterRepresentationPolyData();
297 bool IsMasterRepresentationImageData();
303 void InvalidateNonMasterRepresentations();
317 bool CreateRepresentation(
const std::string& targetRepresentationName,
bool alwaysConvert=
false);
328 void RemoveRepresentation(
const std::string& representationName);
334 bool CanAcceptRepresentation(std::string representationName);
345 std::string AddEmptySegment(std::string segmentId=
"", std::string segmentName=
"",
double color[3]=NULL);
348 void GetPossibleConversions(
const std::string& targetRepresentationName,
352 void SetConversionParameter(
const std::string& name,
const std::string& value) { this->Converter->SetConversionParameter(name, value); };
364 std::string SerializeAllConversionParameters();
368 void DeserializeConversionParameters(std::string conversionParametersString);
373 vtkGetMacro(MasterRepresentationName, std::string);
377 virtual void SetMasterRepresentationName(
const std::string& representationName);
389 bool ConvertSingleSegment(std::string segmentId, std::string targetRepresentationName);
393 void RemoveSegment(SegmentMap::iterator segmentIt);
399 bool SetMasterRepresentationModifiedEnabled(
bool enabled);
404 static void OnSegmentModified(vtkObject* caller,
unsigned long eid,
void* clientData,
void* callData);
408 static void OnMasterRepresentationModified(vtkObject* caller,
unsigned long eid,
void* clientData,
void* callData);
447 friend class qMRMLSegmentEditorWidgetPrivate;
450 #endif // __vtkSegmentation_h 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.
Invoked when content of any representation (including the master representation) in a segment is chan...
Extent is computed as union of extent of all segments.
Invoked if a segment is removed.
std::vector< ConversionPathAndCostType > ConversionPathAndCostListType
int SegmentIdAutogeneratorIndex
Extent is computed as union of effective extent of all segments.
Extent is computed as union of extent of all segments, with a single-voxel padding added on each side...
bool MasterRepresentationModifiedEnabled
Modified events of master representations are observed.
void GetConversionParametersForPath(vtkSegmentationConverterRule::ConversionParameterListType &conversionParameters, const vtkSegmentationConverter::ConversionPathType &path)
Get names of all conversion parameters used by the selected conversion path.
Image data containing orientation information.
vtkCallbackCommand * MasterRepresentationCallbackCommand
Command handling master representation modified events.
Invoked if a representation is created or removed in the segments (e.g., created by conversion from m...
std::deque< std::string > SegmentIds
std::vector< vtkSegmentationConverterRule * > ConversionPathType
vtkCallbackCommand * SegmentCallbackCommand
Command handling segment modified events.
Invoked if new segment is added.
This class encapsulates a segmentation that can contain multiple segments and multiple representation...
std::map< std::string, std::pair< std::string, std::string > > ConversionParameterListType
std::string MasterRepresentationName
std::string GetConversionParameter(const std::string &name)
Extent of common geometry is used as extent.
void SetConversionParameter(const std::string &name, const std::string &value)
Set a conversion parameter to all rules having this parameter.
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.
Class that can convert between different representations of a segment.