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 
136 #ifndef vtkPiecewiseFunction_h
137 #define vtkPiecewiseFunction_h
138 
139 #include "vtkCommonDataModelModule.h" // For export macro
140 #include "vtkDataObject.h"
141 
142 class vtkPiecewiseFunctionInternals;
143 
144 class VTKCOMMONDATAMODEL_EXPORT vtkPiecewiseFunction : public vtkDataObject
145 {
146 public:
149  void PrintSelf(ostream& os, vtkIndent indent) override;
150 
151  void DeepCopy(vtkDataObject* f) override;
152  void ShallowCopy(vtkDataObject* f) override;
153 
157  int GetDataObjectType() override { return VTK_PIECEWISE_FUNCTION; }
158 
162  int GetSize();
163 
165 
171  int AddPoint(double x, double y);
172  int AddPoint(double x, double y, double midpoint, double sharpness);
174 
179  bool RemovePointByIndex(size_t id);
180 
185  int RemovePoint(double x);
186 
191  int RemovePoint(double x, double y);
192 
197 
203  void AddSegment(double x1, double y1, double x2, double y2);
204 
209  double GetValue(double x);
210 
212 
218  int GetNodeValue(int index, double val[4]);
219  int SetNodeValue(int index, double val[4]);
221 
223 
230  double* GetDataPointer();
231  void FillFromDataPointer(int, double*);
233 
235 
238  vtkGetVector2Macro(Range, double);
240 
246  int AdjustRange(double range[2]);
247 
249 
255  void GetTable(
256  double x1, double x2, int size, float* table, int stride = 1, int logIncrements = 0);
257  void GetTable(
258  double x1, double x2, int size, double* table, int stride = 1, int logIncrements = 0);
260 
267  void BuildFunctionFromTable(double x1, double x2, int size, double* table, int stride = 1);
268 
270 
278  vtkSetMacro(Clamping, vtkTypeBool);
279  vtkGetMacro(Clamping, vtkTypeBool);
280  vtkBooleanMacro(Clamping, vtkTypeBool);
282 
288  vtkSetMacro(UseLogScale, bool);
289  vtkGetMacro(UseLogScale, bool);
290  vtkBooleanMacro(UseLogScale, bool);
301  const char* GetType();
302 
308 
314  void Initialize() override;
315 
317 
323 
325 
329  vtkSetMacro(AllowDuplicateScalars, vtkTypeBool);
330  vtkGetMacro(AllowDuplicateScalars, vtkTypeBool);
331  vtkBooleanMacro(AllowDuplicateScalars, vtkTypeBool);
333 
338  int EstimateMinNumberOfSamples(double const& x1, double const& x2);
339 
340 protected:
343 
350 
354  bool UpdateRange();
355 
360 
361  // The internal STL structures
362  vtkPiecewiseFunctionInternals* Internal;
363 
364  // Determines the function value outside of defined points
365  // Zero = always return 0.0 outside of defined points
366  // One = clamp to the lowest value below defined points and
367  // highest value above defined points
369 
370  // Array of points ((X,Y) pairs)
371  double* Function;
372 
373  // Min and max range of function point locations
374  double Range[2];
375 
377 
379 
380 private:
382  void operator=(const vtkPiecewiseFunction&) = delete;
383 };
384 
385 #endif
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:85
vtkPiecewiseFunction::BuildFunctionFromTable
void BuildFunctionFromTable(double x1, double x2, int size, double *table, int stride=1)
Constructs a piecewise function from a table.
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::GetData
static vtkPiecewiseFunction * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
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::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
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...
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:145
vtkPiecewiseFunction::Initialize
void Initialize() override
Clears out the current function.
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::~vtkPiecewiseFunction
~vtkPiecewiseFunction() override
vtkPiecewiseFunction::GetTable
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.
vtkPiecewiseFunction::FillFromDataPointer
void FillFromDataPointer(int, double *)
Returns a pointer to the data stored in the table.
vtkX3D::range
@ range
Definition: vtkX3D.h:244
vtkPiecewiseFunction::SortAndUpdateRange
void SortAndUpdateRange()
Internal method to sort the vector and update the Range whenever a node is added, edited or removed.
vtkPiecewiseFunction::AddPoint
int AddPoint(double x, double y, double midpoint, double sharpness)
Add points 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::Function
double * Function
Definition: vtkPiecewiseFunction.h:371
vtkPiecewiseFunction::GetDataPointer
double * GetDataPointer()
Returns a pointer to the data stored in the table.
vtkPiecewiseFunction::Internal
vtkPiecewiseFunctionInternals * Internal
Definition: vtkPiecewiseFunction.h:362
vtkPiecewiseFunction::GetType
const char * GetType()
Return the type of function: Function Types: 0 : Constant (No change in slope between end points) 1 :...
vtkPiecewiseFunction::New
static vtkPiecewiseFunction * New()
vtkPiecewiseFunction::GetTable
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.
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,...
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkPiecewiseFunction::GetFirstNonZeroValue
double GetFirstNonZeroValue()
Returns the first point location which precedes a non-zero segment of the function.
vtkX3D::size
@ size
Definition: vtkX3D.h:259
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:376
vtkPiecewiseFunction
Defines a 1D piecewise function.
Definition: vtkPiecewiseFunction.h:145
vtkPiecewiseFunction::Clamping
vtkTypeBool Clamping
Definition: vtkPiecewiseFunction.h:368
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkPiecewiseFunction::GetData
static vtkPiecewiseFunction * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
vtkPiecewiseFunction::GetSize
int GetSize()
Get the number of points used to specify the function.
vtkDataObject.h
vtkPiecewiseFunction::FindMinimumXDistance
double FindMinimumXDistance()
Traverses the nodes to find the minimum distance.
vtkPiecewiseFunction::AddPoint
int AddPoint(double x, double y)
Add points to the function.
vtkPiecewiseFunction::GetDataObjectType
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkPiecewiseFunction.h:157
vtkPiecewiseFunction::DeepCopy
void DeepCopy(vtkDataObject *f) override
Shallow and Deep copy.
vtkPiecewiseFunction::GetValue
double GetValue(double x)
Returns the value of the function at the specified location using the specified interpolation.
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:169
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkPiecewiseFunction::UseLogScale
bool UseLogScale
Definition: vtkPiecewiseFunction.h:378
vtkPiecewiseFunction::vtkPiecewiseFunction
vtkPiecewiseFunction()
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkPiecewiseFunction::ShallowCopy
void ShallowCopy(vtkDataObject *f) override
Shallow and Deep copy.
vtkPiecewiseFunction::RemoveAllPoints
void RemoveAllPoints()
Removes all points from the function.
VTK_PIECEWISE_FUNCTION
#define VTK_PIECEWISE_FUNCTION
Definition: vtkType.h:82
vtkPiecewiseFunction::UpdateRange
bool UpdateRange()
Returns true if the range has been updated and Modified() has been called.
vtkPiecewiseFunction::AddSegment
void AddSegment(double x1, double y1, double x2, double y2)
Add a line segment to the function.