Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/med.git] / src / MEDWrapper / Base / MED_TStructures.hxx
1 //  
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : 
25 //  Author : 
26 //  Module : 
27 //  $Header$
28
29 #ifndef MED_TStructures_HeaderFile
30 #define MED_TStructures_HeaderFile
31
32 #include "MED_Structures.hxx"
33
34 namespace MED
35 {
36   //---------------------------------------------------------------
37   //! To provide a common way to handle values of MEDWrapper types as native MED types
38   template<class TValue, class TRepresentation>
39   struct TValueHolder
40   {
41     TValue& myValue;
42     TRepresentation myRepresentation;
43
44     TValueHolder(TValue& theValue):
45       myValue(theValue),
46       myRepresentation(TRepresentation(theValue))
47     {}
48
49     ~TValueHolder()
50     {
51       myValue = TValue(myRepresentation);
52     }
53
54     TRepresentation*
55     operator& ()
56     {
57       return &myRepresentation;
58     }
59
60     operator TRepresentation () const
61     {
62       return myRepresentation;
63     }  
64
65     const TValue&
66     operator() () const
67     {
68       return myValue;
69     }  
70   };
71   
72   //! To customize TValueHolder common template definition for TVector
73   template<class TVal, class TRepresentation>
74   struct TValueHolder<TVector<TVal>, TRepresentation>
75   {
76     typedef TVector<TVal> TValue;
77     TValue& myValue;
78     TRepresentation* myRepresentation;
79
80     TValueHolder(TValue& theValue):
81       myValue(theValue)
82     {
83       if(theValue.empty())
84         myRepresentation = (TRepresentation*)NULL;
85       else
86         myRepresentation = (TRepresentation*)&theValue[0];
87     }
88
89     TRepresentation*
90     operator& ()
91     {
92       return myRepresentation;
93     }
94   };
95   
96   //---------------------------------------------------------------
97   template<EVersion eVersion>
98   struct TTNameInfo: virtual TNameInfo
99   {
100     TTNameInfo(const std::string& theValue)
101     {
102       myName.resize(GetNOMLength<eVersion>()+1);
103       SetName(theValue);
104     }
105
106     virtual
107     std::string
108     GetName() const 
109     { 
110       return GetString(0, GetNOMLength<eVersion>(), myName);
111     }
112
113     virtual
114     void
115     SetName(const std::string& theValue)
116     {
117       SetString(0, GetNOMLength<eVersion>(), myName, theValue);
118     }
119
120     virtual
121     void
122     SetName(const TString& theValue)
123     {
124       SetString(0, GetNOMLength<eVersion>(), myName, theValue);
125     }
126   };
127
128
129   //---------------------------------------------------------------
130   template<EVersion eVersion>
131   struct TTMeshInfo: 
132     virtual TMeshInfo, 
133     virtual TTNameInfo<eVersion>
134   {
135     typedef TTNameInfo<eVersion> TNameInfoBase;
136
137     TTMeshInfo(const PMeshInfo& theInfo):
138       TNameInfoBase(theInfo->GetName())
139     {
140       myDim = theInfo->GetDim();
141       myType = theInfo->GetType();
142       
143       myDesc.resize(GetDESCLength<eVersion>()+1);
144       SetDesc(theInfo->GetDesc());
145     }
146
147     TTMeshInfo(TInt theDim,
148                const std::string& theValue,
149                EMaillage theType,
150                const std::string& theDesc):
151       TNameInfoBase(theValue)
152     {
153       myDim = theDim;
154       myType = theType;
155       
156       myDesc.resize(GetDESCLength<eVersion>()+1);
157       SetDesc(theDesc);
158     }
159
160     virtual 
161     std::string
162     GetDesc() const 
163     { 
164       return GetString(0, GetDESCLength<eVersion>(), myDesc);
165     }
166
167     virtual
168     void
169     SetDesc(const std::string& theValue)
170     {
171       SetString(0, GetDESCLength<eVersion>(), myDesc, theValue);
172     }
173   };
174
175
176   //---------------------------------------------------------------
177   template<EVersion eVersion>
178   struct TTFamilyInfo: 
179     virtual TFamilyInfo, 
180     virtual TTNameInfo<eVersion>
181   {
182     typedef TTNameInfo<eVersion> TNameInfoBase;
183
184     TTFamilyInfo(const PMeshInfo& theMeshInfo, const PFamilyInfo& theInfo):
185       TNameInfoBase(theInfo->GetName())
186     {
187       myMeshInfo = theMeshInfo;
188
189       myId = theInfo->GetId();
190
191       myNbGroup = theInfo->GetNbGroup();
192       myGroupNames.resize(myNbGroup*GetLNOMLength<eVersion>()+1);
193       if(myNbGroup){
194         for(TInt anId = 0; anId < myNbGroup; anId++){
195           SetGroupName(anId,theInfo->GetGroupName(anId));
196         }
197       }
198
199       myNbAttr = theInfo->GetNbAttr();
200       myAttrId.resize(myNbAttr);
201       myAttrVal.resize(myNbAttr);
202       myAttrDesc.resize(myNbAttr*GetDESCLength<eVersion>()+1);
203       if(myNbAttr){
204         for(TInt anId = 0; anId < myNbAttr; anId++){
205           SetAttrDesc(anId,theInfo->GetAttrDesc(anId));
206           myAttrVal[anId] = theInfo->GetAttrVal(anId);
207           myAttrId[anId] = theInfo->GetAttrId(anId);
208         }
209       }
210     }
211
212     TTFamilyInfo(const PMeshInfo& theMeshInfo,
213                  TInt theNbGroup, 
214                  TInt theNbAttr,
215                  TInt theId,
216                  const std::string& theValue):
217       TNameInfoBase(theValue)
218     {
219       myMeshInfo = theMeshInfo;
220
221       myId = theId;
222
223       myNbGroup = theNbGroup;
224       myGroupNames.resize(theNbGroup*GetLNOMLength<eVersion>()+1);
225
226       myNbAttr = theNbAttr;
227       myAttrId.resize(theNbAttr);
228       myAttrVal.resize(theNbAttr);
229       myAttrDesc.resize(theNbAttr*GetDESCLength<eVersion>()+1);
230     }
231
232     TTFamilyInfo(const PMeshInfo& theMeshInfo,
233                  const std::string& theValue,
234                  TInt theId,
235                  const TStringSet& theGroupNames, 
236                  const TStringVector& theAttrDescs, 
237                  const TIntVector& theAttrIds, 
238                  const TIntVector& theAttrVals):
239       TNameInfoBase(theValue)
240     {
241       myMeshInfo = theMeshInfo;
242
243       myId = theId;
244
245       myNbGroup = (TInt)theGroupNames.size();
246       myGroupNames.resize(myNbGroup*GetLNOMLength<eVersion>()+1);
247       if(myNbGroup){
248         TStringSet::const_iterator anIter = theGroupNames.begin();
249         for(TInt anId = 0; anIter != theGroupNames.end(); anIter++, anId++){
250           const std::string& aVal = *anIter;
251           SetGroupName(anId,aVal);
252         }
253       }
254
255       myNbAttr = (TInt)theAttrDescs.size();
256       myAttrId.resize(myNbAttr);
257       myAttrVal.resize(myNbAttr);
258       myAttrDesc.resize(myNbAttr*GetDESCLength<eVersion>()+1);
259       if(myNbAttr){
260         for(TInt anId = 0, anEnd = (TInt)theAttrDescs.size(); anId < anEnd; anId++){
261           SetAttrDesc(anId,theAttrDescs[anId]);
262           myAttrVal[anId] = theAttrVals[anId];
263           myAttrId[anId] = theAttrIds[anId];
264         }
265       }
266     }
267
268     virtual
269     std::string
270     GetGroupName(TInt theId) const 
271     { 
272       return GetString(theId, GetLNOMLength<eVersion>(), myGroupNames);
273     }
274
275     virtual
276     void
277     SetGroupName(TInt theId, const std::string& theValue)
278     {
279       SetString(theId, GetLNOMLength<eVersion>(), myGroupNames, theValue);
280     }
281
282     virtual
283     std::string
284     GetAttrDesc(TInt theId) const 
285     { 
286       return GetString(theId, GetDESCLength<eVersion>(), myAttrDesc);
287     }
288
289     virtual
290     void
291     SetAttrDesc(TInt theId, const std::string& theValue)
292     {
293       SetString(theId, GetDESCLength<eVersion>(), myAttrDesc, theValue);
294     }
295   };
296
297
298   //---------------------------------------------------------------
299   template<EVersion eVersion>
300   struct TTElemInfo: virtual TElemInfo
301   {
302     TTElemInfo(const PMeshInfo& theMeshInfo, const PElemInfo& theInfo)
303     {
304       myMeshInfo = theMeshInfo;
305       
306       myNbElem = theInfo->GetNbElem();
307       myFamNum.reset(new TElemNum(myNbElem));
308
309       myIsElemNum = theInfo->IsElemNum();
310       if(theInfo->IsElemNum())
311         myElemNum.reset(new TElemNum(myNbElem));
312       else
313         myElemNum.reset(new TElemNum());
314
315       myIsElemNames = theInfo->IsElemNames();
316       if(theInfo->IsElemNames())
317         myElemNames.reset(new TString(myNbElem*GetPNOMLength<eVersion>() + 1));
318       else
319         myElemNames.reset(new TString());
320
321       if(theInfo->GetNbElem()){
322         for(TInt anId = 0; anId < myNbElem; anId++){
323           SetFamNum(anId, theInfo->GetFamNum(anId));
324         }
325         if(theInfo->IsElemNum() == eVRAI){
326           for(TInt anId = 0; anId < myNbElem; anId++){
327             SetElemNum(anId, theInfo->GetElemNum(anId));
328           }
329         }
330         if(theInfo->IsElemNames() == eVRAI){
331           for(TInt anId = 0; anId < myNbElem; anId++){
332             SetElemName(anId,theInfo->GetElemName(anId));
333           }
334         }
335       }
336     }
337
338     TTElemInfo(const PMeshInfo& theMeshInfo, 
339                TInt theNbElem,
340                EBooleen theIsElemNum,
341                EBooleen theIsElemNames)
342     {
343       myMeshInfo = theMeshInfo;
344
345       myNbElem = theNbElem;
346       myFamNum.reset(new TElemNum(theNbElem));
347
348       myIsElemNum = theIsElemNum;
349       if(theIsElemNum)
350         myElemNum.reset(new TElemNum(theNbElem));
351       else
352         myElemNum.reset(new TElemNum());
353
354       myIsElemNames = theIsElemNames;
355       if(theIsElemNames)
356         myElemNames.reset(new TString(theNbElem*GetPNOMLength<eVersion>() + 1));
357       else
358         myElemNames.reset(new TString());
359    }
360     
361     TTElemInfo(const PMeshInfo& theMeshInfo, 
362                TInt theNbElem,
363                const TIntVector& theFamilyNums,
364                const TIntVector& theElemNums,
365                const TStringVector& theElemNames)
366     {
367       myMeshInfo = theMeshInfo;
368       
369       myNbElem = theNbElem;
370       myFamNum.reset(new TElemNum(theNbElem));
371       
372       myIsElemNum = theElemNums.size()? eVRAI: eFAUX;
373       if(myIsElemNum)
374         myElemNum.reset(new TElemNum(theNbElem));
375       else
376         myElemNum.reset(new TElemNum());
377       
378       myIsElemNames = theElemNames.size()? eVRAI: eFAUX;
379       if(myIsElemNames)
380         myElemNames.reset(new TString(theNbElem*GetPNOMLength<eVersion>() + 1));
381       else
382         myElemNames.reset(new TString());
383      
384       if(theNbElem){
385
386         if(theFamilyNums.size())
387           *myFamNum = theFamilyNums;
388
389         if(myIsElemNum)
390           *myElemNum = theElemNums;
391
392         if(myIsElemNames){
393           for(TInt anId = 0; anId < theNbElem; anId++){
394             const std::string& aVal = theElemNames[anId];
395             SetElemName(anId,aVal);
396           }
397         }
398       }
399     }
400
401     virtual
402     std::string
403     GetElemName(TInt theId) const 
404     { 
405       return GetString(theId,GetPNOMLength<eVersion>(), *myElemNames);
406     }
407
408     virtual
409     void
410     SetElemName(TInt theId, const std::string& theValue)
411     {
412       SetString(theId,GetPNOMLength<eVersion>(), *myElemNames, theValue);
413     }
414   };
415
416
417   //---------------------------------------------------------------
418   template<EVersion eVersion>
419   struct TTNodeInfo: 
420     virtual TNodeInfo, 
421     virtual TTElemInfo<eVersion>
422   {
423     typedef TTElemInfo<eVersion> TElemInfoBase;
424
425     TTNodeInfo(const PMeshInfo& theMeshInfo, const PNodeInfo& theInfo):
426       TElemInfoBase(theMeshInfo, theInfo),
427       TNodeInfo(theInfo)
428     {
429       myModeSwitch = theInfo->GetModeSwitch();
430       
431       mySystem = theInfo->GetSystem();
432       
433       myCoord.reset(new TNodeCoord(*theInfo->myCoord));
434       
435       TInt aDim = theMeshInfo->GetDim();
436
437       myCoordNames.resize(aDim*GetPNOMLength<eVersion>()+1);
438       for(TInt anId = 0; anId < aDim; anId++)
439         SetCoordName(anId,theInfo->GetCoordName(anId));
440       
441       myCoordUnits.resize(aDim*GetPNOMLength<eVersion>()+1);
442       for(TInt anId = 0; anId < aDim; anId++)
443         SetCoordUnit(anId,theInfo->GetCoordUnit(anId));
444     }
445
446     TTNodeInfo(const PMeshInfo& theMeshInfo, 
447                TInt theNbElem,
448                EModeSwitch theMode,
449                ERepere theSystem, 
450                EBooleen theIsElemNum,
451                EBooleen theIsElemNames):
452       TElemInfoBase(theMeshInfo,
453                     theNbElem,
454                     theIsElemNum,
455                     theIsElemNames),
456       TModeSwitchInfo(theMode)
457     {
458       mySystem = theSystem;
459
460       myCoord.reset(new TNodeCoord(theNbElem * theMeshInfo->myDim));
461
462       if(theIsElemNum)
463         myCoordUnits.resize(theMeshInfo->myDim*GetPNOMLength<eVersion>()+1);
464
465       if(theIsElemNames)
466         myCoordNames.resize(theMeshInfo->myDim*GetPNOMLength<eVersion>()+1);
467     }
468
469     
470     TTNodeInfo(const PMeshInfo& theMeshInfo, 
471                const TFloatVector& theNodeCoords,
472                EModeSwitch theMode,
473                ERepere theSystem, 
474                const TStringVector& theCoordNames,
475                const TStringVector& theCoordUnits,
476                const TIntVector& theFamilyNums,
477                const TIntVector& theElemNums,
478                const TStringVector& theElemNames):
479       TElemInfoBase(theMeshInfo,
480                     (TInt)theNodeCoords.size()/theMeshInfo->GetDim(),
481                     theFamilyNums,
482                     theElemNums,
483                     theElemNames),
484       TModeSwitchInfo(theMode)
485     {
486       mySystem = theSystem;
487
488       myCoord.reset(new TNodeCoord(theNodeCoords));
489       
490       TInt aDim = theMeshInfo->GetDim();
491
492       myCoordNames.resize(aDim*GetPNOMLength<eVersion>()+1);
493       if(!theCoordNames.empty())
494         for(TInt anId = 0; anId < aDim; anId++)
495           SetCoordName(anId,theCoordNames[anId]);
496       
497       myCoordUnits.resize(aDim*GetPNOMLength<eVersion>() + 1);
498       if(!theCoordUnits.empty())
499         for(TInt anId = 0; anId < aDim; anId++)
500           SetCoordUnit(anId, theCoordUnits[anId]);
501     }
502
503     virtual
504     std::string
505     GetCoordName(TInt theId) const 
506     { 
507       return GetString(theId,GetPNOMLength<eVersion>(),myCoordNames);
508     }
509
510     virtual
511     void
512     SetCoordName(TInt theId, const std::string& theValue)
513     {
514       SetString(theId,GetPNOMLength<eVersion>(),myCoordNames,theValue);
515     }
516
517     virtual
518     std::string 
519     GetCoordUnit(TInt theId) const 
520     { 
521       return GetString(theId,GetPNOMLength<eVersion>(),myCoordUnits);
522     }
523
524     virtual
525     void
526     SetCoordUnit(TInt theId, const std::string& theValue)
527     {
528       SetString(theId,GetPNOMLength<eVersion>(),myCoordUnits,theValue);
529     }
530   };
531
532   //---------------------------------------------------------------
533   template<EVersion eVersion>
534   struct TTPolygoneInfo: 
535     virtual TPolygoneInfo, 
536     virtual TTElemInfo<eVersion>
537   {
538     typedef TTElemInfo<eVersion> TElemInfoBase;
539
540     TTPolygoneInfo(const PMeshInfo& theMeshInfo, const PPolygoneInfo& theInfo):
541       TElemInfoBase(theMeshInfo,theInfo)
542     {
543       myEntity = theInfo->GetEntity();
544       myGeom = theInfo->GetGeom();
545
546       myIndex.reset(new TElemNum(*theInfo->myIndex));
547       myConn.reset(new TElemNum(*theInfo->myConn));
548
549       myConnMode = theInfo->GetConnMode();
550     }
551
552     TTPolygoneInfo(const PMeshInfo& theMeshInfo, 
553                    EEntiteMaillage theEntity, 
554                    EGeometrieElement theGeom,
555                    TInt theNbElem,
556                    TInt theConnSize,
557                    EConnectivite theConnMode,
558                    EBooleen theIsElemNum,
559                    EBooleen theIsElemNames):
560       TElemInfoBase(theMeshInfo,
561                     theNbElem,
562                     theIsElemNum,
563                     theIsElemNames)
564     {
565       myEntity = theEntity;
566       myGeom = theGeom;
567
568       myIndex.reset(new TElemNum(theNbElem + 1));
569       myConn.reset(new TElemNum(theConnSize));
570
571       myConnMode = theConnMode;
572     }
573     
574     TTPolygoneInfo(const PMeshInfo& theMeshInfo, 
575                    EEntiteMaillage theEntity, 
576                    EGeometrieElement theGeom,
577                    const TIntVector& theIndexes,
578                    const TIntVector& theConnectivities,
579                    EConnectivite theConnMode,
580                    const TIntVector& theFamilyNums,
581                    const TIntVector& theElemNums,
582                    const TStringVector& theElemNames):
583       TElemInfoBase(theMeshInfo,
584                     (TInt)theIndexes.size() - 1,
585                     theFamilyNums,
586                     theElemNums,
587                     theElemNames)
588     {
589       myEntity = theEntity;
590       myGeom = theGeom;
591
592       myIndex.reset(new TElemNum(theIndexes));
593       myConn.reset(new TElemNum(theConnectivities));
594
595       myConnMode = theConnMode;
596     }
597   };
598   
599   //---------------------------------------------------------------
600   template<EVersion eVersion>
601   struct TTPolyedreInfo: 
602     virtual TPolyedreInfo, 
603     virtual TTElemInfo<eVersion>
604   {
605     typedef TTElemInfo<eVersion> TElemInfoBase;
606
607     TTPolyedreInfo(const PMeshInfo& theMeshInfo, const PPolyedreInfo& theInfo):
608       TElemInfoBase(theMeshInfo,theInfo)
609     {
610       myEntity = theInfo->GetEntity();
611       myGeom = theInfo->GetGeom();
612
613       myIndex.reset(new TElemNum(*theInfo->myIndex));
614       myFaces.reset(new TElemNum(*theInfo->myFaces));
615       myConn.reset(new TElemNum(*theInfo->myConn));
616
617       myConnMode = theInfo->GetConnMode();
618     }
619
620     TTPolyedreInfo(const PMeshInfo& theMeshInfo, 
621                    EEntiteMaillage theEntity, 
622                    EGeometrieElement theGeom,
623                    TInt theNbElem,
624                    TInt theNbFaces,
625                    TInt theConnSize,
626                    EConnectivite theConnMode,
627                    EBooleen theIsElemNum,
628                    EBooleen theIsElemNames):
629       TElemInfoBase(theMeshInfo,
630                     theNbElem,
631                     theIsElemNum,
632                     theIsElemNames)
633     {
634       myEntity = theEntity;
635       myGeom = theGeom;
636
637       myIndex.reset(new TElemNum(theNbElem + 1));
638       myFaces.reset(new TElemNum(theNbFaces));
639       myConn.reset(new TElemNum(theConnSize));
640
641       myConnMode = theConnMode;
642     }
643     
644     TTPolyedreInfo(const PMeshInfo& theMeshInfo, 
645                    EEntiteMaillage theEntity, 
646                    EGeometrieElement theGeom,
647                    const TIntVector& theIndexes,
648                    const TIntVector& theFaces,
649                    const TIntVector& theConnectivities,
650                    EConnectivite theConnMode,
651                    const TIntVector& theFamilyNums,
652                    const TIntVector& theElemNums,
653                    const TStringVector& theElemNames):
654       TElemInfoBase(theMeshInfo,
655                     (TInt)theIndexes.size()-1,
656                     theFamilyNums,
657                     theElemNums,
658                     theElemNames)
659     {
660       myEntity = theEntity;
661       myGeom = theGeom;
662
663       myIndex.reset(new TElemNum(theIndexes));
664       myFaces.reset(new TElemNum(theFaces));
665       myConn.reset(new TElemNum(theConnectivities));
666
667       myConnMode = theConnMode;
668     }
669   };
670
671   //---------------------------------------------------------------
672   template<EVersion eVersion>
673   struct TTCellInfo: 
674     virtual TCellInfo, 
675     virtual TTElemInfo<eVersion>
676   {
677     typedef TTElemInfo<eVersion> TElemInfoBase;
678
679     TTCellInfo(const PMeshInfo& theMeshInfo, const PCellInfo& theInfo):
680       TElemInfoBase(theMeshInfo,theInfo)
681     {
682       myEntity = theInfo->GetEntity();
683       myGeom = theInfo->GetGeom();
684       myConnMode  = theInfo->GetConnMode();
685       
686       TInt aConnDim = GetNbNodes(myGeom);
687       TInt aNbConn = GetNbConn<eVersion>(myGeom, myEntity, myMeshInfo->myDim);
688       myConn.reset(new TElemNum(myNbElem * aNbConn));
689       for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){
690         TConnSlice aConnSlice = GetConnSlice(anElemId);
691         TCConnSlice aConnSlice2 = theInfo->GetConnSlice(anElemId);
692         for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){
693           aConnSlice[anConnId] = aConnSlice2[anConnId];
694         }
695       }
696     }
697
698     TTCellInfo(const PMeshInfo& theMeshInfo, 
699                EEntiteMaillage theEntity, 
700                EGeometrieElement theGeom,
701                TInt theNbElem,
702                EConnectivite theConnMode,
703                EBooleen theIsElemNum,
704                EBooleen theIsElemNames,
705                EModeSwitch theMode):
706       TElemInfoBase(theMeshInfo,
707                     theNbElem,
708                     theIsElemNum,
709                     theIsElemNames),
710       TModeSwitchInfo(theMode)
711     {
712       myEntity = theEntity;
713       myGeom = theGeom;
714
715       myConnMode = theConnMode;
716       TInt aNbConn = GetNbConn<eVersion>(theGeom, myEntity, theMeshInfo->myDim);
717       myConn.reset(new TElemNum(theNbElem * aNbConn));
718     }
719     
720     TTCellInfo(const PMeshInfo& theMeshInfo, 
721                EEntiteMaillage theEntity, 
722                EGeometrieElement theGeom,
723                const TIntVector& theConnectivities,
724                EConnectivite theConnMode,
725                const TIntVector& theFamilyNums,
726                const TIntVector& theElemNums,
727                const TStringVector& theElemNames,
728                EModeSwitch theMode):
729       TElemInfoBase(theMeshInfo,
730                     (TInt)theConnectivities.size() / GetNbNodes(theGeom),
731                     theFamilyNums,
732                     theElemNums,
733                     theElemNames),
734       TModeSwitchInfo(theMode)
735     {
736       myEntity = theEntity;
737       myGeom = theGeom;
738
739       myConnMode = theConnMode;
740       TInt aConnDim = GetNbNodes(myGeom);
741       TInt aNbConn = GetNbConn<eVersion>(myGeom, myEntity, myMeshInfo->myDim);
742       myConn.reset(new TElemNum(myNbElem * aNbConn));
743       for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){
744         TConnSlice aConnSlice = GetConnSlice(anElemId);
745         for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){
746           aConnSlice[anConnId] = theConnectivities[anElemId*aConnDim + anConnId];
747         }
748       }
749     }
750
751     virtual 
752     TInt
753     GetConnDim() const 
754     { 
755       return GetNbConn<eVersion>(myGeom, myEntity, myMeshInfo->myDim);
756     }
757
758   };
759
760
761   //---------------------------------------------------------------
762   template<EVersion eVersion>
763   struct TTFieldInfo: 
764     virtual TFieldInfo, 
765     virtual TTNameInfo<eVersion>
766   {
767     typedef TTNameInfo<eVersion> TNameInfoBase;
768
769     TTFieldInfo(const PMeshInfo& theMeshInfo, const PFieldInfo& theInfo):
770       TNameInfoBase(theInfo->GetName())
771     {
772       myMeshInfo = theMeshInfo;
773
774       myNbComp = theInfo->GetNbComp();
775       myCompNames.resize(myNbComp*GetPNOMLength<eVersion>()+1);
776       for(TInt anId = 0; anId < myNbComp; anId++){
777         SetCompName(anId,theInfo->GetCompName(anId));
778       }
779
780       myUnitNames.resize(myNbComp*GetPNOMLength<eVersion>()+1);
781       for(TInt anId = 0; anId < myNbComp; anId++){
782         SetUnitName(anId,theInfo->GetUnitName(anId));
783       }
784
785       myType = theInfo->GetType();
786
787       myIsLocal = theInfo->GetIsLocal();
788       myNbRef = theInfo->GetNbRef();
789     }
790
791     TTFieldInfo(const PMeshInfo& theMeshInfo, 
792                 TInt theNbComp,
793                 ETypeChamp theType,
794                 const std::string& theValue,
795                 EBooleen theIsLocal,
796                 TInt theNbRef):
797       TNameInfoBase(theValue)
798     {
799       myMeshInfo = theMeshInfo;
800
801       myNbComp = theNbComp;
802       myCompNames.resize(theNbComp*GetPNOMLength<eVersion>()+1);
803       myUnitNames.resize(theNbComp*GetPNOMLength<eVersion>()+1);
804
805       myType = theType;
806
807       myIsLocal = theIsLocal;
808       myNbRef = theNbRef;
809     }
810     
811     virtual 
812     std::string
813     GetCompName(TInt theId) const 
814     { 
815       return GetString(theId,GetPNOMLength<eVersion>(),myCompNames);
816     }
817
818     virtual
819     void
820     SetCompName(TInt theId, const std::string& theValue)
821     {
822       SetString(theId,GetPNOMLength<eVersion>(),myCompNames,theValue);
823     }
824
825     virtual
826     std::string 
827     GetUnitName(TInt theId) const 
828     { 
829       return GetString(theId,GetPNOMLength<eVersion>(),myUnitNames);
830     }
831
832     virtual
833     void
834     SetUnitName(TInt theId, const std::string& theValue)
835     {
836       SetString(theId,GetPNOMLength<eVersion>(),myUnitNames,theValue);
837     }
838   };
839
840
841   //---------------------------------------------------------------
842   template<EVersion eVersion>
843   struct TTGaussInfo: 
844     virtual TGaussInfo,
845     virtual TTNameInfo<eVersion>
846   {
847     typedef TTNameInfo<eVersion> TNameInfoBase;
848
849     TTGaussInfo(const TGaussInfo::TInfo& theInfo,
850                 EModeSwitch theMode):
851       TNameInfoBase(boost::get<1>(boost::get<0>(theInfo))),
852       TModeSwitchInfo(theMode)
853     {
854       const TGaussInfo::TKey& aKey = boost::get<0>(theInfo);
855
856       myGeom = boost::get<0>(aKey);
857       myRefCoord.resize(GetNbRef()*GetDim());
858
859       TInt aNbGauss = boost::get<1>(theInfo);
860       myGaussCoord.resize(aNbGauss*GetDim());
861       myWeight.resize(aNbGauss);
862     }
863   };
864
865
866   //---------------------------------------------------------------
867   template<EVersion eVersion>
868   struct TTTimeStampInfo: virtual TTimeStampInfo
869   {
870     TTTimeStampInfo(const PFieldInfo& theFieldInfo, const PTimeStampInfo& theInfo)
871     {
872       myFieldInfo = theFieldInfo;
873
874       myEntity = theInfo->GetEntity();
875       myGeom2Size = theInfo->GetGeom2Size();
876
877       myNumDt = theInfo->GetNumDt();
878       myNumOrd = theInfo->GetNumOrd();
879       myDt = theInfo->GetDt();
880
881       myUnitDt.resize(GetPNOMLength<eVersion>()+1);
882       SetUnitDt(theInfo->GetUnitDt());
883
884       myGeom2NbGauss = theInfo->myGeom2NbGauss;
885       myGeom2Gauss = theInfo->GetGeom2Gauss();
886     }
887
888     TTTimeStampInfo(const PFieldInfo& theFieldInfo, 
889                     EEntiteMaillage theEntity,
890                     const TGeom2Size& theGeom2Size,
891                     const TGeom2NbGauss& theGeom2NbGauss,
892                     TInt theNumDt,
893                     TInt theNumOrd,
894                     TFloat theDt,
895                     const std::string& theUnitDt,
896                     const TGeom2Gauss& theGeom2Gauss)
897     {
898       myFieldInfo = theFieldInfo;
899
900       myEntity = theEntity;
901       myGeom2Size = theGeom2Size;
902
903       myNumDt = theNumDt;
904       myNumOrd = theNumDt;
905       myDt = theDt;
906
907       myUnitDt.resize(GetPNOMLength<eVersion>()+1);
908       SetUnitDt(theUnitDt);
909
910       myGeom2NbGauss = theGeom2NbGauss;
911       myGeom2Gauss = theGeom2Gauss;
912     }
913
914     virtual 
915     std::string
916     GetUnitDt() const
917     { 
918       return GetString(0,GetPNOMLength<eVersion>(),myUnitDt);
919     }
920
921     virtual
922     void
923     SetUnitDt(const std::string& theValue)
924     {
925       SetString(0,GetPNOMLength<eVersion>(),myUnitDt,theValue);
926     }
927   };
928
929
930   //---------------------------------------------------------------
931   template<EVersion eVersion>
932   struct TTProfileInfo: 
933     virtual TProfileInfo,
934     virtual TTNameInfo<eVersion>
935   {
936     typedef TTNameInfo<eVersion> TNameInfoBase;
937
938     TTProfileInfo(const TProfileInfo::TInfo& theInfo,
939                   EModeProfil theMode):
940       TNameInfoBase(boost::get<0>(theInfo))
941     {
942       TInt aSize = boost::get<1>(theInfo);
943       myElemNum.reset(new TElemNum(aSize));
944       myMode = aSize > 0? theMode: eNO_PFLMOD;
945     }
946   };
947
948
949   //---------------------------------------------------------------
950   template<EVersion eVersion, class TMeshValueType>
951   struct TTTimeStampValue: virtual TTimeStampValue<TMeshValueType>
952   {
953     TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
954                      const PTimeStampValueBase& theInfo,
955                      ETypeChamp theTypeChamp)
956     {
957       typedef TTimeStampValue<TMeshValueType> TCompatible;
958       if(TCompatible* aCompatible = dynamic_cast<TCompatible*>(theInfo.get())){
959         this->myTimeStampInfo = theTimeStampInfo;
960         this->myTypeChamp = theTypeChamp;
961         this->myGeom2Profile = aCompatible->GetGeom2Profile();
962         this->myGeom2Value = aCompatible->myGeom2Value;
963         this->myGeomSet = aCompatible->GetGeomSet();
964       }else
965         EXCEPTION(std::runtime_error,"TTTimeStampValue::TTTimeStampValue - use incompatible arguments!");
966     }
967
968     TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
969                      ETypeChamp theTypeChamp,
970                      const TGeom2Profile& theGeom2Profile,
971                      EModeSwitch theMode):
972       TModeSwitchInfo(theMode)
973     {
974       this->myTimeStampInfo = theTimeStampInfo;
975
976       this->myTypeChamp = theTypeChamp;
977
978       this->myGeom2Profile = theGeom2Profile;
979
980       TInt aNbComp = theTimeStampInfo->myFieldInfo->myNbComp;
981
982       const TGeom2Size& aGeom2Size = theTimeStampInfo->GetGeom2Size();
983       TGeom2Size::const_iterator anIter = aGeom2Size.begin();
984       for(; anIter != aGeom2Size.end(); anIter++){
985         const EGeometrieElement& aGeom = anIter->first;
986         TInt aNbElem = anIter->second;
987
988         MED::PProfileInfo aProfileInfo;
989         MED::TGeom2Profile::const_iterator anIter = theGeom2Profile.find(aGeom);
990         if(anIter != theGeom2Profile.end())
991           aProfileInfo = anIter->second;
992
993         if(aProfileInfo && aProfileInfo->IsPresent())
994           aNbElem = aProfileInfo->GetSize();
995
996         TInt aNbGauss = theTimeStampInfo->GetNbGauss(aGeom);
997         
998         this->GetMeshValue(aGeom).Allocate(aNbElem,aNbGauss,aNbComp);
999       }
1000     }
1001
1002     virtual 
1003     size_t
1004     GetValueSize(EGeometrieElement theGeom) const
1005     {
1006       return this->GetMeshValue(theGeom).GetSize();
1007     }
1008
1009     virtual 
1010     size_t
1011     GetNbVal(EGeometrieElement theGeom) const
1012     {
1013       return this->GetMeshValue(theGeom).GetNbVal();
1014     }
1015
1016     virtual 
1017     size_t
1018     GetNbGauss(EGeometrieElement theGeom) const
1019     {
1020       return this->GetMeshValue(theGeom).GetNbGauss();
1021     }
1022
1023     virtual 
1024     void
1025     AllocateValue(EGeometrieElement theGeom,
1026                   TInt theNbElem,
1027                   TInt theNbGauss,
1028                   TInt theNbComp,
1029                   EModeSwitch theMode = eFULL_INTERLACE)
1030     {
1031       this->GetMeshValue(theGeom).Allocate(theNbElem,theNbGauss,theNbComp,theMode);
1032     }
1033     
1034     virtual 
1035     unsigned char*
1036     GetValuePtr(EGeometrieElement theGeom)
1037     {
1038       return this->GetMeshValue(theGeom).GetValuePtr();
1039     }
1040   };
1041
1042   //---------------------------------------------------------------
1043   template<EVersion eVersion>
1044   struct TTGrilleInfo:
1045     virtual TGrilleInfo
1046   {
1047     TTGrilleInfo(const PMeshInfo& theMeshInfo,
1048                  const PGrilleInfo& theInfo)
1049     {
1050       myMeshInfo        = theMeshInfo;
1051
1052       myCoord           = theInfo->GetNodeCoord();
1053       
1054       myGrilleType      = theInfo->GetGrilleType();
1055
1056       myCoordNames      = theInfo->myCoordNames;
1057
1058       myCoordUnits      = theInfo->myCoordUnits;
1059
1060       myIndixes         = theInfo->GetMapOfIndexes();
1061
1062       myGrilleStructure = theInfo->GetGrilleStructure();
1063
1064       myGrilleType      = theInfo->GetGrilleType();
1065
1066       myFamNumNode.resize(theInfo->GetNbNodes());
1067       myFamNumNode      = theInfo->myFamNumNode;
1068
1069       myFamNum      = theInfo->myFamNum;
1070     }
1071
1072     TTGrilleInfo(const PMeshInfo& theMeshInfo,
1073                  const EGrilleType& type,
1074                  const TInt nnoeuds)
1075     {
1076       myMeshInfo        = theMeshInfo;
1077       TInt aDim = theMeshInfo->GetDim();
1078       if(type == eGRILLE_STANDARD){
1079         myCoord.resize(aDim*nnoeuds);
1080         myCoordNames.resize(aDim*GetPNOMLength<eVersion>()+1);
1081         myCoordUnits.resize(aDim*GetPNOMLength<eVersion>()+1);
1082       } else { //if(type == eGRILLE_CARTESIENNE){
1083         myCoordNames.resize(aDim*GetPNOMLength<eVersion>()+aDim);
1084         myCoordUnits.resize(aDim*GetPNOMLength<eVersion>()+aDim);
1085       }
1086       
1087       myGrilleStructure.resize(theMeshInfo->myDim);
1088       myFamNumNode.resize(nnoeuds);
1089     }
1090
1091     TTGrilleInfo(const PMeshInfo& theMeshInfo,
1092                  const EGrilleType& type)
1093     {
1094       myMeshInfo        = theMeshInfo;
1095       TInt aDim = theMeshInfo->GetDim();
1096       if(type == eGRILLE_STANDARD){
1097         myCoordNames.resize(aDim*GetPNOMLength<eVersion>()+1);
1098         myCoordUnits.resize(aDim*GetPNOMLength<eVersion>()+1);
1099       } else {// if(type == eGRILLE_CARTESIENNE){
1100         myCoordNames.resize(aDim*GetPNOMLength<eVersion>()+aDim);
1101         myCoordUnits.resize(aDim*GetPNOMLength<eVersion>()+aDim);
1102       }
1103       TTGrilleInfo(theMeshInfo,type,0);
1104     }
1105
1106     TTGrilleInfo(const PMeshInfo& theMeshInfo,
1107                  const EGrilleType& type,
1108                  const MED::TIntVector& nbNodeVec)
1109     {
1110       myMeshInfo        = theMeshInfo;
1111
1112       TInt aDim = theMeshInfo->GetDim();
1113       if(type == eGRILLE_STANDARD){
1114         myCoordNames.resize(aDim*GetPNOMLength<eVersion>()+1);
1115         myCoordUnits.resize(aDim*GetPNOMLength<eVersion>()+1);
1116       } else {// if(type == eGRILLE_CARTESIENNE){
1117         myCoordNames.resize(aDim*GetPNOMLength<eVersion>()+aDim);
1118         myCoordUnits.resize(aDim*GetPNOMLength<eVersion>()+aDim);
1119       }
1120
1121       if(type != eGRILLE_STANDARD)
1122         for(int aAxe=0;aAxe<nbNodeVec.size();aAxe++){
1123           myIndixes[aAxe].resize(nbNodeVec[aAxe]);
1124         }
1125       
1126       TTGrilleInfo(theMeshInfo,type,0);
1127     }
1128
1129     virtual
1130     std::string
1131     GetCoordName(TInt theId) const 
1132     { 
1133       return GetString(theId,GetPNOMLength<eVersion>(),myCoordNames);
1134     }
1135
1136     virtual
1137     void
1138     SetCoordName(TInt theId, const std::string& theValue)
1139     {
1140       SetString(theId,GetPNOMLength<eVersion>(),myCoordNames,theValue);
1141     }
1142
1143     virtual
1144     std::string 
1145     GetCoordUnit(TInt theId) const 
1146     { 
1147       return GetString(theId,GetPNOMLength<eVersion>(),myCoordUnits);
1148     }
1149
1150     virtual
1151     void
1152     SetCoordUnit(TInt theId, const std::string& theValue)
1153     {
1154       SetString(theId,GetPNOMLength<eVersion>(),myCoordUnits,theValue);
1155     }
1156
1157   };
1158 }
1159
1160 #endif