VTK  9.5.20250910
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
151#ifndef vtkThreshold_h
152#define vtkThreshold_h
153
154#include "vtkFiltersCoreModule.h" // For export macro
156#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
157
158#define VTK_ATTRIBUTE_MODE_DEFAULT 0
159#define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1
160#define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2
161
162// order / values are important because of the SetClampMacro
163#define VTK_COMPONENT_MODE_USE_SELECTED 0
164#define VTK_COMPONENT_MODE_USE_ALL 1
165#define VTK_COMPONENT_MODE_USE_ANY 2
166
167VTK_ABI_NAMESPACE_BEGIN
168class vtkDataArray;
169class vtkIdList;
170
172{
173public:
174 static vtkThreshold* New();
176 void PrintSelf(ostream& os, vtkIndent indent) override;
177
185 {
186 THRESHOLD_BETWEEN = 0,
188 THRESHOLD_UPPER
189 };
190
192
196 void SetThresholdFunction(int function);
199
201
205 vtkSetMacro(UpperThreshold, double);
206 vtkSetMacro(LowerThreshold, double);
207 vtkGetMacro(UpperThreshold, double);
208 vtkGetMacro(LowerThreshold, double);
210
212
220 vtkSetClampMacro(ComponentMode, int, VTK_COMPONENT_MODE_USE_SELECTED, VTK_COMPONENT_MODE_USE_ANY);
221 vtkGetMacro(ComponentMode, int);
223 void SetComponentModeToUseAll() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL); }
224 void SetComponentModeToUseAny() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY); }
227
229
235 vtkSetClampMacro(SelectedComponent, int, 0, VTK_INT_MAX);
236 vtkGetMacro(SelectedComponent, int);
238
240
246 vtkSetMacro(AllScalars, vtkTypeBool);
247 vtkGetMacro(AllScalars, vtkTypeBool);
248 vtkBooleanMacro(AllScalars, vtkTypeBool);
250
252
260 vtkSetMacro(UseContinuousCellRange, vtkTypeBool);
261 vtkGetMacro(UseContinuousCellRange, vtkTypeBool);
262 vtkBooleanMacro(UseContinuousCellRange, vtkTypeBool);
264
266
271 vtkSetMacro(Invert, bool);
272 vtkGetMacro(Invert, bool);
273 vtkBooleanMacro(Invert, bool);
275
277
282 vtkSetMacro(OutputPointsPrecision, int);
283 vtkGetMacro(OutputPointsPrecision, int);
285
287
300 int Lower(double s) const;
301 int Upper(double s) const;
302 int Between(double s) const;
304protected:
306 ~vtkThreshold() override;
307
308 // Usual data generation method
310
311 int FillInputPortInformation(int port, vtkInformation* info) override;
312
315 vtkTypeBool AllScalars = 1;
316 vtkTypeBool UseContinuousCellRange = 0;
317 bool Invert = false;
318 int AttributeMode = -1;
320 int SelectedComponent = 0;
321 int OutputPointsPrecision = DEFAULT_PRECISION;
322
323 int (vtkThreshold::*ThresholdFunction)(double s) const = &vtkThreshold::Between;
324
325 template <typename TScalarArray>
327 struct EvaluateCellsWorker;
328
329 template <typename TScalarsArray>
330 int EvaluateComponents(TScalarsArray& scalars, vtkIdType id);
331 template <typename TScalarsArray>
332 int EvaluateCell(TScalarsArray& scalars, const vtkIdType* cellPts, vtkIdType numCellPts);
333 template <typename TScalarsArray>
334 int EvaluateCell(TScalarsArray& scalars, int c, const vtkIdType* cellPts, vtkIdType numCellPts);
335
336private:
342 template <typename TScalarsArray>
343 bool ComputeMagnitude(double& magnitude, const TScalarsArray& scalars, vtkIdType id);
344
345 vtkThreshold(const vtkThreshold&) = delete;
346 void operator=(const vtkThreshold&) = delete;
347
348 int NumberOfComponents;
349};
350
351VTK_ABI_NAMESPACE_END
352#endif
abstract superclass for arrays of numeric data
list of point or cell ids
Definition vtkIdList.h:133
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
extracts cells where scalar value in cell satisfies threshold criterion
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int EvaluateCell(TScalarsArray &scalars, const vtkIdType *cellPts, vtkIdType numCellPts)
void SetThresholdFunction(int function)
Get/Set the threshold method, defining which threshold bounds to use.
void SetComponentModeToUseSelected()
Control how the decision of in / out is made with multi-component data.
void SetComponentModeToUseAny()
Control how the decision of in / out is made with multi-component data.
ThresholdType
Possible values for the threshold function:
void SetComponentModeToUseAll()
Control how the decision of in / out is made with multi-component data.
double LowerThreshold
const char * GetComponentModeAsString()
Control how the decision of in / out is made with multi-component data.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
int EvaluateComponents(TScalarsArray &scalars, vtkIdType id)
double UpperThreshold
int Upper(double s) const
Methods used for thresholding.
~vtkThreshold() override
int Between(double s) const
Methods used for thresholding.
int Lower(double s) const
Methods used for thresholding.
int EvaluateCell(TScalarsArray &scalars, int c, const vtkIdType *cellPts, vtkIdType numCellPts)
int GetThresholdFunction()
Get/Set the threshold method, defining which threshold bounds to use.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
static vtkThreshold * New()
Superclass for algorithms that produce only unstructured grid as output.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_COMPONENT_MODE_USE_SELECTED
#define VTK_COMPONENT_MODE_USE_ALL
#define VTK_COMPONENT_MODE_USE_ANY
int vtkIdType
Definition vtkType.h:332
#define VTK_INT_MAX
Definition vtkType.h:161
#define VTK_MARSHALAUTO