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