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 "vtkRenderingCoreModule.h" // For export macro 00064 #include "vtkAbstractMapper3D.h" 00065 #include "vtkScalarsToColors.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS 00066 00067 #define VTK_RESOLVE_OFF 0 00068 #define VTK_RESOLVE_POLYGON_OFFSET 1 00069 #define VTK_RESOLVE_SHIFT_ZBUFFER 2 00070 00071 #define VTK_GET_ARRAY_BY_ID 0 00072 #define VTK_GET_ARRAY_BY_NAME 1 00073 00074 #define VTK_MATERIALMODE_DEFAULT 0 00075 #define VTK_MATERIALMODE_AMBIENT 1 00076 #define VTK_MATERIALMODE_DIFFUSE 2 00077 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3 00078 00079 class vtkWindow; 00080 class vtkRenderer; 00081 class vtkActor; 00082 class vtkDataSet; 00083 class vtkFloatArray; 00084 class vtkImageData; 00085 00086 class VTKRENDERINGCORE_EXPORT vtkMapper : public vtkAbstractMapper3D 00087 { 00088 public: 00089 vtkTypeMacro(vtkMapper, vtkAbstractMapper3D); 00090 void PrintSelf(ostream& os, vtkIndent indent); 00091 00093 void ShallowCopy(vtkAbstractMapper *m); 00094 00097 unsigned long GetMTime(); 00098 00101 virtual void Render(vtkRenderer *ren, vtkActor *a) = 0; 00102 00106 virtual void ReleaseGraphicsResources(vtkWindow *) {} 00107 00109 00110 void SetLookupTable(vtkScalarsToColors *lut); 00111 vtkScalarsToColors *GetLookupTable(); 00113 00116 virtual void CreateDefaultLookupTable(); 00117 00119 00121 vtkSetMacro(ScalarVisibility, int); 00122 vtkGetMacro(ScalarVisibility, int); 00123 vtkBooleanMacro(ScalarVisibility, int); 00125 00127 00131 vtkSetMacro(Static, int); 00132 vtkGetMacro(Static, int); 00133 vtkBooleanMacro(Static, int); 00135 00137 00144 vtkSetMacro(ColorMode, int); 00145 vtkGetMacro(ColorMode, int); 00146 void SetColorModeToDefault() 00147 { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); } 00148 void SetColorModeToMapScalars() 00149 { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); } 00151 00153 const char *GetColorModeAsString(); 00154 00156 00159 vtkSetMacro(InterpolateScalarsBeforeMapping, int); 00160 vtkGetMacro(InterpolateScalarsBeforeMapping, int); 00161 vtkBooleanMacro(InterpolateScalarsBeforeMapping, int); 00163 00165 00171 vtkSetMacro(UseLookupTableScalarRange, int); 00172 vtkGetMacro(UseLookupTableScalarRange, int); 00173 vtkBooleanMacro(UseLookupTableScalarRange, int); 00175 00177 00180 vtkSetVector2Macro(ScalarRange, double); 00181 vtkGetVectorMacro(ScalarRange, double, 2); 00183 00185 00190 vtkSetMacro(ImmediateModeRendering, int); 00191 vtkGetMacro(ImmediateModeRendering, int); 00192 vtkBooleanMacro(ImmediateModeRendering, int); 00194 00196 00201 static void SetGlobalImmediateModeRendering(int val); 00202 static void GlobalImmediateModeRenderingOn() 00203 { vtkMapper::SetGlobalImmediateModeRendering(1); } 00204 static void GlobalImmediateModeRenderingOff() 00205 { vtkMapper::SetGlobalImmediateModeRendering(0); } 00206 static int GetGlobalImmediateModeRendering(); 00208 00209 //BTX 00211 00218 vtkGetMacro(ForceCompileOnly, int); 00219 void SetForceCompileOnly(int value); 00220 //ETX 00222 00224 00239 vtkSetMacro(ScalarMode, int); 00240 vtkGetMacro(ScalarMode, int); 00241 void SetScalarModeToDefault() 00242 { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); } 00243 void SetScalarModeToUsePointData() 00244 { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_DATA); } 00245 void SetScalarModeToUseCellData() 00246 { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_DATA); } 00247 void SetScalarModeToUsePointFieldData() 00248 { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA); } 00249 void SetScalarModeToUseCellFieldData() 00250 { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA); } 00251 void SetScalarModeToUseFieldData() 00252 { this->SetScalarMode(VTK_SCALAR_MODE_USE_FIELD_DATA); } 00254 00256 00259 void SelectColorArray(int arrayNum); 00260 void SelectColorArray(const char* arrayName); 00262 00264 00266 void ColorByArrayComponent(int arrayNum, int component); 00267 void ColorByArrayComponent(const char* arrayName, int component); 00269 00271 00272 char* GetArrayName() { return this->ArrayName; } 00273 int GetArrayId() { return this->ArrayId; } 00274 int GetArrayAccessMode() { return this->ArrayAccessMode; } 00275 int GetArrayComponent() { return this->ArrayComponent; } 00277 00279 const char *GetScalarModeAsString(); 00280 00282 00292 static void SetResolveCoincidentTopology(int val); 00293 static int GetResolveCoincidentTopology(); 00294 static void SetResolveCoincidentTopologyToDefault(); 00295 static void SetResolveCoincidentTopologyToOff() 00296 { SetResolveCoincidentTopology(VTK_RESOLVE_OFF) ;} 00297 static void SetResolveCoincidentTopologyToPolygonOffset() 00298 { SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET); } 00299 static void SetResolveCoincidentTopologyToShiftZBuffer() 00300 { SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER); } 00302 00304 00307 static void SetResolveCoincidentTopologyPolygonOffsetParameters( 00308 double factor, double units); 00309 static void GetResolveCoincidentTopologyPolygonOffsetParameters( 00310 double& factor, double& units); 00312 00314 00319 static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces); 00320 static int GetResolveCoincidentTopologyPolygonOffsetFaces(); 00322 00324 00326 static void SetResolveCoincidentTopologyZShift(double val); 00327 static double GetResolveCoincidentTopologyZShift(); 00329 00331 00333 virtual double *GetBounds(); 00334 virtual void GetBounds(double bounds[6]) 00335 { this->vtkAbstractMapper3D::GetBounds(bounds); } 00337 00339 00342 void SetRenderTime(double time) {this->RenderTime = time;} 00343 vtkGetMacro(RenderTime, double); 00345 00346 //BTX 00348 00350 vtkDataSet *GetInput(); 00351 //ETX 00353 00355 00359 vtkDataSet *GetInputAsDataSet() 00360 { return this->GetInput(); } 00362 00368 vtkUnsignedCharArray *MapScalars(double alpha); 00369 00371 00372 vtkSetMacro(ScalarMaterialMode,int); 00373 vtkGetMacro(ScalarMaterialMode,int); 00374 void SetScalarMaterialModeToDefault() 00375 { this->SetScalarMaterialMode(VTK_MATERIALMODE_DEFAULT); } 00376 void SetScalarMaterialModeToAmbient() 00377 { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT); } 00378 void SetScalarMaterialModeToDiffuse() 00379 { this->SetScalarMaterialMode(VTK_MATERIALMODE_DIFFUSE); } 00380 void SetScalarMaterialModeToAmbientAndDiffuse() 00381 { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE); } 00383 00385 const char *GetScalarMaterialModeAsString(); 00386 00388 00395 virtual bool GetIsOpaque() 00396 { return true; } 00398 00400 00404 virtual bool GetSupportsSelection() 00405 { return false; } 00406 protected: 00407 vtkMapper(); 00408 ~vtkMapper(); 00410 00411 vtkUnsignedCharArray *Colors; 00412 00413 // Use texture coordinates for coloring. 00414 int InterpolateScalarsBeforeMapping; 00415 // Coordinate for each point. 00416 vtkFloatArray *ColorCoordinates; 00417 // 1D ColorMap used for the texture image. 00418 vtkImageData* ColorTextureMap; 00419 void MapScalarsToTexture(vtkDataArray* scalars, double alpha); 00420 00421 vtkScalarsToColors *LookupTable; 00422 int ScalarVisibility; 00423 vtkTimeStamp BuildTime; 00424 double ScalarRange[2]; 00425 int UseLookupTableScalarRange; 00426 int ImmediateModeRendering; 00427 int ColorMode; 00428 int ScalarMode; 00429 int ScalarMaterialMode; 00430 00431 double RenderTime; 00432 00433 // for coloring by a component of a field data array 00434 int ArrayId; 00435 char ArrayName[256]; 00436 int ArrayComponent; 00437 int ArrayAccessMode; 00438 00439 int Static; 00440 00441 int ForceCompileOnly; 00442 00443 private: 00444 vtkMapper(const vtkMapper&); // Not implemented. 00445 void operator=(const vtkMapper&); // Not implemented. 00446 }; 00447 00448 #endif