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