1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef VTKViewer_POLYDATAMAPPER_H
21 #define VTKViewer_POLYDATAMAPPER_H
23 #include "VTKViewer.h"
24 #include "VTKViewer_MarkerDef.h"
34 #include <vtkSmartPointer.h>
38 #ifndef VTK_IMPLEMENT_MESA_CXX
39 #include <vtkOpenGLPolyDataMapper.h>
40 #define MAPPER_SUPERCLASS vtkOpenGLPolyDataMapper
42 #include <vtkMesaPolyDataMapper.h>
43 #define MAPPER_SUPERCLASS vtkMesaPolyDataMapper
46 //----------------------------------------------------------------------------
47 //! OpenGL Point Sprites PolyData Mapper.
49 * VTKViewer_PolyDataMapper is a class that maps polygonal data
50 * (i.e., vtkPolyData) to graphics primitives. It is performing the mapping
51 * to the rendering/graphics hardware/software. It is now possible to set a
52 * memory limit for the pipeline in the mapper. If the total estimated memory
53 * usage of the pipeline is larger than this limit, the mapper will divide
54 * the data into pieces and render each in a for loop.
56 class VTKVIEWER_EXPORT VTKViewer_PolyDataMapper : public MAPPER_SUPERCLASS
59 enum ExtensionsState { ES_None = 0, ES_Error, ES_Ok };
62 static VTKViewer_PolyDataMapper* New();
63 vtkTypeMacro( VTKViewer_PolyDataMapper, MAPPER_SUPERCLASS );
65 //! Set point marker enabled
66 void SetMarkerEnabled( bool );
68 //! Set standard point marker
69 void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
71 //! Set custom point marker
72 void SetMarkerTexture( int, VTK::MarkerTexture );
74 //! Get type of the point marker
75 VTK::MarkerType GetMarkerType();
77 //! Get scale of the point marker
78 VTK::MarkerScale GetMarkerScale();
80 //! Get texture identifier of the point marker
81 int GetMarkerTexture();
83 //! Implement superclass render method.
84 virtual void RenderPiece( vtkRenderer*, vtkActor* );
86 //! Draw method for OpenGL.
87 virtual int Draw( vtkRenderer*, vtkActor* );
90 VTKViewer_PolyDataMapper();
91 ~VTKViewer_PolyDataMapper();
93 //! Initializing OpenGL extensions.
96 //! Activate Point Sprites.
97 void InitPointSprites();
99 //! Deactivate Point Sprites.
100 void CleanupPointSprites();
102 //! Initializing textures for Point Sprites.
106 int ExtensionsInitialized;
108 GLuint PointSpriteTexture;
110 vtkSmartPointer<vtkImageData> ImageData;
113 VTK::MarkerType MarkerType;
114 VTK::MarkerScale MarkerScale;
117 typedef std::map< int, vtkSmartPointer<vtkImageData> > ImageDataMap;
118 ImageDataMap StandardTextures;
119 ImageDataMap CustomTextures;