From 03e67018901ac89a62701443872194dd5f25493a Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 17 Jan 2005 13:46:24 +0000 Subject: [PATCH] Fix on [Bug PAL7023] Problem loading MED file with a large number of families (same as VISU6154) --- src/VISU_I/VISU_Mesh_i.cc | 2 +- src/VISU_I/VISU_Result_i.cc | 181 +++++++++++++++++++++++++++------ src/VISU_I/VISU_Result_i.hh | 4 + src/VISU_I/VISU_ScalarMap_i.cc | 2 +- 4 files changed, 154 insertions(+), 35 deletions(-) diff --git a/src/VISU_I/VISU_Mesh_i.cc b/src/VISU_I/VISU_Mesh_i.cc index dadbcdc7..9da8c729 100644 --- a/src/VISU_I/VISU_Mesh_i.cc +++ b/src/VISU_I/VISU_Mesh_i.cc @@ -219,7 +219,7 @@ VISU::Storable* VISU::Mesh_i::Build(int theRestoring){ if(!theRestoring) { //Setting IOR on the label myMeshPL->Init(); string aResultEntry = myResult->GetEntry(); - string anEntry = FindEntryWithComment(myStudy,aResultEntry.c_str(),aComment.latin1()); + string anEntry = myResult->GetEntry(aComment.latin1()); if(anEntry == "") throw std::runtime_error("Mesh_i::Build - anEntry was not found !!!"); mySObject = myStudy->FindObjectID(anEntry.c_str()); SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index dc8b0903..963c438d 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -253,10 +253,20 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) string aRefFatherEntry = GetRefFatherEntry(); QString aComment; aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s", - GetComment(),VISU::TRESULT,myFileInfo.filePath().latin1(), + GetComment(), + VISU::TRESULT, + myFileInfo.filePath().latin1(), myInitFileName.c_str()); // Restoring of Python dump - string aResultEntry = CreateAttributes(myStudyDocument,aSComponentEntry,aRefFatherEntry.c_str(), - anIOR,myName.c_str(),"",aComment.latin1(),true); + string aResultEntry = + CreateAttributes(myStudyDocument, + aSComponentEntry, + aRefFatherEntry.c_str(), + anIOR, + myName.c_str(), + "", + aComment.latin1(), + true); + myComment2EntryMap[aComment.latin1()] = aResultEntry; mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str()); if(mySObject->_is_nil()) throw std::runtime_error("Build - There is no SObject for the Result !!!"); if(!CORBA::is_nil(theSObject)){ @@ -270,13 +280,32 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; aComment.sprintf("myComment=MESH;myName=%s;myDim=%d", - aMeshName.c_str(),aMesh.myDim); - string aMeshEntry = CreateAttributes(myStudyDocument,aResultEntry.c_str(),aRefFatherEntry.c_str(), - "",aMeshName.c_str(),"",aComment.latin1(),true); - if(aMeshOnEntityMap.empty()) continue; - aComment.sprintf("myComment=FAMILIES;myMeshName=%s",aMeshName.c_str()); - string aSubMeshesEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), - "","Families","",aComment.latin1(),true); + aMeshName.c_str(), + aMesh.myDim); + string aMeshEntry = + CreateAttributes(myStudyDocument, + aResultEntry.c_str(), + aRefFatherEntry.c_str(), + "", + aMeshName.c_str(), + "", + aComment.latin1(), + true); + myComment2EntryMap[aComment.latin1()] = aMeshEntry; + if(aMeshOnEntityMap.empty()) + continue; + aComment.sprintf("myComment=FAMILIES;myMeshName=%s", + aMeshName.c_str()); + string aSubMeshesEntry = + CreateAttributes(myStudyDocument, + aMeshEntry.c_str(), + aRefFatherEntry.c_str(), + "", + "Families", + "", + aComment.latin1(), + true); + myComment2EntryMap[aComment.latin1()] = aSubMeshesEntry; //Import entities and according families aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); typedef map TEntity2Entry; @@ -284,7 +313,9 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d", - VISU::TENTITY,aMeshName.c_str(),anEntity); + VISU::TENTITY, + aMeshName.c_str(), + anEntity); string anEntityName; switch(anEntity){ case VISU::NODE_ENTITY : anEntityName = "onNodes"; break; @@ -294,8 +325,17 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) default: throw std::runtime_error("Build >> Value of entity is incorrect!"); } - aEntity2Entry[anEntity] = CreateAttributes(myStudyDocument,aSubMeshesEntry.c_str(),aRefFatherEntry.c_str(), - "",anEntityName.c_str(),"",aComment.latin1(),true); + string aTmpEntry = + CreateAttributes(myStudyDocument, + aSubMeshesEntry.c_str(), + aRefFatherEntry.c_str(), + "", + anEntityName.c_str(), + "", + aComment.latin1(), + true); + aEntity2Entry[anEntity] = aTmpEntry; + myComment2EntryMap[aComment.latin1()] = aTmpEntry; const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); @@ -303,24 +343,54 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) const string& aFamilyName = aFamilyMapIter->first; const VISU::TFamily& aFamily = aFamilyMapIter->second; aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", - VISU::TFAMILY,aMeshName.c_str(),anEntity,aFamilyName.c_str()); - CreateAttributes(myStudyDocument,aEntity2Entry[anEntity].c_str(),aRefFatherEntry.c_str(), - "",aFamilyName.c_str(),"",aComment.latin1(),true); + VISU::TFAMILY, + aMeshName.c_str(), + anEntity, + aFamilyName.c_str()); + aTmpEntry = + CreateAttributes(myStudyDocument, + aEntity2Entry[anEntity].c_str(), + aRefFatherEntry.c_str(), + "", + aFamilyName.c_str(), + "", + aComment.latin1(), + true); + myComment2EntryMap[aComment.latin1()] = aTmpEntry; } } //Importing groups const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; if(aGroupMap.size() > 0){ - aComment.sprintf("myComment=GROUPS;myMeshName=%s",aMeshName.c_str()); - string aGroupsEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), - "","Groups","",aComment.latin1(),true); + aComment.sprintf("myComment=GROUPS;myMeshName=%s", + aMeshName.c_str()); + string aGroupsEntry = + CreateAttributes(myStudyDocument, + aMeshEntry.c_str(), + aRefFatherEntry.c_str(), + "", + "Groups", + "", + aComment.latin1(), + true); + myComment2EntryMap[aComment.latin1()] = aGroupsEntry; VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ const string& aGroupName = aGroupMapIter->first; aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s", - VISU::TGROUP,aMeshName.c_str(),aGroupName.c_str()); - string aGroupEntry = CreateAttributes(myStudyDocument,aGroupsEntry.c_str(),aRefFatherEntry.c_str(), - "",aGroupName.c_str(),"",aComment.latin1(),true); + VISU::TGROUP, + aMeshName.c_str(), + aGroupName.c_str()); + string aGroupEntry = + CreateAttributes(myStudyDocument, + aGroupsEntry.c_str(), + aRefFatherEntry.c_str(), + "", + aGroupName.c_str(), + "", + aComment.latin1(), + true); + myComment2EntryMap[aComment.latin1()] = aGroupEntry; const VISU::TGroup& aGroup = aGroupMapIter->second; const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup.myFamilyAndEntitySet; VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = aFamilyAndEntitySet.begin(); @@ -329,8 +399,11 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) const string& aFamilyName = aFamilyAndEntity.first; const VISU::TEntity& anEntity = aFamilyAndEntity.second; aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", - VISU::TFAMILY,aMeshName.c_str(),anEntity,aFamilyName.c_str()); - string anEntry = FindEntryWithComment(myStudyDocument,aEntity2Entry[anEntity].c_str(),aComment); + VISU::TFAMILY, + aMeshName.c_str(), + anEntity, + aFamilyName.c_str()); + string anEntry = myComment2EntryMap[aComment.latin1()]; CreateReference(myStudyDocument,aGroupEntry,anEntry); } } @@ -346,9 +419,18 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ if(!isFieldEntryCreated){ - aComment.sprintf("myComment=FIELDS;myMeshName=%s",aMeshName.c_str()); - aFieldsEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), - "","Fields","",aComment.latin1(),true); + aComment.sprintf("myComment=FIELDS;myMeshName=%s", + aMeshName.c_str()); + aFieldsEntry = + CreateAttributes(myStudyDocument, + aMeshEntry.c_str(), + aRefFatherEntry.c_str(), + "", + "Fields", + "", + aComment.latin1(), + true); + myComment2EntryMap[aComment.latin1()] = aFieldsEntry; isFieldEntryCreated = true; } const string& aFieldName = aFieldMapIter->first; @@ -356,19 +438,45 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) const VISU::TField::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", - VISU::TFIELD,aMeshName.c_str(),anEntity,aFieldName.c_str(),aValField.size(),aField.myNbComp); - string aFieldEntry = CreateAttributes(myStudyDocument,aFieldsEntry.c_str(),aRefFatherEntry.c_str(), - "",aFieldNameWithUnit.latin1(),"",aComment.latin1(),true); + VISU::TFIELD, + aMeshName.c_str(), + anEntity, + aFieldName.c_str(), + aValField.size(), + aField.myNbComp); + string aFieldEntry = + CreateAttributes(myStudyDocument, + aFieldsEntry.c_str(), + aRefFatherEntry.c_str(), + "", + aFieldNameWithUnit.latin1(), + "", + aComment.latin1(), + true); + myComment2EntryMap[aComment.latin1()] = aFieldEntry; CreateReference(myStudyDocument,aFieldEntry,aEntity2Entry[anEntity]); VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); for(; aValFieldIter != aValField.end(); aValFieldIter++){ int aTimeStamp = aValFieldIter->first; const VISU::TField::TValForTime& aValForTime = aValFieldIter->second; aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", - VISU::TTIMESTAMP,aMeshName.c_str(),anEntity,aFieldName.c_str(),aTimeStamp,aField.myNbComp); + VISU::TTIMESTAMP, + aMeshName.c_str(), + anEntity, + aFieldName.c_str(), + aTimeStamp, + aField.myNbComp); string aTimeStampId = VISU_Convertor::GenerateName(aValForTime.myTime); - CreateAttributes(myStudyDocument,aFieldEntry.c_str(),aRefFatherEntry.c_str(), - "",aTimeStampId.c_str(),"",aComment.latin1(),true); + string aTimeStampEntry = + CreateAttributes(myStudyDocument, + aFieldEntry.c_str(), + aRefFatherEntry.c_str(), + "", + aTimeStampId.c_str(), + "", + aComment.latin1(), + true); + myComment2EntryMap[aComment.latin1()] = aTimeStampEntry; } } } @@ -581,6 +689,13 @@ string VISU::Result_i::GetEntry(){ const SALOMEDS::SObject_var& VISU::Result_i::GetSObject() const { return mySObject;} const SALOMEDS::Study_var& VISU::Result_i::GetStudyDocument() const { return myStudyDocument;} const SALOMEDS::SComponent_var& VISU::Result_i::GetSComponent() const { return mySComponent;} +std::string VISU::Result_i::GetEntry(const std::string& theComment) const +{ + TComment2EntryMap::const_iterator aComment2EntryMapIter = myComment2EntryMap.find(theComment); + if(aComment2EntryMapIter == myComment2EntryMap.end()) + return ""; + return aComment2EntryMapIter->second; +} VISU::Result_i::~Result_i() { MESSAGE("Result_i::~Result_i() - this = "< TComment2EntryMap; + TComment2EntryMap myComment2EntryMap; public: std::string GetRefFatherEntry(); @@ -92,6 +95,7 @@ namespace VISU{ const SALOMEDS::SObject_var& GetSObject() const; const SALOMEDS::Study_var& GetStudyDocument() const; const SALOMEDS::SComponent_var& GetSComponent() const; + std::string GetEntry(const std::string& theComment) const; }; diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index 1bb7766d..ad028c5a 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -455,7 +455,7 @@ VISU::Storable* VISU::ScalarMap_i::Build(int theRestoring){ VISU::TTIMESTAMP,myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp); string aResultEntry = myResult->GetEntry(); string aRefFatherEntry = myResult->GetRefFatherEntry(); - string anEntry = FindEntryWithComment(myStudy,aResultEntry.c_str(),aComment.latin1()); + string anEntry = myResult->GetEntry(aComment.latin1()); if(anEntry == "") throw std::runtime_error("There is no Entry for binding the presentation !!!"); aComment.sprintf("myComment=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", GetComment(),myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp); -- 2.39.2