From: eap Date: Thu, 5 Nov 2009 11:40:45 +0000 (+0000) Subject: 0020576: EDF 1163 SMESH: Random type of group at MED import X-Git-Tag: V5_1_3rc2~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a17f232b9071fbbe7c8d972f972232d464a44485;p=modules%2Fsmesh.git 0020576: EDF 1163 SMESH: Random type of group at MED import care of families containing elements of different entity types --- diff --git a/src/DriverMED/DriverMED_Family.cxx b/src/DriverMED/DriverMED_Family.cxx index 3a6a37f96..31a69cfc1 100644 --- a/src/DriverMED/DriverMED_Family.cxx +++ b/src/DriverMED/DriverMED_Family.cxx @@ -23,7 +23,6 @@ // File : DriverMED_Family.cxx // Author : Julia DOROVSKIKH // Module : SMESH -// $Header$ // #include "DriverMED_Family.h" #include "MED_Factory.hxx" @@ -83,7 +82,7 @@ void DriverMED_Family ::SetType(const SMDSAbs_ElementType theType) { - myType = theType; + myTypes.insert( myType = theType ); } SMDSAbs_ElementType @@ -93,6 +92,13 @@ DriverMED_Family return myType; } +const std::set< SMDSAbs_ElementType >& +DriverMED_Family +::GetTypes() const +{ + return myTypes; +} + bool DriverMED_Family ::MemberOf(std::string theGroupName) const diff --git a/src/DriverMED/DriverMED_Family.h b/src/DriverMED/DriverMED_Family.h index 2246beb1b..f91693a88 100644 --- a/src/DriverMED/DriverMED_Family.h +++ b/src/DriverMED/DriverMED_Family.h @@ -23,7 +23,6 @@ // File : DriverMED_Family.hxx // Author : Julia DOROVSKIKH // Module : SMESH -// $Header$ // #ifndef _INCLUDE_DRIVERMED_FAMILY #define _INCLUDE_DRIVERMED_FAMILY @@ -99,6 +98,7 @@ class MESHDRIVERMED_EXPORT DriverMED_Family void SetType(const SMDSAbs_ElementType theType); SMDSAbs_ElementType GetType(); + const std::set< SMDSAbs_ElementType >& GetTypes() const; bool MemberOf(std::string theGroupName) const; @@ -133,6 +133,7 @@ class MESHDRIVERMED_EXPORT DriverMED_Family ElementsSet myElements; MED::TStringSet myGroupNames; int myGroupAttributVal; + std::set myTypes; // Issue 0020576 }; #endif diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx index cf41d568d..af538f52f 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx @@ -48,10 +48,11 @@ static int MYDEBUG = 0; #define _EDF_NODE_IDS_ using namespace MED; +using namespace std; void DriverMED_R_SMESHDS_Mesh -::SetMeshName(std::string theMeshName) +::SetMeshName(string theMeshName) { myMeshName = theMeshName; } @@ -60,7 +61,7 @@ static const SMDS_MeshNode* FindNode(const SMDS_Mesh* theMesh, TInt theId){ const SMDS_MeshNode* aNode = theMesh->FindNode(theId); if(aNode) return aNode; - EXCEPTION(std::runtime_error,"SMDS_Mesh::FindNode - cannot find a SMDS_MeshNode for ID = "< DriverMED_R_SMESHDS_Mesh::GetMeshNames(Status& theStatus) return aMeshNames; } -std::list DriverMED_R_SMESHDS_Mesh::GetGroupNamesAndTypes() +list DriverMED_R_SMESHDS_Mesh::GetGroupNamesAndTypes() { - std::list aResult; - std::set aResGroupNames; + list aResult; + set aResGroupNames; - std::map::iterator aFamsIter = myFamilies.begin(); + map::iterator aFamsIter = myFamilies.begin(); for (; aFamsIter != myFamilies.end(); aFamsIter++) { DriverMED_FamilyPtr aFamily = (*aFamsIter).second; const MED::TStringSet& aGroupNames = aFamily->GetGroupNames(); - std::set::const_iterator aGrNamesIter = aGroupNames.begin(); + set::const_iterator aGrNamesIter = aGroupNames.begin(); for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++) { - TNameAndType aNameAndType = make_pair( *aGrNamesIter, aFamily->GetType() ); - // Check, if this is a Group or SubMesh name -//if (aName.substr(0, 5) == string("Group")) { + const set< SMDSAbs_ElementType >& types = aFamily->GetTypes(); + set< SMDSAbs_ElementType >::const_iterator type = types.begin(); + for ( ; type != types.end(); ++type ) + { + TNameAndType aNameAndType = make_pair( *aGrNamesIter, *type ); if ( aResGroupNames.insert( aNameAndType ).second ) { aResult.push_back( aNameAndType ); } -// } + } } } @@ -792,28 +795,28 @@ std::list DriverMED_R_SMESHDS_Mesh::GetGroupNamesAndTypes() void DriverMED_R_SMESHDS_Mesh::GetGroup(SMESHDS_Group* theGroup) { - std::string aGroupName (theGroup->GetStoreName()); + string aGroupName (theGroup->GetStoreName()); if(MYDEBUG) MESSAGE("Get Group " << aGroupName); - std::map::iterator aFamsIter = myFamilies.begin(); + map::iterator aFamsIter = myFamilies.begin(); for (; aFamsIter != myFamilies.end(); aFamsIter++) { DriverMED_FamilyPtr aFamily = (*aFamsIter).second; - if (aFamily->GetType() == theGroup->GetType() && aFamily->MemberOf(aGroupName)) + if (aFamily->GetTypes().count( theGroup->GetType() ) && aFamily->MemberOf(aGroupName)) { - const std::set& anElements = aFamily->GetElements(); - std::set::const_iterator anElemsIter = anElements.begin(); - const SMDS_MeshElement * element = 0; + const set& anElements = aFamily->GetElements(); + set::const_iterator anElemsIter = anElements.begin(); for (; anElemsIter != anElements.end(); anElemsIter++) { - element = *anElemsIter; - theGroup->SMDSGroup().Add(element); - int aGroupAttrVal = aFamily->GetGroupAttributVal(); - if( aGroupAttrVal != 0) - theGroup->SetColorGroup(aGroupAttrVal); + const SMDS_MeshElement * element = *anElemsIter; + if ( element->GetType() == theGroup->GetType() ) // Issue 0020576 + theGroup->SMDSGroup().Add(element); } - if ( element ) - theGroup->SetType( theGroup->SMDSGroup().GetType() ); + int aGroupAttrVal = aFamily->GetGroupAttributVal(); + if( aGroupAttrVal != 0) + theGroup->SetColorGroup(aGroupAttrVal); +// if ( element ) -- Issue 0020576 +// theGroup->SetType( theGroup->SMDSGroup().GetType() ); } } } @@ -823,15 +826,15 @@ void DriverMED_R_SMESHDS_Mesh::GetSubMesh (SMESHDS_SubMesh* theSubMesh, { char submeshGrpName[ 30 ]; sprintf( submeshGrpName, "SubMesh %d", theId ); - std::string aName (submeshGrpName); - std::map::iterator aFamsIter = myFamilies.begin(); + string aName (submeshGrpName); + map::iterator aFamsIter = myFamilies.begin(); for (; aFamsIter != myFamilies.end(); aFamsIter++) { DriverMED_FamilyPtr aFamily = (*aFamsIter).second; if (aFamily->MemberOf(aName)) { - const std::set& anElements = aFamily->GetElements(); - std::set::const_iterator anElemsIter = anElements.begin(); + const set& anElements = aFamily->GetElements(); + set::const_iterator anElemsIter = anElements.begin(); if (aFamily->GetType() == SMDSAbs_Node) { for (; anElemsIter != anElements.end(); anElemsIter++) @@ -853,21 +856,21 @@ void DriverMED_R_SMESHDS_Mesh::GetSubMesh (SMESHDS_SubMesh* theSubMesh, void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes () { - std::map::iterator aFamsIter = myFamilies.begin(); + map::iterator aFamsIter = myFamilies.begin(); for (; aFamsIter != myFamilies.end(); aFamsIter++) { DriverMED_FamilyPtr aFamily = (*aFamsIter).second; MED::TStringSet aGroupNames = aFamily->GetGroupNames(); - std::set::iterator aGrNamesIter = aGroupNames.begin(); + set::iterator aGrNamesIter = aGroupNames.begin(); for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++) { - std::string aName = *aGrNamesIter; + string aName = *aGrNamesIter; // Check, if this is a Group or SubMesh name - if (aName.substr(0, 7) == std::string("SubMesh")) + if (aName.substr(0, 7) == string("SubMesh")) { - int Id = atoi(std::string(aName).substr(7).c_str()); - std::set anElements = aFamily->GetElements(); - std::set::iterator anElemsIter = anElements.begin(); + int Id = atoi(string(aName).substr(7).c_str()); + set anElements = aFamily->GetElements(); + set::iterator anElemsIter = anElements.begin(); if (aFamily->GetType() == SMDSAbs_Node) { for (; anElemsIter != anElements.end(); anElemsIter++) @@ -909,7 +912,7 @@ void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes () bool DriverMED_R_SMESHDS_Mesh::checkFamilyID(DriverMED_FamilyPtr & aFamily, int anID) const { if ( !aFamily || aFamily->GetId() != anID ) { - std::map::const_iterator i_fam = myFamilies.find(anID); + map::const_iterator i_fam = myFamilies.find(anID); if ( i_fam == myFamilies.end() ) return false; aFamily = i_fam->second; @@ -960,7 +963,7 @@ bool DriverMED_R_SMESHDS_Mesh::buildMeshGrille(const MED::PWrapper& theWrapper, case MED::eSEG2: if(aNodeIds.size() != 2){ res = false; - EXCEPTION(std::runtime_error,"buildMeshGrille Error. Incorrect size of ids 2!="<