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

Filtering/vtkColorTransferFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkColorTransferFunction.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 =========================================================================*/
00060 #ifndef __vtkColorTransferFunction_h
00061 #define __vtkColorTransferFunction_h
00062 
00063 #include "vtkScalarsToColors.h"
00064 #include "vtkPiecewiseFunction.h"
00065 
00066 #define VTK_CTF_RGB   0
00067 #define VTK_CTF_HSV   1
00068 
00069 class VTK_FILTERING_EXPORT vtkColorTransferFunction : public vtkScalarsToColors 
00070 {
00071 public:
00072   static vtkColorTransferFunction *New();
00073   vtkTypeMacro(vtkColorTransferFunction,vtkScalarsToColors);
00074   void DeepCopy( vtkColorTransferFunction *f );
00075 
00077   void PrintSelf(ostream& os, vtkIndent indent);
00078 
00080   int GetSize() {return this->NumberOfPoints;};
00081   
00083 
00084   void AddRGBPoint( float x, float r, float g, float b );
00085   void AddHSVPoint( float x, float h, float s, float v );
00087 
00089 
00090   void AddRGBSegment( float x1, float r1, float g1, float b1, 
00091                       float x2, float r2, float g2, float b2 );
00092   void AddHSVSegment( float x1, float h1, float s1, float v1, 
00093                       float x2, float h2, float s2, float v2 );
00095   
00097 
00098   void RemovePoint( float x );
00099   void RemoveAllPoints();
00101 
00103 
00105   float *GetColor(float x) { 
00106     return vtkScalarsToColors::GetColor(x); }
00107   void GetColor(float x, float rgb[3]);
00109 
00111 
00112   float GetRedValue( float x );
00113   float GetGreenValue( float x );
00114   float GetBlueValue( float x );
00116 
00118   virtual unsigned char *MapValue(float v);
00119 
00121 
00122   vtkGetVector2Macro( Range, float );
00124 
00126 
00127   void GetTable( float x1, float x2, int n, float* table );
00128   const unsigned char *GetTable( float x1, float x2, int n);
00130 
00135   void BuildFunctionFromTable( float x1, float x2, int size, float *table);
00136 
00138 
00139   vtkSetClampMacro( Clamping, int, 0, 1 );
00140   vtkGetMacro( Clamping, int );
00141   vtkBooleanMacro( Clamping, int );
00143   
00145 
00146   vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_HSV );
00147   void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
00148   void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
00149   vtkGetMacro( ColorSpace, int );
00151     
00153   float *GetDataPointer() {return this->Function;};
00154 
00156 
00157   virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00158                                      int inputDataType, int numberOfValues,
00159                                      int inputIncrement, int outputIncrement);
00161   
00162 protected:
00163   vtkColorTransferFunction();
00164   ~vtkColorTransferFunction();
00165 
00166   // Determines the function value outside of defined points
00167   // Zero = always return 0.0 outside of defined points
00168   // One  = clamp to the lowest value below defined points and
00169   //        highest value above defined points
00170   int Clamping;
00171 
00172   // The color space in which interpolation is performed
00173   int ColorSpace;
00174   
00175   // The color function
00176   float       *Function;
00177   int         FunctionSize;
00178   int         NumberOfPoints;
00179 
00180   // conversion methods
00181   void RGBToHSV( float r, float g, float b, float &h, float &s, float &v );
00182   void HSVToRGB( float h, float s, float v, float &r, float &g, float &b );
00183   
00184   // An evaluated color (0 to 255 RGBA A=255)
00185   unsigned char UnsignedCharRGBAValue[4];
00186 
00187   // The min and max point locations for all three transfer functions
00188   float Range[2]; 
00189 
00190   // Transfer functions for each color component
00191   // Remove after corresponding depricated methods are removed
00192   vtkPiecewiseFunction  *Red;
00193   vtkPiecewiseFunction  *Green;
00194   vtkPiecewiseFunction  *Blue;
00195   vtkTimeStamp BuildTime;
00196   unsigned char *Table;
00197   int TableSize;
00198   
00200 
00202   virtual void SetRange(float, float) {};
00203   void SetRange(float rng[2]) {this->SetRange(rng[0],rng[1]);};
00205 
00206 
00207 private:
00208   vtkColorTransferFunction(const vtkColorTransferFunction&);  // Not implemented.
00209   void operator=(const vtkColorTransferFunction&);  // Not implemented.
00210 };
00211 
00212 #endif
00213 
00214 

Generated on Thu Mar 28 14:19:18 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001