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) VTK_OVERRIDE;
57 
58  void DeepCopy( vtkDataObject *f ) VTK_OVERRIDE;
59  void ShallowCopy( vtkDataObject *f ) VTK_OVERRIDE;
60 
64  int GetDataObjectType() VTK_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 
143  void GetTable( double x1, double x2, int size, float *table, int stride=1 );
144  void GetTable( double x1, double x2, int size, double *table, int stride=1 );
146 
153  void BuildFunctionFromTable( double x1, double x2, int size,
154  double *table, int stride=1 );
155 
157 
165  vtkSetMacro( Clamping, int );
166  vtkGetMacro( Clamping, int );
167  vtkBooleanMacro( Clamping, int );
169 
178  const char *GetType();
179 
185 
191  void Initialize() VTK_OVERRIDE;
192 
194 
198  static vtkPiecewiseFunction* GetData(vtkInformationVector* v, int i=0);
200 
202 
206  vtkSetMacro(AllowDuplicateScalars, int);
207  vtkGetMacro(AllowDuplicateScalars, int);
208  vtkBooleanMacro(AllowDuplicateScalars, int);
210 
215  int EstimateMinNumberOfSamples(double const & x1, double const & x2);
216 
217 protected:
219  ~vtkPiecewiseFunction() VTK_OVERRIDE;
220 
221  // Internal method to sort the vector and update the
222  // Range whenever a node is added, edited or removed.
223  // It always calls Modified().
224  void SortAndUpdateRange();
225  // Returns true if the range has been updated and Modified() has been called
226  bool UpdateRange();
227 
231  double FindMinimumXDistance();
232 
233  // The internal STL structures
234  vtkPiecewiseFunctionInternals *Internal;
235 
236  // Determines the function value outside of defined points
237  // Zero = always return 0.0 outside of defined points
238  // One = clamp to the lowest value below defined points and
239  // highest value above defined points
240  int Clamping;
241 
242  // Array of points ((X,Y) pairs)
243  double *Function;
244 
245  // Min and max range of function point locations
246  double Range[2];
247 
248  int AllowDuplicateScalars;
249 
250 private:
251  vtkPiecewiseFunction(const vtkPiecewiseFunction&) VTK_DELETE_FUNCTION;
252  void operator=(const vtkPiecewiseFunction&) VTK_DELETE_FUNCTION;
253 };
254 
255 #endif
256 
257 
general representation of visualization data
Definition: vtkDataObject.h:65
a simple class to control print indentation
Definition: vtkIndent.h:40
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)
int RemovePoint(double x)
double * GetDataPointer()
Returns a pointer to the data stored in the table.
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.
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.
void Initialize() override
Clears out the current function.
void RemoveAllPoints()
Removes all points from the function.
void DeepCopy(vtkDataObject *f) override
static vtkPiecewiseFunction * New()
void GetTable(double x1, double x2, int size, float *table, int stride=1)
Fills in an array of function values evaluated at regular intervals.
const char * GetType()
Return the type of function: Function Types: 0 : Constant (No change in slope between end points) 1 :...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void AddSegment(double x1, double y1, double x2, double y2)
Add a line segment to the function.
void GetTable(double x1, double x2, int size, double *table, int stride=1)
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:376
@ range
Definition: vtkX3D.h:238
@ size
Definition: vtkX3D.h:253
@ index
Definition: vtkX3D.h:246
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
#define VTK_PIECEWISE_FUNCTION
Definition: vtkType.h:92