VTK  9.7.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 #include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
37 
38 VTK_ABI_NAMESPACE_BEGIN
39 class vtkPiecewiseFunctionInternals;
40 
41 class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALMANUAL vtkPiecewiseFunction : public vtkDataObject
42 {
43 public:
44  static vtkPiecewiseFunction* New();
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
48  void DeepCopy(vtkDataObject* f) override;
49  void ShallowCopy(vtkDataObject* f) override;
50 
52  {
53  BINARY_SEARCH = 0,
54  INTERPOLATION_SEARCH = 1,
55  MAX_ENUM = 2
56  };
57 
61  int GetDataObjectType() VTK_FUTURE_CONST override { return VTK_PIECEWISE_FUNCTION; }
62 
66  int GetSize();
67 
69 
75  int AddPoint(double x, double y);
76  int AddPoint(double x, double y, double midpoint, double sharpness);
78 
83  bool RemovePointByIndex(size_t id);
84 
89  int RemovePoint(double x);
90 
95  int RemovePoint(double x, double y);
96 
100  void RemoveAllPoints();
101 
107  void AddSegment(double x1, double y1, double x2, double y2);
108 
113  double GetValue(double x);
114 
116 
122  int GetNodeValue(int index, double val[4]);
123  int SetNodeValue(int index, double val[4]);
125 
127 
134  double* GetDataPointer();
135  void FillFromDataPointer(int, double*);
137 
139 
142  vtkGetVector2Macro(Range, double);
144 
150  int AdjustRange(double range[2]);
151 
153 
161  void GetTable(double x1, double x2, int size, float* table, int stride = 1, int logIncrements = 0,
162  double epsilon = 1e-5);
163  void GetTable(double x1, double x2, int size, double* table, int stride = 1,
164  int logIncrements = 0, double epsilon = 1e-5);
166 
173  void BuildFunctionFromTable(double x1, double x2, int size, double* table, int stride = 1);
174 
176 
184  vtkSetMacro(Clamping, vtkTypeBool);
185  vtkGetMacro(Clamping, vtkTypeBool);
186  vtkBooleanMacro(Clamping, vtkTypeBool);
188 
194  vtkSetMacro(UseLogScale, bool);
195  vtkGetMacro(UseLogScale, bool);
196  vtkBooleanMacro(UseLogScale, bool);
207  const char* GetType();
208 
213  double GetFirstNonZeroValue();
214 
220  void Initialize() override;
221 
223 
227  static vtkPiecewiseFunction* GetData(vtkInformationVector* v, int i = 0);
229 
231 
235  vtkSetMacro(AllowDuplicateScalars, vtkTypeBool);
236  vtkGetMacro(AllowDuplicateScalars, vtkTypeBool);
237  vtkBooleanMacro(AllowDuplicateScalars, vtkTypeBool);
239 
244  int EstimateMinNumberOfSamples(double const& x1, double const& x2);
245 
251  void UpdateSearchMethod(double epsilon = 1e-12, double thresh = 1e-4);
252 
254 
260  int GetAutomaticSearchMethod();
261  void SetUseCustomSearchMethod(bool use);
262  void SetCustomSearchMethod(int type);
263  int GetCustomSearchMethod();
265 
266 protected:
268  ~vtkPiecewiseFunction() override;
269 
277  void SortAndUpdateRange(bool updateSearchMethod = true);
278 
282  bool UpdateRange();
283 
287  double FindMinimumXDistance();
288 
289  // The internal STL structures
290  vtkPiecewiseFunctionInternals* Internal;
291 
292  // Determines the function value outside of defined points
293  // Zero = always return 0.0 outside of defined points
294  // One = clamp to the lowest value below defined points and
295  // highest value above defined points
297 
298  // Array of points ((X,Y) pairs)
299  double* Function;
300 
301  // Min and max range of function point locations
302  double Range[2];
303 
305 
307 
308 private:
310  void operator=(const vtkPiecewiseFunction&) = delete;
311 };
312 
313 VTK_ABI_NAMESPACE_END
314 #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()
Defines a 1D piecewise function.
Store vtkAlgorithm input/output information.
int GetDataObjectType() VTK_FUTURE_CONST override
Return what type of dataset this is.
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
#define VTK_MARSHALMANUAL
a simple class to control print indentation
Definition: vtkIndent.h:28
void UpdateRange(A &min, A &max, const A &value)
Update an existing min - max range with a new prospective value.
Store zero or more vtkInformation instances.
general representation of visualization data
Definition: vtkDataObject.h:55
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.