]> SALOME platform Git repositories - modules/visu.git/blob - src/PIPELINE/VISU_GaussPointsPL.hxx
Salome HOME
Porting to VTK 6.
[modules/visu.git] / src / PIPELINE / VISU_GaussPointsPL.hxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  VISU OBJECT : interactive object for VISU entities implementation
24 // File:    VISU_GaussPointsPL.hxx
25 // Author:  
26 // Module : VISU
27 //
28 #ifndef VISU_GaussPointsPL_HeaderFile
29 #define VISU_GaussPointsPL_HeaderFile
30
31 #include "VISUPipeline.hxx"
32 #include "VISU_MergedPL.hxx"
33 #include "VISU_ColoredPL.hxx"
34
35 #include <vector>
36
37 class VISU_OpenGLPointSpriteMapper;
38 class VISU_PointSpriteMapperHolder;
39
40 class vtkGeometryFilter;
41 class vtkGlyph3D;
42 class vtkSphereSource;
43 class vtkDataArray;
44 class vtkImageData;
45 class vtkPointSet;
46 class vtkPassThroughFilter;
47 class vtkDataSet;
48
49 class vtkWarpVector;
50 class SALOME_Transform;
51
52 class VISU_AppendFilter;
53 class VISU_GaussMergeFilter;
54
55 //----------------------------------------------------------------------------
56 //! Pipeline for the Gauss Points presentation.
57 /*!
58  * This class uses the special mapper (VISU_OpenGLPointSpriteMapper)
59  * for rendering the Gauss Points as Point Sprites.
60  */
61 class VISU_PIPELINE_EXPORT VISU_GaussPointsPL : public VISU_MergedPL,
62                                                 public VISU_ColoredPL
63 {
64 public:
65   //----------------------------------------------------------------------------
66   vtkTypeMacro(VISU_GaussPointsPL, VISU_ColoredPL);
67
68   static 
69   VISU_GaussPointsPL* 
70   New();
71   
72   virtual
73   unsigned long int 
74   GetMTime();
75
76   //----------------------------------------------------------------------------
77   void 
78   SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper);
79
80   const VISU::PGaussPtsIDMapper&  
81   GetGaussPtsIDMapper();
82
83   VISU_PointSpriteMapperHolder*
84   GetPointSpriteMapperHolder();
85
86   //! Get the internal #VISU_OpenGLPointSpriteMapper.
87   VISU_OpenGLPointSpriteMapper*
88   GetPointSpriteMapper();
89
90   vtkDataSet*  
91   GetParentMesh();
92
93   //! Get an intermediate dataset that can be picked  
94   vtkAlgorithmOutput*
95   GetPickableDataSet();
96
97   //----------------------------------------------------------------------------
98   //! Redefined method for initialization of the pipeline.
99   virtual
100   void
101   Init();
102
103   //! Redefined method for updating the pipeline.
104   virtual
105   void
106   Update();
107
108   //! Gets memory size used by the instance (bytes).
109   virtual
110   unsigned long int
111   GetMemorySize();
112
113   //----------------------------------------------------------------------------
114   //! Update glyph.
115   void
116   UpdateGlyph();
117
118   virtual 
119   VISU::TGaussPointID 
120   GetObjID(vtkIdType theID);
121
122   //! Set the Bicolor mode.
123   /*!
124    * When the Bicolor parameter is set to true, scalar bars are
125    * drawing with two colors : red color correspoonds to positive
126    * scalar values, blue color - to negative values.
127    */
128   void
129   SetBicolor(bool theBicolor);
130
131   //! Get the Bicolor mode.
132   bool
133   GetBicolor();
134
135   //! Set the Multicolored mode.
136   /*!
137    * This parameter is using to switch between Results and Geometry
138    * modes. Multiple colors are using when the presentation is
139    * drawing in the Results mode, one color - in the Geometry mode.
140    */
141   void
142   SetIsColored(bool theIsColored);
143
144   bool 
145   GetIsColored();
146
147   //! Set type of the primitives.
148   void
149   SetPrimitiveType(int thePrimitiveType);
150
151   //! Get type of the primitives.
152   int
153   GetPrimitiveType();
154
155   //! Get the maximum Point Sprite size, which is supported by hardware.
156   double 
157   GetMaximumSupportedSize();
158
159   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteClamp.
160   void
161   SetClamp(double theClamp);
162
163   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteClamp, double).
164   double
165   GetClamp();
166
167   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteSize.
168   void
169   SetSize(double theSize);
170
171   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteSize, double).
172   double 
173   GetSize();
174
175   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteMinSize.
176   void
177   SetMinSize(double theMinSize);
178
179   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteMinSize, double).
180   double 
181   GetMinSize();
182
183   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteMinSize.
184   void
185   SetMaxSize(double theMaxSize);
186
187   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteMaxSize, double).
188   double 
189   GetMaxSize();
190
191   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteMagnification.
192   void
193   SetMagnification(double theMagnification);
194
195   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteMagnification, double).
196   double
197   GetMagnification();
198
199   //! Set the increment of changing Magnification parameter.
200   void
201   SetMagnificationIncrement(double theIncrement);
202
203   //! Get the increment of changing Magnification parameter.
204   double
205   GetMagnificationIncrement() { return myMagnificationIncrement; }
206
207   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteAlphaThreshold.
208   void
209   SetAlphaThreshold(double theAlphaThreshold);
210
211   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteAlphaThreshold, double).
212   double
213   GetAlphaThreshold();
214
215   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteOpacity.
216   void
217   SetOpacity(double theOpacity);
218
219   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteOpacity, double).
220   double
221   GetOpacity();
222
223   //! Set resolution of the Geometrical Sphere.
224   void
225   SetResolution(int theResolution);
226
227   //! Get resolution of the Geometrical Sphere.
228   int
229   GetResolution();
230
231   //! Method for changing the Magnification parameter.
232   void
233   ChangeMagnification( bool up );
234
235   //! Get the maximum size of Point Sprites in the presentation.
236   double
237   GetMaxPointSize();
238
239   //! Get point size by element's Id.
240   double
241   GetPointSize(vtkIdType theID);
242
243   //! Get point size by element's Id using the specified scalar array.
244   double
245   GetPointSize(vtkIdType theID, vtkDataArray* theScalarArray);
246
247   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkSetMacro(AverageCellSize, double).
248   void
249   SetAverageCellSize(double AverageCellSize);
250
251   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(AverageCellSize, double).
252   double
253   GetAverageCellSize();
254
255   //! Set image data for the Point Sprite texture.
256   void
257   SetImageData(vtkImageData* theImageData);
258
259   //! Make the image data for Point Sprite texture.
260   /*!
261    * First parameter - texture for shape.
262    * Second parameter - texture for alpha mask.
263    */
264   static
265   vtkSmartPointer<vtkImageData>
266   MakeTexture( const char* theMainTexture,
267                const char* theAlphaTexture );
268
269 public:
270   //----------------------------------------------------------------------------
271   virtual 
272   void
273   SetIsDeformed( bool theIsDeformed );
274
275   virtual
276   bool
277   GetIsDeformed();
278
279   virtual
280   void
281   SetScale( double theScale );
282
283   virtual
284   double 
285   GetScale();
286
287   virtual
288   void
289   SetMapScale( double theMapScale = 1.0 );
290
291 public:
292
293   virtual  
294   void  
295   SetSourceGeometry();
296
297   virtual
298   int
299   AddGeometry(vtkDataSet* theGeometry, const VISU::TName& theGeomName);
300
301   virtual
302   vtkDataSet*
303   GetGeometry(int theGeomNumber, VISU::TName& theGeomName);
304
305   virtual
306   int
307   GetNumberOfGeometry();
308
309   virtual
310   bool 
311   IsExternalGeometryUsed();
312
313   virtual
314   void
315   ClearGeometry();
316
317   virtual
318   void
319   GetSourceRange(double theRange[2]);
320
321   virtual 
322   vtkPointSet* 
323   GetMergedInput();
324
325   virtual 
326   vtkAlgorithmOutput* 
327   GetMergedInputPort();
328
329 protected:
330   //----------------------------------------------------------------------------
331   VISU_GaussPointsPL();
332
333   virtual
334   ~VISU_GaussPointsPL();
335
336   virtual
337   void
338   OnCreateMapperHolder();
339
340   virtual
341   void
342   Build();
343
344   virtual
345   vtkAlgorithmOutput* 
346   InsertCustomPL();
347
348   virtual
349   void
350   DoShallowCopy(VISU_PipeLine *thePipeLine,
351                 bool theIsCopyInput);
352
353 private:
354   //----------------------------------------------------------------------------
355   double myScaleFactor;
356   vtkWarpVector *myWarpVector;
357   std::vector<vtkPassThroughFilter*> myPassFilter;
358   vtkSmartPointer<VISU_PointSpriteMapperHolder> myPointSpriteMapperHolder;
359   
360   vtkGlyph3D* myGlyph;
361   vtkSphereSource* mySphereSource;
362
363   double myMagnificationIncrement;
364
365   int myPrimitiveType;
366
367   vtkSmartPointer<VISU_AppendFilter>      myAppendFilter;
368   vtkSmartPointer<VISU_GaussMergeFilter>  myMergeFilter;
369
370 private:
371   VISU_GaussPointsPL(const VISU_GaussPointsPL&);  // Not implemented.
372   void operator=(const VISU_GaussPointsPL&);  // Not implemented.
373 };
374   
375 #endif