VTK  9.3.1
vtkPiecewiseFunction.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
3 
31 #ifndef vtkPiecewiseFunction_h
32 #define vtkPiecewiseFunction_h
33 
34 #include "vtkCommonDataModelModule.h" // For export macro
35 #include "vtkDataObject.h"
36 
37 VTK_ABI_NAMESPACE_BEGIN
38 class vtkPiecewiseFunctionInternals;
39 
40 class VTKCOMMONDATAMODEL_EXPORT vtkPiecewiseFunction : public vtkDataObject
41 {
42 public:
43  static vtkPiecewiseFunction* New();
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
47  void DeepCopy(vtkDataObject* f) override;
48  void ShallowCopy(vtkDataObject* f) override;
49 
51  {
52  BINARY_SEARCH = 0,
53  INTERPOLATION_SEARCH = 1,
54  MAX_ENUM = 2
55  };
56 
60  int GetDataObjectType() override { return VTK_PIECEWISE_FUNCTION; }
61 
65  int GetSize();
66 
68 
74  int AddPoint(double x, double y);
75  int AddPoint(double x, double y, double midpoint, double sharpness);
77 
82  bool RemovePointByIndex(size_t id);
83 
88  int RemovePoint(double x);
89 
94  int RemovePoint(double x, double y);
95 
99  void RemoveAllPoints();
100 
106  void AddSegment(double x1, double y1, double x2, double y2);
107 
112  double GetValue(double x);
113 
115 
121  int GetNodeValue(int index, double val[4]);
122  int SetNodeValue(int index, double val[4]);
124 
126 
133  double* GetDataPointer();
134  void FillFromDataPointer(int, double*);
136 
138 
141  vtkGetVector2Macro(Range, double);
143 
149  int AdjustRange(double range[2]);
150 
152 
160  void GetTable(double x1, double x2, int size, float* table, int stride = 1, int logIncrements = 0,
161  double epsilon = 1e-5);
162  void GetTable(double x1, double x2, int size, double* table, int stride = 1,
163  int logIncrements = 0, double epsilon = 1e-5);
165 
172  void BuildFunctionFromTable(double x1, double x2, int size, double* table, int stride = 1);
173 
175 
183  vtkSetMacro(Clamping, vtkTypeBool);
184  vtkGetMacro(Clamping, vtkTypeBool);
185  vtkBooleanMacro(Clamping, vtkTypeBool);
187 
193  vtkSetMacro(UseLogScale, bool);
194  vtkGetMacro(UseLogScale, bool);
195  vtkBooleanMacro(UseLogScale, bool);
206  const char* GetType();
207 
212  double GetFirstNonZeroValue();
213 
219  void Initialize() override;
220 
222 
226  static vtkPiecewiseFunction* GetData(vtkInformationVector* v, int i = 0);
228 
230 
234  vtkSetMacro(AllowDuplicateScalars, vtkTypeBool);
235  vtkGetMacro(AllowDuplicateScalars, vtkTypeBool);
236  vtkBooleanMacro(AllowDuplicateScalars, vtkTypeBool);
238 
243  int EstimateMinNumberOfSamples(double const& x1, double const& x2);
244 
250  void UpdateSearchMethod(double epsilon = 1e-12, double thresh = 1e-4);
251 
253 
259  int GetAutomaticSearchMethod();
260  void SetUseCustomSearchMethod(bool use);
261  void SetCustomSearchMethod(int type);
262  int GetCustomSearchMethod();
264 
265 protected:
267  ~vtkPiecewiseFunction() override;
268 
276  void SortAndUpdateRange(bool updateSearchMethod = true);
277 
281  bool UpdateRange();
282 
286  double FindMinimumXDistance();
287 
288  // The internal STL structures
289  vtkPiecewiseFunctionInternals* Internal;
290 
291  // Determines the function value outside of defined points
292  // Zero = always return 0.0 outside of defined points
293  // One = clamp to the lowest value below defined points and
294  // highest value above defined points
296 
297  // Array of points ((X,Y) pairs)
298  double* Function;
299 
300  // Min and max range of function point locations
301  double Range[2];
302 
304 
306 
307 private:
309  void operator=(const vtkPiecewiseFunction&) = delete;
310 };
311 
312 VTK_ABI_NAMESPACE_END
313 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkDataObject * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
static vtkDataObject * New()
#define VTK_PIECEWISE_FUNCTION
Definition: vtkType.h:70
Defines a 1D piecewise function.
Store vtkAlgorithm input/output information.
virtual void Initialize()
Restore data object to initial state,.
int vtkTypeBool
Definition: vtkABI.h:64
auto Range(IterablePtr iterable, Options &&...opts) -> typename detail::IterableTraits< typename detail::StripPointers< IterablePtr >::type >::RangeType
Generate an iterable STL proxy object for a VTK container.
Definition: vtkRange.h:74
int GetDataObjectType() override
Return what type of dataset this is.
a simple class to control print indentation
Definition: vtkIndent.h:28
void UpdateRange(A &min0, A &max0, const A &value, typename std::enable_if<!std::is_floating_point< A >::value >::type *=nullptr)
Store zero or more vtkInformation instances.
general representation of visualization data
Definition: vtkDataObject.h:54
vtkPiecewiseFunctionInternals * Internal
virtual void DeepCopy(vtkDataObject *src)
The goal of the method is to copy the complete data from src into this object.
virtual void ShallowCopy(vtkDataObject *src)
The goal of the method is to copy the data up to the array pointers only.