3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
29 #include "MED_Algorithm.hxx"
30 #include "MED_Utilities.hxx"
33 static int MYDEBUG = 0;
35 static int MYDEBUG = 0;
39 //---------------------------------------------------------------
41 GetElemsByEntity(TWrapper& theWrapper,
42 const PMeshInfo& theMeshInfo,
43 const MED::TEntityInfo& theEntityInfo)
45 MSG(MYDEBUG,"GetElemsByEntity(...)");
47 MED::TEntityInfo::const_iterator anIter = theEntityInfo.begin();
48 for(; anIter != theEntityInfo.end(); anIter++){
49 const EEntiteMaillage& anEntity = anIter->first;
50 const MED::TGeom& aGeom = anIter->second;
51 TElemMap& anElemMap = aGroup[anEntity];
53 if(anEntity == eNOEUD){
54 anElemMap[ePOINT1] = theWrapper.GetPNodeInfo(theMeshInfo);
58 MED::TGeom::const_iterator anGeomIter = aGeom.begin();
59 for(; anGeomIter != aGeom.end(); anGeomIter++){
60 const EGeometrieElement& aGeo = anGeomIter->first;
63 anElemMap[ePOLYGONE] = theWrapper.GetPPolygoneInfo(theMeshInfo,anEntity,aGeo);
67 anElemMap[ePOLYEDRE] = theWrapper.GetPPolyedreInfo(theMeshInfo,anEntity,aGeo);
71 anElemMap[aGeo] = theWrapper.GetPCellInfo(theMeshInfo,anEntity,aGeo);
81 //---------------------------------------------------------------
83 GetFamilies(TWrapper& theWrapper,
84 const PMeshInfo& theMeshInfo)
86 MSG(MYDEBUG,"GetFamilies(...)");
89 TInt aNbFam = theWrapper.GetNbFamilies(*theMeshInfo);
90 INITMSG(MYDEBUG,"GetNbFamilies() = "<<aNbFam<<"\n");
91 for(TInt iFam = 1; iFam <= aNbFam; iFam++){
92 PFamilyInfo aFamilyInfo = theWrapper.GetPFamilyInfo(theMeshInfo,iFam,&anErr);
94 aGroup.insert(aFamilyInfo);
102 GetFamiliesByGroup(const TFamilyGroup& theGroupInfo)
104 MSG(MYDEBUG,"GetFamiliesByGroup(...)");
106 TFamilyGroup::const_iterator anIter = theGroupInfo.begin();
107 for(; anIter != theGroupInfo.end(); anIter++){
108 const PFamilyInfo& aFamilyInfo = *anIter;
109 TInt aNbGroup = aFamilyInfo->GetNbGroup();
110 for(TInt iGroup = 0; iGroup < aNbGroup; iGroup++){
111 aGroup[aFamilyInfo->GetGroupName(iGroup)].insert(aFamilyInfo);
117 TGroupInfo::const_iterator anIter = aGroup.begin();
118 for(; anIter != aGroup.end(); anIter++){
119 string aName = anIter->first;
120 INITMSG(MYDEBUG,"aGroupName = '"<<aName<<"'\n");
121 const TFamilyGroup& aFamilyGroup = anIter->second;
122 TFamilyGroup::const_iterator anFamIter = aFamilyGroup.begin();
123 for(; anFamIter != aFamilyGroup.end(); anFamIter++){
124 const PFamilyInfo& aFamilyInfo = *anFamIter;
125 INITMSG(MYDEBUG,"aFamilyName = '"<<aFamilyInfo->GetName()<<"'\n");
128 ADDMSG(MYDEBUG,"\n");
136 //---------------------------------------------------------------
138 GetFieldsByEntity(TWrapper& theWrapper,
139 const PMeshInfo& theMeshInfo,
140 const MED::TEntityInfo& theEntityInfo)
142 MSG(MYDEBUG,"GetFieldsByEntity(...)");
143 TTimeStampGroup aGroup;
144 TInt aNbFields = theWrapper.GetNbFields();
145 INITMSG(MYDEBUG,"GetNbFields() = "<<aNbFields<<"\n");
146 for(TInt iField = 1; iField <= aNbFields; iField++){
147 PFieldInfo aFieldInfo = theWrapper.GetPFieldInfo(theMeshInfo,iField);
148 INITMSG(MYDEBUG,"aFieldName = '"<<aFieldInfo->GetName()<<
149 "'; aNbComp = "<<aFieldInfo->GetNbComp()<<"; ");
151 EEntiteMaillage anEntity = EEntiteMaillage(-1);
152 TInt aNbTimeStamps = theWrapper.GetNbTimeStamps(aFieldInfo,theEntityInfo,anEntity,aGeom);
153 ADDMSG(MYDEBUG,"anEntity = "<<anEntity<<"; GetNbTimeStamps = "<<aNbTimeStamps<<"\n");
154 for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){
155 PTimeStampInfo aTimeStamp =
156 theWrapper.GetPTimeStampInfo(aFieldInfo,anEntity,aGeom,iTimeStamp);
157 aGroup[aFieldInfo].insert(aTimeStamp);
158 INITMSG(MYDEBUG,"aDt = "<<aTimeStamp->GetDt()
159 <<", Unit = \'"<<aTimeStamp->GetUnitDt()
160 <<"\', aNbGauss = "<<aTimeStamp->GetNbGauss()<<"\n");
163 ADDMSG(MYDEBUG,"\n");
169 GetFieldsByEntity(const TTimeStampGroup& theTimeStampGroup)
172 TTimeStampGroup::const_iterator anIter = theTimeStampGroup.begin();
173 for(; anIter != theTimeStampGroup.end(); anIter++){
174 //const PFieldInfo& aFieldInfo = anIter->first;
175 const TTimeStampSet& aTimeStampSet = anIter->second;
176 if(aTimeStampSet.empty()) continue;
177 const PTimeStampInfo& aTimeStampInfo = *aTimeStampSet.begin();
178 aGroup[aTimeStampInfo->GetEntity()].insert(*anIter);
185 GetFamiliesByEntity(TWrapper& theWrapper,
186 const TElemGroup& theElemGroup,
187 const TFamilyGroup& theFamilyGroup)
189 MSG(MYDEBUG,"GetFamiliesByEntity(...)");
190 TFamilyByEntity aFamilyByEntity;
192 typedef map<TInt,PFamilyInfo> TFamilyByIdMap;
193 TFamilyByIdMap aFamilyByIdMap;
194 TFamilyGroup::const_iterator anIter = theFamilyGroup.begin();
195 for(; anIter != theFamilyGroup.end(); anIter++){
196 const PFamilyInfo& aFamilyInfo = *anIter;
197 aFamilyByIdMap.insert(TFamilyByIdMap::value_type(aFamilyInfo->GetId(),aFamilyInfo));
200 if(!aFamilyByIdMap.empty()){
201 typedef set<TInt> TFamilyIdSet;
202 typedef map<EEntiteMaillage,TFamilyIdSet> TFamilyIdByEntity;
203 TFamilyIdByEntity aFamilyIdByEntity;
205 if(!theElemGroup.empty()){
206 TElemGroup::const_iterator anIter = theElemGroup.begin();
207 for(; anIter != theElemGroup.end(); anIter++){
208 const EEntiteMaillage& anEntity = anIter->first;
209 TFamilyIdSet& aFamilyIdSet = aFamilyIdByEntity[anEntity];
210 const TElemMap& anElemMap = anIter->second;
211 TElemMap::const_iterator anElemIter = anElemMap.begin();
212 for(; anElemIter != anElemMap.end(); anElemIter++){
213 const PElemInfo& aElemInfo = anElemIter->second;
214 if(TInt aNbElem = aElemInfo->GetNbElem()){
215 for(TInt i = 0; i < aNbElem; i++){
216 aFamilyIdSet.insert(aElemInfo->GetFamNum(i));
223 if(!aFamilyIdByEntity.empty()){
224 TFamilyIdByEntity::const_iterator anIter = aFamilyIdByEntity.begin();
225 for(; anIter != aFamilyIdByEntity.end(); anIter++){
226 const EEntiteMaillage& anEntity = anIter->first;
227 INITMSG(MYDEBUG,"anEntity = "<<anEntity<<":\n");
228 const TFamilyIdSet& aFamilyIdSet = anIter->second;
229 TFamilyIdSet::const_iterator anFamilyIdIter = aFamilyIdSet.begin();
230 for(; anFamilyIdIter != aFamilyIdSet.end(); anFamilyIdIter++){
231 const TInt& aFamilyId = *anFamilyIdIter;
232 TFamilyByIdMap::const_iterator
233 anFamilyByIdMapIter = aFamilyByIdMap.find(aFamilyId);
234 if(anFamilyByIdMapIter != aFamilyByIdMap.end()){
235 const PFamilyInfo& aFamilyInfo = anFamilyByIdMapIter->second;
236 aFamilyByEntity[anEntity].insert(aFamilyInfo);
238 "aFamilyName = '"<<aFamilyInfo->GetName()<<
239 "' anId = "<<aFamilyInfo->GetId()<<"\n");
245 ADDMSG(MYDEBUG,"\n");
246 return aFamilyByEntity;