VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkMapper.h 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 =========================================================================*/ 00060 #ifndef __vtkMapper_h 00061 #define __vtkMapper_h 00062 00063 #include "vtkAbstractMapper3D.h" 00064 #include "vtkScalarsToColors.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS 00065 00066 #define VTK_RESOLVE_OFF 0 00067 #define VTK_RESOLVE_POLYGON_OFFSET 1 00068 #define VTK_RESOLVE_SHIFT_ZBUFFER 2 00069 00070 #define VTK_GET_ARRAY_BY_ID 0 00071 #define VTK_GET_ARRAY_BY_NAME 1 00072 00073 #define VTK_MATERIALMODE_DEFAULT 0 00074 #define VTK_MATERIALMODE_AMBIENT 1 00075 #define VTK_MATERIALMODE_DIFFUSE 2 00076 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3 00077 00078 class vtkWindow; 00079 class vtkRenderer; 00080 class vtkActor; 00081 class vtkDataSet; 00082 class vtkFloatArray; 00083 class vtkImageData; 00084 00085 class VTK_RENDERING_EXPORT vtkMapper : public vtkAbstractMapper3D 00086 { 00087 public: 00088 vtkTypeMacro(vtkMapper,vtkAbstractMapper3D); 00089 void PrintSelf(ostream& os, vtkIndent indent); 00090 00092 void ShallowCopy(vtkAbstractMapper *m); 00093 00096 unsigned long GetMTime(); 00097 00100 virtual void Render(vtkRenderer *ren, vtkActor *a) = 0; 00101 00105 virtual void ReleaseGraphicsResources(vtkWindow *) {}; 00106 00108 00109 void SetLookupTable(vtkScalarsToColors *lut); 00110 vtkScalarsToColors *GetLookupTable(); 00112 00115 virtual void CreateDefaultLookupTable(); 00116 00118 00120 vtkSetMacro(ScalarVisibility,int); 00121 vtkGetMacro(ScalarVisibility,int); 00122 vtkBooleanMacro(ScalarVisibility,int); 00124 00126 00130 vtkSetMacro(Static,int); 00131 vtkGetMacro(Static,int); 00132 vtkBooleanMacro(Static,int); 00134 00136 00143 vtkSetMacro(ColorMode,int); 00144 vtkGetMacro(ColorMode,int); 00145 void SetColorModeToDefault() 00146 {this->SetColorMode(VTK_COLOR_MODE_DEFAULT);}; 00147 void SetColorModeToMapScalars() 00148 {this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS);}; 00150 00152 const char *GetColorModeAsString(); 00153 00155 00158 vtkSetMacro(InterpolateScalarsBeforeMapping,int); 00159 vtkGetMacro(InterpolateScalarsBeforeMapping,int); 00160 vtkBooleanMacro(InterpolateScalarsBeforeMapping,int); 00162 00164 00170 vtkSetMacro(UseLookupTableScalarRange,int); 00171 vtkGetMacro(UseLookupTableScalarRange,int); 00172 vtkBooleanMacro(UseLookupTableScalarRange,int); 00174 00176 00179 vtkSetVector2Macro(ScalarRange,double); 00180 vtkGetVectorMacro(ScalarRange,double,2); 00182 00184 00189 vtkSetMacro(ImmediateModeRendering,int); 00190 vtkGetMacro(ImmediateModeRendering,int); 00191 vtkBooleanMacro(ImmediateModeRendering,int); 00193 00195 00200 static void SetGlobalImmediateModeRendering(int val); 00201 static void GlobalImmediateModeRenderingOn() 00202 {vtkMapper::SetGlobalImmediateModeRendering(1);}; 00203 static void GlobalImmediateModeRenderingOff() 00204 {vtkMapper::SetGlobalImmediateModeRendering(0);}; 00205 static int GetGlobalImmediateModeRendering(); 00207 00208 //BTX 00210 00217 vtkGetMacro(ForceCompileOnly,int); 00218 void SetForceCompileOnly(int value); 00219 //ETX 00221 00223 00238 vtkSetMacro(ScalarMode,int); 00239 vtkGetMacro(ScalarMode,int); 00240 void SetScalarModeToDefault() { 00241 this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT);}; 00242 void SetScalarModeToUsePointData() { 00243 this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_DATA);}; 00244 void SetScalarModeToUseCellData() { 00245 this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_DATA);}; 00246 void SetScalarModeToUsePointFieldData() { 00247 this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);}; 00248 void SetScalarModeToUseCellFieldData() { 00249 this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA);}; 00250 void SetScalarModeToUseFieldData() { 00251 this->SetScalarMode(VTK_SCALAR_MODE_USE_FIELD_DATA); } 00253 00255 00258 void SelectColorArray(int arrayNum); 00259 void SelectColorArray(const char* arrayName); 00261 00263 00265 void ColorByArrayComponent(int arrayNum, int component); 00266 void ColorByArrayComponent(const char* arrayName, int component); 00268 00270 00271 char* GetArrayName() { return this->ArrayName; } 00272 int GetArrayId() { return this->ArrayId; } 00273 int GetArrayAccessMode() { return this->ArrayAccessMode; } 00274 int GetArrayComponent() { return this->ArrayComponent; } 00276 00278 const char *GetScalarModeAsString(); 00279 00281 00291 static void SetResolveCoincidentTopology(int val); 00292 static int GetResolveCoincidentTopology(); 00293 static void SetResolveCoincidentTopologyToDefault(); 00294 static void SetResolveCoincidentTopologyToOff() 00295 {SetResolveCoincidentTopology(VTK_RESOLVE_OFF);} 00296 static void SetResolveCoincidentTopologyToPolygonOffset() 00297 {SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET);} 00298 static void SetResolveCoincidentTopologyToShiftZBuffer() 00299 {SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER);} 00301 00303 00306 static void SetResolveCoincidentTopologyPolygonOffsetParameters( 00307 double factor, double units); 00308 static void GetResolveCoincidentTopologyPolygonOffsetParameters( 00309 double& factor, double& units); 00311 00313 00318 static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces); 00319 static int GetResolveCoincidentTopologyPolygonOffsetFaces(); 00321 00323 00325 static void SetResolveCoincidentTopologyZShift(double val); 00326 static double GetResolveCoincidentTopologyZShift(); 00328 00330 00332 virtual double *GetBounds(); 00333 virtual void GetBounds(double bounds[6]) 00334 {this->vtkAbstractMapper3D::GetBounds(bounds);}; 00336 00338 00341 void SetRenderTime(double time) {this->RenderTime = time;} 00342 vtkGetMacro(RenderTime, double); 00344 00345 //BTX 00347 00349 vtkDataSet *GetInput(); 00350 //ETX 00352 00354 00358 vtkDataSet *GetInputAsDataSet() 00359 {return this->GetInput();} 00361 00367 vtkUnsignedCharArray *MapScalars(double alpha); 00368 00370 00371 vtkSetMacro(ScalarMaterialMode,int); 00372 vtkGetMacro(ScalarMaterialMode,int); 00373 void SetScalarMaterialModeToDefault() 00374 {this->SetScalarMaterialMode(VTK_MATERIALMODE_DEFAULT);}; 00375 void SetScalarMaterialModeToAmbient() 00376 {this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT);}; 00377 void SetScalarMaterialModeToDiffuse() 00378 {this->SetScalarMaterialMode(VTK_MATERIALMODE_DIFFUSE);}; 00379 void SetScalarMaterialModeToAmbientAndDiffuse() 00380 {this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE);}; 00382 00384 const char *GetScalarMaterialModeAsString(); 00385 00393 virtual bool GetIsOpaque() { return true; } 00394 00396 00400 virtual bool GetSupportsSelection() 00401 { return false; } 00402 protected: 00403 vtkMapper(); 00404 ~vtkMapper(); 00406 00407 vtkUnsignedCharArray *Colors; 00408 00409 // Use texture coordinates for coloring. 00410 int InterpolateScalarsBeforeMapping; 00411 // Coordinate for each point. 00412 vtkFloatArray *ColorCoordinates; 00413 // 1D ColorMap used for the texture image. 00414 vtkImageData* ColorTextureMap; 00415 void MapScalarsToTexture(vtkDataArray* scalars, double alpha); 00416 00417 vtkScalarsToColors *LookupTable; 00418 int ScalarVisibility; 00419 vtkTimeStamp BuildTime; 00420 double ScalarRange[2]; 00421 int UseLookupTableScalarRange; 00422 int ImmediateModeRendering; 00423 int ColorMode; 00424 int ScalarMode; 00425 int ScalarMaterialMode; 00426 00427 double RenderTime; 00428 00429 // for coloring by a component of a field data array 00430 int ArrayId; 00431 char ArrayName[256]; 00432 int ArrayComponent; 00433 int ArrayAccessMode; 00434 00435 int Static; 00436 00437 int ForceCompileOnly; 00438 00439 private: 00440 vtkMapper(const vtkMapper&); // Not implemented. 00441 void operator=(const vtkMapper&); // Not implemented. 00442 }; 00443 00444 #endif