VTK
dox/Common/DataModel/vtkPiecewiseFunction.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkPiecewiseFunction.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 
00042 #ifndef __vtkPiecewiseFunction_h
00043 #define __vtkPiecewiseFunction_h
00044 
00045 #include "vtkCommonDataModelModule.h" // For export macro
00046 #include "vtkDataObject.h"
00047 
00048 class vtkPiecewiseFunctionInternals;
00049 
00050 class VTKCOMMONDATAMODEL_EXPORT vtkPiecewiseFunction : public vtkDataObject
00051 {
00052 public:
00053   static vtkPiecewiseFunction *New();
00054   vtkTypeMacro(vtkPiecewiseFunction,vtkDataObject);
00055   void PrintSelf(ostream& os, vtkIndent indent);
00056 
00057   void DeepCopy( vtkDataObject *f );
00058   void ShallowCopy( vtkDataObject *f );
00059 
00061   int GetDataObjectType() {return VTK_PIECEWISE_FUNCTION;};
00062 
00064   int  GetSize();
00065 
00067 
00070   int AddPoint( double x, double y );
00071   int AddPoint( double x, double y, double midpoint, double sharpness );
00072   int RemovePoint( double x );
00074 
00076   void RemoveAllPoints();
00077 
00082   void AddSegment( double x1, double y1, double x2, double y2 );
00083 
00086   double GetValue( double x );
00087 
00089 
00092   int GetNodeValue( int index, double val[4] );
00093   int SetNodeValue( int index, double val[4] );
00095 
00097 
00102   double *GetDataPointer();
00103   void FillFromDataPointer(int, double*);
00105 
00107 
00108   vtkGetVector2Macro( Range, double );
00110 
00113   int AdjustRange(double range[2]);
00114 
00116 
00118   void GetTable( double x1, double x2, int size, float *table, int stride=1 );
00119   void GetTable( double x1, double x2, int size, double *table, int stride=1 );
00121 
00123 
00127   void BuildFunctionFromTable( double x1, double x2, int size,
00128                                double *table, int stride=1 );
00130 
00132 
00138   vtkSetMacro( Clamping, int );
00139   vtkGetMacro( Clamping, int );
00140   vtkBooleanMacro( Clamping, int );
00142 
00148   const char  *GetType();
00149 
00152   double GetFirstNonZeroValue();
00153 
00157   void Initialize();
00158 
00159   //BTX
00161 
00162   static vtkPiecewiseFunction* GetData(vtkInformation* info);
00163   static vtkPiecewiseFunction* GetData(vtkInformationVector* v, int i=0);
00164   //ETX
00166 
00168 
00170   vtkSetMacro(AllowDuplicateScalars, int);
00171   vtkGetMacro(AllowDuplicateScalars, int);
00172   vtkBooleanMacro(AllowDuplicateScalars, int);
00174 
00175 protected:
00176   vtkPiecewiseFunction();
00177   ~vtkPiecewiseFunction();
00178 
00179   // The internal STL structures
00180   vtkPiecewiseFunctionInternals *Internal;
00181 
00182   // Determines the function value outside of defined points
00183   // Zero = always return 0.0 outside of defined points
00184   // One  = clamp to the lowest value below defined points and
00185   //        highest value above defined points
00186   int   Clamping;
00187 
00188   // Array of points ((X,Y) pairs)
00189   double *Function;
00190 
00191   // Min and max range of function point locations
00192   double Range[2];
00193 
00194   // Internal method to sort the vector and update the
00195   // Range whenever a node is added, edited or removed.
00196   // It always calls Modified().
00197   void SortAndUpdateRange();
00198   // Returns true if the range has been updated and Modified() has been called
00199   bool UpdateRange();
00200 
00201   int AllowDuplicateScalars;
00202 
00203 private:
00204   vtkPiecewiseFunction(const vtkPiecewiseFunction&);  // Not implemented.
00205   void operator=(const vtkPiecewiseFunction&);  // Not implemented.
00206 };
00207 
00208 #endif
00209 
00210