VTK: Filters/Core/vtkPackLabels.h Source File

| VTK 9.3.1

vtkPackLabels.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
52 #ifndef vtkPackLabels_h
53 #define vtkPackLabels_h
54
55 #include "vtkDataArray.h" // For returning list of labels
56 #include "vtkDataSetAlgorithm.h"
57 #include "vtkFiltersCoreModule.h" // For export macro
58 #include "vtkIdTypeArray.h" // For returning count of labels
59 #include "vtkSmartPointer.h" // For returning list of labels
60
61 VTK_ABI_NAMESPACE_BEGIN
62 struct vtkLabelMap;
63
64 class VTKFILTERSCORE_EXPORT vtkPackLabels : public vtkDataSetAlgorithm
65 {
66 public:
68
72 static vtkPackLabels* New();
73 vtkTypeMacro(vtkPackLabels, vtkDataSetAlgorithm);
74 void PrintSelf(ostream& os, vtkIndent indent) override;
76
78
86 vtkDataArray* GetLabels() { return this->LabelsArray; }
87 vtkIdType GetNumberOfLabels()
88 {
89 return (this->LabelsArray ? this->LabelsArray->GetNumberOfTuples() : 0);
90 }
92
105 vtkIdTypeArray* GetLabelsCount() { return this->LabelsCount; }
106
110 enum SortBy
111 {
112 SORT_BY_LABEL_VALUE = 0,
113 SORT_BY_LABEL_COUNT
114 };
115
117
125 vtkSetClampMacro(SortBy, int, SORT_BY_LABEL_VALUE, SORT_BY_LABEL_COUNT);
126 vtkGetMacro(SortBy, int);
127 void SortByLabelValue() { this->SetSortBy(SORT_BY_LABEL_VALUE); }
128 void SortByLabelCount() { this->SetSortBy(SORT_BY_LABEL_COUNT); }
130
132
143 enum DefaultScalarType
144 {
145 VTK_DEFAULT_TYPE = -1
146 };
147 vtkSetMacro(OutputScalarType, int);
148 vtkGetMacro(OutputScalarType, int);
149 void SetOutputScalarTypeToDefault() { this->SetOutputScalarType(VTK_DEFAULT_TYPE); }
150 void SetOutputScalarTypeToUnsignedChar() { this->SetOutputScalarType(VTK_UNSIGNED_CHAR); }
151 void SetOutputScalarTypeToUnsignedShort() { this->SetOutputScalarType(VTK_UNSIGNED_SHORT); }
152 void SetOutputScalarTypeToUnsignedInt() { this->SetOutputScalarType(VTK_UNSIGNED_INT); }
153 void SetOutputScalarTypeToUnsignedLong() { this->SetOutputScalarType(VTK_UNSIGNED_LONG); }
155
157
164 vtkSetMacro(BackgroundValue, unsigned long);
165 vtkGetMacro(BackgroundValue, unsigned long);
167
169
175 vtkSetMacro(PassPointData, bool);
176 vtkGetMacro(PassPointData, bool);
177 vtkBooleanMacro(PassPointData, bool);
178 vtkSetMacro(PassCellData, bool);
179 vtkGetMacro(PassCellData, bool);
180 vtkBooleanMacro(PassCellData, bool);
181 vtkSetMacro(PassFieldData, bool);
182 vtkGetMacro(PassFieldData, bool);
183 vtkBooleanMacro(PassFieldData, bool);
185
186 protected:
187 vtkPackLabels();
188 ~vtkPackLabels() override = default;
189
190 vtkSmartPointer<vtkDataArray> LabelsArray;
191 vtkSmartPointer<vtkIdTypeArray> LabelsCount;
192 int SortBy;
193 int OutputScalarType;
194 unsigned long BackgroundValue;
195 bool PassPointData;
196 bool PassCellData;
197 bool PassFieldData;
198
199 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
200
201 private:
202 vtkPackLabels(const vtkPackLabels&) = delete;
203 void operator=(const vtkPackLabels&) = delete;
204 };
205
206 VTK_ABI_NAMESPACE_END
207 #endif
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkDataSetAlgorithm
Superclass for algorithms that produce output of the same type as input.
Definition: vtkDataSetAlgorithm.h:38
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:37
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:40
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:72
vtkPackLabels
renumber segmentation labels into contiguous runs of (potentially) smaller type
Definition: vtkPackLabels.h:65
vtkPackLabels::New
static vtkPackLabels * New()
Standard methods for instantiation, obtaining type information, and printing an object.
vtkPackLabels::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instantiation, obtaining type information, and printing an object.
vtkPackLabels::SetOutputScalarTypeToUnsignedChar
void SetOutputScalarTypeToUnsignedChar()
Specify the data type of the output image.
Definition: vtkPackLabels.h:150
vtkPackLabels::PassFieldData
bool PassFieldData
Definition: vtkPackLabels.h:197
vtkPackLabels::SetOutputScalarTypeToUnsignedShort
void SetOutputScalarTypeToUnsignedShort()
Specify the data type of the output image.
Definition: vtkPackLabels.h:151
vtkPackLabels::~vtkPackLabels
~vtkPackLabels() override=default
vtkPackLabels::SortByLabelValue
void SortByLabelValue()
Indicate whether to sort the output labels by their input scalars label value (SortByLabelValue),...
Definition: vtkPackLabels.h:127
vtkPackLabels::GetLabels
vtkDataArray * GetLabels()
Return the number of and list of labels found in the input label map.
Definition: vtkPackLabels.h:86
vtkPackLabels::PassPointData
bool PassPointData
Definition: vtkPackLabels.h:195
vtkPackLabels::SetOutputScalarTypeToDefault
void SetOutputScalarTypeToDefault()
Specify the data type of the output image.
Definition: vtkPackLabels.h:149
vtkPackLabels::GetNumberOfLabels
vtkIdType GetNumberOfLabels()
Return the number of and list of labels found in the input label map.
Definition: vtkPackLabels.h:87
vtkPackLabels::SortBy
int SortBy
Definition: vtkPackLabels.h:192
vtkPackLabels::BackgroundValue
unsigned long BackgroundValue
Definition: vtkPackLabels.h:194
vtkPackLabels::PassCellData
bool PassCellData
Definition: vtkPackLabels.h:196
vtkPackLabels::LabelsCount
vtkSmartPointer< vtkIdTypeArray > LabelsCount
Definition: vtkPackLabels.h:191
vtkPackLabels::SetOutputScalarTypeToUnsignedInt
void SetOutputScalarTypeToUnsignedInt()
Specify the data type of the output image.
Definition: vtkPackLabels.h:152
vtkPackLabels::SortBy
SortBy
Flags to control how sorting of the labels is performed.
Definition: vtkPackLabels.h:111
vtkPackLabels::SortByLabelCount
void SortByLabelCount()
Indicate whether to sort the output labels by their input scalars label value (SortByLabelValue),...
Definition: vtkPackLabels.h:128
vtkPackLabels::GetLabelsCount
vtkIdTypeArray * GetLabelsCount()
Return the frequency of occurence (i.e., the count) of each label returned in the LabelsArray.
Definition: vtkPackLabels.h:105
vtkPackLabels::vtkPackLabels
vtkPackLabels()
vtkPackLabels::DefaultScalarType
DefaultScalarType
Specify the data type of the output image.
Definition: vtkPackLabels.h:144
vtkPackLabels::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called within ProcessRequest when a request asks the algorithm to do its work.
vtkPackLabels::LabelsArray
vtkSmartPointer< vtkDataArray > LabelsArray
Definition: vtkPackLabels.h:190
vtkPackLabels::OutputScalarType
int OutputScalarType
Definition: vtkPackLabels.h:193
vtkPackLabels::SetOutputScalarTypeToUnsignedLong
void SetOutputScalarTypeToUnsignedLong()
Specify the data type of the output image.
Definition: vtkPackLabels.h:153
vtkSmartPointer< vtkDataArray >
vtkDataArray.h
vtkDataSetAlgorithm.h
vtkIdTypeArray.h
vtkSmartPointer.h
vtkIdType
int vtkIdType
Definition: vtkType.h:315
VTK_UNSIGNED_INT
#define VTK_UNSIGNED_INT
Definition: vtkType.h:39
VTK_UNSIGNED_CHAR
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:35
VTK_UNSIGNED_SHORT
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:37
VTK_UNSIGNED_LONG
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:41