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

Rendering/vtkMapper.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkMapper.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 =========================================================================*/
00054 #ifndef __vtkMapper_h
00055 #define __vtkMapper_h
00056 
00057 #include "vtkAbstractMapper3D.h"
00058 #include "vtkScalarsToColors.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
00059 
00060 #define VTK_RESOLVE_OFF 0
00061 #define VTK_RESOLVE_POLYGON_OFFSET 1
00062 #define VTK_RESOLVE_SHIFT_ZBUFFER 2
00063 
00064 #define VTK_GET_ARRAY_BY_ID 0
00065 #define VTK_GET_ARRAY_BY_NAME 1
00066 
00067 #define VTK_MATERIALMODE_DEFAULT  0
00068 #define VTK_MATERIALMODE_AMBIENT  1
00069 #define VTK_MATERIALMODE_DIFFUSE  2
00070 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE  3
00071 
00072 class vtkWindow;
00073 class vtkRenderer;
00074 class vtkActor;
00075 class vtkDataSet;
00076 
00077 class VTK_RENDERING_EXPORT vtkMapper : public vtkAbstractMapper3D
00078 {
00079 public:
00080   vtkTypeRevisionMacro(vtkMapper,vtkAbstractMapper3D);
00081   void PrintSelf(ostream& os, vtkIndent indent);
00082 
00084   void ShallowCopy(vtkAbstractMapper *m);
00085 
00088   unsigned long GetMTime();
00089 
00092   virtual void Render(vtkRenderer *ren, vtkActor *a) = 0;
00093 
00097   virtual void ReleaseGraphicsResources(vtkWindow *) {};
00098 
00100 
00101   void SetLookupTable(vtkScalarsToColors *lut);
00102   vtkScalarsToColors *GetLookupTable();
00104 
00107   virtual void CreateDefaultLookupTable();
00108 
00110 
00112   vtkSetMacro(ScalarVisibility,int);
00113   vtkGetMacro(ScalarVisibility,int);
00114   vtkBooleanMacro(ScalarVisibility,int);
00116 
00118 
00125   vtkSetMacro(ColorMode,int);
00126   vtkGetMacro(ColorMode,int);
00127   void SetColorModeToDefault() 
00128     {this->SetColorMode(VTK_COLOR_MODE_DEFAULT);};
00129   void SetColorModeToMapScalars() 
00130     {this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS);};
00132 
00134   const char *GetColorModeAsString();
00135 
00137 
00143   vtkSetMacro(UseLookupTableScalarRange,int);
00144   vtkGetMacro(UseLookupTableScalarRange,int);
00145   vtkBooleanMacro(UseLookupTableScalarRange,int);
00147 
00149 
00152   vtkSetVector2Macro(ScalarRange,double);
00153   vtkGetVectorMacro(ScalarRange,double,2);
00155 
00157 
00162   vtkSetMacro(ImmediateModeRendering,int);
00163   vtkGetMacro(ImmediateModeRendering,int);
00164   vtkBooleanMacro(ImmediateModeRendering,int);
00166 
00168 
00173   static void SetGlobalImmediateModeRendering(int val);
00174   static void GlobalImmediateModeRenderingOn() 
00175     {vtkMapper::SetGlobalImmediateModeRendering(1);};
00176   static void GlobalImmediateModeRenderingOff() 
00177     {vtkMapper::SetGlobalImmediateModeRendering(0);};
00178   static int  GetGlobalImmediateModeRendering();
00180 
00182 
00192   vtkSetMacro(ScalarMode,int);
00193   vtkGetMacro(ScalarMode,int);
00194   void SetScalarModeToDefault() {
00195     this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT);};
00196   void SetScalarModeToUsePointData() {
00197     this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_DATA);};
00198   void SetScalarModeToUseCellData() {
00199     this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_DATA);};
00200   void SetScalarModeToUsePointFieldData() {
00201     this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);};
00202   void SetScalarModeToUseCellFieldData() {
00203     this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA);};
00205   
00207 
00210   void SelectColorArray(int arrayNum); 
00211   void SelectColorArray(const char* arrayName); 
00213 
00215 
00217   void ColorByArrayComponent(int arrayNum, int component);
00218   void ColorByArrayComponent(const char* arrayName, int component);
00220   
00222 
00223   char* GetArrayName() { return this->ArrayName; }
00224   int GetArrayId() { return this->ArrayId; }
00225   int GetArrayAccessMode() { return this->ArrayAccessMode; }
00226   int GetArrayComponent() { return this->ArrayComponent; }
00228 
00230   const char *GetScalarModeAsString();
00231 
00233 
00243   static void SetResolveCoincidentTopology(int val);
00244   static int  GetResolveCoincidentTopology();
00245   static void SetResolveCoincidentTopologyToDefault();
00246   static void SetResolveCoincidentTopologyToOff() 
00247     {SetResolveCoincidentTopology(VTK_RESOLVE_OFF);}
00248   static void SetResolveCoincidentTopologyToPolygonOffset() 
00249     {SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET);}
00250   static void SetResolveCoincidentTopologyToShiftZBuffer() 
00251     {SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER);}
00253 
00255 
00258   static void SetResolveCoincidentTopologyPolygonOffsetParameters(
00259     double factor, double units);
00260   static void GetResolveCoincidentTopologyPolygonOffsetParameters(
00261     double& factor, double& units);
00263 
00265 
00267   static void SetResolveCoincidentTopologyZShift(double val);
00268   static double GetResolveCoincidentTopologyZShift();
00270 
00272 
00274   virtual double *GetBounds();
00275   virtual void GetBounds(double bounds[6]) 
00276     {this->vtkAbstractMapper3D::GetBounds(bounds);};
00278 
00280 
00283   void SetRenderTime(double time) {this->RenderTime = time;}
00284   vtkGetMacro(RenderTime, double);
00286 
00287   //BTX
00289 
00291   vtkDataSet *GetInput();
00292   //ETX
00294 
00296 
00300   vtkDataSet *GetInputAsDataSet() 
00301     {return this->GetInput();}
00303 
00309   vtkUnsignedCharArray *MapScalars(double alpha);
00310   
00312   virtual void Update();
00313 
00315 
00316   vtkSetMacro(ScalarMaterialMode,int);
00317   vtkGetMacro(ScalarMaterialMode,int);
00318   void SetScalarMaterialModeToDefault() 
00319     {this->SetScalarMaterialMode(VTK_MATERIALMODE_DEFAULT);};
00320   void SetScalarMaterialModeToAmbient() 
00321     {this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT);};
00322   void SetScalarMaterialModeToDiffuse() 
00323     {this->SetScalarMaterialMode(VTK_MATERIALMODE_DIFFUSE);};
00324   void SetScalarMaterialModeToAmbientAndDiffuse() 
00325     {this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE);};
00327 
00329   const char *GetScalarMaterialModeAsString();
00330 
00331 protected:
00332   vtkMapper();
00333   ~vtkMapper();
00334 
00335   vtkUnsignedCharArray *Colors;
00336 
00337   vtkScalarsToColors *LookupTable;
00338   int ScalarVisibility;
00339   vtkTimeStamp BuildTime;
00340   double ScalarRange[2];
00341   int UseLookupTableScalarRange;
00342   int ImmediateModeRendering;
00343   int ColorMode;
00344   int ScalarMode;
00345   int ScalarMaterialMode;
00346 
00347   double RenderTime;
00348 
00349   // for coloring by a component of a field data array
00350   int ArrayId;
00351   char ArrayName[256];
00352   int ArrayComponent;
00353   int ArrayAccessMode;
00354 
00355 private:
00356   vtkMapper(const vtkMapper&);  // Not implemented.
00357   void operator=(const vtkMapper&);  // Not implemented.
00358 };
00359 
00360 #endif