Salome HOME
c4efc7d25c80c2471f5f83b6b4651e4869cdcbad
[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) const;
460     
461     PGaussImpl myGauss; //<! Keep reference to corresponding TGauss structure
462
463     //! Keeps status of the structure
464     /*!
465       In some cases MED file does not use MED GAUSS, but at VISU creates corresponding data strucutre
466       in order to construct mesh for MED TIEMSTAMPS in uniform way.
467     */
468     ESubMeshStatus myStatus;
469
470     TPointCoords myPointCoords; //!< Keeps coordinates of Gauss Points
471   };
472   typedef SharedPtr<TGaussSubMeshImpl> PGaussSubMeshImpl;
473
474
475   //---------------------------------------------------------------
476   typedef TVector<PGaussSubMeshImpl> TGaussSubMeshArr;
477   typedef std::map<EGeometry,PGaussSubMeshImpl> TGeom2GaussSubMesh;
478
479   //! Specialize TGaussMesh to provide VTK mapping for the entity
480   struct TGaussMeshImpl: virtual TGaussMesh, 
481                          virtual TAppendFilter
482   {
483     TGaussMeshImpl();
484
485     //! Reimplement the TGaussPtsIDMapper::GetObjID
486     virtual
487     TGaussPointID
488     GetObjID(vtkIdType theID) const;
489
490     //! Reimplement the TIDMapper::GetVTKOutput
491     virtual
492     TVTKOutput* 
493     GetVTKOutput();
494
495     //! Reimplement the TGaussPtsIDMapper::GetParent
496     virtual 
497     TNamedIDMapper*
498     GetParent();
499
500     TSource mySource; //!< Keeps VTK representation of the Gauss Points
501     TNamedIDMapper* myParent; //!< Refer to parent mesh
502     TGaussSubMeshArr myGaussSubMeshArr; //!< Keeps sequence of TGaussSubMesh as they were added into TAppendFilter
503     TGeom2GaussSubMesh myGeom2GaussSubMesh; //!< Keeps TGaussSubMesh according to their geometrical type
504   };
505   typedef SharedPtr<TGaussMeshImpl> PGaussMeshImpl;
506
507
508   //---------------------------------------------------------------
509   //! Specialize TGaussPtsIDMapper to provide VTK mapping for MED TIMESTAMP mesh
510   struct TGaussPtsIDFilter: virtual TIDMapperFilter,
511                             virtual TGaussPtsIDMapper
512   { 
513     PGaussPtsIDMapper myGaussPtsIDMapper;
514
515     //! Reimplement the TGaussPtsIDMapper::GetObjID
516     virtual 
517     TGaussPointID 
518     GetObjID(vtkIdType theID) const;
519
520     //! Reimplement the TGaussPtsIDMapper::GetParent
521     virtual 
522     TNamedIDMapper*
523     GetParent();
524   };
525   typedef SharedPtr<TGaussPtsIDFilter> PGaussPtsIDFilter;
526
527
528   //---------------------------------------------------------------
529   typedef TVector<vtkIdType> TConnect;
530   typedef TVector<TConnect> TCell2Connect;
531
532   //! The class is responsible for mapping of cells of defined geometrical type  
533   struct TSubMeshImpl: virtual TSource
534   {
535     
536     //! To implement the TIDMapper::GetElemObjID
537     virtual 
538     vtkIdType 
539     GetElemObjID(vtkIdType theID) const;
540
541     //! To implement the TNamedIDMapper::GetElemName
542     virtual
543     std::string 
544     GetElemName(vtkIdType theObjID) const;
545
546     vtkIdType myStartID;
547     TCell2Connect myCell2Connect; //!< Contains connectivity for the cells
548   };
549   typedef SharedPtr<TSubMeshImpl> PSubMeshImpl;
550
551
552   //---------------------------------------------------------------
553   typedef std::map<EGeometry,PSubMeshImpl> TGeom2SubMesh;
554   typedef TVector<PSubMeshImpl> TSubMeshArr;
555
556   //! Specialize TMeshOnEntity to provide VTK mapping for the entity
557   struct TMeshOnEntityImpl: virtual TMeshOnEntity, 
558                             virtual TAppendFilter, 
559                             virtual TSizeCounter
560   {
561     //! Reimplement the TIDMapper::GetNodeVTKID
562     virtual 
563     vtkIdType 
564     GetNodeVTKID(vtkIdType theID) const;
565
566     //! Reimplement the TIDMapper::GetNodeObjID
567     virtual 
568     vtkIdType 
569     GetNodeObjID(vtkIdType theID) const;
570
571     //! Reimplement the TIDMapper::GetElemVTKID
572     virtual 
573     vtkIdType 
574     GetElemVTKID(vtkIdType theID) const;
575
576     //! Reimplement the TIDMapper::GetElemObjID
577     virtual 
578     vtkIdType 
579     GetElemObjID(vtkIdType theID) const;
580
581     //! Reimplement the TNamedIDMapper::GetNodeName
582     virtual
583     std::string 
584     GetNodeName(vtkIdType theObjID) const;
585
586     //! Reimplement the TNamedIDMapper::GetElemName
587     virtual
588     std::string 
589     GetElemName(vtkIdType theObjID) const;
590
591     TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping 
592     TSubMeshArr mySubMeshArr; //!< Keeps sequence of TSubMeshImpl as they were added into TAppendFilter
593     PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
594
595     TGeom2SubMesh myGeom2SubMesh; //!< Keeps TSubMeshImpl according to their geometrical type
596   };
597   typedef SharedPtr<TMeshOnEntityImpl> PMeshOnEntityImpl;
598
599
600   //---------------------------------------------------------------
601   typedef std::map<EGeometry,TSubMeshID> TGeom2SubMeshID;
602
603   //! Specialize TFamily to provide VTK mapping for the entity
604   struct TFamilyImpl: virtual TFamily, 
605                       virtual TSource
606   {
607     //! Reimplement the TIDMapper::GetNodeObjID
608     vtkIdType 
609     GetNodeObjID(vtkIdType theID) const ;
610
611     //! Reimplement the TIDMapper::GetNodeVTKID
612     virtual 
613     vtkIdType 
614     GetNodeVTKID(vtkIdType theID) const ;
615
616     //! Reimplement the TIDMapper::GetElemVTKID
617     virtual 
618     vtkIdType 
619     GetElemVTKID(vtkIdType theID) const;
620
621     //! Reimplement the TIDMapper::GetElemObjID
622     virtual 
623     vtkIdType 
624     GetElemObjID(vtkIdType theID) const;
625
626     //! Reimplement the TIDMapper::GetVTKOutput
627     virtual
628     TVTKOutput* 
629     GetVTKOutput();
630
631     PNamedPointCoords myNamedPointCoords;  //!< Share the same instance with TMesh to implement nodal mapping
632     TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
633     TSubMeshID myMeshID; //!< Keeps numbers of mesh elements that belongs to the MED FAMILY
634
635     TGeom2SubMeshID myGeom2SubMeshID; //!< Keeps TSubMeshID according to their geometrical type
636   };
637   typedef SharedPtr<TFamilyImpl> PFamilyImpl;
638
639
640   //---------------------------------------------------------------
641   typedef std::pair<vtkIdType,vtkIdType> TNbASizeCells;
642   typedef TVector<PFamilyImpl> TFamilyArr;
643
644   //! Specialize TGroup to provide VTK mapping for the entity
645   struct TGroupImpl: virtual TGroup, 
646                      virtual TAppendFilter
647   {
648     //! Calculate pair of values - number of cells and its size
649     TNbASizeCells 
650     GetNbASizeCells() const;
651
652     //! Reimplement the TIDMapper::GetElemVTKID
653     virtual 
654     vtkIdType 
655     GetElemVTKID(vtkIdType theID) const;
656
657     //! Reimplement the TIDMapper::GetElemObjID
658     virtual 
659     vtkIdType 
660     GetElemObjID(vtkIdType theID) const;
661
662     //! Reimplement the TIDMapper::GetNodeObjID
663     virtual 
664     vtkIdType 
665     GetNodeObjID(vtkIdType theID) const;
666
667     //! Reimplement the TIDMapper::GetNodeVTKID
668     virtual 
669     vtkIdType 
670     GetNodeVTKID(vtkIdType theID) const;
671
672     TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
673     TFamilyArr myFamilyArr; //!< Keeps sequence of TFamily as they were added into TAppendFilter
674     PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
675   };
676   typedef SharedPtr<TGroupImpl> PGroupImpl;
677
678
679   //---------------------------------------------------------------
680   typedef TVector<TMinMax> TMinMaxArr;
681
682   //! Specialize TField to provide VTK mapping for the entity
683   struct TFieldImpl: virtual TField
684   {
685     vtkIdType myDataSize; //!< Keeps size of the assigned data
686
687     TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD
688
689     //! Implement the TField::GetMinMax
690     virtual
691     TMinMax 
692     GetMinMax(vtkIdType theCompID);
693
694     //! To initialize the data structure    
695     void 
696     InitArrays(vtkIdType theNbComp);
697
698     TFieldImpl();
699   };
700   typedef SharedPtr<TFieldImpl> PFieldImpl;
701
702
703   //---------------------------------------------------------------
704   typedef TVector<float> TValue;
705   typedef TSlice<TValue> TValueSlice;
706   typedef TCSlice<TValue> TCValueSlice;
707
708   typedef TVector<TCValueSlice> TCValueSliceArr;
709   typedef TVector<TValueSlice> TValueSliceArr;
710
711   //! Define a container to get access to data assigned to mesh
712   struct TMeshValue
713   {
714     TValue myValue; //!< Keeps all values as one dimensional sequence
715
716     vtkIdType myNbElem; //!< Defines number of mesh elements where the data assigned to
717     vtkIdType myNbComp; //!< Keeps number of components of corresponding MED FIELD
718     vtkIdType myNbGauss; //!< Defines number of Gauss Points
719     vtkIdType myStep; //! Internal variable
720
721     //! To intitilize the data strucutre
722     void
723     Init(vtkIdType theNbElem,
724          vtkIdType theNbGauss,
725          vtkIdType theNbComp);
726
727     //! To get assigned values first by Gauss Points and then by components (constant version)
728     TCValueSliceArr
729     GetGaussValueSliceArr(vtkIdType theElemId) const;
730
731     //! To get assigned values first by Gauss Points and then by components
732     TValueSliceArr 
733     GetGaussValueSliceArr(vtkIdType theElemId);
734
735     //! To get assigned values first by components and then by Gauss Points (constant version)
736     TCValueSliceArr
737     GetCompValueSliceArr(vtkIdType theElemId) const;
738
739     //! To get assigned values first by components and then by Gauss Points
740     TValueSliceArr 
741     GetCompValueSliceArr(vtkIdType theElemId);
742   };
743   
744
745   //---------------------------------------------------------------
746   typedef std::map<EGeometry,TMeshValue> TGeom2Value;
747   typedef std::map<EGeometry,vtkIdType> TGeom2NbGauss;
748
749   //! Specialize TValForTime to provide VTK mapping for the entity
750   struct TValForTimeImpl: virtual TValForTime
751   {
752     PGaussPtsIDFilter myGaussPtsIDFilter; //!< Keep VTK representation for mesh and data on Gauss Points
753     PIDMapperFilter myIDMapperFilter; //!< Keep VTK representation for ordinary mesh and data
754     TGeom2Value myGeom2Value; //!< Keep value that is assigned to the mesh
755     TGeom2NbGauss myGeom2NbGauss; //!< Keep number of Gauss Points
756    
757     TValForTimeImpl();
758
759     //! Get mesh data for defined geometrical type (constant version)
760     const TMeshValue& 
761     GetMeshValue(EGeometry theGeom) const;
762
763     //! Get mesh data for defined geometrical type
764     TMeshValue& 
765     GetMeshValue(EGeometry theGeom);
766
767     //! Get number of Gauss Points for defined geometrical type
768     virtual
769     int
770     GetNbGauss(EGeometry theGeom) const;
771   };
772   typedef SharedPtr<TValForTimeImpl> PValForTimeImpl;
773 }
774
775
776 //! This class perfroms mapping of intermediate data strucutres into corresponding VTK representation
777 /*!
778   It implements VISU_Convertor public interface and declare new pure virtual functions
779   to fill its intermediate data structure from a MED source
780 */
781 class VISU_Convertor_impl: public VISU_Convertor
782 {
783 public:
784   VISU_Convertor_impl();
785
786   virtual
787   ~VISU_Convertor_impl();
788
789   //! Just to define default behaviour
790   virtual
791   VISU_Convertor* 
792   Build();
793
794   //! Just to define default behaviour
795   virtual
796   VISU_Convertor* 
797   BuildEntities();
798
799   //! Just to define default behaviour
800   virtual
801   VISU_Convertor* 
802   BuildFields();
803
804   //! Just to define default behaviour
805   virtual
806   VISU_Convertor* 
807   BuildMinMax();
808
809   //! Just to define default behaviour
810   virtual
811   VISU_Convertor* 
812   BuildGroups();
813
814   //! Implemention of the VISU_Convertor::GetSize
815   virtual 
816   float
817   GetSize();
818
819   //! Implemention of the VISU_Convertor::GetMeshOnEntity
820   virtual 
821   VISU::PNamedIDMapper 
822   GetMeshOnEntity(const std::string& theMeshName, 
823                   const VISU::TEntity& theEntity);
824
825   //! Implemention of the VISU_Convertor::GetMeshOnEntitySize
826   virtual 
827   float 
828   GetMeshOnEntitySize(const std::string& theMeshName, 
829                        const VISU::TEntity& theEntity);
830
831   //! Implemention of the VISU_Convertor::GetFamilyOnEntity
832   virtual 
833   VISU::PIDMapper 
834   GetFamilyOnEntity(const std::string& theMeshName, 
835                     const VISU::TEntity& theEntity,
836                     const std::string& theFamilyName);
837
838   //! Implemention of the VISU_Convertor::GetFamilyOnEntitySize
839   virtual 
840   float 
841   GetFamilyOnEntitySize(const std::string& theMeshName, 
842                         const VISU::TEntity& theEntity,
843                         const std::string& theFamilyName);
844
845   //! Implemention of the VISU_Convertor::GetMeshOnGroup
846   virtual 
847   VISU::PIDMapper 
848   GetMeshOnGroup(const std::string& theMeshName, 
849                  const std::string& theGroupName);
850   
851   //! Implemention of the VISU_Convertor::GetMeshOnGroupSize
852   virtual 
853   float 
854   GetMeshOnGroupSize(const std::string& theMeshName, 
855                      const std::string& theGroupName);
856
857   //! Implemention of the VISU_Convertor::GetTimeStampOnMesh
858   virtual
859   VISU::PIDMapper 
860   GetTimeStampOnMesh(const std::string& theMeshName, 
861                      const VISU::TEntity& theEntity,
862                      const std::string& theFieldName,
863                      int theStampsNum);
864
865   //! Implemention of the VISU_Convertor::GetTimeStampSize
866   virtual 
867   float 
868   GetTimeStampSize(const std::string& theMeshName, 
869                    const VISU::TEntity& theEntity,
870                    const std::string& theFieldName,
871                    int theStampsNum);
872
873   //! Implemention of the VISU_Convertor::GetTimeStampOnGaussPts
874   virtual
875   VISU::PGaussPtsIDMapper 
876   GetTimeStampOnGaussPts(const std::string& theMeshName, 
877                          const VISU::TEntity& theEntity,
878                          const std::string& theFieldName,
879                          int theStampsNum);
880   
881   //! Implemention of the VISU_Convertor::GetFieldOnMeshSize
882   virtual 
883   float 
884   GetFieldOnMeshSize(const std::string& theMeshName, 
885                      const VISU::TEntity& theEntity,
886                      const std::string& theFieldName);
887
888   //! Implemention of the VISU_Convertor::GetField
889   virtual 
890   const VISU::PField 
891   GetField(const std::string& theMeshName, 
892            VISU::TEntity theEntity, 
893            const std::string& theFieldName);
894
895   //! Implemention of the VISU_Convertor::GetTimeStamp
896   virtual 
897   const VISU::PValForTime 
898   GetTimeStamp(const std::string& theMeshName, 
899                const VISU::TEntity& theEntity,
900                const std::string& theFieldName,
901                int theStampsNum);
902
903 protected:
904   //! An utility method to find TMesh by its name
905   VISU::PMeshImpl 
906   FindMesh(const std::string& theMeshName);
907
908   //! An utility method to find TMeshOnEntity by name of its parent mesh and entity
909   typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl> TFindMeshOnEntity;
910   TFindMeshOnEntity
911   FindMeshOnEntity(const std::string& theMeshName,
912                    const VISU::TEntity& theEntity);
913
914   //! An utility method to find TFamily by name of its parent mesh, corresponding entity and its name
915   typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl,VISU::PFamilyImpl> TFindFamilyOnEntity;
916   TFindFamilyOnEntity
917   FindFamilyOnEntity(const std::string& theMeshName,
918                     const VISU::TEntity& theEntity,
919                     const std::string& theFamilyName);
920
921   //! An utility method to find Group by name of its parent mesh and its name
922   typedef boost::tuple<VISU::PMeshImpl,VISU::PGroupImpl> TFindMeshOnGroup;
923   TFindMeshOnGroup
924   FindMeshOnGroup(const std::string& theMeshName, 
925                   const std::string& theGroupName);
926
927   //! An utility method to find TField by name of its parent mesh, corresponding entity and its name
928   typedef boost::tuple<VISU::PMeshImpl,
929                        VISU::PMeshOnEntityImpl,
930                        VISU::PMeshOnEntityImpl,
931                        VISU::PFieldImpl> TFindField;
932   TFindField
933   FindField(const std::string& theMeshName, 
934             const VISU::TEntity& theEntity, 
935             const std::string& theFieldName);
936
937   //! An utility method to find TTimeStamp by name of its parent mesh, corresponding entity, field name and its number
938   typedef boost::tuple<VISU::PMeshImpl,
939                        VISU::PMeshOnEntityImpl,
940                        VISU::PMeshOnEntityImpl,
941                        VISU::PFieldImpl,
942                        VISU::PValForTimeImpl> TFindTimeStamp;
943   TFindTimeStamp
944   FindTimeStamp(const std::string& theMeshName, 
945                 const VISU::TEntity& theEntity, 
946                 const std::string& theFieldName, 
947                 int theStampsNum);
948
949   VISU::TVTKOutput*
950   GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh,
951                         const VISU::PMeshOnEntityImpl& theMeshOnEntity,
952                         const VISU::PFieldImpl& theField,
953                         const VISU::PValForTimeImpl& theValForTime,
954                         const VISU::PIDMapperFilter& theIDMapperFilter,
955                         const VISU::PProfileImpl& theProfile,
956                         const VISU::TEntity& theEntity);
957   
958 protected:
959   //! To fill intermeiate representation of TMeshOnEntity from a MED source
960   virtual
961   int
962   LoadMeshOnEntity(VISU::PMeshImpl theMesh,
963                    VISU::PMeshOnEntityImpl theMeshOnEntity) = 0;
964
965   //! To fill intermeiate representation of TFamily from a MED source
966   virtual
967   int
968   LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
969                      VISU::PMeshOnEntityImpl theMeshOnEntity, 
970                      VISU::PFamilyImpl theFamily) = 0;
971
972   //! To fill intermeiate representation of TGroup from a MED source
973   virtual 
974   int
975   LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
976                   const VISU::TFamilySet& theFamilySet) = 0;
977
978   //! To fill intermeiate representation of TValForTime for ordinary mesh from a MED source
979   virtual 
980   int
981   LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, 
982                        VISU::PMeshOnEntityImpl theMeshOnEntity, 
983                        VISU::PFieldImpl theField, 
984                        VISU::PValForTimeImpl theValForTime) = 0;
985
986   //! To fill intermeiate representation of TValForTime for mesh on Gauss Points from a MED source
987   virtual 
988   int
989   LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh, 
990                            VISU::PMeshOnEntityImpl theMeshOnEntity, 
991                            VISU::PFieldImpl theField, 
992                            VISU::PValForTimeImpl theValForTime) = 0;
993 };
994
995 #endif