VTK
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:
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 
77  int AddPoint( double x, double y );
78  int AddPoint( double x, double y, double midpoint, double sharpness );
79  int RemovePoint( double x );
81 
86 
93  void AddSegment( double x1, double y1, double x2, double y2 );
94 
99  double GetValue( double x );
100 
102 
108  int GetNodeValue( int index, double val[4] );
109  int SetNodeValue( int index, double val[4] );
111 
113 
120  double *GetDataPointer();
121  void FillFromDataPointer(int, double*);
123 
125 
128  vtkGetVector2Macro( Range, double );
130 
136  int AdjustRange(double range[2]);
137 
139 
145  void GetTable( double x1, double x2, int size, float *table, int stride=1, int logIncrements=0 );
146  void GetTable( double x1, double x2, int size, double *table, int stride=1, int logIncrements=0 );
148 
155  void BuildFunctionFromTable( double x1, double x2, int size,
156  double *table, int stride=1 );
157 
159 
167  vtkSetMacro( Clamping, vtkTypeBool );
168  vtkGetMacro( Clamping, vtkTypeBool );
169  vtkBooleanMacro( Clamping, vtkTypeBool );
171 
177  vtkSetMacro(UseLogScale, bool)
178  vtkGetMacro(UseLogScale, bool)
179  vtkBooleanMacro(UseLogScale, bool)
190  const char *GetType();
191 
196  double GetFirstNonZeroValue();
197 
203  void Initialize() override;
204 
206 
210  static vtkPiecewiseFunction* GetData(vtkInformationVector* v, int i=0);
212 
214 
218  vtkSetMacro(AllowDuplicateScalars, vtkTypeBool);
219  vtkGetMacro(AllowDuplicateScalars, vtkTypeBool);
220  vtkBooleanMacro(AllowDuplicateScalars, vtkTypeBool);
222 
227  int EstimateMinNumberOfSamples(double const & x1, double const & x2);
228 
229 protected:
231  ~vtkPiecewiseFunction() override;
232 
233  // Internal method to sort the vector and update the
234  // Range whenever a node is added, edited or removed.
235  // It always calls Modified().
236  void SortAndUpdateRange();
237  // Returns true if the range has been updated and Modified() has been called
238  bool UpdateRange();
239 
243  double FindMinimumXDistance();
244 
245  // The internal STL structures
246  vtkPiecewiseFunctionInternals *Internal;
247 
248  // Determines the function value outside of defined points
249  // Zero = always return 0.0 outside of defined points
250  // One = clamp to the lowest value below defined points and
251  // highest value above defined points
252  vtkTypeBool Clamping;
253 
254  // Array of points ((X,Y) pairs)
255  double *Function;
256 
257  // Min and max range of function point locations
258  double Range[2];
259 
260  vtkTypeBool AllowDuplicateScalars;
261 
262  bool UseLogScale;
263 
264 private:
266  void operator=(const vtkPiecewiseFunction&) = delete;
267 };
268 
269 #endif
270 
271 
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)
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.
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:42
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::GetTable
void GetTable(double x1, double x2, int size, double *table, int stride=1, int logIncrements=0)
vtkPiecewiseFunction::FillFromDataPointer
void FillFromDataPointer(int, double *)
vtkX3D::range
@ range
Definition: vtkX3D.h:238
vtkPiecewiseFunction::AddPoint
int AddPoint(double x, double y, double midpoint, double sharpness)
vtkPiecewiseFunction::GetDataPointer
double * GetDataPointer()
Returns a pointer to the data stored in the table.
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.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkX3D::size
@ size
Definition: vtkX3D.h:253
vtkPiecewiseFunction::SetNodeValue
int SetNodeValue(int index, double val[4])
vtkPiecewiseFunction
Defines a 1D piecewise function.
Definition: vtkPiecewiseFunction.h:52
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:87
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkPiecewiseFunction::GetSize
int GetSize()
Get the number of points used to specify the function.
vtkDataObject.h
vtkPiecewiseFunction::AddPoint
int AddPoint(double x, double y)
Add/Remove points to/from the function.
vtkPiecewiseFunction::GetDataObjectType
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkPiecewiseFunction.h:64
vtkPiecewiseFunction::DeepCopy
void DeepCopy(vtkDataObject *f) override
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:65
vtkX3D::index
@ index
Definition: vtkX3D.h:246
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:96
vtkPiecewiseFunction::AddSegment
void AddSegment(double x1, double y1, double x2, double y2)
Add a line segment to the function.