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:
54  static vtkPiecewiseFunction *New();
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 
85  void RemoveAllPoints();
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 
175  vtkSetMacro(UseLogScale, bool)
176  vtkGetMacro(UseLogScale, bool)
177  vtkBooleanMacro(UseLogScale, bool)
188  const char *GetType();
189 
194  double GetFirstNonZeroValue();
195 
201  void Initialize() override;
202 
204 
210 
212 
216  vtkSetMacro(AllowDuplicateScalars, int);
217  vtkGetMacro(AllowDuplicateScalars, int);
218  vtkBooleanMacro(AllowDuplicateScalars, int);
220 
225  int EstimateMinNumberOfSamples(double const & x1, double const & x2);
226 
227 protected:
229  ~vtkPiecewiseFunction() override;
230 
231  // Internal method to sort the vector and update the
232  // Range whenever a node is added, edited or removed.
233  // It always calls Modified().
234  void SortAndUpdateRange();
235  // Returns true if the range has been updated and Modified() has been called
236  bool UpdateRange();
237 
241  double FindMinimumXDistance();
242 
243  // The internal STL structures
244  vtkPiecewiseFunctionInternals *Internal;
245 
246  // Determines the function value outside of defined points
247  // Zero = always return 0.0 outside of defined points
248  // One = clamp to the lowest value below defined points and
249  // highest value above defined points
250  int Clamping;
251 
252  // Array of points ((X,Y) pairs)
253  double *Function;
254 
255  // Min and max range of function point locations
256  double Range[2];
257 
259 
261 
262 private:
264  void operator=(const vtkPiecewiseFunction&) = delete;
265 };
266 
267 #endif
268 
269 
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkDataObject * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
static vtkDataObject * New()
#define VTK_PIECEWISE_FUNCTION
Definition: vtkType.h:96
Defines a 1D piecewise function.
Store vtkAlgorithm input/output information.
virtual void Initialize()
Restore data object to initial state,.
int GetDataObjectType() override
Return what type of dataset this is.
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
Store zero or more vtkInformation instances.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
general representation of visualization data
Definition: vtkDataObject.h:64
vtkPiecewiseFunctionInternals * Internal
virtual void DeepCopy(vtkDataObject *src)
Shallow and Deep copy.
virtual void ShallowCopy(vtkDataObject *src)
Shallow and Deep copy.