From: enk Date: Thu, 13 Jul 2006 13:51:20 +0000 (+0000) Subject: Fix for X-Git-Tag: T3_2_1_pre X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0d8ad0142873ce1d3e77ce60793ed3b5f35a4080;p=modules%2Fvisu.git Fix for Bug PAL12820: EDF207 SMESH and VISU: Visualization of groups on nodes and cells of a standard grid Bug PAL12613: Groups aren't read from the med files, containing mesh of MED_GRILLE_STANDARD type. --- diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 66c2293e..6dec1496 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -647,7 +647,7 @@ namespace aMeshOnEntity->myEntity = aVEntity; aMeshOnEntity->myMeshName = aMeshName; aMeshOnEntity->myGeom2Size = aGeom2Size; -// TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize; + TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize; INITMSG(MYDEBUG, "- aMEntity = "<myNbCells = theGrilleInfo->GetNbNodes(); aMeshOnEntity->myCellsSize = 2*theGrilleInfo->GetNbNodes(); - // must be implemented (shadow point for GRILLE STANDARD,CARTESIAN,...) -// for(TInt iElem = 0; iElem < theMesh->myNbPoints; iElem++){ -// TInt aFamId = theNodeInfo->GetFamNum(iElem); -// if(aFamId != 0) -// aFamilyID2CellsSize[aFamId] += 2; -// } + if((theGrilleInfo->myFamNumNode).size() > 0) + for(TInt iElem = 0; iElem < theGrilleInfo->GetNbNodes(); iElem++){ + TInt aFamId = theGrilleInfo->GetFamNumNode(iElem); + if(aFamId != 0) + aFamilyID2CellsSize[aFamId] += 2; + } INITMSG(MYDEBUG, "- myNbCells = "<myNbCells<< @@ -689,11 +689,12 @@ namespace "; myCellsSize = "<myCellsSize<< endl); -// for(TInt iElem = 0; iElem < aNbElem; iElem++){ -// TInt aFamId = aCellInfo->GetFamNum(iElem); -// if(aFamId != 0) -// aFamilyID2CellsSize[aFamId] += aVNbNodes + 1; -// } + if((theGrilleInfo->myFamNum).size() > 0) + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + TInt aFamId = theGrilleInfo->GetFamNum(iElem); + if(aFamId != 0) + aFamilyID2CellsSize[aFamId] += aVNbNodes + 1; + } } } @@ -858,6 +859,74 @@ namespace } } + + /*! + * Build grille family map + */ + void + BuildGrilleFamilyMap(PMEDMesh theMesh, + const MED::TEntityInfo& theEntityInfo, + const MED::TFamilyInfoSet& theFamilyInfoSet, + MED::PWrapper theMEDWrapper) + { + TTimerLog aTimerLog(MYDEBUG,"BuildGrilleFamilyMap"); + INITMSG(MYDEBUG,"BuildGrilleFamilyMap\n"); + + TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; + + MED::TEntityInfo::const_iterator aEntityIter = theEntityInfo.begin(); + + const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo; + MED::PGrilleInfo aGrilleInfo = theMEDWrapper->GetPGrilleInfo(aMeshInfo); + + const MED::TFamilyID2NbCells& aFam2NbCells = MED::GetFamilyID2NbCells(aGrilleInfo); + + MED::TFamilyInfoSet::iterator aFamInter = theFamilyInfoSet.begin(); + for(;aFamInter != theFamilyInfoSet.end();aFamInter++){ + TInt anId = (*aFamInter)->GetId(); + + if(anId == 0) + continue; + + std::string aFamilyName = (*aFamInter)->GetName(); + const MED::EEntiteMaillage& aMEntity = MED::GetEntityByFamilyId(aGrilleInfo, + anId); + TEntity aVEntity = MEDEntityToVTK(aMEntity); + + PMEDMeshOnEntity aMeshOnEntity; + TMeshOnEntityMap::iterator aMeshOnEntityIter = aMeshOnEntityMap.find(aVEntity); + if(aMeshOnEntityIter != aMeshOnEntityMap.end()) + aMeshOnEntity = aMeshOnEntityIter->second; + + TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; + + PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily()); + aFamily->myId = anId; + aFamily->myEntity = aVEntity; + aFamily->myName = aFamilyName; + aFamily->myNbCells = 0; + aFamily->myCellsSize = 0; + + TFamilyID2CellsSize::iterator aFamilyid2CellsSizeIter = (aMeshOnEntity->myFamilyID2CellsSize).find(anId); + if(aFamilyid2CellsSizeIter != (aMeshOnEntity->myFamilyID2CellsSize).end()) + aFamily->myCellsSize = aFamilyid2CellsSizeIter->second; + MED::TFamilyID2NbCells::const_iterator aFam2NbCellsIter = aFam2NbCells.find(anId); + if(aFam2NbCellsIter != aFam2NbCells.end()) + aFamily->myNbCells = aFam2NbCellsIter->second; + + INITMSG(MY_FAMILY_DEBUG, + "- aFamilyName =|"<myName<<"|" + << "; myId = "<myId + << "; aNbAttr = "<<(*aFamInter)->GetNbAttr() + << "; aNbGroup = "<<(*aFamInter)->GetNbGroup() + << "; aVEntity = "<GetType(); + MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo); MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo = @@ -1481,11 +1552,17 @@ VISU_MedConvertor #endif MED::TFamilyInfoSet aFamilyInfoSet = MED::GetFamilyInfoSet(aMed,aMeshInfo); - BuildFamilyMap(aMesh, - anEntityInfo, - anEntity2TGeom2ElemInfo, - aFamilyInfoSet, - aMed); + if(aType == MED::eNON_STRUCTURE) + BuildFamilyMap(aMesh, + anEntityInfo, + anEntity2TGeom2ElemInfo, + aFamilyInfoSet, + aMed); + else + BuildGrilleFamilyMap(aMesh, + anEntityInfo, + aFamilyInfoSet, + aMed); BuildGroupMap(aMesh, aFamilyInfoSet); @@ -1493,7 +1570,7 @@ VISU_MedConvertor }catch(std::exception& exc){ MSG(MYDEBUG,"Follow exception was occured in:\n"<myIsDone) return 0; + const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo; + MED::EMaillage aType = aMeshInfo->GetType(); + //Main part of code - MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo); - TInt aNbElem = aNodeInfo->GetNbElem(); - - if(aNbElem > 0){ - TInt anId = theFamily->myId; - TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1]; - for(TInt iElem = 0; iElem < aNbElem; iElem++) - if(aNodeInfo->GetFamNum(iElem) == anId) - aSubMeshID.push_back(iElem); + if(MED::eNON_STRUCTURE){ + MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo); + TInt aNbElem = aNodeInfo->GetNbElem(); + + if(aNbElem > 0){ + TInt anId = theFamily->myId; + TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1]; + for(TInt iElem = 0; iElem < aNbElem; iElem++) + if(aNodeInfo->GetFamNum(iElem) == anId) + aSubMeshID.push_back(iElem); + } + } else { + MED::PGrilleInfo aGrilleInfo = theMed->GetPGrilleInfo(aMeshInfo); + TInt aNbElem = aGrilleInfo->GetNbNodes(); + + if(aNbElem > 0){ + TInt anId = theFamily->myId; + TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1]; + for(TInt iElem = 0; iElem < aNbElem; iElem++) + if(aGrilleInfo->GetFamNumNode(iElem) == anId) + aSubMeshID.push_back(iElem); + } } theFamily->myIsDone = true; @@ -2149,35 +2242,54 @@ VISU_MedConvertor const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo; TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID; + MED::EMaillage aType = aMeshInfo->GetType(); const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size; MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin(); for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){ const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first; - MED::PElemInfo anElemInfo; - switch(aMGeom){ - case MED::ePOLYGONE: { - anElemInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom); - break; - } - case MED::ePOLYEDRE: { - anElemInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom); - break; - } - default: { - anElemInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom); - break; - }} - if(anElemInfo){ - if(TInt aNbElem = anElemInfo->GetNbElem()){ - TSubMeshID aSubMeshID; - for(TInt iElem = 0; iElem < aNbElem; iElem++) - if(anElemInfo->GetFamNum(iElem) == anId) - aSubMeshID.push_back(iElem); - if(!aSubMeshID.empty()){ - VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); - INITMSG(MYDEBUG,"aMGeom = "<GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom); + break; + } + case MED::ePOLYEDRE: { + anElemInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom); + break; + } + default: { + anElemInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom); + break; + }} + if(anElemInfo){ + if(TInt aNbElem = anElemInfo->GetNbElem()){ + TSubMeshID aSubMeshID; + for(TInt iElem = 0; iElem < aNbElem; iElem++) + if(anElemInfo->GetFamNum(iElem) == anId) + aSubMeshID.push_back(iElem); + if(!aSubMeshID.empty()){ + VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); + INITMSG(MYDEBUG,"aMGeom = "<GetPGrilleInfo(aMeshInfo); + if(anElemInfo){ + TInt aNbElem = anElemInfo->GetNbCells(); + if(aNbElem>0 && (aMGeom == anElemInfo->GetGeom()) ){ + TSubMeshID aSubMeshID; + for(TInt iElem = 0; iElem < aNbElem; iElem++) + if(anElemInfo->GetFamNum(iElem) == anId) + aSubMeshID.push_back(iElem); + if(!aSubMeshID.empty()){ + VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); + INITMSG(MYDEBUG,"aMGeom = "<GetInput()->GetFamilyOnEntity(myMeshName,(VISU::TEntity)myEntity,mySubMeshName); - aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", - VISU::TFAMILY,myMeshName.c_str(),myEntity,mySubMeshName.c_str()); + aComment = ""; + aComment.append(aTmp.sprintf("myComment=FAMILY;myType=%d;",VISU::TFAMILY)); + aComment.append("myMeshName=");aComment.append(myMeshName);aComment.append(";"); + aComment.append(aTmp.sprintf("myEntityId=%d;",myEntity)); + aComment.append("myName=");aComment.append(mySubMeshName); break; case VISU::TGROUP : anIDMapper = myResult->GetInput()->GetMeshOnGroup(myMeshName,mySubMeshName); - aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s", - VISU::TGROUP,myMeshName.c_str(),mySubMeshName.c_str()); + aComment = ""; + aComment.append(aTmp.sprintf("myComment=GROUP;myType=%d;",VISU::TGROUP)); + aComment.append("myMeshName=");aComment.append(myMeshName);aComment.append(";"); + aComment.append("myName=");aComment.append(mySubMeshName); + break; } if(!anIDMapper) diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index 2abc3b87..8fd3bd92 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -401,7 +401,7 @@ namespace VISU theInput->BuildEntities(); } - QString aComment; + QString aComment,aTmp; const TMeshMap& aMeshMap = theInput->GetMeshMap(); TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ @@ -410,10 +410,10 @@ namespace VISU const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; if(aMeshOnEntityMap.empty()) continue; - - aComment.sprintf("myComment=MESH;myName=%s;myDim=%d", - aMeshName.c_str(), - aMesh->myDim); + aComment = ""; + aComment.append("myComment=MESH;"); + aComment.append("myName=");aComment.append(aMeshName);aComment.append(";"); + aComment.append(aTmp.sprintf("myDim=%d",aMesh->myDim)); aMesh->myEntry = CreateAttributes(theStudy, theResultEntry, @@ -422,8 +422,9 @@ namespace VISU aComment.latin1(), true); - aComment.sprintf("myComment=FAMILIES;myMeshName=%s", - aMeshName.c_str()); + aComment = ""; + aComment.append("myComment=FAMILIES;"); + aComment.append("myMeshName=");aComment.append(aMeshName); string aSubMeshesEntry = CreateAttributes(theStudy, aMesh->myEntry, @@ -476,10 +477,11 @@ namespace VISU continue; } - aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d", - VISU::TENTITY, - aMeshName.c_str(), - anEntity); + aComment = ""; + aComment.append(aTmp.sprintf("myComment=ENTITY;myType=%d;",VISU::TENTITY)); + aComment.append("myMeshName=");aComment.append(aMeshName);aComment.append(";"); + aComment.append(aTmp.sprintf("myId=%d",anEntity)); + aMeshOnEntity->myEntry = CreateAttributes(theStudy, @@ -515,7 +517,7 @@ namespace VISU theInput->BuildGroups(); } - QString aComment; + QString aComment,aTmp; const TMeshMap& aMeshMap = theInput->GetMeshMap(); TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ @@ -536,11 +538,12 @@ namespace VISU for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ const string& aFamilyName = aFamilyMapIter->first; const PFamily& aFamily = aFamilyMapIter->second; - aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", - TFAMILY, - aMeshName.c_str(), - anEntity, - aFamilyName.c_str()); + aComment = ""; + aComment.append(aTmp.sprintf("myComment=FAMILY;myType=%d;",TFAMILY)); + aComment.append("myMeshName=");aComment.append(aMeshName);aComment.append(";"); + aComment.append(aTmp.sprintf("myEntityId=%d;",anEntity)); + aComment.append("myName=");aComment.append(aFamilyName); + aFamily->myEntry = CreateAttributes(theStudy, aMeshOnEntity->myEntry, @@ -553,8 +556,9 @@ namespace VISU //Importing groups const TGroupMap& aGroupMap = aMesh->myGroupMap; if(!aGroupMap.empty()){ - aComment.sprintf("myComment=GROUPS;myMeshName=%s", - aMeshName.c_str()); + aComment = ""; + aComment.append("myComment=GROUPS;"); + aComment.append("myMeshName=");aComment.append(aMeshName); UpdateAttributes(theStudy, aMesh->myGroupsEntry, @@ -566,8 +570,11 @@ namespace VISU for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ const string& aGroupName = aGroupMapIter->first; const PGroup& aGroup = aGroupMapIter->second; - aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s", - TGROUP,aMeshName.c_str(),aGroupName.c_str()); + aComment = ""; + aComment.sprintf("myComment=GROUP;myType=%d;", + TGROUP); + aComment.append("myMeshName=");aComment.append(aMeshName);aComment.append(";"); + aComment.append("myName=");aComment.append(aGroupName); aGroup->myEntry = CreateAttributes(theStudy, aMesh->myGroupsEntry, @@ -614,7 +621,7 @@ namespace VISU theInput->BuildFields(); } - QString aComment; + QString aComment,aTmp; const TMeshMap& aMeshMap = theInput->GetMeshMap(); TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ @@ -635,9 +642,10 @@ namespace VISU TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ if(!anIsFieldsEntryUpdated){ - aComment.sprintf("myComment=FIELDS;myMeshName=%s", - aMeshName.c_str()); - + aComment = ""; + aComment.append("myComment=FIELDS;"); + aComment.append("myMeshName=");aComment.append(aMeshName); + UpdateAttributes(theStudy, aMesh->myFieldsEntry, "", @@ -650,13 +658,13 @@ namespace VISU const PField& aField = aFieldMapIter->second; const TValField& aValField = aField->myValField; QString aFieldNameWithUnit = GenerateFieldName(aFieldName,aField->myUnitNames[0]); - aComment.sprintf("myComment=FIELD;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d", - TFIELD, - aMeshName.c_str(), - anEntity, - aFieldName.c_str(), - aValField.size(), - aField->myNbComp); + aComment = ""; + aComment.sprintf("myComment=FIELD;myType=%d;",TFIELD); + aComment.append("myMeshName=");aComment.append(aMeshName);aComment.append(";"); + aComment.append(aTmp.sprintf("myEntityId=%d;",anEntity)); + aComment.append("myName=");aComment.append(aFieldName);aComment.append(";"); + aComment.append(aTmp.sprintf("myNbTimeStamps=%d;",aValField.size())); + aComment.append(aTmp.sprintf("myNumComponent=%d",aField->myNbComp)); aField->myEntry = CreateAttributes(theStudy, aMesh->myFieldsEntry, @@ -671,13 +679,13 @@ namespace VISU for(; aValFieldIter != aValField.end(); aValFieldIter++){ int aTimeStamp = aValFieldIter->first; const PValForTime& aValForTime = aValFieldIter->second; - aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", - TTIMESTAMP, - aMeshName.c_str(), - anEntity, - aFieldName.c_str(), - aTimeStamp, - aField->myNbComp); + aComment = ""; + aComment.sprintf("myComment=TIMESTAMP;myType=%d;",TTIMESTAMP); + aComment.append("myMeshName=");aComment.append(aMeshName);aComment.append(";"); + aComment.append(aTmp.sprintf("myEntityId=%d;",anEntity)); + aComment.append("myFieldName=");aComment.append(aFieldName);aComment.append(";"); + aComment.append(aTmp.sprintf("myTimeStampId=%d;myNumComponent=%d",aTimeStamp,aField->myNbComp)); + string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime); aValForTime->myEntry = CreateAttributes(theStudy,