1 // Copyright (C) 2003 CEA/DEN, EDF R&D
5 // File : VISU_Structure.cxx
6 // Author : Eugeny NIKOLAEV
9 #include "MED_Structures.hxx"
10 #include "MED_Utilities.hxx"
17 GetNbNodes(EGeometrieElement typmai)
25 const TString& theString)
27 const char* aPos = &theString[theId*theStep];
28 TInt aSize = std::min(TInt(strlen(aPos)),theStep);
29 return std::string(aPos,aSize);
36 const std::string& theValue)
38 TInt aSize = std::min(TInt(theValue.size()+1),theStep);
39 char* aPos = &theString[theId*theStep];
40 strncpy(aPos,theValue.c_str(),aSize);
44 GetDimGaussCoord(EGeometrieElement theGeom)
50 GetNbRefCoord(EGeometrieElement theGeom)
57 //---------------------------------------------------------------
60 ::GetAttrId(TInt theId) const
62 return myAttrId[theId];
67 ::GetAttrVal(TInt theId) const
69 return myAttrVal[theId];
74 ::SetAttrId(TInt theId,TInt theVal)
76 myAttrId[theId] = theVal;
81 ::SetAttrVal(TInt theId,TInt theVal)
83 myAttrVal[theId] = theVal;
86 //---------------------------------------------------------------
89 ::GetFamNum(TInt theId) const
91 return myFamNum[theId];
96 ::GetElemNum(TInt theId) const
98 return myElemNum[theId];
103 ::SetFamNum(TInt theId,TInt theVal)
105 myFamNum[theId] = theVal;
108 //---------------------------------------------------------------
111 ::GetCoordSlice(TInt theId) const
113 TInt aDim = myMeshInfo->GetDim();
114 if(GetModeSwitch() == eFULL_INTERLACE)
115 return TCCoordSlice(myCoord,std::slice(theId*aDim,aDim,1));
117 return TCCoordSlice(myCoord,std::slice(theId,aDim,aDim));
122 ::GetCoordSlice(TInt theId)
124 TInt aDim = myMeshInfo->GetDim();
125 if(GetModeSwitch() == eFULL_INTERLACE)
126 return TCoordSlice(myCoord,std::slice(theId*aDim,aDim,1));
128 return TCoordSlice(myCoord,std::slice(theId,aDim,aDim));
131 //---------------------------------------------------------------
134 ::GetConnSlice(TInt theElemId) const
136 if(GetModeSwitch() == eFULL_INTERLACE)
137 return TCConnSlice(myConn,std::slice(GetConnDim()*theElemId,GetNbNodes(myGeom),1));
139 return TCConnSlice(myConn,std::slice(theElemId,GetNbNodes(myGeom),GetConnDim()));
144 ::GetConnSlice(TInt theElemId)
146 if(GetModeSwitch() == eFULL_INTERLACE)
147 return TConnSlice(myConn,std::slice(GetConnDim()*theElemId,GetNbNodes(myGeom),1));
149 return TConnSlice(myConn,std::slice(theElemId,GetNbNodes(myGeom),GetConnDim()));
153 //---------------------------------------------------------------
156 ::GetNbConn(TInt theElemId) const
158 return myIndex[theElemId + 1] - myIndex[theElemId];
163 ::GetConnSlice(TInt theElemId) const
165 return TCConnSlice(myConn,std::slice(myIndex[theElemId]-1,GetNbConn(theElemId),1));
170 ::GetConnSlice(TInt theElemId)
172 return TConnSlice(myConn,std::slice(myIndex[theElemId]-1,GetNbConn(theElemId),1));
176 //---------------------------------------------------------------
179 ::GetNbFaces(TInt theElemId) const
181 return myIndex[theElemId+1] - myIndex[theElemId];
186 ::GetNbNodes(TInt theElemId) const
189 TInt aNbFaces = GetNbFaces(theElemId);
190 TInt aStartFaceId = myIndex[theElemId] - 1;
191 for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){
192 TInt aCurrentId = myFaces[aStartFaceId];
193 TInt aDiff = myFaces[aStartFaceId + 1] - aCurrentId;
201 ::GetConnSliceArr(TInt theElemId) const
203 TInt aNbFaces = GetNbFaces(theElemId);
204 TCConnSliceArr aConnSliceArr(aNbFaces);
205 TInt aStartFaceId = myIndex[theElemId] - 1;
206 for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){
207 TInt aCurrentId = myFaces[aStartFaceId];
208 TInt aDiff = myFaces[aStartFaceId + 1] - aCurrentId;
209 aConnSliceArr[aFaceId] =
210 TCConnSlice(myConn,std::slice(aCurrentId - 1,aDiff,1));
212 return aConnSliceArr;
217 ::GetConnSliceArr(TInt theElemId)
219 TInt aNbFaces = GetNbFaces(theElemId);
220 TConnSliceArr aConnSliceArr(aNbFaces);
221 TInt aStartFaceId = myIndex[theElemId] - 1;
222 for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){
223 TInt aCurrentId = myFaces[aStartFaceId];
224 TInt aDiff = myFaces[aStartFaceId + 1] - aCurrentId;
225 aConnSliceArr[aFaceId] =
226 TConnSlice(myConn,std::slice(aCurrentId - 1,aDiff,1));
228 return aConnSliceArr;
232 //---------------------------------------------------------------
235 ::GetElemNum(TInt theId) const
237 return myElemNum[theId];
242 ::SetElemNum(TInt theId,TInt theVal)
244 myElemNum[theId] = theVal;
247 //---------------------------------------------------------------
250 ::operator()(const TKey& theLeft, const TKey& theRight) const
252 EGeometrieElement aLGeom = boost::get<0>(theLeft);
253 EGeometrieElement aRGeom = boost::get<0>(theRight);
255 return aLGeom < aRGeom;
257 const std::string& aLStr = boost::get<1>(theLeft);
258 const std::string& aRStr = boost::get<1>(theRight);
259 return aLStr < aRStr;
264 ::operator()(const TGaussInfo& theLeft, const TGaussInfo& theRight) const
266 if(theLeft.myGeom != theRight.myGeom)
267 return theLeft.myGeom < theRight.myGeom;
269 if(theLeft.myRefCoord != theRight.myRefCoord)
270 return theLeft.myRefCoord < theRight.myRefCoord;
272 return theLeft.myGaussCoord < theRight.myGaussCoord;
277 ::GetRefCoordSlice(TInt theId) const
279 if(GetModeSwitch() == eFULL_INTERLACE)
280 return TCCoordSlice(myRefCoord,std::slice(theId*GetDim(),GetDim(),1));
282 return TCCoordSlice(myRefCoord,std::slice(theId,GetDim(),GetDim()));
287 ::GetRefCoordSlice(TInt theId)
289 if(GetModeSwitch() == eFULL_INTERLACE)
290 return TCoordSlice(myRefCoord,std::slice(theId*GetDim(),GetDim(),1));
292 return TCoordSlice(myRefCoord,std::slice(theId,GetDim(),GetDim()));
297 ::GetGaussCoordSlice(TInt theId) const
299 if(GetModeSwitch() == eFULL_INTERLACE)
300 return TCCoordSlice(myGaussCoord,std::slice(theId*GetDim(),GetDim(),1));
302 return TCCoordSlice(myGaussCoord,std::slice(theId,GetDim(),GetDim()));
307 ::GetGaussCoordSlice(TInt theId)
309 if(GetModeSwitch() == eFULL_INTERLACE)
310 return TCoordSlice(myGaussCoord,std::slice(theId*GetDim(),GetNbGauss(),1));
312 return TCoordSlice(myGaussCoord,std::slice(theId,GetNbGauss(),GetDim()));
316 //---------------------------------------------------------------
319 ::GetNbGauss(EGeometrieElement theGeom) const
321 TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.find(theGeom);
322 if(anIter == myGeom2NbGauss.end())
323 EXCEPTION(runtime_error,"TTimeStampInfo::GetNbGauss - myGeom2NbGauss.find(theGeom) fails");
325 return anIter->second;
329 //---------------------------------------------------------------
332 ::Init(TInt theNbElem,
337 myModeSwitch = theMode;
339 myNbElem = theNbElem;
340 myNbGauss = theNbGauss;
341 myNbComp = theNbComp;
343 myStep = theNbComp*theNbGauss;
345 myValue.resize(theNbElem*myStep);
348 //---------------------------------------------------------------
351 ::GetGaussValueSliceArr(TInt theElemId) const
353 TCValueSliceArr aValueSliceArr(myNbGauss);
354 if(GetModeSwitch() == eFULL_INTERLACE){
355 TInt anId = theElemId*myStep;
356 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
357 aValueSliceArr[aGaussId] =
358 TCValueSlice(myValue,std::slice(anId,myNbComp,1));
363 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
364 aValueSliceArr[aGaussId] =
365 TCValueSlice(myValue,std::slice(theElemId,myNbComp,myStep));
368 return aValueSliceArr;
373 ::GetGaussValueSliceArr(TInt theElemId)
375 TValueSliceArr aValueSliceArr(myNbGauss);
376 if(GetModeSwitch() == eFULL_INTERLACE){
377 TInt anId = theElemId*myStep;
378 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
379 aValueSliceArr[aGaussId] =
380 TValueSlice(myValue,std::slice(anId,myNbComp,1));
385 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
386 aValueSliceArr[aGaussId] =
387 TValueSlice(myValue,std::slice(theElemId,myNbComp,myStep));
390 return aValueSliceArr;
393 //---------------------------------------------------------------
396 ::GetCompValueSliceArr(TInt theElemId) const
398 TCValueSliceArr aValueSliceArr(myNbComp);
399 if(GetModeSwitch() == eFULL_INTERLACE){
400 TInt anId = theElemId*myStep;
401 for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
402 aValueSliceArr[aCompId] =
403 TCValueSlice(myValue,std::slice(anId,myNbGauss,myNbComp));
408 for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
409 aValueSliceArr[aCompId] =
410 TCValueSlice(myValue,std::slice(theElemId,myNbGauss,myStep));
413 return aValueSliceArr;
419 ::GetCompValueSliceArr(TInt theElemId)
421 TValueSliceArr aValueSliceArr(myNbGauss);
422 if(GetModeSwitch() == eFULL_INTERLACE){
423 TInt anId = theElemId*myStep;
424 for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
425 aValueSliceArr[aCompId] =
426 TValueSlice(myValue,std::slice(anId,myNbGauss,myNbComp));
431 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
432 aValueSliceArr[aGaussId] =
433 TValueSlice(myValue,std::slice(theElemId,myNbComp,myStep));
436 return aValueSliceArr;
440 //---------------------------------------------------------------
443 ::GetMeshValue(EGeometrieElement theGeom) const
445 TGeom2Value::const_iterator anIter = myGeom2Value.find(theGeom);
446 if(anIter == myGeom2Value.end())
447 EXCEPTION(runtime_error,"TTimeStampVal::GetMeshValue - myGeom2Value.find(theGeom) fails");
448 return anIter->second;
453 ::GetMeshValue(EGeometrieElement theGeom)
455 return myGeom2Value[theGeom];