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