VTK: Common/DataModel/vtkPiecewiseFunction.h Source File

| 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
40 #ifndef vtkPiecewiseFunction_h
41 #define vtkPiecewiseFunction_h
42
43 #include "vtkCommonDataModelModule.h" // For export macro
44 #include "vtkDataObject.h"
45
46 VTK_ABI_NAMESPACE_BEGIN
47 class vtkPiecewiseFunctionInternals;
48
49 class VTKCOMMONDATAMODEL_EXPORT vtkPiecewiseFunction : public vtkDataObject
50 {
51 public:
52 static vtkPiecewiseFunction* New();
53 vtkTypeMacro(vtkPiecewiseFunction, vtkDataObject);
54 void PrintSelf(ostream& os, vtkIndent indent) override;
55
56 void DeepCopy(vtkDataObject* f) override;
57 void ShallowCopy(vtkDataObject* f) override;
58
59 enum SearchMethod
60 {
61 BINARY_SEARCH = 0,
62 INTERPOLATION_SEARCH = 1,
63 MAX_ENUM = 2
64 };
65
69 int GetDataObjectType() override { return VTK_PIECEWISE_FUNCTION; }
70
74 int GetSize();
75
77
83 int AddPoint(double x, double y);
84 int AddPoint(double x, double y, double midpoint, double sharpness);
86
91 bool RemovePointByIndex(size_t id);
92
97 int RemovePoint(double x);
98
103 int RemovePoint(double x, double y);
104
108 void RemoveAllPoints();
109
115 void AddSegment(double x1, double y1, double x2, double y2);
116
121 double GetValue(double x);
122
124
130 int GetNodeValue(int index, double val[4]);
131 int SetNodeValue(int index, double val[4]);
133
135
142 double* GetDataPointer();
143 void FillFromDataPointer(int, double*);
145
147
150 vtkGetVector2Macro(Range, double);
152
158 int AdjustRange(double range[2]);
159
161
169 void GetTable(double x1, double x2, int size, float* table, int stride = 1, int logIncrements = 0,
170 double epsilon = 1e-5);
171 void GetTable(double x1, double x2, int size, double* table, int stride = 1,
172 int logIncrements = 0, double epsilon = 1e-5);
174
181 void BuildFunctionFromTable(double x1, double x2, int size, double* table, int stride = 1);
182
184
192 vtkSetMacro(Clamping, vtkTypeBool);
193 vtkGetMacro(Clamping, vtkTypeBool);
194 vtkBooleanMacro(Clamping, vtkTypeBool);
196
202 vtkSetMacro(UseLogScale, bool);
203 vtkGetMacro(UseLogScale, bool);
204 vtkBooleanMacro(UseLogScale, bool);
215 const char* GetType();
216
221 double GetFirstNonZeroValue();
222
228 void Initialize() override;
229
231
234 static vtkPiecewiseFunction* GetData(vtkInformation* info);
235 static vtkPiecewiseFunction* GetData(vtkInformationVector* v, int i = 0);
237
239
243 vtkSetMacro(AllowDuplicateScalars, vtkTypeBool);
244 vtkGetMacro(AllowDuplicateScalars, vtkTypeBool);
245 vtkBooleanMacro(AllowDuplicateScalars, vtkTypeBool);
247
252 int EstimateMinNumberOfSamples(double const& x1, double const& x2);
253
259 void UpdateSearchMethod(double epsilon = 1e-12, double thresh = 1e-4);
260
262
268 int GetAutomaticSearchMethod();
269 void SetUseCustomSearchMethod(bool use);
270 void SetCustomSearchMethod(int type);
271 int GetCustomSearchMethod();
273
274 protected:
275 vtkPiecewiseFunction();
276 ~vtkPiecewiseFunction() override;
277
285 void SortAndUpdateRange(bool updateSearchMethod = true);
286
290 bool UpdateRange();
291
295 double FindMinimumXDistance();
296
297 // The internal STL structures
298 vtkPiecewiseFunctionInternals* Internal;
299
300 // Determines the function value outside of defined points
301 // Zero = always return 0.0 outside of defined points
302 // One = clamp to the lowest value below defined points and
303 // highest value above defined points
304 vtkTypeBool Clamping;
305
306 // Array of points ((X,Y) pairs)
307 double* Function;
308
309 // Min and max range of function point locations
310 double Range[2];
311
312 vtkTypeBool AllowDuplicateScalars;
313
314 bool UseLogScale;
315
316 private:
317 vtkPiecewiseFunction(const vtkPiecewiseFunction&) = delete;
318 void operator=(const vtkPiecewiseFunction&) = delete;
319 };
320
321 VTK_ABI_NAMESPACE_END
322 #endif
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:64
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:40
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:72
vtkPiecewiseFunction
Defines a 1D piecewise function.
Definition: vtkPiecewiseFunction.h:50
vtkPiecewiseFunction::SetNodeValue
int SetNodeValue(int index, double val[4])
For the node specified by index, set/get the location (X), value (Y), midpoint, and sharpness values ...
vtkPiecewiseFunction::AllowDuplicateScalars
vtkTypeBool AllowDuplicateScalars
Definition: vtkPiecewiseFunction.h:312
vtkPiecewiseFunction::Clamping
vtkTypeBool Clamping
Definition: vtkPiecewiseFunction.h:304
vtkPiecewiseFunction::GetTable
void GetTable(double x1, double x2, int size, float *table, int stride=1, int logIncrements=0, double epsilon=1e-5)
Fills in an array of function values evaluated at regular intervals.
vtkPiecewiseFunction::Function
double * Function
Definition: vtkPiecewiseFunction.h:307
vtkPiecewiseFunction::AdjustRange
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.
vtkPiecewiseFunction::GetValue
double GetValue(double x)
Returns the value of the function at the specified location using the specified interpolation.
vtkPiecewiseFunction::AddPoint
int AddPoint(double x, double y, double midpoint, double sharpness)
Add points to the function.
vtkPiecewiseFunction::GetData
static vtkPiecewiseFunction * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
vtkPiecewiseFunction::RemovePoint
int RemovePoint(double x)
Remove the first point found at the given x location Return the index of the remove point if any,...
vtkPiecewiseFunction::GetDataPointer
double * GetDataPointer()
Returns a pointer to the data stored in the table.
vtkPiecewiseFunction::GetCustomSearchMethod
int GetCustomSearchMethod()
vtkPiecewiseFunction::UpdateSearchMethod
void UpdateSearchMethod(double epsilon=1e-12, double thresh=1e-4)
Analyses the point distribution and automatically updates the search method to optimize the time proc...
vtkPiecewiseFunction::AddPoint
int AddPoint(double x, double y)
Add points to the function.
vtkPiecewiseFunction::GetFirstNonZeroValue
double GetFirstNonZeroValue()
Returns the first point location which precedes a non-zero segment of the function.
vtkPiecewiseFunction::GetTable
void GetTable(double x1, double x2, int size, double *table, int stride=1, int logIncrements=0, double epsilon=1e-5)
Fills in an array of function values evaluated at regular intervals.
vtkPiecewiseFunction::GetAutomaticSearchMethod
int GetAutomaticSearchMethod()
Methods to set / get the search method used.
vtkPiecewiseFunction::RemovePoint
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...
vtkPiecewiseFunction::Internal
vtkPiecewiseFunctionInternals * Internal
Definition: vtkPiecewiseFunction.h:298
vtkPiecewiseFunction::FillFromDataPointer
void FillFromDataPointer(int, double *)
Returns a pointer to the data stored in the table.
vtkPiecewiseFunction::SetUseCustomSearchMethod
void SetUseCustomSearchMethod(bool use)
vtkPiecewiseFunction::BuildFunctionFromTable
void BuildFunctionFromTable(double x1, double x2, int size, double *table, int stride=1)
Constructs a piecewise function from a table.
vtkPiecewiseFunction::GetSize
int GetSize()
Get the number of points used to specify the function.
vtkPiecewiseFunction::SearchMethod
SearchMethod
Definition: vtkPiecewiseFunction.h:60
vtkPiecewiseFunction::SetCustomSearchMethod
void SetCustomSearchMethod(int type)
vtkPiecewiseFunction::~vtkPiecewiseFunction
~vtkPiecewiseFunction() override
vtkPiecewiseFunction::Initialize
void Initialize() override
Clears out the current function.
vtkPiecewiseFunction::UpdateRange
bool UpdateRange()
Returns true if the range has been updated and Modified() has been called.
vtkPiecewiseFunction::RemoveAllPoints
void RemoveAllPoints()
Removes all points from the function.
vtkPiecewiseFunction::vtkPiecewiseFunction
vtkPiecewiseFunction()
vtkPiecewiseFunction::DeepCopy
void DeepCopy(vtkDataObject *f) override
The goal of the method is to copy the complete data from src into this object.
vtkPiecewiseFunction::New
static vtkPiecewiseFunction * New()
vtkPiecewiseFunction::GetType
const char * GetType()
Return the type of function: Function Types: 0 : Constant (No change in slope between end points) 1 :...
vtkPiecewiseFunction::FindMinimumXDistance
double FindMinimumXDistance()
Traverses the nodes to find the minimum distance.
vtkPiecewiseFunction::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPiecewiseFunction::GetData
static vtkPiecewiseFunction * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
vtkPiecewiseFunction::AddSegment
void AddSegment(double x1, double y1, double x2, double y2)
Add a line segment to the function.
vtkPiecewiseFunction::EstimateMinNumberOfSamples
int EstimateMinNumberOfSamples(double const &x1, double const &x2)
Estimates the minimum size of a table such that it would correctly sample this function.
vtkPiecewiseFunction::RemovePointByIndex
bool RemovePointByIndex(size_t id)
Remove a point from the function at a given id Return true if point has been found and removed,...
vtkPiecewiseFunction::SortAndUpdateRange
void SortAndUpdateRange(bool updateSearchMethod=true)
Internal methods to sort the vector and update the Range whenever a node is added,...
vtkPiecewiseFunction::GetNodeValue
int GetNodeValue(int index, double val[4])
For the node specified by index, set/get the location (X), value (Y), midpoint, and sharpness values ...
vtkPiecewiseFunction::GetDataObjectType
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkPiecewiseFunction.h:69
vtkPiecewiseFunction::ShallowCopy
void ShallowCopy(vtkDataObject *f) override
The goal of the method is to copy the data up to the array pointers only.
vtkPiecewiseFunction::UseLogScale
bool UseLogScale
Definition: vtkPiecewiseFunction.h:314
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkX3D::range
@ range
Definition: vtkX3D.h:238
vtkX3D::type
@ type
Definition: vtkX3D.h:516
vtkX3D::size
@ size
Definition: vtkX3D.h:253
vtkX3D::index
@ index
Definition: vtkX3D.h:246
vtk::Range
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
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64
vtkDataObject.h
VTK_PIECEWISE_FUNCTION
#define VTK_PIECEWISE_FUNCTION
Definition: vtkType.h:70