VTK  9.7.1
vtkThreshold.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
42 #ifndef vtkThreshold_h
43 #define vtkThreshold_h
44 
45 #include "vtkFiltersCoreModule.h" // For export macro
47 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
48 
49 #define VTK_ATTRIBUTE_MODE_DEFAULT 0
50 #define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1
51 #define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2
52 
53 // order / values are important because of the SetClampMacro
54 #define VTK_COMPONENT_MODE_USE_SELECTED 0
55 #define VTK_COMPONENT_MODE_USE_ALL 1
56 #define VTK_COMPONENT_MODE_USE_ANY 2
57 
58 VTK_ABI_NAMESPACE_BEGIN
59 class vtkDataArray;
60 class vtkIdList;
61 
62 class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkThreshold : public vtkUnstructuredGridAlgorithm
63 {
64 public:
65  static vtkThreshold* New();
67  void PrintSelf(ostream& os, vtkIndent indent) override;
68 
76  {
77  THRESHOLD_BETWEEN = 0,
79  THRESHOLD_UPPER
80  };
81 
83 
87  void SetThresholdFunction(int function);
88  int GetThresholdFunction();
90 
92 
96  vtkSetMacro(UpperThreshold, double);
97  vtkSetMacro(LowerThreshold, double);
98  vtkGetMacro(UpperThreshold, double);
99  vtkGetMacro(LowerThreshold, double);
101 
103 
111  vtkSetClampMacro(ComponentMode, int, VTK_COMPONENT_MODE_USE_SELECTED, VTK_COMPONENT_MODE_USE_ANY);
112  vtkGetMacro(ComponentMode, int);
114  void SetComponentModeToUseAll() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL); }
115  void SetComponentModeToUseAny() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY); }
116  const char* GetComponentModeAsString();
118 
120 
126  vtkSetClampMacro(SelectedComponent, int, 0, VTK_INT_MAX);
127  vtkGetMacro(SelectedComponent, int);
129 
131 
137  vtkSetMacro(AllScalars, vtkTypeBool);
138  vtkGetMacro(AllScalars, vtkTypeBool);
139  vtkBooleanMacro(AllScalars, vtkTypeBool);
141 
143 
151  vtkSetMacro(UseContinuousCellRange, vtkTypeBool);
152  vtkGetMacro(UseContinuousCellRange, vtkTypeBool);
153  vtkBooleanMacro(UseContinuousCellRange, vtkTypeBool);
155 
157 
162  vtkSetMacro(Invert, bool);
163  vtkGetMacro(Invert, bool);
164  vtkBooleanMacro(Invert, bool);
166 
168 
173  vtkSetMacro(OutputPointsPrecision, int);
174  vtkGetMacro(OutputPointsPrecision, int);
176 
178 
191  int Lower(double s) const;
192  int Upper(double s) const;
193  int Between(double s) const;
195 protected:
196  vtkThreshold();
197  ~vtkThreshold() override;
198 
199  // Usual data generation method
201 
202  int FillInputPortInformation(int port, vtkInformation* info) override;
203 
206  vtkTypeBool AllScalars = 1;
207  vtkTypeBool UseContinuousCellRange = 0;
208  bool Invert = false;
209  int AttributeMode = -1;
210  int ComponentMode = VTK_COMPONENT_MODE_USE_SELECTED;
211  int SelectedComponent = 0;
212  int OutputPointsPrecision = DEFAULT_PRECISION;
213 
214  int (vtkThreshold::*ThresholdFunction)(double s) const = &vtkThreshold::Between;
215 
216  template <typename TScalarArray>
218  struct EvaluateCellsWorker;
219 
220  template <typename TScalarsArray>
221  int EvaluateComponents(TScalarsArray& scalars, vtkIdType id);
222  template <typename TScalarsArray>
223  int EvaluateCell(TScalarsArray& scalars, const vtkIdType* cellPts, vtkIdType numCellPts);
224  template <typename TScalarsArray>
225  int EvaluateCell(TScalarsArray& scalars, int c, const vtkIdType* cellPts, vtkIdType numCellPts);
226 
227 private:
233  template <typename TScalarsArray>
234  bool ComputeMagnitude(double& magnitude, const TScalarsArray& scalars, vtkIdType id);
235 
236  vtkThreshold(const vtkThreshold&) = delete;
237  void operator=(const vtkThreshold&) = delete;
238 
239  int NumberOfComponents;
240 };
241 
242 VTK_ABI_NAMESPACE_END
243 #endif
double UpperThreshold
Definition: vtkThreshold.h:205
double LowerThreshold
Definition: vtkThreshold.h:204
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
Store vtkAlgorithm input/output information.
#define VTK_INT_MAX
Definition: vtkType.h:192
static vtkUnstructuredGridAlgorithm * New()
int vtkIdType
Definition: vtkType.h:363
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
int vtkTypeBool
Definition: vtkABI.h:64
extracts cells where scalar value in cell satisfies threshold criterion
Definition: vtkThreshold.h:62
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:28
#define VTK_COMPONENT_MODE_USE_SELECTED
Definition: vtkThreshold.h:54
list of point or cell ids
Definition: vtkIdList.h:25
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
#define VTK_COMPONENT_MODE_USE_ALL
Definition: vtkThreshold.h:55
Superclass for algorithms that produce only unstructured grid as output.
void SetComponentModeToUseSelected()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:113
#define vtkThreshold
Definition: vtkmThreshold.h:29
void SetComponentModeToUseAll()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:114
#define VTK_COMPONENT_MODE_USE_ANY
Definition: vtkThreshold.h:56
Store zero or more vtkInformation instances.
#define VTK_MARSHALAUTO
int Between(double s) const
Methods used for thresholding.
ThresholdType
Possible values for the threshold function:
Definition: vtkThreshold.h:75
void SetComponentModeToUseAny()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:115