]> SALOME platform Git repositories - modules/med.git/blob - src/MEDWrapper/Base/MED_Wrapper.cxx
Salome HOME
update after merging trhe branches CEA_V3_0_x, OCC_V3_1_0_a1_x, and the main
[modules/med.git] / src / MEDWrapper / Base / MED_Wrapper.cxx
1 //  Copyright (C) 2003  CEA/DEN, EDF R&D
2 //
3 //
4 //
5 //  File   : VISU_DatConvertor.cxx
6 //  Author : Alexey PETROV
7 //  Module : VISU
8
9 #include "MED_Wrapper.hxx"
10 #include "MED_Utilities.hxx"
11  
12 #ifdef _DEBUG_
13 static int MYDEBUG = 0;
14 static int MYVALUEDEBUG = 0;
15 #else
16 static int MYDEBUG = 0;
17 static int MYVALUEDEBUG = 0;
18 #endif
19
20 namespace MED{
21   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22   PMeshInfo TWrapper::GetPMeshInfo(TInt theId,
23                                    TErr* theErr)
24   {
25     PMeshInfo anInfo = CrMeshInfo();
26     GetMeshInfo(theId,*anInfo,theErr);
27     return anInfo;
28   }
29
30
31   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32   PFamilyInfo TWrapper::GetPFamilyInfo(const PMeshInfo& theMeshInfo, 
33                                        TInt theId,
34                                        TErr* theErr)
35   {
36     TInt aNbAttr = GetNbFamAttr(theId,*theMeshInfo);
37     TInt aNbGroup = GetNbFamGroup(theId,*theMeshInfo);
38     PFamilyInfo anInfo = CrFamilyInfo(theMeshInfo,aNbGroup,aNbAttr);
39     GetFamilyInfo(theId,*anInfo,theErr);
40
41 #ifdef _DEBUG_
42     string aName = anInfo->GetName();
43     INITMSG(MYDEBUG,"GetPFamilyInfo - aFamilyName = '"<<aName<<
44             "'; andId = "<<anInfo->GetId()<<
45             "; aNbAttr = "<<aNbAttr<<
46             "; aNbGroup = "<<aNbGroup<<"\n");
47     for(TInt iGroup = 0; iGroup < aNbGroup; iGroup++){
48       aName = anInfo->GetGroupName(iGroup);
49       INITMSG(MYDEBUG,"aGroupName = '"<<aName<<"'\n");
50     }
51 #endif
52     
53     return anInfo;
54   }
55
56
57   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58   PNodeInfo TWrapper::GetPNodeInfo(const PMeshInfo& theMeshInfo,
59                                    TErr* theErr)
60   {
61     TInt aNbElems = GetNbNodes(*theMeshInfo);
62     PNodeInfo anInfo = CrNodeInfo(theMeshInfo,aNbElems);
63     GetNodeInfo(*anInfo,theErr);
64
65 #ifdef _DEBUG_
66     TInt aDim = theMeshInfo->myDim;
67     TInt aNbElem = anInfo->GetNbElem();
68     INITMSG(MYDEBUG,"GetPNodeInfo - aCoords: "<<aNbElem<<": ");
69     TNodeCoord& aCoord = anInfo->myCoord;
70     for(TInt iElem = 0; iElem < aNbElem; iElem++){
71       for(TInt iDim = 0, anId = iElem*aDim; iDim < aDim; iDim++, anId++){
72         ADDMSG(MYVALUEDEBUG,aCoord[anId]<<",");
73       }
74       ADDMSG(MYVALUEDEBUG," ");
75     }
76     ADDMSG(MYDEBUG,endl);
77
78     BEGMSG(MYDEBUG,"GetPNodeInfo - GetFamNum: ");
79     for(TInt iElem = 0; iElem < aNbElem; iElem++){
80       ADDMSG(MYVALUEDEBUG,anInfo->GetFamNum(iElem)<<", ");
81     }
82     ADDMSG(MYDEBUG,endl);
83
84     if(anInfo->IsElemNum()){
85       BEGMSG(MYDEBUG,"GetPNodeInfo - GetElemNum: ");
86       for(TInt iElem = 0; iElem < aNbElem; iElem++){
87         ADDMSG(MYVALUEDEBUG,anInfo->GetElemNum(iElem)<<", ");
88       }
89       ADDMSG(MYDEBUG,endl);
90     }
91
92     ADDMSG(MYDEBUG,endl);
93 #endif
94     
95     return anInfo;
96   }
97
98   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99   PPolygoneInfo TWrapper::GetPPolygoneInfo(const PMeshInfo& theMeshInfo,
100                                            EEntiteMaillage theEntity, 
101                                            EGeometrieElement theGeom, 
102                                            EConnectivite theConn)
103   {
104     TInt aNbElem = GetNbPolygones(*theMeshInfo,theEntity,theGeom,theConn);
105     TInt aNbConn = GetNbPolygoneConn(*theMeshInfo,theEntity,theGeom,theConn);
106     PPolygoneInfo anInfo = CrPolygoneInfo(theMeshInfo,aNbElem,aNbConn,theEntity,theGeom,theConn);
107     GetPolygoneInfo(*anInfo);
108
109 #ifdef _DEBUG_
110     TElemNum aConn  = anInfo->GetConnectivite();
111     TElemNum aIndex = anInfo->GetIndex();
112     TInt aNbIndex = aIndex.size();
113     TInt aIndex0 = aIndex[0];
114     INITMSG(MYDEBUG,"theGeom = "<<theGeom<<"; aNbElem = "<<aNbIndex-1<<": ");
115     for(TInt iElem = 1; iElem < aNbIndex; iElem++){
116       for (TInt i = aIndex0; i < aIndex[iElem];i++)
117         ADDMSG(MYVALUEDEBUG,aConn[i-1]<<",");
118       ADDMSG(MYDEBUG," ");
119       aIndex0 = aIndex[iElem];
120     }
121     ADDMSG(MYDEBUG,endl);
122     BEGMSG(MYDEBUG,"Indexes: ");
123     for(TInt iElem = 0; iElem < aIndex.size(); iElem++){
124       ADDMSG(MYVALUEDEBUG,aIndex[iElem]<<",");
125     }
126     ADDMSG(MYDEBUG,endl);
127 #endif
128
129     return anInfo;
130   }
131   
132   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
133   PPolyedreInfo TWrapper::GetPPolyedreInfo(const PMeshInfo& theMeshInfo,
134                                            EEntiteMaillage theEntity, 
135                                            EGeometrieElement theGeom, 
136                                            EConnectivite theConn)
137   {
138     TInt aNbElem  = GetNbPolyedres(*theMeshInfo,theEntity,theGeom,theConn);
139     TInt aNbConn = 0;
140     TInt aNbFaces = 0;
141     GetNbPolyedreConnF(*theMeshInfo,theConn,aNbFaces,aNbConn);
142     PPolyedreInfo anInfo = CrPolyedreInfo(theMeshInfo,aNbElem,aNbConn,aNbFaces,theEntity,theGeom,theConn);
143     GetPolyedreInfo(*anInfo);
144
145 #ifdef _DEBUG_
146     TElemNum aConn        = anInfo->GetConnectivite();
147     TElemNum aFacesIndex  = anInfo->GetFacesIndex();
148     TElemNum aIndex       = anInfo->GetIndex();
149     
150     TInt aNbIndex      = aIndex.size();
151     
152     for (int aNp = 0; aNp < aNbIndex-1;aNp++){
153       if (anInfo->IsElemNames())
154         ADDMSG(MYDEBUG,anInfo->GetElemName(aNp)<<endl);
155       else 
156         ADDMSG(MYDEBUG,"POLYEDRE "<<aNp+1<<endl);
157       
158       for (int aNf = aIndex[aNp]-1;aNf < aIndex[aNp+1]-1;aNf++){
159         ADDMSG(MYDEBUG,"Face "<<aNf-aIndex[aNp]+2<<": [");
160         for (int aNc = aFacesIndex[aNf]-1; aNc < aFacesIndex[aNf+1]-1;aNc++){
161           ADDMSG(MYDEBUG," "<<aConn[aNc]);
162         }
163         ADDMSG(MYDEBUG," ]"<<endl;);
164       }
165     }
166 #endif
167
168     return anInfo;
169   }
170   
171   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
172   PCellInfo TWrapper::GetPCellInfo(const PMeshInfo& theMeshInfo,
173                                    EEntiteMaillage theEntity, 
174                                    EGeometrieElement theGeom, 
175                                    EConnectivite theConn,
176                                    TErr* theErr)
177   {
178     TInt aNbElem = GetNbCells(*theMeshInfo,theEntity,theGeom,theConn);
179     PCellInfo anInfo = CrCellInfo(theMeshInfo,aNbElem,theEntity,theGeom,theConn);
180     GetCellInfo(*anInfo,theErr);
181
182 #ifdef _DEBUG_
183     TInt aConnDim = anInfo->GetConnDim();
184     INITMSG(MYDEBUG,"GetPCellInfo - theEntity = "<<theEntity<<"; theGeom = "<<theGeom<<"; aConnDim: "<<aConnDim<<"\n");
185     BEGMSG(MYDEBUG,"GetPCellInfo - aNbElem: "<<aNbElem<<": ");
186     for(TInt iElem = 0; iElem < aNbElem; iElem++){
187       for(TInt iConn = 0; iConn < aConnDim; iConn++){
188         ADDMSG(MYVALUEDEBUG,anInfo->GetConn(iElem,iConn)<<",");
189       }
190       ADDMSG(MYVALUEDEBUG," ");
191     }
192     ADDMSG(MYDEBUG,endl);
193
194     BEGMSG(MYDEBUG,"GetPCellInfo - GetFamNum: ");
195     for(TInt iElem = 0; iElem < aNbElem; iElem++){
196       ADDMSG(MYVALUEDEBUG,anInfo->GetFamNum(iElem)<<", ");
197     }
198     ADDMSG(MYDEBUG,endl);
199
200     if(anInfo->IsElemNum()){
201       BEGMSG(MYDEBUG,"GetPCellInfo - GetElemNum: ");
202       for(TInt iElem = 0; iElem < aNbElem; iElem++){
203         ADDMSG(MYVALUEDEBUG,anInfo->GetElemNum(iElem)<<", ");
204       }
205       ADDMSG(MYDEBUG,endl);
206     }
207     ADDMSG(MYDEBUG,endl);
208 #endif
209     
210     return anInfo;
211   }
212
213
214   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
215   PFieldInfo TWrapper::GetPFieldInfo(const PMeshInfo& theMeshInfo, 
216                                      TInt theId,
217                                      TErr* theErr)
218   {
219     TInt aNbComp = GetNbComp(theId);
220     PFieldInfo anInfo = CrFieldInfo(theMeshInfo,aNbComp);
221     GetFieldInfo(theId,*anInfo,theErr);
222
223 #ifdef _DEBUG_
224     INITMSG(MYDEBUG,
225             "GetPFieldInfo - aNbComp = "<<aNbComp<<
226             "; aType = "<<anInfo->GetType()<<"\n");
227 #endif
228     
229     return anInfo;
230   }
231
232
233   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
234   PTimeStampInfo TWrapper::GetPTimeStampInfo(const PFieldInfo& theFieldInfo,
235                                              EEntiteMaillage theEntity,
236                                              const MED::TGeom& theGeom,
237                                              TInt theId,
238                                              TErr* theErr)
239   {
240     PTimeStampInfo anInfo = CrTimeStampInfo(theFieldInfo,theEntity,theGeom);
241     GetTimeStampInfo(theId,*anInfo,theErr);
242
243 #ifdef _DEBUG_
244     INITMSG(MYDEBUG,
245             "GetPTimeStampInfo - aNbGauss = "<<anInfo->GetNbGauss()<<
246             "; aNumDt = "<<anInfo->GetNumDt()<<"\n");
247 #endif
248
249     return anInfo;
250   }
251
252
253   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
254   PTimeStampVal TWrapper::GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
255                                            TErr* theErr)
256   {
257     PTimeStampVal anInfo = CrTimeStampVal(theTimeStampInfo);
258     GetTimeStampVal(*anInfo,theErr);
259
260 #ifdef _DEBUG_
261     TInt aNbGauss = theTimeStampInfo->GetNbGauss();
262     PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
263     TInt aNbComp = aFieldInfo->GetNbComp();
264     INITMSG(MYDEBUG,"GetPTimeStampVal\n");
265     TMeshValue& aMeshValue = anInfo->myMeshValue;
266     TMeshValue::const_iterator aMeshValueIter = aMeshValue.begin();
267     for(; aMeshValueIter != aMeshValue.end(); aMeshValueIter++){
268       const EGeometrieElement& aGeom = aMeshValueIter->first;
269       const TValue& aValue = aMeshValueIter->second;
270       TInt iElemEnd = aValue.size() / aNbComp / aNbGauss;
271       INITMSG(MYDEBUG,"aGeom = "<<aGeom<<" - "<<iElemEnd<<": ");
272       for(TInt iElem = 0, anId = 0; iElem < iElemEnd; iElem++){
273         ADDMSG(MYVALUEDEBUG,"{");
274         for(TInt iComp = 0; iComp < aNbComp; iComp++){
275           for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
276             ADDMSG(MYVALUEDEBUG,aValue[anId++]<<" ");
277           }
278           ADDMSG(MYVALUEDEBUG,"| ");
279         }
280         ADDMSG(MYVALUEDEBUG,"} ");
281       }
282       ADDMSG(MYDEBUG,"\n");
283     }
284 #endif
285
286     return anInfo;
287   }
288 }