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;
95 MasterRepresentationModified = 62100,
108 SegmentsOrderModified
122 EXTENT_UNION_OF_EFFECTIVE_SEGMENTS_PADDED
126 typedef std::map<std::string, vtkSmartPointer<vtkSegment> >
SegmentMap;
131 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
134 virtual void ReadXMLAttributes(
const char** atts);
137 virtual void WriteXML(ostream& of,
int indent);
146 virtual void GetBounds(
double bounds[6]);
150 virtual void ApplyLinearTransform(vtkAbstractTransform* transform);
154 virtual void ApplyNonLinearTransform(vtkAbstractTransform* transform);
166 std::string DetermineCommonLabelmapGeometry(
int extentComputationMode = EXTENT_UNION_OF_SEGMENTS,
const std::vector<std::string>& segmentIDs = std::vector<std::string>());
173 void DetermineCommonLabelmapExtent(
int commonGeometryExtent[6],
vtkOrientedImageData* commonGeometryImage,
174 const std::vector<std::string>& segmentIDs = std::vector<std::string>(),
bool computeEffectiveExtent=
false,
bool addPadding=
false);
176 #endif // __VTK_WRAP__ 179 std::string DetermineCommonLabelmapGeometry(
int extentComputationMode, vtkStringArray* segmentIds);
182 void DetermineCommonLabelmapExtent(
int commonGeometryExtent[6],
vtkOrientedImageData* commonGeometryImage,
183 vtkStringArray* segmentIds,
bool computeEffectiveExtent=
false,
bool addPadding=
false);
187 bool SetImageGeometryFromCommonLabelmapGeometry(
vtkOrientedImageData* imageData, vtkStringArray* segmentIDs = NULL,
204 bool AddSegment(
vtkSegment* segment, std::string segmentId =
"", std::string insertBeforeSegmentId =
"");
209 std::string GenerateUniqueSegmentID(std::string
id);
213 void RemoveSegment(std::string segmentId);
220 void RemoveAllSegments();
224 vtkSegment* GetSegment(std::string segmentId);
227 void GetSegmentIDs(std::vector<std::string> &segmentIds);
230 void GetSegmentIDs(vtkStringArray* segmentIds);
233 int GetNumberOfSegments()
const;
236 vtkSegment* GetNthSegment(
unsigned int index)
const;
239 std::string GetNthSegmentID(
unsigned int index)
const;
244 int GetSegmentIndex(
const std::string& segmentId);
249 bool SetSegmentIndex(
const std::string& segmentId,
unsigned int newIndex);
255 void ReorderSegments(std::vector<std::string> segmentIdsToMove, std::string insertBeforeSegmentId =
"");
259 std::string GetSegmentIdBySegment(
vtkSegment* segment);
264 std::string GetSegmentIdBySegmentName(std::string name);
270 std::vector<vtkSegment*> GetSegmentsByTag(std::string tag, std::string value=
"");
273 vtkDataObject* GetSegmentRepresentation(std::string segmentId, std::string representationName);
281 bool CopySegmentFromSegmentation(
vtkSegmentation* fromSegmentation, std::string segmentId,
bool removeFromSource=
false);
288 void GetContainedRepresentationNames(std::vector<std::string>& representationNames);
293 bool ContainsRepresentation(std::string representationName);
296 bool IsMasterRepresentationPolyData();
299 bool IsMasterRepresentationImageData();
305 void InvalidateNonMasterRepresentations();
319 bool CreateRepresentation(
const std::string& targetRepresentationName,
bool alwaysConvert=
false);
330 void RemoveRepresentation(
const std::string& representationName);
336 bool CanAcceptRepresentation(std::string representationName);
347 std::string AddEmptySegment(std::string segmentId=
"", std::string segmentName=
"",
double color[3]=NULL);
350 void GetPossibleConversions(
const std::string& targetRepresentationName,
354 void SetConversionParameter(
const std::string& name,
const std::string& value) { this->Converter->SetConversionParameter(name, value); };
366 std::string SerializeAllConversionParameters();
370 void DeserializeConversionParameters(std::string conversionParametersString);
375 vtkGetMacro(MasterRepresentationName, std::string);
379 virtual void SetMasterRepresentationName(
const std::string& representationName);
391 bool ConvertSingleSegment(std::string segmentId, std::string targetRepresentationName);
395 void RemoveSegment(SegmentMap::iterator segmentIt);
401 bool SetMasterRepresentationModifiedEnabled(
bool enabled);
407 bool SetSegmentModifiedEnabled(
bool enabled);
412 static void OnSegmentModified(vtkObject* caller,
unsigned long eid,
void* clientData,
void* callData);
416 static void OnMasterRepresentationModified(vtkObject* caller,
unsigned long eid,
void* clientData,
void* callData);
459 friend class qMRMLSegmentEditorWidgetPrivate;
462 #endif // __vtkSegmentation_h Invoked if a segment is removed.
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.
std::vector< ConversionPathAndCostType > ConversionPathAndCostListType
int SegmentIdAutogeneratorIndex
Invoked if a representation is created or removed in the segments (e.g., created by conversion from m...
bool MasterRepresentationModifiedEnabled
Modified events of master representations are observed.
Extent is computed as union of extent of all segments, with a single-voxel padding added on each side...
Invoked if new segment is added.
Extent is computed as union of extent of all segments.
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.
Extent of common geometry is used as extent.
vtkCallbackCommand * MasterRepresentationCallbackCommand
Command handling master representation modified events.
std::deque< std::string > SegmentIds
std::vector< vtkSegmentationConverterRule * > ConversionPathType
vtkCallbackCommand * SegmentCallbackCommand
Command handling segment modified events.
bool SegmentModifiedEnabled
Modified events of segments are observed.
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 is computed as union of effective extent of all segments.
void SetConversionParameter(const std::string &name, const std::string &value)
Set a conversion parameter to all rules having this parameter.
vtkSegmentationConverter * Converter
Converter instance.
Invoked when content of any representation (including the master representation) in a segment is chan...
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.
MRML node containing segmentationsSegmentation node stores a set of segments (also known as contours ...
Class that can convert between different representations of a segment.