Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkPiecewiseFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkPiecewiseFunction.h,v $
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 
00043 #ifndef __vtkPiecewiseFunction_h
00044 #define __vtkPiecewiseFunction_h
00045 
00046 #include "vtkDataObject.h"
00047 
00048 class VTK_FILTERING_EXPORT vtkPiecewiseFunction : public vtkDataObject
00049 {
00050 public:
00051   static vtkPiecewiseFunction *New();
00052   vtkTypeRevisionMacro(vtkPiecewiseFunction,vtkDataObject);
00053   void PrintSelf(ostream& os, vtkIndent indent);
00054 
00055   void Initialize();
00056   void DeepCopy( vtkDataObject *f );
00057   void ShallowCopy( vtkDataObject *f );
00058 
00060   int GetDataObjectType() {return VTK_PIECEWISE_FUNCTION;};
00061   
00063   int  GetSize();
00064 
00066 
00069   int AddPoint( double x, double val );
00070   int RemovePoint( double x );
00072 
00074   void RemoveAllPoints();
00075 
00078   void AddSegment( double x1, double val1, double x2, double val2 );
00079 
00083   double GetValue( double x );
00084 
00086 
00088   double *GetDataPointer() {return this->Function;};
00089   void FillFromDataPointer(int, double*);
00091 
00093   double *GetRange();
00094 
00096 
00100   void GetTable( double x1, double x2, int size, float *table, int stride=1 );
00101   void GetTable( double x1, double x2, int size, double *table, int stride=1 );
00103 
00105 
00110   void BuildFunctionFromTable( double x1, double x2, int size,
00111                                double *table, int stride=1 );
00113   
00115 
00121   vtkSetMacro( Clamping, int );
00122   vtkGetMacro( Clamping, int );
00123   vtkBooleanMacro( Clamping, int );
00125 
00131   const char  *GetType();
00132 
00135   unsigned long GetMTime();
00136 
00139   double GetFirstNonZeroValue();
00140 
00141 protected:
00142   vtkPiecewiseFunction();
00143   ~vtkPiecewiseFunction();
00144 
00145   // Size of the array used to store function points
00146   int   ArraySize;
00147 
00148   // Determines the function value outside of defined points
00149   // Zero = always return 0.0 outside of defined points
00150   // One  = clamp to the lowest value below defined points and
00151   //        highest value above defined points
00152   int   Clamping;
00153 
00154   // Array of points ((X,Y) pairs)
00155   double *Function;
00156 
00157   // Number of points used to specify function
00158   int   FunctionSize;
00159 
00160   // Min and max range of function point locations
00161   double FunctionRange[2];
00162 
00163   // Increases size of the function array. The array grows by a factor of 2
00164   // when the array limit has been reached.
00165   void IncreaseArraySize();
00166 
00167   // Private function to add a point to the function. Returns the array
00168   // index of the inserted point.
00169   int InsertPoint( double x, double val );
00170 
00171   // Move points one index down or up in the array. This is useful for 
00172   // inserting and deleting points into the array.
00173   void MovePoints( int index, int down );
00174 private:
00175   vtkPiecewiseFunction(const vtkPiecewiseFunction&);  // Not implemented.
00176   void operator=(const vtkPiecewiseFunction&);  // Not implemented.
00177 };
00178 
00179 #endif
00180