X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FDriverMED%2FDriverMED_R_SMESHDS_Mesh.cxx;h=9eab4fc8858bec48fc6344e878c6c35f0b53895c;hb=f028e1d7bf48b6f5eab99a7b85488c2952fd5b55;hp=58f9c0ca024bcb095ba5b5b63407b84149060769;hpb=e074bae4b74bc02aeebb7437fbae12a55bdad0c1;p=modules%2Fsmesh.git diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx index 58f9c0ca0..9eab4fc88 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -36,18 +36,12 @@ #include "MED_Utilities.hxx" #include +#include #include "utilities.h" //#include -#ifdef _DEBUG_ -static int MYDEBUG = 1; -//#define _DEXCEPT_ -#else -static int MYDEBUG = 0; -#endif - #define _EDF_NODE_IDS_ using namespace MED; @@ -109,8 +103,8 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() try { #endif myFamilies.clear(); - if(MYDEBUG) MESSAGE("Perform - myFile : "<GetNbMeshes(); @@ -124,7 +118,7 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() if (myMeshId != -1) aMeshName = SMESH_Comment( myMeshId ); else aMeshName = myMeshName; - if(MYDEBUG) MESSAGE("Perform - aMeshName : "<GetName()); + MESSAGE("Perform - aMeshName : "<GetName()); if ( aMeshName != aMeshInfo->GetName() ) continue; aResult = DRS_OK; @@ -132,18 +126,18 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() //------------------------------------------------ TErr anErr; TInt aNbFams = aMed->GetNbFamilies(aMeshInfo); - if(MYDEBUG) MESSAGE("Read " << aNbFams << " families"); + MESSAGE("Read " << aNbFams << " families"); for (TInt iFam = 0; iFam < aNbFams; iFam++) { PFamilyInfo aFamilyInfo = aMed->GetPFamilyInfo(aMeshInfo,iFam+1,&anErr); if(anErr >= 0){ TInt aFamId = aFamilyInfo->GetId(); - if(MYDEBUG) MESSAGE("Family " << aFamId << " :"); + MESSAGE("Family " << aFamId << " :"); DriverMED_FamilyPtr aFamily (new DriverMED_Family); TInt aNbGrp = aFamilyInfo->GetNbGroup(); - if(MYDEBUG) MESSAGE("belong to " << aNbGrp << " groups"); + MESSAGE("belong to " << aNbGrp << " groups"); bool isAttrOk = false; if(aFamilyInfo->GetNbAttr() == aNbGrp) isAttrOk = true; @@ -154,8 +148,9 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() TInt anAttrVal = aFamilyInfo->GetAttrVal(iGr); aFamily->SetGroupAttributVal(anAttrVal); } - if(MYDEBUG) MESSAGE(aGroupName); - aFamily->AddGroupName(aGroupName); + MESSAGE(aGroupName); + if ( strncmp( aGroupName.c_str(), NIG_GROUP_PREFIX, strlen(NIG_GROUP_PREFIX) ) != 0 ) + aFamily->AddGroupName( fixUTF8( aGroupName )); } aFamily->SetId( aFamId ); myFamilies[aFamId] = aFamily; @@ -180,7 +175,7 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() EBooleen anIsNodeNum = aNodeInfo->IsElemNum(); TInt aNbElems = aNodeInfo->GetNbElem(); - if(MYDEBUG) MESSAGE("Perform - aNodeInfo->GetNbElem() = "<GetNbElem() = "<compactMesh(); // Mantis issue 0020483 if (aResult == DRS_OK && isDescConn) { @@ -1010,7 +1039,7 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() aResult = DRS_WARN_DESCENDING; } - if(MYDEBUG) MESSAGE("Perform - aResult status = "<GetNbMeshes()) { for (int iMesh = 0; iMesh < aNbMeshes; iMesh++) { @@ -1055,8 +1084,8 @@ list DriverMED_R_SMESHDS_Mesh::GetGroupNamesAndTypes() set::const_iterator aGrNamesIter = aGroupNames.begin(); for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++) { - const set< SMDSAbs_ElementType >& types = aFamily->GetTypes(); - set< SMDSAbs_ElementType >::const_iterator type = types.begin(); + const ElemTypeSet& types = aFamily->GetTypes(); + ElemTypeSet::const_iterator type = types.begin(); for ( ; type != types.end(); ++type ) { TNameAndType aNameAndType = make_pair( *aGrNamesIter, *type ); @@ -1072,28 +1101,59 @@ list DriverMED_R_SMESHDS_Mesh::GetGroupNamesAndTypes() void DriverMED_R_SMESHDS_Mesh::GetGroup(SMESHDS_Group* theGroup) { - string aGroupName (theGroup->GetStoreName()); - if(MYDEBUG) MESSAGE("Get Group " << aGroupName); + TFamilyVec * famVecPtr; - map::iterator aFamsIter = myFamilies.begin(); - for (; aFamsIter != myFamilies.end(); aFamsIter++) + if ( myGroups2FamiliesMap.IsEmpty() ) // PAL23514 { - DriverMED_FamilyPtr aFamily = (*aFamsIter).second; - if (aFamily->GetTypes().count( theGroup->GetType() ) && aFamily->MemberOf(aGroupName)) + TFamilyVec famVector( 1 ); + map::iterator famIter = myFamilies.begin(); + for ( ; famIter != myFamilies.end(); famIter++ ) { - const set& anElements = aFamily->GetElements(); - set::const_iterator anElemsIter = anElements.begin(); - for (; anElemsIter != anElements.end(); anElemsIter++) + DriverMED_FamilyPtr family = famIter->second; + const MED::TStringSet& groups = family->GetGroupNames(); + famVector[ 0 ] = family; + MED::TStringSet::const_iterator grpIter = groups.begin(); + for ( ; grpIter != groups.end(); ++grpIter ) { - const SMDS_MeshElement * element = *anElemsIter; - if ( element->GetType() == theGroup->GetType() ) // Issue 0020576 - theGroup->SMDSGroup().Add(element); + TCollection_AsciiString groupName = grpIter->c_str(); + if (( famVecPtr = myGroups2FamiliesMap.ChangeSeek( groupName ))) + famVecPtr->push_back( family ); + else + myGroups2FamiliesMap.Bind( groupName, famVector ); + } + } + } + + const char* aGroupName = theGroup->GetStoreName(); + MESSAGE("Get Group " << aGroupName); + + if (( famVecPtr = myGroups2FamiliesMap.ChangeSeek( aGroupName ))) + { + size_t groupSize = 0; + for ( size_t i = 0; i < famVecPtr->size(); ++i ) + { + DriverMED_FamilyPtr aFamily = (*famVecPtr)[i]; + groupSize += aFamily->NbElements( theGroup->GetType() ); + } + theGroup->SMDSGroup().Reserve( groupSize ); + + for ( size_t i = 0; i < famVecPtr->size(); ++i ) + { + DriverMED_FamilyPtr aFamily = (*famVecPtr)[i]; + if ( aFamily->GetTypes().count( theGroup->GetType() )) + { + const ElementsSet& anElements = aFamily->GetElements(); + ElementsSet::const_iterator anElemsIter = anElements.begin(); + for (; anElemsIter != anElements.end(); anElemsIter++) + { + const SMDS_MeshElement * element = *anElemsIter; + if ( element->GetType() == theGroup->GetType() ) // Issue 0020576 + theGroup->SMDSGroup().Add(element); + } + int aGroupAttrVal = aFamily->GetGroupAttributVal(); + if( aGroupAttrVal != 0 ) + theGroup->SetColorGroup(aGroupAttrVal); } - int aGroupAttrVal = aFamily->GetGroupAttributVal(); - if( aGroupAttrVal != 0) - theGroup->SetColorGroup(aGroupAttrVal); -// if ( element ) -- Issue 0020576 -// theGroup->SetType( theGroup->SMDSGroup().GetType() ); } } } @@ -1110,8 +1170,8 @@ void DriverMED_R_SMESHDS_Mesh::GetSubMesh (SMESHDS_SubMesh* theSubMesh, DriverMED_FamilyPtr aFamily = (*aFamsIter).second; if (aFamily->MemberOf(aName)) { - const set& anElements = aFamily->GetElements(); - set::const_iterator anElemsIter = anElements.begin(); + const ElementsSet& anElements = aFamily->GetElements(); + ElementsSet::const_iterator anElemsIter = anElements.begin(); if (aFamily->GetType() == SMDSAbs_Node) { for (; anElemsIter != anElements.end(); anElemsIter++) @@ -1146,14 +1206,13 @@ void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes () if (aName.substr(0, 7) == string("SubMesh")) { int Id = atoi(string(aName).substr(7).c_str()); - set anElements = aFamily->GetElements(); - set::iterator anElemsIter = anElements.begin(); + const ElementsSet& anElements = aFamily->GetElements(); + ElementsSet::const_iterator anElemsIter = anElements.begin(); if (aFamily->GetType() == SMDSAbs_Node) { for (; anElemsIter != anElements.end(); anElemsIter++) { - SMDS_MeshNode* node = const_cast - ( static_cast( *anElemsIter )); + const SMDS_MeshNode* node = static_cast( *anElemsIter ); // find out a shape type TopoDS_Shape aShape = myMesh->IndexToShape( Id ); int aShapeType = ( aShape.IsNull() ? -1 : aShape.ShapeType() );