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

graphics/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 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00040 
00055 #ifndef __vtkPiecewiseFunction_h
00056 #define __vtkPiecewiseFunction_h
00057 
00058 #include "vtkDataObject.h"
00059 
00060 class VTK_EXPORT vtkPiecewiseFunction : public vtkDataObject
00061 {
00062 public:
00063   static vtkPiecewiseFunction *New();
00064   vtkTypeMacro(vtkPiecewiseFunction,vtkDataObject);
00065   void PrintSelf(ostream& os, vtkIndent indent);
00066 
00067   vtkDataObject *MakeObject();
00068   void Initialize();
00069   void DeepCopy( vtkDataObject *f );
00070   void ShallowCopy( vtkDataObject *f );
00071 
00073   int GetDataObjectType() {return VTK_PIECEWISE_FUNCTION;};
00074   
00076   int  GetSize();
00077 
00080   void AddPoint( float x, float val );
00081   void RemovePoint( float x );
00082 
00084   void RemoveAllPoints();
00085 
00088   void AddSegment( float x1, float val1, float x2, float val2 );
00089 
00093   float GetValue( float x );
00094 
00096   float *GetDataPointer() {return this->Function;};
00097 
00099   float *GetRange();
00100 
00105   void GetTable( float x1, float x2, int size, float *table, int stride=1 );
00106 
00112   void BuildFunctionFromTable( float x1, float x2, int size,
00113                 float *table, int stride=1 );
00114   
00121   vtkSetMacro( Clamping, int );
00122   vtkGetMacro( Clamping, int );
00123   vtkBooleanMacro( Clamping, int );
00124 
00130   const char  *GetType();
00131 
00134   unsigned long GetMTime();
00135 
00138   float GetFirstNonZeroValue();
00139 
00140 protected:
00141   vtkPiecewiseFunction();
00142   ~vtkPiecewiseFunction();
00143   vtkPiecewiseFunction(const vtkPiecewiseFunction&) {};
00144   void operator=(const vtkPiecewiseFunction&) {};
00145 
00146   // Size of the array used to store function points
00147   int ArraySize;
00148 
00149   // Determines the function value outside of defined points
00150   // Zero = always return 0.0 outside of defined points
00151   // One  = clamp to the lowest value below defined points and
00152   //        highest value above defined points
00153   int Clamping;
00154 
00155   // Array of points ((X,Y) pairs)
00156   float  *Function;
00157 
00158   // Number of points used to specify function
00159   int   FunctionSize;
00160 
00161   // Min and max range of function point locations
00162   float FunctionRange[2];
00163 
00164   // Increases size of the function array. The array grows by a factor of 2
00165   // when the array limit has been reached.
00166   void IncreaseArraySize();
00167 
00168   // Private function to add a point to the function. Returns the array
00169   // index of the inserted point.
00170   int InsertPoint( float x, float val );
00171 
00172   // Move points one index down or up in the array. This is useful for 
00173   // inserting and deleting points into the array.
00174   void MovePoints( int index, int down );
00175 };
00176 
00177 #endif
00178 

Generated on Wed Nov 21 12:27:01 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001