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) override;
51 
52  void DeepCopy( vtkDataObject *f ) override;
53  void ShallowCopy( vtkDataObject *f ) override;
54 
58  int GetDataObjectType() 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 
139  void GetTable( double x1, double x2, int size, float *table, int stride=1, int logIncrements=0 );
140  void GetTable( double x1, double x2, int size, double *table, int stride=1, int logIncrements=0 );
142 
149  void BuildFunctionFromTable( double x1, double x2, int size,
150  double *table, int stride=1 );
151 
153 
161  vtkSetMacro( Clamping, vtkTypeBool );
162  vtkGetMacro( Clamping, vtkTypeBool );
163  vtkBooleanMacro( Clamping, vtkTypeBool );
165 
171  vtkSetMacro(UseLogScale, bool)
172  vtkGetMacro(UseLogScale, bool)
173  vtkBooleanMacro(UseLogScale, bool)
184  const char *GetType();
185 
190  double GetFirstNonZeroValue();
191 
197  void Initialize() override;
198 
200 
206 
208 
212  vtkSetMacro(AllowDuplicateScalars, vtkTypeBool);
213  vtkGetMacro(AllowDuplicateScalars, vtkTypeBool);
214  vtkBooleanMacro(AllowDuplicateScalars, vtkTypeBool);
216 
221  int EstimateMinNumberOfSamples(double const & x1, double const & x2);
222 
223 protected:
225  ~vtkPiecewiseFunction() override;
226 
227  // Internal method to sort the vector and update the
228  // Range whenever a node is added, edited or removed.
229  // It always calls Modified().
230  void SortAndUpdateRange();
231  // Returns true if the range has been updated and Modified() has been called
232  bool UpdateRange();
233 
237  double FindMinimumXDistance();
238 
239  // The internal STL structures
240  vtkPiecewiseFunctionInternals *Internal;
241 
242  // Determines the function value outside of defined points
243  // Zero = always return 0.0 outside of defined points
244  // One = clamp to the lowest value below defined points and
245  // highest value above defined points
247 
248  // Array of points ((X,Y) pairs)
249  double *Function;
250 
251  // Min and max range of function point locations
252  double Range[2];
253 
255 
257 
258 private:
260  void operator=(const vtkPiecewiseFunction&) = delete;
261 };
262 
263 #endif
264 
265 
vtkDataObject::Initialize
virtual void Initialize()
Restore data object to initial state,.
vtkDataObject::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:35
vtkX3D::range
Definition: vtkX3D.h:238
vtkDataObject::DeepCopy
virtual void DeepCopy(vtkDataObject *src)
vtkPiecewiseFunction::Function
double * Function
Definition: vtkPiecewiseFunction.h:249
vtkPiecewiseFunction::Internal
vtkPiecewiseFunctionInternals * Internal
Definition: vtkPiecewiseFunction.h:240
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkX3D::size
Definition: vtkX3D.h:253
vtkPiecewiseFunction::AllowDuplicateScalars
vtkTypeBool AllowDuplicateScalars
Definition: vtkPiecewiseFunction.h:254
vtkPiecewiseFunction
Defines a 1D piecewise function.
Definition: vtkPiecewiseFunction.h:45
vtkPiecewiseFunction::Clamping
vtkTypeBool Clamping
Definition: vtkPiecewiseFunction.h:246
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:80
vtkX3D::info
Definition: vtkX3D.h:376
vtkDataObject.h
vtkPiecewiseFunction::GetDataObjectType
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkPiecewiseFunction.h:58
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:58
vtkX3D::index
Definition: vtkX3D.h:246
vtkDataObject::ShallowCopy
virtual void ShallowCopy(vtkDataObject *src)
Shallow and Deep copy.
vtkPiecewiseFunction::UseLogScale
bool UseLogScale
Definition: vtkPiecewiseFunction.h:256
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
VTK_PIECEWISE_FUNCTION
#define VTK_PIECEWISE_FUNCTION
Definition: vtkType.h:96
vtkDataObject::GetData
static vtkDataObject * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
vtkDataObject::New
static vtkDataObject * New()