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"
19 #if defined __GNUC_2__
20 #define GETINDEX(anArray,ind) anArray[ind]
22 #define GETINDEX(anArray,ind) anArray.at(ind)
27 TInt GetNbNodes(EGeometrieElement typmai)
33 TInt GetNbConn<eV2_1>(EGeometrieElement typmai,
34 EEntiteMaillage typent,
39 if(typent == eMAILLE){
40 TInt edim = typmai / 100;
41 if(mdim == 2 || mdim == 3)
50 return nsup + typmai%100;
54 TInt GetNbConn<eV2_2>(EGeometrieElement typmai,
55 EEntiteMaillage typent,
61 std::string GetString(TInt theId, TInt theStep,
62 const TString& theString)
64 const char* aPos = &GETINDEX(theString,theId*theStep);
65 TInt aSize = std::min(TInt(strlen(aPos)),theStep);
66 return std::string(aPos,aSize);
69 void SetString(TInt theId, TInt theStep,
71 const std::string& theValue)
73 TInt aSize = std::min(TInt(theValue.size()+1),theStep);
74 char* aPos = &GETINDEX(theString,theId*theStep);
75 strncpy(aPos,theValue.c_str(),aSize);
80 //---------------------------------------------------------------
81 TInt TFamilyInfo::GetAttrId(TInt theId) const {
82 return GETINDEX(myAttrId,theId);
85 TInt TFamilyInfo::GetAttrVal(TInt theId) const {
86 return GETINDEX(myAttrVal,theId);
89 void TFamilyInfo::SetAttrId(TInt theId,TInt theVal) {
90 GETINDEX(myAttrId,theId) = theVal;
93 void TFamilyInfo::SetAttrVal(TInt theId,TInt theVal) {
94 GETINDEX(myAttrVal,theId) = theVal;
97 //---------------------------------------------------------------
98 TInt TElemInfo::GetFamNum(TInt theId) const {
99 return GETINDEX(myFamNum,theId);
102 TInt TElemInfo::GetElemNum(TInt theId) const {
103 return GETINDEX(myElemNum,theId);
106 void TElemInfo::SetFamNum(TInt theId,TInt theVal) {
107 GETINDEX(myFamNum,theId) = theVal;
110 //---------------------------------------------------------------
111 TFloat TNodeInfo::GetNodeCoord(TInt theId,TInt theComp) const {
112 return GETINDEX(myCoord,myMeshInfo->myDim*theId + theComp);
115 void TNodeInfo::SetNodeCoord(TInt theId,TInt theComp,TFloat theVal) {
116 GETINDEX(myCoord,myMeshInfo->myDim*theId + theComp) = theVal;
119 //---------------------------------------------------------------
120 TInt TCellInfo::GetConn(TInt theElemId, TInt theConnId) const {
121 return GETINDEX(myConn,GetConnDim()*theElemId + theConnId);
124 void TCellInfo::SetConn(TInt theElemId, TInt theConnId, TInt theVal){
125 GETINDEX(myConn,GetConnDim()*theElemId + theConnId) = theVal;
129 TCellInfo::GetConnSlice(TInt theElemId) const
131 return TConstConnSlice(myConn,std::slice(GetConnDim()*theElemId,GetNbNodes(myTGeom),1));
135 TCellInfo::GetConnSlice(TInt theElemId)
137 return TConnSlice(myConn,std::slice(GetConnDim()*theElemId,GetNbNodes(myTGeom),1));
140 //---------------------------------------------------------------
141 TInt TPolygoneInfo::GetNbConn(TInt theElemId) const {
142 TInt i1 = GETINDEX(myIndex,theElemId);
143 TInt i2 = GETINDEX(myIndex,theElemId+1);
148 //---------------------------------------------------------------
149 TInt TPolyedreInfo::GetNbConn(TInt theElemId) const {
150 TInt ind1 = GETINDEX(myIndex,theElemId);
151 TInt ind2 = GETINDEX(myIndex,theElemId+1);
153 TInt inf1 = GETINDEX(myFacesIndex,ind1-1);
154 TInt inf2 = GETINDEX(myFacesIndex,ind2-1);
156 TInt ret = inf2-inf1;
160 //---------------------------------------------------------------
161 TFloat TTimeStampVal::GetVal(EGeometrieElement theGeom, TInt theId,
162 TInt theComp, TInt theGauss) const {
163 TInt aNbComp = myTimeStampInfo->myFieldInfo->myNbComp;
164 TInt aNbGauss = myTimeStampInfo->myNbGauss;
165 TInt aStep = aNbComp*aNbGauss;
166 TMeshValue::const_iterator anIter = myMeshValue.find(theGeom);
167 if(anIter != myMeshValue.end()){
168 TFloat aRet=GETINDEX(anIter->second,theId*aStep + theComp*aNbGauss + theGauss);
174 void TTimeStampVal::SetVal(EGeometrieElement theGeom, TInt theId,
175 TInt theComp, TFloat theVal, TInt theGauss)
177 TInt aNbComp = myTimeStampInfo->myFieldInfo->myNbComp;
178 TInt aNbGauss = myTimeStampInfo->myNbGauss;
179 TInt aStep = aNbComp*aNbGauss;
180 GETINDEX(myMeshValue[theGeom],theId*aStep + theComp*aNbGauss + theGauss) = theVal;