Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/visu.git] / src / CONVERTOR / VISU_Convertor_impl.hxx
1 //  SALOME VTKViewer : build VTK viewer into Salome desktop
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : 
25 //  Author : 
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef VISU_Convertor_impl_HeaderFile
30 #define VISU_Convertor_impl_HeaderFile
31
32 #include <vtkSmartPointer.h>
33
34 #include <boost/tuple/tuple.hpp>
35
36 class vtkCell;
37 class vtkPoints;
38 class vtkUnstructuredGrid;
39 class VTKViewer_AppendFilter;
40 class VISU_MergeFilter;
41
42 #include "VISU_Convertor.hxx"
43 #include "MED_SliceArray.hxx"
44
45 #ifndef VISU_ENABLE_QUADRATIC
46 #define VISU_ENABLE_QUADRATIC
47 #define VISU_USE_VTK_QUADRATIC
48 #endif
49
50 namespace VISU
51 {
52   //! Defines VISU enumeration of geometrical types
53   enum EGeometry {ePOINT1=1, eSEG2=102, eSEG3=103, eTRIA3=203,
54                   eQUAD4=204, eTRIA6=206,eQUAD8=208, eTETRA4=304,
55                   ePYRA5=305, ePENTA6=306, eHEXA8=308, eTETRA10=310, 
56                   ePYRA13=313, ePENTA15=315, eHEXA20=320, 
57                   ePOLYGONE=400, ePOLYEDRE=500, eNONE=-1};
58
59   //! Get number of nodes for defined geometrical type
60   vtkIdType
61   VISUGeom2NbNodes(EGeometry theGeom);
62
63   //! Maps VISU geometrical type to VTK one
64   vtkIdType
65   VISUGeom2VTK(EGeometry theGeom);
66
67   //---------------------------------------------------------------
68   using MED::TCSlice;
69   using MED::TSlice;
70
71   typedef vtkUnstructuredGrid TDataSet;
72
73   typedef vtkSmartPointer<TDataSet> TVTKSource;
74   typedef vtkSmartPointer<vtkPoints> TVTKPoints;
75   typedef vtkSmartPointer<VISU_MergeFilter> TVTKMergeFilter;
76
77   typedef vtkSmartPointer<VTKViewer_AppendFilter> TVTKAppendFilter;
78
79   typedef float TCoord;
80
81   //---------------------------------------------------------------
82   //! Define an utility base class which is repsonsible for preventing repetion
83   struct TIsVTKDone: virtual TBaseStructure
84   {
85     TIsVTKDone();
86     bool myIsDone; //!< Say, is the corresponding MED entity already loaded into intermediate data structure 
87     bool myIsVTKDone; //!< Say, is the corresponding intermediate data structure already mapped into VTK representation  
88   };
89
90   
91   //---------------------------------------------------------------
92   //! Define an utility base class which allow to keep calculated number of cells and their size
93   struct TSizeCounter: virtual TIsVTKDone
94   {
95     TSizeCounter();
96     vtkIdType myNbCells; //!< Number of cells contained into corresponding sublclass
97     vtkIdType myCellsSize; //!< Size of cells contained into corresponding sublclass
98   };
99
100
101   //---------------------------------------------------------------
102   //! Define a container for VTK representation
103   class TSource: public virtual TSizeCounter
104   {
105   protected:
106     mutable TVTKSource mySource;
107   public:
108     TSource();
109
110     //! This method allow to create corresponding VTK data set by demand (not at once)
111     const TVTKSource& 
112     GetSource() const;
113
114     //! Reimplement the TIDMapper::GetVTKOutput
115     virtual
116     TVTKOutput* 
117     GetVTKOutput();
118   };
119
120
121   //---------------------------------------------------------------
122   //! Define a container for VTK representation
123   /*!
124     This container allow to combine other VTK representation into single one.
125   */
126   class TAppendFilter: public virtual TIsVTKDone,
127                        public virtual TIDMapper
128   {
129   protected:
130     mutable TVTKAppendFilter myFilter;
131   public:
132     TAppendFilter();
133
134     //! This method allow to create corresponding VTK filter by demand (not at once)
135     const TVTKAppendFilter& 
136     GetFilter() const;
137
138     //! Reimplement the TIDMapper::GetVTKOutput
139     virtual
140     TVTKOutput* 
141     GetVTKOutput();
142   };
143
144
145   //---------------------------------------------------------------
146   //! Define a container for VTK representation
147   /*!
148     This container allow to assign data to mesh and represent them into single VTK representation
149   */
150   class TMergeFilter: public virtual TIsVTKDone,
151                       public virtual TIDMapper
152   {
153   protected:
154     mutable TVTKMergeFilter myFilter;
155   public:
156     TMergeFilter();
157
158     //! This method allow to create corresponding VTK filter by demand (not at once)
159     const TVTKMergeFilter& 
160     GetFilter() const;
161
162     //! Reimplement the TIDMapper::GetVTKOutput
163     virtual
164     TVTKOutput* 
165     GetVTKOutput();
166   };
167
168
169   //---------------------------------------------------------------
170   typedef TVector<TCoord> TCoordArray;
171   typedef TSlice<TCoordArray> TCoordSlice;
172   typedef TCSlice<TCoordArray> TCCoordSlice;
173
174   //! This class is responsible for representation of mesh nodes
175   class TPointCoords: public virtual TBaseStructure
176   {
177   protected:
178     vtkIdType myDim; //!< Dimension of the nodal coordinates
179     vtkIdType myNbPoints; //!< Number of nodes in corresponding mesh
180
181     //! An container for coordinates of the nodes
182     /*!
183       Usage of slices allow to minimize amount of memory to store the nodal coordinates and
184       provide unifirm way of conversation with this coordinates (independant from mesh dimension)
185     */
186     TCoordArray myCoord; 
187     TVTKPoints myPoints; //!< VTK representation for the mesh nodes
188
189   public:
190     TPointCoords();
191
192     //! To initilize the class
193     void
194     Init(vtkIdType theNbPoints,
195          vtkIdType theDim);
196
197     //! Get slice of coordinates for defined node (const version)
198     TCCoordSlice
199     GetCoordSlice(vtkIdType theNodeId) const;
200
201     //! Get slice of coordinates for defined node
202     TCoordSlice 
203     GetCoordSlice(vtkIdType theNodeId);
204
205     vtkIdType
206     GetNbPoints() const { return myNbPoints; }
207
208     vtkIdType
209     GetDim() const { return myDim; }
210
211     vtkIdType
212     size() const { return GetNbPoints(); }
213
214     const TVTKPoints&
215     GetPoints() const { return myPoints;}
216   };
217   typedef SharedPtr<TPointCoords> PPointCoords;
218
219
220   //---------------------------------------------------------------
221   typedef TVector<vtkIdType> TVectorID;
222   typedef std::map<vtkIdType,vtkIdType> TObj2VTKID;
223
224   //! This class is responsible for representation of mesh nodes
225   /*!
226     In additition to its base functionlity it support mapping of VTK to object numeration and
227     keeps names for each of nodes.
228   */
229   class TNamedPointCoords: public virtual TPointCoords
230   {
231   protected:
232     typedef TVector<std::string> TPointsDim;
233     TPointsDim myPointsDim; //!< Keeps name of each dimension
234     TVectorID myVectorID; //!< Keeps object¶ numeration
235     TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one
236
237   public:
238
239     //! To initilize the class (numeration of the nodes can be missed)
240     void
241     Init(vtkIdType theNbPoints,
242          vtkIdType theDim,
243          const TVectorID& theVectorID = TVectorID());
244     
245     //! Get name for defined dimension
246     std::string&
247     GetName(vtkIdType theDim);
248     
249     //! Get name for defined dimension (const version)
250     const std::string&
251     GetName(vtkIdType theDim) const;
252
253     //! Get object number for node by its VTK one
254     virtual
255     vtkIdType
256     GetObjID(vtkIdType theID) const;
257
258     //! Get VTK number for node by its object one
259     virtual
260     vtkIdType
261     GetVTKID(vtkIdType theID) const;
262
263     //! Get name of node by its object number
264     virtual
265     std::string 
266     GetNodeName(vtkIdType theObjID) const;
267   };
268   typedef SharedPtr<TNamedPointCoords> PNamedPointCoords;
269
270
271   //---------------------------------------------------------------
272   //! Specialize TMesh to provide VTK mapping for nodes
273   struct TMeshImpl: virtual TMesh, 
274                     virtual TIsVTKDone
275   {
276     PNamedPointCoords myNamedPointCoords; //!< Keeps intermediate representation of the nodes
277
278     TVTKPoints myPoints; //!< Keeps VTK representation of the nodes
279     vtkIdType myNbPoints; //!< Keeps number of the nodes
280
281     TMeshImpl();
282   };
283   typedef SharedPtr<TMeshImpl> PMeshImpl;
284
285
286   //---------------------------------------------------------------
287   typedef TVector<vtkIdType> TSubMeshID;
288   typedef enum {eRemoveAll, eAddAll, eAddPart, eNone} ESubMeshStatus; 
289
290   //! Specialize TSubProfile to provide VTK mapping
291   struct TSubProfileImpl: virtual TSubProfile, 
292                           virtual TSource
293   {
294     TSubProfileImpl();
295
296     EGeometry myGeom; //!< Defines to what geometrical type the MED PROFILE belong to
297     std::string myName; //!< Keeps its name
298
299     //! Get object number of mesh cell by its VTK one
300     virtual 
301     vtkIdType 
302     GetElemObjID(int theVtkI) const;
303
304     //! Keeps status of the structure
305     /*!
306       In some cases MED file does not use MED PROFILES, but at VISU creates corresponding data strucutre
307       in order to construct mesh for MED TIEMSTAMPS in uniform way.
308     */
309     ESubMeshStatus myStatus; 
310     TSubMeshID mySubMeshID; //!< Keeps numbers of mesh cell which contain the MED PROFILE
311   };
312   typedef SharedPtr<TSubProfileImpl> PSubProfileImpl;
313
314
315   //---------------------------------------------------------------
316   struct TMeshOnEntityImpl;
317
318   typedef std::map<vtkIdType,vtkIdType> TID2ID;
319   typedef TVector<PSubProfileImpl> TSubProfileArr;
320   typedef std::map<EGeometry,PSubProfileImpl> TGeom2SubProfile;
321
322   //! Specialize TProfile to provide VTK mapping for MED TIMESTAMP mesh
323   struct TProfileImpl: virtual TProfile, 
324                        virtual TAppendFilter
325   {
326     TProfileImpl();
327     bool myIsAll; //!< Say, whether the MED TIMESTAMP defined on all MED ENTITY or not
328    
329     //! Reimplement the TIDMapper::GetNodeObjID
330     virtual 
331     vtkIdType 
332     GetNodeObjID(vtkIdType theID) const;
333
334     //! Reimplement the TIDMapper::GetNodeVTKID
335     virtual 
336     vtkIdType 
337     GetNodeVTKID(vtkIdType theID) const;
338
339     //! Reimplement the TIDMapper::GetNodeCoord
340     virtual 
341     float*  
342     GetNodeCoord(vtkIdType theObjID);
343
344     //! Reimplement the TIDMapper::GetElemObjID
345     virtual 
346     vtkIdType 
347     GetElemObjID(vtkIdType theID) const;
348
349     //! Reimplement the TIDMapper::GetElemVTKID
350     virtual 
351     vtkIdType 
352     GetElemVTKID(vtkIdType theID) const;
353
354     //! Reimplement the TIDMapper::GetElemCell
355     virtual
356     vtkCell* 
357     GetElemCell(vtkIdType theObjID);
358     
359     //! Reimplement the TIDMapper::GetVTKOutput
360     virtual
361     TVTKOutput* 
362     GetVTKOutput();
363
364     //! Reimplement the TNamedIDMapper::GetNodeName
365     virtual
366     std::string 
367     GetNodeName(vtkIdType theObjID) const;
368
369     //! Reimplement the TNamedIDMapper::GetElemName
370     virtual
371     std::string 
372     GetElemName(vtkIdType theObjID) const;
373
374     TID2ID myElemObj2VTKID; //!< Keeps object to VTK numeration mapping
375     TSubProfileArr mySubProfileArr; //!< Keeps sequence of TSubProfiles as they were added into TAppendFilter
376     PNamedPointCoords myNamedPointCoords; //!< Keeps reference on the same TNamedPointCoords as TMesh
377     TMeshOnEntityImpl* myMeshOnEntity; //<! Keeps backward reference to corresponding MED ENTITY mesh
378
379     TSource mySource; //!< Keeps VTK representation of the MED TIMESTAMP mesh
380     TGeom2SubProfile myGeom2SubProfile; //!< Keeps TSubProfiles according to their geometrical type
381   };
382   typedef SharedPtr<TProfileImpl> PProfileImpl;
383
384
385   //---------------------------------------------------------------
386   //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
387   struct TIDMapperFilter: virtual TMergeFilter
388   {
389     TAppendFilter myIDMapper; //!< Responsible for numbering
390     TSource mySource; //!< Keeps assigned data
391
392     //! Reimplement the TIDMapper::GetNodeObjID
393     virtual 
394     vtkIdType 
395     GetNodeObjID(vtkIdType theID) const;
396
397     //! Reimplement the TIDMapper::GetNodeVTKID
398     virtual 
399     vtkIdType 
400     GetNodeVTKID(vtkIdType theID) const;
401
402     //! Reimplement the TIDMapper::GetNodeCoord
403     virtual 
404     float*  
405     GetNodeCoord(vtkIdType theObjID);
406
407     //! Reimplement the TIDMapper::GetElemObjID
408     virtual 
409     vtkIdType 
410     GetElemObjID(vtkIdType theID) const;
411
412     //! Reimplement the TIDMapper::GetElemVTKID
413     virtual 
414     vtkIdType 
415     GetElemVTKID(vtkIdType theID) const;
416
417     //! Reimplement the TIDMapper::GetElemCell
418     virtual
419     vtkCell* 
420     GetElemCell(vtkIdType theObjID);
421     
422     //! Reimplement the TIDMapper::GetVTKOutput
423     virtual
424     TVTKOutput* 
425     GetVTKOutput();
426   };
427   typedef SharedPtr<TIDMapperFilter> PIDMapperFilter;
428
429
430   //---------------------------------------------------------------
431   struct TGaussImpl;
432   typedef SharedPtr<TGaussImpl> PGaussImpl;
433
434   //! Specialize TGauss to provide more detail information of the MED GAUSS entity for VTK mapping
435   struct TGaussImpl: virtual TGauss
436   {
437     EGeometry myGeom; //!< Define, to which geometrical type the MED GAUSS entity belongs
438     std::string myName; //!< Keeps name of the MED GAUSS entity
439     vtkIdType myNbPoints; //<! Keeps number of points for the MED GAUSS entity
440
441     //! To define a way to implement more detail comparision of the TGaussSubMesh instances
442     virtual
443     void
444     LessThan(const PGaussImpl& theGauss,
445              bool& theResult) const;
446   };
447
448
449   //---------------------------------------------------------------
450   //! Specialize TGaussSubMesh to provide VTK mapping for the entity
451   struct TGaussSubMeshImpl: virtual TGaussSubMesh, 
452                             virtual TSource
453   {
454     TGaussSubMeshImpl();
455
456     //! To implement the TGaussPtsIDMapper::GetObjID
457     virtual
458     TGaussPointID
459     GetObjID(vtkIdType theID,
460              vtkIdType theStartID) const;
461     
462     PGaussImpl myGauss; //<! Keep reference to corresponding TGauss structure
463
464     //! Keeps status of the structure
465     /*!
466       In some cases MED file does not use MED GAUSS, but at VISU creates corresponding data strucutre
467       in order to construct mesh for MED TIEMSTAMPS in uniform way.
468     */
469     ESubMeshStatus myStatus;
470
471     TPointCoords myPointCoords; //!< Keeps coordinates of Gauss Points
472   };
473   typedef SharedPtr<TGaussSubMeshImpl> PGaussSubMeshImpl;
474
475
476   //---------------------------------------------------------------
477   typedef TVector<PGaussSubMeshImpl> TGaussSubMeshArr;
478   typedef std::map<EGeometry,PGaussSubMeshImpl> TGeom2GaussSubMesh;
479
480   //! Specialize TGaussMesh to provide VTK mapping for the entity
481   struct TGaussMeshImpl: virtual TGaussMesh, 
482                          virtual TAppendFilter
483   {
484     TGaussMeshImpl();
485
486     //! Reimplement the TGaussPtsIDMapper::GetObjID
487     virtual
488     TGaussPointID
489     GetObjID(vtkIdType theID) const;
490
491     //! Reimplement the TIDMapper::GetVTKOutput
492     virtual
493     TVTKOutput* 
494     GetVTKOutput();
495
496     //! Reimplement the TGaussPtsIDMapper::GetParent
497     virtual 
498     TNamedIDMapper*
499     GetParent();
500
501     TSource mySource; //!< Keeps VTK representation of the Gauss Points
502     TNamedIDMapper* myParent; //!< Refer to parent mesh
503     TGaussSubMeshArr myGaussSubMeshArr; //!< Keeps sequence of TGaussSubMesh as they were added into TAppendFilter
504     TGeom2GaussSubMesh myGeom2GaussSubMesh; //!< Keeps TGaussSubMesh according to their geometrical type
505   };
506   typedef SharedPtr<TGaussMeshImpl> PGaussMeshImpl;
507
508
509   //---------------------------------------------------------------
510   //! Specialize TGaussPtsIDMapper to provide VTK mapping for MED TIMESTAMP mesh
511   struct TGaussPtsIDFilter: virtual TIDMapperFilter,
512                             virtual TGaussPtsIDMapper
513   { 
514     PGaussPtsIDMapper myGaussPtsIDMapper;
515
516     //! Reimplement the TGaussPtsIDMapper::GetObjID
517     virtual 
518     TGaussPointID 
519     GetObjID(vtkIdType theID) const;
520
521     //! Reimplement the TGaussPtsIDMapper::GetParent
522     virtual 
523     TNamedIDMapper*
524     GetParent();
525   };
526   typedef SharedPtr<TGaussPtsIDFilter> PGaussPtsIDFilter;
527
528
529   //---------------------------------------------------------------
530   typedef TVector<vtkIdType> TConnect;
531   typedef TVector<TConnect> TCell2Connect;
532
533   //! The class is responsible for mapping of cells of defined geometrical type  
534   struct TSubMeshImpl: virtual TSource
535   {
536     
537     //! To implement the TIDMapper::GetElemObjID
538     virtual 
539     vtkIdType 
540     GetElemObjID(vtkIdType theID) const;
541
542     //! To implement the TNamedIDMapper::GetElemName
543     virtual
544     std::string 
545     GetElemName(vtkIdType theObjID) const;
546
547     vtkIdType myStartID;
548     TCell2Connect myCell2Connect; //!< Contains connectivity for the cells
549   };
550   typedef SharedPtr<TSubMeshImpl> PSubMeshImpl;
551
552
553   //---------------------------------------------------------------
554   typedef std::map<EGeometry,PSubMeshImpl> TGeom2SubMesh;
555   typedef TVector<PSubMeshImpl> TSubMeshArr;
556
557   //! Specialize TMeshOnEntity to provide VTK mapping for the entity
558   struct TMeshOnEntityImpl: virtual TMeshOnEntity, 
559                             virtual TAppendFilter, 
560                             virtual TSizeCounter
561   {
562     //! Reimplement the TIDMapper::GetNodeVTKID
563     virtual 
564     vtkIdType 
565     GetNodeVTKID(vtkIdType theID) const;
566
567     //! Reimplement the TIDMapper::GetNodeObjID
568     virtual 
569     vtkIdType 
570     GetNodeObjID(vtkIdType theID) const;
571
572     //! Reimplement the TIDMapper::GetElemVTKID
573     virtual 
574     vtkIdType 
575     GetElemVTKID(vtkIdType theID) const;
576
577     //! Reimplement the TIDMapper::GetElemObjID
578     virtual 
579     vtkIdType 
580     GetElemObjID(vtkIdType theID) const;
581
582     //! Reimplement the TNamedIDMapper::GetNodeName
583     virtual
584     std::string 
585     GetNodeName(vtkIdType theObjID) const;
586
587     //! Reimplement the TNamedIDMapper::GetElemName
588     virtual
589     std::string 
590     GetElemName(vtkIdType theObjID) const;
591
592     TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping 
593     TSubMeshArr mySubMeshArr; //!< Keeps sequence of TSubMeshImpl as they were added into TAppendFilter
594     PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
595
596     TGeom2SubMesh myGeom2SubMesh; //!< Keeps TSubMeshImpl according to their geometrical type
597   };
598   typedef SharedPtr<TMeshOnEntityImpl> PMeshOnEntityImpl;
599
600
601   //---------------------------------------------------------------
602   typedef std::map<EGeometry,TSubMeshID> TGeom2SubMeshID;
603
604   //! Specialize TFamily to provide VTK mapping for the entity
605   struct TFamilyImpl: virtual TFamily, 
606                       virtual TSource
607   {
608     //! Reimplement the TIDMapper::GetNodeObjID
609     vtkIdType 
610     GetNodeObjID(vtkIdType theID) const ;
611
612     //! Reimplement the TIDMapper::GetNodeVTKID
613     virtual 
614     vtkIdType 
615     GetNodeVTKID(vtkIdType theID) const ;
616
617     //! Reimplement the TIDMapper::GetElemVTKID
618     virtual 
619     vtkIdType 
620     GetElemVTKID(vtkIdType theID) const;
621
622     //! Reimplement the TIDMapper::GetElemObjID
623     virtual 
624     vtkIdType 
625     GetElemObjID(vtkIdType theID) const;
626
627     //! Reimplement the TIDMapper::GetVTKOutput
628     virtual
629     TVTKOutput* 
630     GetVTKOutput();
631
632     PNamedPointCoords myNamedPointCoords;  //!< Share the same instance with TMesh to implement nodal mapping
633     TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
634     TSubMeshID myMeshID; //!< Keeps numbers of mesh elements that belongs to the MED FAMILY
635
636     TGeom2SubMeshID myGeom2SubMeshID; //!< Keeps TSubMeshID according to their geometrical type
637   };
638   typedef SharedPtr<TFamilyImpl> PFamilyImpl;
639
640
641   //---------------------------------------------------------------
642   typedef std::pair<vtkIdType,vtkIdType> TNbASizeCells;
643   typedef TVector<PFamilyImpl> TFamilyArr;
644
645   //! Specialize TGroup to provide VTK mapping for the entity
646   struct TGroupImpl: virtual TGroup, 
647                      virtual TAppendFilter
648   {
649     //! Calculate pair of values - number of cells and its size
650     TNbASizeCells 
651     GetNbASizeCells() const;
652
653     //! Reimplement the TIDMapper::GetElemVTKID
654     virtual 
655     vtkIdType 
656     GetElemVTKID(vtkIdType theID) const;
657
658     //! Reimplement the TIDMapper::GetElemObjID
659     virtual 
660     vtkIdType 
661     GetElemObjID(vtkIdType theID) const;
662
663     //! Reimplement the TIDMapper::GetNodeObjID
664     virtual 
665     vtkIdType 
666     GetNodeObjID(vtkIdType theID) const;
667
668     //! Reimplement the TIDMapper::GetNodeVTKID
669     virtual 
670     vtkIdType 
671     GetNodeVTKID(vtkIdType theID) const;
672
673     TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
674     TFamilyArr myFamilyArr; //!< Keeps sequence of TFamily as they were added into TAppendFilter
675     PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
676   };
677   typedef SharedPtr<TGroupImpl> PGroupImpl;
678
679
680   //---------------------------------------------------------------
681   typedef TVector<TMinMax> TMinMaxArr;
682
683   //! Specialize TField to provide VTK mapping for the entity
684   struct TFieldImpl: virtual TField
685   {
686     vtkIdType myDataSize; //!< Keeps size of the assigned data
687
688     TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD
689
690     //! Implement the TField::GetMinMax
691     virtual
692     TMinMax 
693     GetMinMax(vtkIdType theCompID);
694
695     //! To initialize the data structure    
696     void 
697     InitArrays(vtkIdType theNbComp);
698
699     TFieldImpl();
700   };
701   typedef SharedPtr<TFieldImpl> PFieldImpl;
702
703
704   //---------------------------------------------------------------
705   typedef TVector<float> TValue;
706   typedef TSlice<TValue> TValueSlice;
707   typedef TCSlice<TValue> TCValueSlice;
708
709   typedef TVector<TCValueSlice> TCValueSliceArr;
710   typedef TVector<TValueSlice> TValueSliceArr;
711
712   //! Define a container to get access to data assigned to mesh
713   struct TMeshValue
714   {
715     TValue myValue; //!< Keeps all values as one dimensional sequence
716
717     vtkIdType myNbElem; //!< Defines number of mesh elements where the data assigned to
718     vtkIdType myNbComp; //!< Keeps number of components of corresponding MED FIELD
719     vtkIdType myNbGauss; //!< Defines number of Gauss Points
720     vtkIdType myStep; //! Internal variable
721
722     //! To intitilize the data strucutre
723     void
724     Init(vtkIdType theNbElem,
725          vtkIdType theNbGauss,
726          vtkIdType theNbComp);
727
728     //! To get assigned values first by Gauss Points and then by components (constant version)
729     TCValueSliceArr
730     GetGaussValueSliceArr(vtkIdType theElemId) const;
731
732     //! To get assigned values first by Gauss Points and then by components
733     TValueSliceArr 
734     GetGaussValueSliceArr(vtkIdType theElemId);
735
736     //! To get assigned values first by components and then by Gauss Points (constant version)
737     TCValueSliceArr
738     GetCompValueSliceArr(vtkIdType theElemId) const;
739
740     //! To get assigned values first by components and then by Gauss Points
741     TValueSliceArr 
742     GetCompValueSliceArr(vtkIdType theElemId);
743   };
744   
745
746   //---------------------------------------------------------------
747   typedef std::map<EGeometry,TMeshValue> TGeom2Value;
748   typedef std::map<EGeometry,vtkIdType> TGeom2NbGauss;
749
750   //! Specialize TValForTime to provide VTK mapping for the entity
751   struct TValForTimeImpl: virtual TValForTime
752   {
753     PGaussPtsIDFilter myGaussPtsIDFilter; //!< Keep VTK representation for mesh and data on Gauss Points
754     PIDMapperFilter myIDMapperFilter; //!< Keep VTK representation for ordinary mesh and data
755     TGeom2Value myGeom2Value; //!< Keep value that is assigned to the mesh
756     TGeom2NbGauss myGeom2NbGauss; //!< Keep number of Gauss Points
757    
758     TValForTimeImpl();
759
760     //! Get mesh data for defined geometrical type (constant version)
761     const TMeshValue& 
762     GetMeshValue(EGeometry theGeom) const;
763
764     //! Get mesh data for defined geometrical type
765     TMeshValue& 
766     GetMeshValue(EGeometry theGeom);
767
768     //! Get number of Gauss Points for defined geometrical type
769     virtual
770     int
771     GetNbGauss(EGeometry theGeom) const;
772   };
773   typedef SharedPtr<TValForTimeImpl> PValForTimeImpl;
774 }
775
776
777 //! This class perfroms mapping of intermediate data strucutres into corresponding VTK representation
778 /*!
779   It implements VISU_Convertor public interface and declare new pure virtual functions
780   to fill its intermediate data structure from a MED source
781 */
782 class VISU_Convertor_impl: public VISU_Convertor
783 {
784 public:
785   VISU_Convertor_impl();
786
787   virtual
788   ~VISU_Convertor_impl();
789
790   //! Just to define default behaviour
791   virtual
792   VISU_Convertor* 
793   Build();
794
795   //! Just to define default behaviour
796   virtual
797   VISU_Convertor* 
798   BuildEntities();
799
800   //! Just to define default behaviour
801   virtual
802   VISU_Convertor* 
803   BuildFields();
804
805   //! Just to define default behaviour
806   virtual
807   VISU_Convertor* 
808   BuildMinMax();
809
810   //! Just to define default behaviour
811   virtual
812   VISU_Convertor* 
813   BuildGroups();
814
815   //! Implemention of the VISU_Convertor::GetSize
816   virtual 
817   float
818   GetSize();
819
820   //! Implemention of the VISU_Convertor::GetMeshOnEntity
821   virtual 
822   VISU::PNamedIDMapper 
823   GetMeshOnEntity(const std::string& theMeshName, 
824                   const VISU::TEntity& theEntity);
825
826   //! Implemention of the VISU_Convertor::GetMeshOnEntitySize
827   virtual 
828   float 
829   GetMeshOnEntitySize(const std::string& theMeshName, 
830                        const VISU::TEntity& theEntity);
831
832   //! Implemention of the VISU_Convertor::GetFamilyOnEntity
833   virtual 
834   VISU::PIDMapper 
835   GetFamilyOnEntity(const std::string& theMeshName, 
836                     const VISU::TEntity& theEntity,
837                     const std::string& theFamilyName);
838
839   //! Implemention of the VISU_Convertor::GetFamilyOnEntitySize
840   virtual 
841   float 
842   GetFamilyOnEntitySize(const std::string& theMeshName, 
843                         const VISU::TEntity& theEntity,
844                         const std::string& theFamilyName);
845
846   //! Implemention of the VISU_Convertor::GetMeshOnGroup
847   virtual 
848   VISU::PIDMapper 
849   GetMeshOnGroup(const std::string& theMeshName, 
850                  const std::string& theGroupName);
851   
852   //! Implemention of the VISU_Convertor::GetMeshOnGroupSize
853   virtual 
854   float 
855   GetMeshOnGroupSize(const std::string& theMeshName, 
856                      const std::string& theGroupName);
857
858   //! Implemention of the VISU_Convertor::GetTimeStampOnMesh
859   virtual
860   VISU::PIDMapper 
861   GetTimeStampOnMesh(const std::string& theMeshName, 
862                      const VISU::TEntity& theEntity,
863                      const std::string& theFieldName,
864                      int theStampsNum);
865
866   //! Implemention of the VISU_Convertor::GetTimeStampSize
867   virtual 
868   float 
869   GetTimeStampSize(const std::string& theMeshName, 
870                    const VISU::TEntity& theEntity,
871                    const std::string& theFieldName,
872                    int theStampsNum);
873
874   //! Implemention of the VISU_Convertor::GetTimeStampOnGaussPts
875   virtual
876   VISU::PGaussPtsIDMapper 
877   GetTimeStampOnGaussPts(const std::string& theMeshName, 
878                          const VISU::TEntity& theEntity,
879                          const std::string& theFieldName,
880                          int theStampsNum);
881   
882   //! Implemention of the VISU_Convertor::GetFieldOnMeshSize
883   virtual 
884   float 
885   GetFieldOnMeshSize(const std::string& theMeshName, 
886                      const VISU::TEntity& theEntity,
887                      const std::string& theFieldName);
888
889   //! Implemention of the VISU_Convertor::GetField
890   virtual 
891   const VISU::PField 
892   GetField(const std::string& theMeshName, 
893            VISU::TEntity theEntity, 
894            const std::string& theFieldName);
895
896   //! Implemention of the VISU_Convertor::GetTimeStamp
897   virtual 
898   const VISU::PValForTime 
899   GetTimeStamp(const std::string& theMeshName, 
900                const VISU::TEntity& theEntity,
901                const std::string& theFieldName,
902                int theStampsNum);
903
904 protected:
905   //! An utility method to find TMesh by its name
906   VISU::PMeshImpl 
907   FindMesh(const std::string& theMeshName);
908
909   //! An utility method to find TMeshOnEntity by name of its parent mesh and entity
910   typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl> TFindMeshOnEntity;
911   TFindMeshOnEntity
912   FindMeshOnEntity(const std::string& theMeshName,
913                    const VISU::TEntity& theEntity);
914
915   //! An utility method to find TFamily by name of its parent mesh, corresponding entity and its name
916   typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl,VISU::PFamilyImpl> TFindFamilyOnEntity;
917   TFindFamilyOnEntity
918   FindFamilyOnEntity(const std::string& theMeshName,
919                     const VISU::TEntity& theEntity,
920                     const std::string& theFamilyName);
921
922   //! An utility method to find Group by name of its parent mesh and its name
923   typedef boost::tuple<VISU::PMeshImpl,VISU::PGroupImpl> TFindMeshOnGroup;
924   TFindMeshOnGroup
925   FindMeshOnGroup(const std::string& theMeshName, 
926                   const std::string& theGroupName);
927
928   //! An utility method to find TField by name of its parent mesh, corresponding entity and its name
929   typedef boost::tuple<VISU::PMeshImpl,
930                        VISU::PMeshOnEntityImpl,
931                        VISU::PMeshOnEntityImpl,
932                        VISU::PFieldImpl> TFindField;
933   TFindField
934   FindField(const std::string& theMeshName, 
935             const VISU::TEntity& theEntity, 
936             const std::string& theFieldName);
937
938   //! An utility method to find TTimeStamp by name of its parent mesh, corresponding entity, field name and its number
939   typedef boost::tuple<VISU::PMeshImpl,
940                        VISU::PMeshOnEntityImpl,
941                        VISU::PMeshOnEntityImpl,
942                        VISU::PFieldImpl,
943                        VISU::PValForTimeImpl> TFindTimeStamp;
944   TFindTimeStamp
945   FindTimeStamp(const std::string& theMeshName, 
946                 const VISU::TEntity& theEntity, 
947                 const std::string& theFieldName, 
948                 int theStampsNum);
949
950   VISU::TVTKOutput*
951   GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh,
952                         const VISU::PMeshOnEntityImpl& theMeshOnEntity,
953                         const VISU::PFieldImpl& theField,
954                         const VISU::PValForTimeImpl& theValForTime,
955                         const VISU::PIDMapperFilter& theIDMapperFilter,
956                         const VISU::PProfileImpl& theProfile,
957                         const VISU::TEntity& theEntity);
958   
959 protected:
960   //! To fill intermeiate representation of TMeshOnEntity from a MED source
961   virtual
962   int
963   LoadMeshOnEntity(VISU::PMeshImpl theMesh,
964                    VISU::PMeshOnEntityImpl theMeshOnEntity) = 0;
965
966   //! To fill intermeiate representation of TFamily from a MED source
967   virtual
968   int
969   LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
970                      VISU::PMeshOnEntityImpl theMeshOnEntity, 
971                      VISU::PFamilyImpl theFamily) = 0;
972
973   //! To fill intermeiate representation of TGroup from a MED source
974   virtual 
975   int
976   LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
977                   const VISU::TFamilySet& theFamilySet) = 0;
978
979   //! To fill intermeiate representation of TValForTime for ordinary mesh from a MED source
980   virtual 
981   int
982   LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, 
983                        VISU::PMeshOnEntityImpl theMeshOnEntity, 
984                        VISU::PFieldImpl theField, 
985                        VISU::PValForTimeImpl theValForTime) = 0;
986
987   //! To fill intermeiate representation of TValForTime for mesh on Gauss Points from a MED source
988   virtual 
989   int
990   LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh, 
991                            VISU::PMeshOnEntityImpl theMeshOnEntity, 
992                            VISU::PFieldImpl theField, 
993                            VISU::PValForTimeImpl theValForTime) = 0;
994 };
995
996 #endif