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 
37 #ifndef vtkPiecewiseFunction_h
38 #define vtkPiecewiseFunction_h
39 
40 #include "vtkCommonDataModelModule.h" // For export macro
41 #include "vtkDataObject.h"
42 
43 class vtkPiecewiseFunctionInternals;
44 
45 class VTKCOMMONDATAMODEL_EXPORT vtkPiecewiseFunction : public vtkDataObject
46 {
47 public:
48  static vtkPiecewiseFunction *New();
50  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
51 
52  void DeepCopy( vtkDataObject *f ) VTK_OVERRIDE;
53  void ShallowCopy( vtkDataObject *f ) VTK_OVERRIDE;
54 
58  int GetDataObjectType() VTK_OVERRIDE {return VTK_PIECEWISE_FUNCTION;};
59 
63  int GetSize();
64 
66 
71  int AddPoint( double x, double y );
72  int AddPoint( double x, double y, double midpoint, double sharpness );
73  int RemovePoint( double x );
75 
79  void RemoveAllPoints();
80 
87  void AddSegment( double x1, double y1, double x2, double y2 );
88 
93  double GetValue( double x );
94 
96 
102  int GetNodeValue( int index, double val[4] );
103  int SetNodeValue( int index, double val[4] );
105 
107 
114  double *GetDataPointer();
115  void FillFromDataPointer(int, double*);
117 
119 
122  vtkGetVector2Macro( Range, double );
124 
130  int AdjustRange(double range[2]);
131 
133 
137  void GetTable( double x1, double x2, int size, float *table, int stride=1 );
138  void GetTable( double x1, double x2, int size, double *table, int stride=1 );
140 
147  void BuildFunctionFromTable( double x1, double x2, int size,
148  double *table, int stride=1 );
149 
151 
159  vtkSetMacro( Clamping, int );
160  vtkGetMacro( Clamping, int );
161  vtkBooleanMacro( Clamping, int );
163 
172  const char *GetType();
173 
178  double GetFirstNonZeroValue();
179 
185  void Initialize() VTK_OVERRIDE;
186 
188 
191  static vtkPiecewiseFunction* GetData(vtkInformation* info);
192  static vtkPiecewiseFunction* GetData(vtkInformationVector* v, int i=0);
194 
196 
200  vtkSetMacro(AllowDuplicateScalars, int);
201  vtkGetMacro(AllowDuplicateScalars, int);
202  vtkBooleanMacro(AllowDuplicateScalars, int);
204 
209  int EstimateMinNumberOfSamples(double const & x1, double const & x2);
210 
211 protected:
213  ~vtkPiecewiseFunction() VTK_OVERRIDE;
214 
215  // Internal method to sort the vector and update the
216  // Range whenever a node is added, edited or removed.
217  // It always calls Modified().
218  void SortAndUpdateRange();
219  // Returns true if the range has been updated and Modified() has been called
220  bool UpdateRange();
221 
225  double FindMinimumXDistance();
226 
227  // The internal STL structures
228  vtkPiecewiseFunctionInternals *Internal;
229 
230  // Determines the function value outside of defined points
231  // Zero = always return 0.0 outside of defined points
232  // One = clamp to the lowest value below defined points and
233  // highest value above defined points
234  int Clamping;
235 
236  // Array of points ((X,Y) pairs)
237  double *Function;
238 
239  // Min and max range of function point locations
240  double Range[2];
241 
242  int AllowDuplicateScalars;
243 
244 private:
245  vtkPiecewiseFunction(const vtkPiecewiseFunction&) VTK_DELETE_FUNCTION;
246  void operator=(const vtkPiecewiseFunction&) VTK_DELETE_FUNCTION;
247 };
248 
249 #endif
250 
251 
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
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:33
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:58
virtual void DeepCopy(vtkDataObject *src)
Shallow and Deep copy.
virtual void ShallowCopy(vtkDataObject *src)
Shallow and Deep copy.