VTK  9.1.0
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
46#ifndef vtkPiecewiseFunction_h
47#define vtkPiecewiseFunction_h
48
49#include "vtkCommonDataModelModule.h" // For export macro
50#include "vtkDataObject.h"
51
52class vtkPiecewiseFunctionInternals;
53
54class VTKCOMMONDATAMODEL_EXPORT vtkPiecewiseFunction : public vtkDataObject
55{
56public:
59 void PrintSelf(ostream& os, vtkIndent indent) override;
60
61 void DeepCopy(vtkDataObject* f) override;
62 void ShallowCopy(vtkDataObject* f) override;
63
67 int GetDataObjectType() override { return VTK_PIECEWISE_FUNCTION; }
68
72 int GetSize();
73
75
81 int AddPoint(double x, double y);
82 int AddPoint(double x, double y, double midpoint, double sharpness);
84
89 bool RemovePointByIndex(size_t id);
90
95 int RemovePoint(double x);
96
101 int RemovePoint(double x, double y);
102
107
113 void AddSegment(double x1, double y1, double x2, double y2);
114
119 double GetValue(double x);
120
122
128 int GetNodeValue(int index, double val[4]);
129 int SetNodeValue(int index, double val[4]);
131
133
140 double* GetDataPointer();
141 void FillFromDataPointer(int, double*);
143
145
148 vtkGetVector2Macro(Range, double);
150
156 int AdjustRange(double range[2]);
157
159
166 double x1, double x2, int size, float* table, int stride = 1, int logIncrements = 0);
168 double x1, double x2, int size, double* table, int stride = 1, int logIncrements = 0);
170
177 void BuildFunctionFromTable(double x1, double x2, int size, double* table, int stride = 1);
178
180
188 vtkSetMacro(Clamping, vtkTypeBool);
189 vtkGetMacro(Clamping, vtkTypeBool);
190 vtkBooleanMacro(Clamping, vtkTypeBool);
192
198 vtkSetMacro(UseLogScale, bool);
199 vtkGetMacro(UseLogScale, bool);
200 vtkBooleanMacro(UseLogScale, bool);
211 const char* GetType();
212
218
224 void Initialize() override;
225
227
233
235
239 vtkSetMacro(AllowDuplicateScalars, vtkTypeBool);
240 vtkGetMacro(AllowDuplicateScalars, vtkTypeBool);
241 vtkBooleanMacro(AllowDuplicateScalars, vtkTypeBool);
243
248 int EstimateMinNumberOfSamples(double const& x1, double const& x2);
249
250protected:
253
260
265
270
271 // The internal STL structures
272 vtkPiecewiseFunctionInternals* Internal;
273
274 // Determines the function value outside of defined points
275 // Zero = always return 0.0 outside of defined points
276 // One = clamp to the lowest value below defined points and
277 // highest value above defined points
279
280 // Array of points ((X,Y) pairs)
281 double* Function;
282
283 // Min and max range of function point locations
284 double Range[2];
285
287
289
290private:
292 void operator=(const vtkPiecewiseFunction&) = delete;
293};
294
295#endif
general representation of visualization data
Definition: vtkDataObject.h:69
a simple class to control print indentation
Definition: vtkIndent.h:43
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Defines a 1D piecewise function.
int SetNodeValue(int index, double val[4])
For the node specified by index, set/get the location (X), value (Y), midpoint, and sharpness values ...
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)
Add points to the function.
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)
Remove the first point found at the given x location Return the index of the remove point if any,...
void GetTable(double x1, double x2, int size, double *table, int stride=1, int logIncrements=0)
Fills in an array of function values evaluated at regular intervals.
int AddPoint(double x, double y)
Add points to the function.
double GetFirstNonZeroValue()
Returns the first point location which precedes a non-zero segment of the function.
int RemovePoint(double x, double y)
Remove the first point found at the given x and y location Return the index of the remove point if an...
void SortAndUpdateRange()
Internal method to sort the vector and update the Range whenever a node is added, edited or removed.
vtkPiecewiseFunctionInternals * Internal
void FillFromDataPointer(int, double *)
Returns a pointer to the data stored in the table.
void BuildFunctionFromTable(double x1, double x2, int size, double *table, int stride=1)
Constructs a piecewise function from a table.
static vtkPiecewiseFunction * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
int GetSize()
Get the number of points used to specify the function.
~vtkPiecewiseFunction() override
void Initialize() override
Clears out the current function.
bool UpdateRange()
Returns true if the range has been updated and Modified() has been called.
void RemoveAllPoints()
Removes all points from the function.
void DeepCopy(vtkDataObject *f) override
Shallow and Deep copy.
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.
const char * GetType()
Return the type of function: Function Types: 0 : Constant (No change in slope between end points) 1 :...
void AddSegment(double x1, double y1, double x2, double y2)
Add a line segment to the function.
static vtkPiecewiseFunction * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
int EstimateMinNumberOfSamples(double const &x1, double const &x2)
Estimates the minimum size of a table such that it would correctly sample this function.
bool RemovePointByIndex(size_t id)
Remove a point from the function at a given id Return true if point has been found and removed,...
double * GetDataPointer()
Returns a pointer to the data stored in the table.
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.
static vtkPiecewiseFunction * New()
@ 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:82