Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Filtering/vtkPiecewiseFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkPiecewiseFunction.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00016 
00047 #ifndef __vtkPiecewiseFunction_h
00048 #define __vtkPiecewiseFunction_h
00049 
00050 #include "vtkDataObject.h"
00051 
00052 class VTK_FILTERING_EXPORT vtkPiecewiseFunction : public vtkDataObject
00053 {
00054 public:
00055   static vtkPiecewiseFunction *New();
00056   vtkTypeRevisionMacro(vtkPiecewiseFunction,vtkDataObject);
00057   void PrintSelf(ostream& os, vtkIndent indent);
00058 
00059   void Initialize();
00060   void DeepCopy( vtkDataObject *f );
00061   void ShallowCopy( vtkDataObject *f );
00062 
00064   int GetDataObjectType() {return VTK_PIECEWISE_FUNCTION;};
00065   
00067   int  GetSize();
00068 
00070 
00072   void AddPoint( float x, float val );
00073   void RemovePoint( float x );
00075 
00077   void RemoveAllPoints();
00078 
00081   void AddSegment( float x1, float val1, float x2, float val2 );
00082 
00086   float GetValue( float x );
00087 
00089 
00091   float *GetDataPointer() {return this->Function;};
00092   void FillFromDataPointer(int, float*);
00094 
00096   float *GetRange();
00097 
00102   void GetTable( float x1, float x2, int size, float *table, int stride=1 );
00103 
00105 
00110   void BuildFunctionFromTable( float x1, float x2, int size,
00111                                float *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   float 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   float *Function;
00156 
00157   // Number of points used to specify function
00158   int   FunctionSize;
00159 
00160   // Min and max range of function point locations
00161   float 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( float x, float 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