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 "vtkSystemIncludes.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 class vtkScalarsToColors; 00086 class vtkUnsignedCharArray; 00087 00088 class VTKRENDERINGCORE_EXPORT vtkMapper : public vtkAbstractMapper3D 00089 { 00090 public: 00091 vtkTypeMacro(vtkMapper, vtkAbstractMapper3D); 00092 void PrintSelf(ostream& os, vtkIndent indent); 00093 00095 void ShallowCopy(vtkAbstractMapper *m); 00096 00099 unsigned long GetMTime(); 00100 00103 virtual void Render(vtkRenderer *ren, vtkActor *a) = 0; 00104 00108 virtual void ReleaseGraphicsResources(vtkWindow *) {} 00109 00111 00112 void SetLookupTable(vtkScalarsToColors *lut); 00113 vtkScalarsToColors *GetLookupTable(); 00115 00118 virtual void CreateDefaultLookupTable(); 00119 00121 00123 vtkSetMacro(ScalarVisibility, int); 00124 vtkGetMacro(ScalarVisibility, int); 00125 vtkBooleanMacro(ScalarVisibility, int); 00127 00129 00133 vtkSetMacro(Static, int); 00134 vtkGetMacro(Static, int); 00135 vtkBooleanMacro(Static, int); 00137 00139 00148 vtkSetMacro(ColorMode, int); 00149 vtkGetMacro(ColorMode, int); 00150 void SetColorModeToDefault() 00151 { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); } 00152 void SetColorModeToMapScalars() 00153 { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); } 00154 void SetColorModeToDirectScalars() 00155 { this->SetColorMode(VTK_COLOR_MODE_DIRECT_SCALARS); } 00157 00159 const char *GetColorModeAsString(); 00160 00162 00165 vtkSetMacro(InterpolateScalarsBeforeMapping, int); 00166 vtkGetMacro(InterpolateScalarsBeforeMapping, int); 00167 vtkBooleanMacro(InterpolateScalarsBeforeMapping, int); 00169 00171 00177 vtkSetMacro(UseLookupTableScalarRange, int); 00178 vtkGetMacro(UseLookupTableScalarRange, int); 00179 vtkBooleanMacro(UseLookupTableScalarRange, int); 00181 00183 00186 vtkSetVector2Macro(ScalarRange, double); 00187 vtkGetVectorMacro(ScalarRange, double, 2); 00189 00191 00196 vtkSetMacro(ImmediateModeRendering, int); 00197 vtkGetMacro(ImmediateModeRendering, int); 00198 vtkBooleanMacro(ImmediateModeRendering, int); 00200 00202 00207 static void SetGlobalImmediateModeRendering(int val); 00208 static void GlobalImmediateModeRenderingOn() 00209 { vtkMapper::SetGlobalImmediateModeRendering(1); } 00210 static void GlobalImmediateModeRenderingOff() 00211 { vtkMapper::SetGlobalImmediateModeRendering(0); } 00212 static int GetGlobalImmediateModeRendering(); 00214 00215 //BTX 00217 00224 vtkGetMacro(ForceCompileOnly, int); 00225 void SetForceCompileOnly(int value); 00226 //ETX 00228 00240 // When ScalarMode is set to use Field Data (ScalarModeToFieldData), 00241 // you must call SelectColorArray to choose the field data array to 00242 // be used to color cells. In this mode, the default behavior is to 00243 // treat the field data tuples as being associated with cells. If 00244 // the poly data contains triangle strips, the array is expected to 00245 // contain the cell data for each mini-cell formed by any triangle 00246 // strips in the poly data as opposed to treating them as a single 00247 // tuple that applies to the entire strip. This mode can also be 00248 // used to color the entire poly data by a single color obtained by 00249 // mapping the tuple at a given index in the field data array 00250 // through the color map. Use SetFieldDataTupleId() to specify 00251 // the tuple index. 00252 vtkSetMacro(ScalarMode, int); 00253 vtkGetMacro(ScalarMode, int); 00254 void SetScalarModeToDefault() 00255 { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); } 00256 void SetScalarModeToUsePointData() 00257 { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_DATA); } 00258 void SetScalarModeToUseCellData() 00259 { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_DATA); } 00260 void SetScalarModeToUsePointFieldData() 00261 { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA); } 00262 void SetScalarModeToUseCellFieldData() 00263 { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA); } 00264 void SetScalarModeToUseFieldData() 00265 { this->SetScalarMode(VTK_SCALAR_MODE_USE_FIELD_DATA); } 00266 00268 00271 void SelectColorArray(int arrayNum); 00272 void SelectColorArray(const char* arrayName); 00274 00275 00276 // When ScalarMode is set to UseFieldData, set the index of the 00277 // tuple by which to color the entire data set. By default, the 00278 // index is -1, which means to treat the field data array selected 00279 // with SelectColorArray as having a scalar value for each cell. 00280 // Indices of 0 or higher mean to use the tuple at the given index 00281 // for coloring the entire data set. 00282 vtkSetMacro(FieldDataTupleId, vtkIdType); 00283 vtkGetMacro(FieldDataTupleId, vtkIdType); 00284 00286 00288 void ColorByArrayComponent(int arrayNum, int component); 00289 void ColorByArrayComponent(const char* arrayName, int component); 00291 00293 00294 char* GetArrayName() { return this->ArrayName; } 00295 int GetArrayId() { return this->ArrayId; } 00296 int GetArrayAccessMode() { return this->ArrayAccessMode; } 00297 int GetArrayComponent() { return this->ArrayComponent; } 00299 00301 const char *GetScalarModeAsString(); 00302 00304 00314 static void SetResolveCoincidentTopology(int val); 00315 static int GetResolveCoincidentTopology(); 00316 static void SetResolveCoincidentTopologyToDefault(); 00317 static void SetResolveCoincidentTopologyToOff() 00318 { SetResolveCoincidentTopology(VTK_RESOLVE_OFF) ;} 00319 static void SetResolveCoincidentTopologyToPolygonOffset() 00320 { SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET); } 00321 static void SetResolveCoincidentTopologyToShiftZBuffer() 00322 { SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER); } 00324 00326 00329 static void SetResolveCoincidentTopologyPolygonOffsetParameters( 00330 double factor, double units); 00331 static void GetResolveCoincidentTopologyPolygonOffsetParameters( 00332 double& factor, double& units); 00334 00336 00341 static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces); 00342 static int GetResolveCoincidentTopologyPolygonOffsetFaces(); 00344 00346 00348 static void SetResolveCoincidentTopologyZShift(double val); 00349 static double GetResolveCoincidentTopologyZShift(); 00351 00353 00355 virtual double *GetBounds(); 00356 virtual void GetBounds(double bounds[6]) 00357 { this->vtkAbstractMapper3D::GetBounds(bounds); } 00359 00361 00364 void SetRenderTime(double time) {this->RenderTime = time;} 00365 vtkGetMacro(RenderTime, double); 00367 00368 //BTX 00370 00372 vtkDataSet *GetInput(); 00373 //ETX 00375 00377 00381 vtkDataSet *GetInputAsDataSet() 00382 { return this->GetInput(); } 00384 00386 00391 virtual vtkUnsignedCharArray *MapScalars(double alpha); 00392 virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input, 00393 double alpha); 00395 00397 00398 vtkSetMacro(ScalarMaterialMode,int); 00399 vtkGetMacro(ScalarMaterialMode,int); 00400 void SetScalarMaterialModeToDefault() 00401 { this->SetScalarMaterialMode(VTK_MATERIALMODE_DEFAULT); } 00402 void SetScalarMaterialModeToAmbient() 00403 { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT); } 00404 void SetScalarMaterialModeToDiffuse() 00405 { this->SetScalarMaterialMode(VTK_MATERIALMODE_DIFFUSE); } 00406 void SetScalarMaterialModeToAmbientAndDiffuse() 00407 { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE); } 00409 00411 const char *GetScalarMaterialModeAsString(); 00412 00414 00421 virtual bool GetIsOpaque() 00422 { return true; } 00424 00426 00430 virtual bool GetSupportsSelection() 00431 { return false; } 00432 protected: 00433 vtkMapper(); 00434 ~vtkMapper(); 00436 00437 vtkUnsignedCharArray *Colors; 00438 00439 // Use texture coordinates for coloring. 00440 int InterpolateScalarsBeforeMapping; 00441 // Coordinate for each point. 00442 vtkFloatArray *ColorCoordinates; 00443 // 1D ColorMap used for the texture image. 00444 vtkImageData* ColorTextureMap; 00445 void MapScalarsToTexture(vtkDataArray* scalars, double alpha); 00446 00447 vtkScalarsToColors *LookupTable; 00448 int ScalarVisibility; 00449 vtkTimeStamp BuildTime; 00450 double ScalarRange[2]; 00451 int UseLookupTableScalarRange; 00452 int ImmediateModeRendering; 00453 int ColorMode; 00454 int ScalarMode; 00455 int ScalarMaterialMode; 00456 00457 double RenderTime; 00458 00459 // for coloring by a component of a field data array 00460 int ArrayId; 00461 char ArrayName[256]; 00462 int ArrayComponent; 00463 int ArrayAccessMode; 00464 00465 // If coloring by field data, which tuple to use to color the entire 00466 // data set. If -1, treat array values as cell data. 00467 vtkIdType FieldDataTupleId; 00468 00469 int Static; 00470 00471 int ForceCompileOnly; 00472 00473 private: 00474 vtkMapper(const vtkMapper&); // Not implemented. 00475 void operator=(const vtkMapper&); // Not implemented. 00476 }; 00477 00478 #endif