1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 5 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 6 All rights reserved. 7 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 8 9 This software is distributed WITHOUT ANY WARRANTY; without even 10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 11 PURPOSE. See the above copyright notice for more information. 12 13 =========================================================================*/ 14 /** 15 * @class vtkOpenGLPointGaussianMapper 16 * @brief draw PointGaussians using imposters 17 * 18 * An OpenGL mapper that uses imposters to draw PointGaussians. Supports 19 * transparency and picking as well. 20 */ 21 22 #ifndef vtkOpenGLPointGaussianMapper_h 23 #define vtkOpenGLPointGaussianMapper_h 24 25 #include "vtkRenderingOpenGL2Module.h" // For export macro 26 #include "vtkPointGaussianMapper.h" 27 #include <vector> // for ivar 28 29 class vtkOpenGLPointGaussianMapperHelper; 30 31 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLPointGaussianMapper : public vtkPointGaussianMapper 32 { 33 public: 34 static vtkOpenGLPointGaussianMapper* New(); 35 vtkTypeMacro(vtkOpenGLPointGaussianMapper, vtkPointGaussianMapper) 36 void PrintSelf(ostream& os, vtkIndent indent) override; 37 38 /** 39 * Release any graphics resources that are being consumed by this mapper. 40 * The parameter window could be used to determine which graphic 41 * resources to release. 42 */ 43 void ReleaseGraphicsResources(vtkWindow *) override; 44 45 /** 46 * Is this mapper opqaue? currently always false. 47 */ 48 bool GetIsOpaque() override; 49 50 /** 51 * This calls RenderPiece (in a for loop if streaming is necessary). 52 */ 53 void Render(vtkRenderer *ren, vtkActor *act) override; 54 55 /** 56 * allows a mapper to update a selections color buffers 57 * Called from a prop which in turn is called from the selector 58 */ 59 void ProcessSelectorPixelBuffers(vtkHardwareSelector *sel, 60 std::vector<unsigned int> &pixeloffsets, 61 vtkProp *prop) override; 62 63 protected: 64 vtkOpenGLPointGaussianMapper(); 65 ~vtkOpenGLPointGaussianMapper() override; 66 67 void ReportReferences(vtkGarbageCollector* collector) override; 68 69 std::vector<vtkOpenGLPointGaussianMapperHelper *> Helpers; 70 vtkOpenGLPointGaussianMapperHelper *CreateHelper(); 71 void CopyMapperValuesToHelper( 72 vtkOpenGLPointGaussianMapperHelper *helper); 73 74 vtkTimeStamp HelperUpdateTime; 75 vtkTimeStamp ScaleTableUpdateTime; 76 vtkTimeStamp OpacityTableUpdateTime; 77 78 // unused RenderPiece(vtkRenderer *,vtkActor *)79 void RenderPiece(vtkRenderer *, vtkActor *) override {}; 80 81 void RenderInternal(vtkRenderer *, vtkActor *); 82 83 // create the table for opacity values 84 void BuildOpacityTable(); 85 86 // create the table for scale values 87 void BuildScaleTable(); 88 89 float *OpacityTable; // the table 90 double OpacityScale; // used for quick lookups 91 double OpacityOffset; // used for quick lookups 92 float *ScaleTable; // the table 93 double ScaleScale; // used for quick lookups 94 double ScaleOffset; // used for quick lookups 95 96 /** 97 * We need to override this method because the standard streaming 98 * demand driven pipeline may not be what we need as we can handle 99 * hierarchical data as input 100 */ 101 vtkExecutive* CreateDefaultExecutive() override; 102 103 /** 104 * Need to define the type of data handled by this mapper. 105 */ 106 int FillInputPortInformation(int port, vtkInformation* info) override; 107 108 /** 109 * Need to loop over the hierarchy to compute bounds 110 */ 111 void ComputeBounds() override; 112 113 // used by the hardware selector 114 std::vector<std::vector<unsigned int>> PickPixels; 115 116 private: 117 vtkOpenGLPointGaussianMapper(const vtkOpenGLPointGaussianMapper&) = delete; 118 void operator=(const vtkOpenGLPointGaussianMapper&) = delete; 119 }; 120 121 #endif 122