VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkGenericCompositePolyDataMapper2.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 =========================================================================*/ 00024 #ifndef vtkGenericCompositePolyDataMapper2_h 00025 #define vtkGenericCompositePolyDataMapper2_h 00026 00027 #include "vtkRenderingOpenGL2Module.h" // For export macro 00028 #include "vtkSmartPointer.h" // for vtkSmartPointer 00029 #include "vtkOpenGLPolyDataMapper.h" 00030 00031 #include "vtkColor.h" // used for ivars 00032 #include <map> // use for ivars 00033 #include <stack> // used for ivars 00034 00035 class vtkCompositeDataDisplayAttributes; 00036 class vtkCompositeMapperHelper; 00037 00038 class VTKRENDERINGOPENGL2_EXPORT vtkGenericCompositePolyDataMapper2 : public vtkOpenGLPolyDataMapper 00039 { 00040 public: 00041 static vtkGenericCompositePolyDataMapper2* New(); 00042 vtkTypeMacro(vtkGenericCompositePolyDataMapper2, vtkOpenGLPolyDataMapper); 00043 void PrintSelf(ostream& os, vtkIndent indent); 00044 00053 virtual bool GetIsOpaque(); 00054 00056 00057 void SetCompositeDataDisplayAttributes(vtkCompositeDataDisplayAttributes *attributes); 00058 vtkCompositeDataDisplayAttributes* GetCompositeDataDisplayAttributes(); 00060 00062 00063 void SetBlockVisibility(unsigned int index, bool visible); 00064 bool GetBlockVisibility(unsigned int index) const; 00065 void RemoveBlockVisibility(unsigned int index); 00066 void RemoveBlockVisibilites(); 00068 00070 00071 void SetBlockColor(unsigned int index, double color[3]); 00072 void SetBlockColor(unsigned int index, double r, double g, double b) 00073 { 00074 double color[3] = {r, g, b}; 00075 this->SetBlockColor(index, color); 00076 } 00077 double* GetBlockColor(unsigned int index); 00078 void RemoveBlockColor(unsigned int index); 00079 void RemoveBlockColors(); 00081 00083 00084 void SetBlockOpacity(unsigned int index, double opacity); 00085 double GetBlockOpacity(unsigned int index); 00086 void RemoveBlockOpacity(unsigned int index); 00087 void RemoveBlockOpacities(); 00089 00090 //BTX 00091 protected: 00092 vtkGenericCompositePolyDataMapper2(); 00093 ~vtkGenericCompositePolyDataMapper2(); 00094 00098 vtkExecutive* CreateDefaultExecutive(); 00099 00101 virtual int FillInputPortInformation(int port, vtkInformation* info); 00102 00104 virtual void ComputeBounds(); 00105 00107 vtkTimeStamp BoundsMTime; 00108 00109 // what "index" are we currently rendering, -1 means none 00110 int CurrentFlatIndex; 00111 std::map<const vtkShaderProgram *, bool> ShadersInitialized; 00112 std::map<const vtkDataSet *, vtkCompositeMapperHelper *> Helpers; 00113 vtkTimeStamp HelperMTime; 00114 00115 // save resending uniforms every time 00116 bool GetShaderInitialized(vtkShaderProgram *); 00117 void SetShaderInitialized(vtkShaderProgram *, bool); 00118 00119 // copy values to the helpers 00120 void CopyMapperValuesToHelper(vtkCompositeMapperHelper *helper); 00121 00122 // free up memory 00123 void FreeGenericStructures(); 00124 00125 class RenderBlockState 00126 { 00127 public: 00128 std::stack<bool> Visibility; 00129 std::stack<double> Opacity; 00130 std::stack<vtkColor3d> AmbientColor; 00131 std::stack<vtkColor3d> DiffuseColor; 00132 std::stack<vtkColor3d> SpecularColor; 00133 }; 00134 00135 RenderBlockState BlockState; 00136 void RenderBlock(vtkRenderer *renderer, 00137 vtkActor *actor, 00138 vtkDataObject *dobj, 00139 unsigned int &flat_index); 00140 00142 virtual void RenderGeneric(vtkRenderer *ren, vtkActor *act); 00143 00145 vtkSmartPointer<vtkCompositeDataDisplayAttributes> CompositeAttributes; 00146 00147 friend class vtkCompositeMapperHelper; 00148 00149 private: 00150 unsigned long int LastOpaqueCheckTime; 00151 bool LastOpaqueCheckValue; 00152 double ColorResult[3]; 00153 00154 vtkGenericCompositePolyDataMapper2(const vtkGenericCompositePolyDataMapper2&); // Not implemented. 00155 void operator=(const vtkGenericCompositePolyDataMapper2&); // Not implemented. 00156 //ETX 00157 }; 00158 00159 #endif