X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FDriverMED%2FDriverMED_R_SMESHDS_Mesh.cxx;h=8388327d91af7d64048b6ee04b50f72f003a7606;hp=25e517cf44d0da1b53a5d92e550b3ec1bb8805ae;hb=87fd8ca50b1fe004fc046c66c5b5df6199861981;hpb=090aff07266d376ae028ae43434bdea7c0a0f9bb diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx index 25e517cf4..8388327d9 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx @@ -38,6 +38,12 @@ #include +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + #define _EDF_NODE_IDS_ using namespace MED; @@ -136,7 +142,7 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() Status aResult = DRS_FAIL; try{ myFamilies.clear(); - MESSAGE("Perform - myFile : "<GetName()); + if(MYDEBUG) MESSAGE("Perform - aMeshName : "<GetName()); if(aMeshName != aMeshInfo->GetName()) continue; aResult = DRS_OK; //TInt aMeshDim = aMeshInfo->GetDim(); // Reading MED families to the temporary structure //------------------------------------------------ - TInt aNbFams = aMed->GetNbFamilies(aMeshInfo); - MESSAGE("Read " << aNbFams << " families"); + TErr anErr; + TInt aNbFams = aMed->GetNbFamilies(aMeshInfo); + if(MYDEBUG) MESSAGE("Read " << aNbFams << " families"); for (TInt iFam = 0; iFam < aNbFams; iFam++) { - PFamilyInfo aFamilyInfo = aMed->GetPFamilyInfo(aMeshInfo, iFam+1); - TInt aFamId = aFamilyInfo->GetId(); - MESSAGE("Family " << aFamId << " :"); - + PFamilyInfo aFamilyInfo = aMed->GetPFamilyInfo(aMeshInfo,iFam+1,&anErr); + if(anErr >= 0){ + TInt aFamId = aFamilyInfo->GetId(); + if(MYDEBUG) MESSAGE("Family " << aFamId << " :"); + DriverMED_FamilyPtr aFamily (new DriverMED_Family); - + TInt aNbGrp = aFamilyInfo->GetNbGroup(); - MESSAGE("belong to " << aNbGrp << " groups"); + if(MYDEBUG) MESSAGE("belong to " << aNbGrp << " groups"); for (TInt iGr = 0; iGr < aNbGrp; iGr++) { string aGroupName = aFamilyInfo->GetGroupName(iGr); - MESSAGE(aGroupName); + if(MYDEBUG) MESSAGE(aGroupName); aFamily->AddGroupName(aGroupName); } + aFamily->SetId( aFamId ); myFamilies[aFamId] = aFamily; + } } // Reading MED nodes to the corresponding SMDS structure @@ -221,7 +231,8 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() EBooleen anIsNodeNum = aNodeInfo->IsElemNum(); TInt aNbElems = aNodeInfo->GetNbElem(); - MESSAGE("Perform - aNodeInfo->GetNbElem() = "<GetNbElem() = "<GetFamNum(iElem); try{ + //MESSAGE("Try to create element # " << iElem << " with id = " + // << aCellInfo->GetElemNum(iElem)); switch(aGeom){ case eSEG2: case eSEG3: @@ -468,10 +665,11 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() if (aResult < DRS_WARN_RENUMBER) aResult = DRS_WARN_RENUMBER; } - if (myFamilies.find(aFamNum) != myFamilies.end()) { + if ( checkFamilyID ( aFamily, aFamNum )) + { // Save reference to this element from its family - myFamilies[aFamNum]->AddElement(anElement); - myFamilies[aFamNum]->SetType(anElement->GetType()); + aFamily->AddElement(anElement); + aFamily->SetType(anElement->GetType()); } } } @@ -487,7 +685,7 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() INFOS("Unknown exception was cought !!!"); aResult = DRS_FAIL; } - MESSAGE("Perform - aResult status = "< DriverMED_R_SMESHDS_Mesh::GetMeshNames(Status& theStatus) return aMeshNames; } -list DriverMED_R_SMESHDS_Mesh::GetGroupNames() +list DriverMED_R_SMESHDS_Mesh::GetGroupNamesAndTypes() { - list aResult; - set aResGroupNames; + list aResult; + set aResGroupNames; map::iterator aFamsIter = myFamilies.begin(); for (; aFamsIter != myFamilies.end(); aFamsIter++) { DriverMED_FamilyPtr aFamily = (*aFamsIter).second; const MED::TStringSet& aGroupNames = aFamily->GetGroupNames(); - set::iterator aGrNamesIter = aGroupNames.begin(); + set::const_iterator aGrNamesIter = aGroupNames.begin(); for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++) { - string aName = *aGrNamesIter; + TNameAndType aNameAndType = make_pair( *aGrNamesIter, aFamily->GetType() ); // Check, if this is a Group or SubMesh name //if (aName.substr(0, 5) == string("Group")) { - if (aResGroupNames.find(aName) == aResGroupNames.end()) { - aResGroupNames.insert(aName); - aResult.push_back(aName); + if ( aResGroupNames.insert( aNameAndType ).second ) { + aResult.push_back( aNameAndType ); } // } } @@ -549,21 +746,21 @@ list DriverMED_R_SMESHDS_Mesh::GetGroupNames() void DriverMED_R_SMESHDS_Mesh::GetGroup(SMESHDS_Group* theGroup) { string aGroupName (theGroup->GetStoreName()); - MESSAGE("Get Group " << aGroupName); + if(MYDEBUG) MESSAGE("Get Group " << aGroupName); map::iterator aFamsIter = myFamilies.begin(); for (; aFamsIter != myFamilies.end(); aFamsIter++) { DriverMED_FamilyPtr aFamily = (*aFamsIter).second; - if (aFamily->MemberOf(aGroupName)) + if (aFamily->GetType() == theGroup->GetType() && aFamily->MemberOf(aGroupName)) { const set& anElements = aFamily->GetElements(); - set::iterator anElemsIter = anElements.begin(); + set::const_iterator anElemsIter = anElements.begin(); const SMDS_MeshElement * element = 0; for (; anElemsIter != anElements.end(); anElemsIter++) { element = *anElemsIter; - theGroup->SMDSGroup().Add(element); + theGroup->SMDSGroup().Add(element); } if ( element ) theGroup->SetType( element->GetType() ); @@ -584,7 +781,7 @@ void DriverMED_R_SMESHDS_Mesh::GetSubMesh (SMESHDS_SubMesh* theSubMesh, if (aFamily->MemberOf(aName)) { const set& anElements = aFamily->GetElements(); - set::iterator anElemsIter = anElements.begin(); + set::const_iterator anElemsIter = anElements.begin(); if (aFamily->GetType() == SMDSAbs_Node) { for (; anElemsIter != anElements.end(); anElemsIter++) @@ -653,3 +850,20 @@ void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes () } } } +/*! + * \brief Ensure aFamily to have required ID + * \param aFamily - a family to check and update + * \param anID - an ID aFamily should have + * \retval bool - true if successful + */ +bool DriverMED_R_SMESHDS_Mesh::checkFamilyID(DriverMED_FamilyPtr & aFamily, int anID) const +{ + if ( !aFamily || aFamily->GetId() != anID ) { + map::const_iterator i_fam = myFamilies.find(anID); + if ( i_fam == myFamilies.end() ) + return false; + aFamily = i_fam->second; + } + return ( aFamily->GetId() == anID ); +} +