VTK  9.0.3
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 
37 #ifndef vtkPiecewiseFunction_h
38 #define vtkPiecewiseFunction_h
39 
40 #include "vtkCommonDataModelModule.h" // For export macro
41 #include "vtkDataObject.h"
42 
43 class vtkPiecewiseFunctionInternals;
44 
45 class VTKCOMMONDATAMODEL_EXPORT vtkPiecewiseFunction : public vtkDataObject
46 {
47 public:
50  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
52  void DeepCopy(vtkDataObject* f) override;
53  void ShallowCopy(vtkDataObject* f) override;
54 
58  int GetDataObjectType() override { return VTK_PIECEWISE_FUNCTION; }
59 
63  int GetSize();
64 
66 
71  int AddPoint(double x, double y);
72  int AddPoint(double x, double y, double midpoint, double sharpness);
73  int RemovePoint(double x);
75 
80 
87  void AddSegment(double x1, double y1, double x2, double y2);
88 
93  double GetValue(double x);
94 
96 
102  int GetNodeValue(int index, double val[4]);
103  int SetNodeValue(int index, double val[4]);
105 
107 
114  double* GetDataPointer();
115  void FillFromDataPointer(int, double*);
117 
119 
122  vtkGetVector2Macro(Range, double);
124 
130  int AdjustRange(double range[2]);
131 
133 
139  void GetTable(
140  double x1, double x2, int size, float* table, int stride = 1, int logIncrements = 0);
141  void GetTable(
142  double x1, double x2, int size, double* table, int stride = 1, int logIncrements = 0);
144 
151  void BuildFunctionFromTable(double x1, double x2, int size, double* table, int stride = 1);
152 
154 
162  vtkSetMacro(Clamping, vtkTypeBool);
163  vtkGetMacro(Clamping, vtkTypeBool);
164  vtkBooleanMacro(Clamping, vtkTypeBool);
166 
172  vtkSetMacro(UseLogScale, bool);
173  vtkGetMacro(UseLogScale, bool);
174  vtkBooleanMacro(UseLogScale, bool);
185  const char* GetType();
186 
192 
198  void Initialize() override;
199 
201 
207 
209 
213  vtkSetMacro(AllowDuplicateScalars, vtkTypeBool);
214  vtkGetMacro(AllowDuplicateScalars, vtkTypeBool);
215  vtkBooleanMacro(AllowDuplicateScalars, vtkTypeBool);
217 
222  int EstimateMinNumberOfSamples(double const& x1, double const& x2);
223 
224 protected:
227 
228  // Internal method to sort the vector and update the
229  // Range whenever a node is added, edited or removed.
230  // It always calls Modified().
232  // Returns true if the range has been updated and Modified() has been called
233  bool UpdateRange();
234 
239 
240  // The internal STL structures
241  vtkPiecewiseFunctionInternals* Internal;
242 
243  // Determines the function value outside of defined points
244  // Zero = always return 0.0 outside of defined points
245  // One = clamp to the lowest value below defined points and
246  // highest value above defined points
248 
249  // Array of points ((X,Y) pairs)
250  double* Function;
251 
252  // Min and max range of function point locations
253  double Range[2];
254 
256 
258 
259 private:
261  void operator=(const vtkPiecewiseFunction&) = delete;
262 };
263 
264 #endif
general representation of visualization data
Definition: vtkDataObject.h:60
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Defines a 1D piecewise function.
int SetNodeValue(int index, double val[4])
int AdjustRange(double range[2])
Remove all points out of the new range, and make sure there is a point at each end of that range.
double GetValue(double x)
Returns the value of the function at the specified location using the specified interpolation.
int AddPoint(double x, double y, double midpoint, double sharpness)
static vtkPiecewiseFunction * GetData(vtkInformationVector *v, int i=0)
void GetTable(double x1, double x2, int size, float *table, int stride=1, int logIncrements=0)
Fills in an array of function values evaluated at regular intervals.
int RemovePoint(double x)
double * GetDataPointer()
Returns a pointer to the data stored in the table.
void GetTable(double x1, double x2, int size, double *table, int stride=1, int logIncrements=0)
int AddPoint(double x, double y)
Add/Remove points to/from the function.
double GetFirstNonZeroValue()
Returns the first point location which precedes a non-zero segment of the function.
vtkPiecewiseFunctionInternals * Internal
void FillFromDataPointer(int, double *)
void BuildFunctionFromTable(double x1, double x2, int size, double *table, int stride=1)
Constructs a piecewise function from a table.
int GetSize()
Get the number of points used to specify the function.
~vtkPiecewiseFunction() override
void Initialize() override
Clears out the current function.
void RemoveAllPoints()
Removes all points from the function.
void DeepCopy(vtkDataObject *f) override
static vtkPiecewiseFunction * New()
const char * GetType()
Return the type of function: Function Types: 0 : Constant (No change in slope between end points) 1 :...
double FindMinimumXDistance()
Traverses the nodes to find the minimum distance.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkPiecewiseFunction * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
void AddSegment(double x1, double y1, double x2, double y2)
Add a line segment to the function.
int EstimateMinNumberOfSamples(double const &x1, double const &x2)
Estimates the minimum size of a table such that it would correctly sample this function.
int GetNodeValue(int index, double val[4])
For the node specified by index, set/get the location (X), value (Y), midpoint, and sharpness values ...
int GetDataObjectType() override
Return what type of dataset this is.
void ShallowCopy(vtkDataObject *f) override
Shallow and Deep copy.
@ info
Definition: vtkX3D.h:382
@ range
Definition: vtkX3D.h:244
@ size
Definition: vtkX3D.h:259
@ index
Definition: vtkX3D.h:252
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 vtkTypeBool
Definition: vtkABI.h:69
#define VTK_PIECEWISE_FUNCTION
Definition: vtkType.h:90