VTK  9.2.6
vtkPiecewiseFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPiecewiseFunction.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
43 #ifndef vtkPiecewiseFunction_h
44 #define vtkPiecewiseFunction_h
45 
46 #include "vtkCommonDataModelModule.h" // For export macro
47 #include "vtkDataObject.h"
48 
49 class vtkPiecewiseFunctionInternals;
50 
51 class VTKCOMMONDATAMODEL_EXPORT vtkPiecewiseFunction : public vtkDataObject
52 {
53 public:
54  static vtkPiecewiseFunction* New();
56  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
58  void DeepCopy(vtkDataObject* f) override;
59  void ShallowCopy(vtkDataObject* f) override;
60 
64  int GetDataObjectType() override { return VTK_PIECEWISE_FUNCTION; }
65 
69  int GetSize();
70 
72 
78  int AddPoint(double x, double y);
79  int AddPoint(double x, double y, double midpoint, double sharpness);
81 
86  bool RemovePointByIndex(size_t id);
87 
92  int RemovePoint(double x);
93 
98  int RemovePoint(double x, double y);
99 
103  void RemoveAllPoints();
104 
110  void AddSegment(double x1, double y1, double x2, double y2);
111 
116  double GetValue(double x);
117 
119 
125  int GetNodeValue(int index, double val[4]);
126  int SetNodeValue(int index, double val[4]);
128 
130 
137  double* GetDataPointer();
138  void FillFromDataPointer(int, double*);
140 
142 
145  vtkGetVector2Macro(Range, double);
147 
153  int AdjustRange(double range[2]);
154 
156 
162  void GetTable(
163  double x1, double x2, int size, float* table, int stride = 1, int logIncrements = 0);
164  void GetTable(
165  double x1, double x2, int size, double* table, int stride = 1, int logIncrements = 0);
167 
174  void BuildFunctionFromTable(double x1, double x2, int size, double* table, int stride = 1);
175 
177 
185  vtkSetMacro(Clamping, vtkTypeBool);
186  vtkGetMacro(Clamping, vtkTypeBool);
187  vtkBooleanMacro(Clamping, vtkTypeBool);
189 
195  vtkSetMacro(UseLogScale, bool);
196  vtkGetMacro(UseLogScale, bool);
197  vtkBooleanMacro(UseLogScale, bool);
208  const char* GetType();
209 
214  double GetFirstNonZeroValue();
215 
221  void Initialize() override;
222 
224 
228  static vtkPiecewiseFunction* GetData(vtkInformationVector* v, int i = 0);
230 
232 
236  vtkSetMacro(AllowDuplicateScalars, vtkTypeBool);
237  vtkGetMacro(AllowDuplicateScalars, vtkTypeBool);
238  vtkBooleanMacro(AllowDuplicateScalars, vtkTypeBool);
240 
245  int EstimateMinNumberOfSamples(double const& x1, double const& x2);
246 
247 protected:
249  ~vtkPiecewiseFunction() override;
250 
256  void SortAndUpdateRange();
257 
261  bool UpdateRange();
262 
266  double FindMinimumXDistance();
267 
268  // The internal STL structures
269  vtkPiecewiseFunctionInternals* Internal;
270 
271  // Determines the function value outside of defined points
272  // Zero = always return 0.0 outside of defined points
273  // One = clamp to the lowest value below defined points and
274  // highest value above defined points
276 
277  // Array of points ((X,Y) pairs)
278  double* Function;
279 
280  // Min and max range of function point locations
281  double Range[2];
282 
284 
286 
287 private:
289  void operator=(const vtkPiecewiseFunction&) = delete;
290 };
291 
292 #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.
void UpdateRange(A &min0, A &max0, const A &value, typename std::enable_if<!std::is_floating_point< A >::value >::type *=0)
static vtkDataObject * New()
#define VTK_PIECEWISE_FUNCTION
Definition: vtkType.h:82
Defines a 1D piecewise function.
Store vtkAlgorithm input/output information.
virtual void Initialize()
Restore data object to initial state,.
int vtkTypeBool
Definition: vtkABI.h:69
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:85
int GetDataObjectType() override
Return what type of dataset this is.
a simple class to control print indentation
Definition: vtkIndent.h:39
Store zero or more vtkInformation instances.
general representation of visualization data
Definition: vtkDataObject.h:65
vtkPiecewiseFunctionInternals * Internal
virtual void DeepCopy(vtkDataObject *src)
Shallow and Deep copy.
virtual void ShallowCopy(vtkDataObject *src)
Shallow and Deep copy.