VTK  9.7.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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
61 
62 VTK_ABI_NAMESPACE_BEGIN
63 struct vtkLabelMap;
64 
65 class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkPackLabels : public vtkDataSetAlgorithm
66 {
67 public:
69 
73  static vtkPackLabels* New();
75  void PrintSelf(ostream& os, vtkIndent indent) override;
77 
79 
87  vtkDataArray* GetLabels() { return this->LabelsArray; }
89  {
90  return (this->LabelsArray ? this->LabelsArray->GetNumberOfTuples() : 0);
91  }
93 
106  vtkIdTypeArray* GetLabelsCount() { return this->LabelsCount; }
107 
111  enum SortBy
112  {
113  SORT_BY_LABEL_VALUE = 0,
114  SORT_BY_LABEL_COUNT
115  };
116 
118 
126  vtkSetClampMacro(SortBy, int, SORT_BY_LABEL_VALUE, SORT_BY_LABEL_COUNT);
127  vtkGetMacro(SortBy, int);
128  void SortByLabelValue() { this->SetSortBy(SORT_BY_LABEL_VALUE); }
129  void SortByLabelCount() { this->SetSortBy(SORT_BY_LABEL_COUNT); }
131 
133 
145  {
146  VTK_DEFAULT_TYPE = -1
147  };
148  vtkSetMacro(OutputScalarType, int);
149  vtkGetMacro(OutputScalarType, int);
150  void SetOutputScalarTypeToDefault() { this->SetOutputScalarType(VTK_DEFAULT_TYPE); }
151  void SetOutputScalarTypeToUnsignedChar() { this->SetOutputScalarType(VTK_UNSIGNED_CHAR); }
152  void SetOutputScalarTypeToUnsignedShort() { this->SetOutputScalarType(VTK_UNSIGNED_SHORT); }
153  void SetOutputScalarTypeToUnsignedInt() { this->SetOutputScalarType(VTK_UNSIGNED_INT); }
154  void SetOutputScalarTypeToUnsignedLong() { this->SetOutputScalarType(VTK_UNSIGNED_LONG); }
156 
158 
165  vtkSetMacro(BackgroundValue, unsigned long);
166  vtkGetMacro(BackgroundValue, unsigned long);
168 
170 
176  vtkSetMacro(PassPointData, bool);
177  vtkGetMacro(PassPointData, bool);
178  vtkBooleanMacro(PassPointData, bool);
179  vtkSetMacro(PassCellData, bool);
180  vtkGetMacro(PassCellData, bool);
181  vtkBooleanMacro(PassCellData, bool);
182  vtkSetMacro(PassFieldData, bool);
183  vtkGetMacro(PassFieldData, bool);
184  vtkBooleanMacro(PassFieldData, bool);
186 
187 protected:
188  vtkPackLabels();
189  ~vtkPackLabels() override = default;
190 
193  int SortBy;
195  unsigned long BackgroundValue;
199 
201 
202 private:
203  vtkPackLabels(const vtkPackLabels&) = delete;
204  void operator=(const vtkPackLabels&) = delete;
205 };
206 
207 VTK_ABI_NAMESPACE_END
208 #endif
void SortByLabelValue()
Indicate whether to sort the output labels by their input scalars label value (SortByLabelValue), or to sort by the frequency of occurrence of the label values(SortByLabelCount).
#define VTK_UNSIGNED_INT
Definition: vtkType.h:40
unsigned long BackgroundValue
Store vtkAlgorithm input/output information.
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:38
vtkSmartPointer< vtkIdTypeArray > LabelsCount
void SortByLabelCount()
Indicate whether to sort the output labels by their input scalars label value (SortByLabelValue), or to sort by the frequency of occurrence of the label values(SortByLabelCount).
void SetOutputScalarTypeToDefault()
Specify the data type of the output image.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:363
vtkSmartPointer< vtkDataArray > LabelsArray
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetOutputScalarTypeToUnsignedLong()
Specify the data type of the output image.
a simple class to control print indentation
Definition: vtkIndent.h:28
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
void SetOutputScalarTypeToUnsignedShort()
Specify the data type of the output image.
vtkDataArray * GetLabels()
Return the number of and list of labels found in the input label map.
Definition: vtkPackLabels.h:87
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called within ProcessRequest when a request asks the algorithm to do its work.
void SetOutputScalarTypeToUnsignedChar()
Specify the data type of the output image.
void SetOutputScalarTypeToUnsignedInt()
Specify the data type of the output image.
SortBy
Flags to control how sorting of the labels is performed.
renumber segmentation labels into contiguous runs of (potentially) smaller type
Definition: vtkPackLabels.h:65
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:36
vtkIdType GetNumberOfLabels()
Return the number of and list of labels found in the input label map.
Definition: vtkPackLabels.h:88
Store zero or more vtkInformation instances.
vtkIdTypeArray * GetLabelsCount()
Return the frequency of occurrence (i.e., the count) of each label returned in the LabelsArray...
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:42
#define VTK_MARSHALAUTO
Superclass for algorithms that produce output of the same type as input.
DefaultScalarType
Specify the data type of the output image.
static vtkDataSetAlgorithm * New()