From 5335da8a6c8bb9ce49ccc98711e77bd003b8ed2b Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 23 Nov 2005 09:27:15 +0000 Subject: [PATCH] To provide thread-safety for VISU_Gen::ImportFile functionality --- src/VISUGUI/VisuGUI.cxx | 2 - src/VISU_I/VISU_Result_i.cc | 849 +++++++++++++++++++++--------------- src/VISU_I/VISU_Result_i.hh | 1 + 3 files changed, 488 insertions(+), 364 deletions(-) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 0862abd4..d1acbbc1 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -219,8 +219,6 @@ OnImportFromFile() INFOS( "VisuGUI::OnImportFromFile() : File importing done in " << vtkTimerLog::GetCPUTime() - initialTime << " seconds" ); - UpdateObjBrowser(this); - QTime aTime; int mSecs = ( int )( 1000 * ( vtkTimerLog::GetCPUTime() - initialTime ) ); aTime = aTime.addMSecs( mSecs ); diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index 778dfd08..fa1aece5 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -28,6 +28,7 @@ #include "VISU_Convertor_impl.hxx" #include "VISU_CorbaMedConvertor.hxx" +#include "VISU_ConvertorUtils.hxx" #include "VISU_PipeLine.hxx" #include "SUIT_ResourceMgr.h" @@ -40,7 +41,10 @@ #include "SalomeApp_Study.h" #include "SalomeApp_Application.h" +#include #include + +#include #include // QT Includes @@ -61,11 +65,16 @@ using namespace std; #ifdef _DEBUG_ static int MYDEBUG = 0; +static int MYTIMEDEBUG = 0; #else static int MYDEBUG = 0; +static int MYTIMEDEBUG = 0; #endif -VISU::Result_var VISU::FindResult (SALOMEDS::SObject_ptr theSObject) + +//--------------------------------------------------------------- +VISU::Result_var +VISU::FindResult (SALOMEDS::SObject_ptr theSObject) { SALOMEDS::SComponent_var aSComponent = theSObject->GetFatherComponent(); SALOMEDS::SObject_var aFather = theSObject->GetFather(); @@ -84,311 +93,200 @@ VISU::Result_var VISU::FindResult (SALOMEDS::SObject_ptr theSObject) return aResult; } -QString GenerateName (const char* theName) -{ - typedef map TNameMap; - static TNameMap aMap; - TNameMap::const_iterator i = aMap.find(theName); - QString tmp; - if (i == aMap.end()) { - aMap[theName] = 0; - tmp = theName; - } else { - tmp = VISU::GenerateName(theName,++aMap[theName]); - } - if(MYDEBUG) MESSAGE("GenerateName - "<NewBuilder(); - SALOMEDS::SObject_var aFather = theStudyDocument->FindObjectID(theFatherEntry.c_str()); - SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(aFather); - SALOMEDS::SObject_var aRefSObj = theStudyDocument->FindObjectID(theRefEntry.c_str()); - aStudyBuilder->Addreference(newObj,aRefSObj); -} + static TMutex myMutex; -string GetComponentDataType (SALOMEDS::SObject_ptr theSObject) -{ - SALOMEDS::SComponent_var aCompRefSObj = theSObject->GetFatherComponent(); - CORBA::String_var aDataType = aCompRefSObj->ComponentDataType(); - return aDataType.in(); -} + //--------------------------------------------------------------- + struct TGetStudy: public SALOME_Event + { + typedef _PTR(Study) TResult; + TResult myResult; + int myStudyId; -//============================================================================== + TGetStudy(const int theStudyId): + myStudyId(theStudyId) + {} + + virtual + void + Execute() + { + SUIT_Session* aSession = SUIT_Session::session(); + QPtrList anApplications = aSession->applications(); + QPtrListIterator anIter (anApplications); + while (SUIT_Application* aSApp = anIter.current()) { + if(SalomeApp_Application* anApp = dynamic_cast(aSApp)){ + if(SalomeApp_Study* aStudy = dynamic_cast(anApp->activeStudy())) { + myResult = aStudy->studyDS(); + break; + } + } + ++anIter; + } + } + }; -const string VISU::Result_i::myComment = "RESULT"; -const char* VISU::Result_i::GetComment() const { return myComment.c_str();} - -VISU::Result_i -::Result_i (SALOMEDS::Study_ptr theStudy, - const ESourceId& theSourceId, - const ECreationId& theCreationId): - myStudyDocument(SALOMEDS::Study::_duplicate(theStudy)), - myCreationId(theCreationId), - mySourceId(theSourceId), - myInput(NULL), - myIsFieldsDone(0), - myIsGroupsDone(0), - myIsMinMaxDone(0), - myIsDone(0) -{ -} + //--------------------------------------------------------------- + QString + GenerateName (const char* theName) + { + TLock aLock(myMutex); -void VISU::Result_i::RemoveFromStudy() -{ - // Remove the result with all presentations and other possible sub-objects - VISU::RemoveFromStudy(mySObject,false); - Destroy(); -} + typedef map TNameMap; + static TNameMap aMap; + TNameMap::const_iterator i = aMap.find(theName); + QString tmp; + if (i == aMap.end()) { + aMap[theName] = 0; + tmp = theName; + } else { + tmp = VISU::GenerateName(theName,++aMap[theName]); + } + if(MYDEBUG) MESSAGE("GenerateName - "<GetSize(); - bool aResult = VISU_PipeLine::CheckAvailableMemory(aSize); - MESSAGE("Result_i::IsPossible - CheckAvailableMemory = "<myGroupMap; - VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); - for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ - const string& aGroupName = aGroupMapIter->first; - try{ - myInput->GetMeshOnGroup(aMeshName,aGroupName); - }catch(std::exception& exc){ - INFOS("Follow exception was occured :\n"<myFamilyMap; - VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); - for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ - const string& aFamilyName = aFamilyMapIter->first; - try{ - myInput->GetFamilyOnEntity(aMeshName,anEntity,aFamilyName); - }catch(std::exception& exc){ - INFOS("Follow exception was occured :\n"<GetMeshOnEntity(aMeshName,anEntity); - }catch(std::exception& exc){ - INFOS("Follow exception was occured :\n"<GetFatherComponent(); + CORBA::String_var aDataType = aCompRefSObj->ComponentDataType(); + return aDataType.in(); } - return myIsDone; -} -//--------------------------------------------------------------- -void -VISU::Result_i -::BuildEntities(SALOMEDS::SObject_ptr theSObject) -{ - SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder(); - aStudyBuilder->NewCommand(); // There is a transaction + //--------------------------------------------------------------- + void + CreateReference (SALOMEDS::Study_ptr theStudyDocument, + const string& theFatherEntry, + const string& theRefEntry) + { + SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder(); + SALOMEDS::SObject_var aFather = theStudyDocument->FindObjectID(theFatherEntry.c_str()); + SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(aFather); + SALOMEDS::SObject_var aRefSObj = theStudyDocument->FindObjectID(theRefEntry.c_str()); + aStudyBuilder->Addreference(newObj,aRefSObj); + } - QString aComment; - string aRefFatherEntry = GetRefFatherEntry(); - mySComponent = FindOrCreateVisuComponent(myStudyDocument); - CORBA::String_var aSComponentEntry = mySComponent->GetID(); - CORBA::String_var anIOR(GetID()); - aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s", - 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); - mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str()); - if(!CORBA::is_nil(theSObject)){ - CORBA::String_var aString = theSObject->GetID(); - CreateReference(myStudyDocument,aResultEntry,aString.in()); + //--------------------------------------------------------------- + void + CreateReference (_PTR(Study) theStudyDocument, + const string& theFatherEntry, + const string& theRefEntry) + { + TLock aLock(myMutex); + + _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); + _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry); + _PTR(SObject) aNewObj = aStudyBuilder->NewObject(aFather); + _PTR(SObject) aRefSObj = theStudyDocument->FindObjectID(theRefEntry); + aStudyBuilder->Addreference(aNewObj,aRefSObj); } - myInput->BuildEntities(); - const TMeshMap& aMeshMap = myInput->GetMeshMap(); - TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ - const string& aMeshName = aMeshMapIter->first; - const PMesh& aMesh = aMeshMapIter->second; - const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; - if(aMeshOnEntityMap.empty()) - continue; - - aComment.sprintf("myComment=MESH;myName=%s;myDim=%d", - aMeshName.c_str(), - aMesh->myDim); - aMesh->myEntry = - CreateAttributes(myStudyDocument, - aResultEntry.c_str(), - aRefFatherEntry.c_str(), - "", - aMeshName.c_str(), - "", - aComment.latin1(), - true); - - aComment.sprintf("myComment=FAMILIES;myMeshName=%s", - aMeshName.c_str()); - string aSubMeshesEntry = - CreateAttributes(myStudyDocument, - aMesh->myEntry.c_str(), - aRefFatherEntry.c_str(), - "", - "Families", - "", - aComment.latin1(), - true); - //Import entities - TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const TEntity& anEntity = aMeshOnEntityMapIter->first; - const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - - string anEntityName; - switch(anEntity){ - case NODE_ENTITY: - anEntityName = "onNodes"; - break; - case EDGE_ENTITY: - anEntityName = "onEdges"; - break; - case FACE_ENTITY: - anEntityName = "onFaces"; - break; - case CELL_ENTITY: - anEntityName = "onCells"; - break; - default: - continue; - } - - aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d", - VISU::TENTITY, - aMeshName.c_str(), - anEntity); - - aMeshOnEntity->myEntry = - CreateAttributes(myStudyDocument, - aSubMeshesEntry.c_str(), - aRefFatherEntry.c_str(), - "", - anEntityName.c_str(), - "", - aComment.latin1(), - true); + string + CreateAttributes(_PTR(Study) theStudyDocument, + const string& theFatherEntry, + const string& theIOR, + const string& theName, + const string& thePersistentRef, + const string& theComment, + CORBA::Boolean theCreateNew) + { + TLock aLock(myMutex); + + _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); + _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry); + + _PTR(SObject) aNewObj; + if(theCreateNew) + aNewObj = aStudyBuilder->NewObject(aFather); + else + aNewObj = aFather; + + _PTR(GenericAttribute) anAttr; + if (theIOR != "") { + anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeIOR"); + _PTR(AttributeIOR) anIOR (anAttr); + anIOR->SetValue(theIOR); + } + if (theName != "") { + anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeName"); + _PTR(AttributeName) aName (anAttr); + aName->SetValue(theName); + } + if (thePersistentRef != "") { + anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributePersistentRef"); + _PTR(AttributePersistentRef) aPRef (anAttr); + aPRef->SetValue(thePersistentRef); } + if (theComment != "") { + anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeComment"); + _PTR(AttributeComment) aCmnt (anAttr); + aCmnt->SetValue(theComment); + } + return aNewObj->GetID(); } - - aStudyBuilder->CommitCommand(); -} + + //--------------------------------------------------------------- + struct TResultManager + { + VISU::Result_i* myResult; + + TResultManager(VISU::Result_i* theResult): + myResult(theResult) + { + myResult->Register(); + } + + ~TResultManager() + { + myResult->Destroy(); + } + }; -namespace -{ //--------------------------------------------------------------- - struct TMemManager + struct TTransactionManager { - VISU::Result_i* myResult; - TMemManager(VISU::Result_i* theResult): - myResult(theResult) + _PTR(StudyBuilder) myStudyBuilder; + + TTransactionManager(_PTR(Study) theStudyDocument): + myStudyBuilder(theStudyDocument->NewBuilder()) { - myResult->Register(); + TLock aLock(myMutex); + myStudyBuilder->NewCommand(); } - ~TMemManager() + ~TTransactionManager() { - myResult->Destroy(); + TLock aLock(myMutex); + myStudyBuilder->CommitCommand(); } }; @@ -408,6 +306,7 @@ namespace void Execute() { + TLock aLock(myMutex); SUIT_Session* aSession = SUIT_Session::session(); QPtrList anApplications = aSession->applications(); QPtrListIterator anIter (anApplications); @@ -416,7 +315,7 @@ namespace if (SalomeApp_Study* aStudy = dynamic_cast(anApp->activeStudy())) { if (_PTR(Study) aCStudy = aStudy->studyDS()) { if (myStudyId == aCStudy->StudyId()) { - MESSAGE("Result_i::updateObjectBrowser"); + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::updateObjectBrowser"); anApp->updateObjectBrowser(); *myIsDone = true; break; @@ -435,16 +334,18 @@ namespace BuildGroups(VISU::Result_i* theResult, VISU_Convertor* theInput, CORBA::Boolean* theIsDone, - SALOMEDS::Study_var theStudyDocument, - const std::string& theRefFatherEntry) + _PTR(Study) theStudy) { - TMemManager aMemManager(theResult); - - SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder(); - aStudyBuilder->NewCommand(); // There is a transaction + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildGroups"); + TResultManager aResultManager(theResult); + TTransactionManager aTransactionManager(theStudy); + { + TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildGroups"); + theInput->BuildGroups(); + } + QString aComment; - theInput->BuildGroups(); const TMeshMap& aMeshMap = theInput->GetMeshMap(); TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ @@ -471,11 +372,10 @@ namespace anEntity, aFamilyName.c_str()); aFamily->myEntry = - CreateAttributes(theStudyDocument, - aMeshOnEntity->myEntry.c_str(), - theRefFatherEntry.c_str(), + CreateAttributes(theStudy, + aMeshOnEntity->myEntry, "", - aFamilyName.c_str(), + aFamilyName, "", aComment.latin1(), true); @@ -487,9 +387,8 @@ namespace aComment.sprintf("myComment=GROUPS;myMeshName=%s", aMeshName.c_str()); string aGroupsEntry = - CreateAttributes(theStudyDocument, - aMesh->myEntry.c_str(), - theRefFatherEntry.c_str(), + CreateAttributes(theStudy, + aMesh->myEntry, "", "Groups", "", @@ -502,11 +401,10 @@ namespace aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s", TGROUP,aMeshName.c_str(),aGroupName.c_str()); aGroup->myEntry = - CreateAttributes(theStudyDocument, - aGroupsEntry.c_str(), - theRefFatherEntry.c_str(), + CreateAttributes(theStudy, + aGroupsEntry, "", - aGroupName.c_str(), + aGroupName, "", aComment.latin1(), true); @@ -514,7 +412,7 @@ namespace TFamilySet::const_iterator aFamilyIter = aFamilySet.begin(); for(; aFamilyIter != aFamilySet.end(); aFamilyIter++){ const PFamily& aFamily = *aFamilyIter; - CreateReference(theStudyDocument, + CreateReference(theStudy, aGroup->myEntry, aFamily->myEntry); } @@ -522,9 +420,7 @@ namespace } } - aStudyBuilder->CommitCommand(); - - ProcessVoidEvent(new TUpdateObjBrowser(theStudyDocument->StudyId(),theIsDone)); + ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); } @@ -533,16 +429,18 @@ namespace BuildFields(VISU::Result_i* theResult, VISU_Convertor* theInput, CORBA::Boolean* theIsDone, - SALOMEDS::Study_var theStudyDocument, - const std::string& theRefFatherEntry) + _PTR(Study) theStudy) { - TMemManager aMemManager(theResult); + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildFields"); + TResultManager aResultManager(theResult); + TTransactionManager aTransactionManager(theStudy); + + { + TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildFields"); + theInput->BuildFields(); + } - SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder(); - aStudyBuilder->NewCommand(); // There is a transaction - QString aComment; - theInput->BuildFields(); const TMeshMap& aMeshMap = theInput->GetMeshMap(); TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ @@ -568,9 +466,8 @@ namespace aComment.sprintf("myComment=FIELDS;myMeshName=%s", aMeshName.c_str()); aFieldsEntry = - CreateAttributes(theStudyDocument, - aMesh->myEntry.c_str(), - theRefFatherEntry.c_str(), + CreateAttributes(theStudy, + aMesh->myEntry, "", "Fields", "", @@ -581,7 +478,7 @@ namespace const string& aFieldName = aFieldMapIter->first; const PField& aField = aFieldMapIter->second; const TValField& aValField = aField->myValField; - QString aFieldNameWithUnit = ::GenerateFieldName(aFieldName,aField->myUnitNames[0]); + 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(), @@ -590,15 +487,14 @@ namespace aValField.size(), aField->myNbComp); aField->myEntry = - CreateAttributes(theStudyDocument, - aFieldsEntry.c_str(), - theRefFatherEntry.c_str(), + CreateAttributes(theStudy, + aFieldsEntry, "", aFieldNameWithUnit.latin1(), "", aComment.latin1(), true); - CreateReference(theStudyDocument, + CreateReference(theStudy, aField->myEntry, aMeshOnEntity->myEntry); TValField::const_iterator aValFieldIter = aValField.begin(); @@ -614,11 +510,10 @@ namespace aField->myNbComp); string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime); aValForTime->myEntry = - CreateAttributes(theStudyDocument, - aField->myEntry.c_str(), - theRefFatherEntry.c_str(), + CreateAttributes(theStudy, + aField->myEntry, "", - aTimeStampId.c_str(), + aTimeStampId, "", aComment.latin1(), true); @@ -627,9 +522,7 @@ namespace } } - aStudyBuilder->CommitCommand(); - - ProcessVoidEvent(new TUpdateObjBrowser(theStudyDocument->StudyId(),theIsDone)); + ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); } @@ -639,7 +532,8 @@ namespace VISU_Convertor* theInput, CORBA::Boolean* theIsDone) { - TMemManager aMemManager(theResult); + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildMinMax"); + TResultManager aResultManager(theResult); theInput->BuildMinMax(); *theIsDone = true; @@ -648,24 +542,275 @@ namespace //--------------------------------------------------------------- void - BuildMinMaxFields(VISU::Result_i* theResult, - VISU_Convertor* theInput, - CORBA::Boolean* theFieldsIsDone, - CORBA::Boolean* theMinMaxIsDone, - SALOMEDS::Study_var theStudyDocument, - const std::string& theRefFatherEntry) + BuildDataTree(VISU::Result_i* theResult, + VISU_Convertor* theInput, + CORBA::Boolean* theIsFieldsDone, + CORBA::Boolean* theIsMinMaxDone, + CORBA::Boolean* theIsGroupsDone, + _PTR(Study) theStudy) { BuildFields(theResult, theInput, - theFieldsIsDone, - theStudyDocument, - theRefFatherEntry); + theIsFieldsDone, + theStudy); BuildMinMax(theResult, theInput, - theMinMaxIsDone); + theIsMinMaxDone); + + BuildGroups(theResult, + theInput, + theIsGroupsDone, + theStudy); + } + +} + + +//--------------------------------------------------------------- +const string VISU::Result_i::myComment = "RESULT"; +const char* VISU::Result_i::GetComment() const { return myComment.c_str();} + +//--------------------------------------------------------------- +VISU::Result_i +::Result_i (SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId): + myStudyDocument(SALOMEDS::Study::_duplicate(theStudy)), + myCreationId(theCreationId), + mySourceId(theSourceId), + myInput(NULL), + myIsFieldsDone(0), + myIsGroupsDone(0), + myIsMinMaxDone(0), + myIsDone(0) +{ + myStudy = ProcessEvent(new TGetStudy(myStudyDocument->StudyId())); +} + + +//--------------------------------------------------------------- +void +VISU::Result_i +::RemoveFromStudy() +{ + // Remove the result with all presentations and other possible sub-objects + VISU::RemoveFromStudy(mySObject,false); + Destroy(); +} + + +//--------------------------------------------------------------- +int +VISU::Result_i +::IsPossible() +{ + try{ + float aSize = myInput->GetSize(); + bool aResult = VISU_PipeLine::CheckAvailableMemory(aSize); + MESSAGE("Result_i::IsPossible - CheckAvailableMemory = "<myGroupMap; + VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); + for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ + const string& aGroupName = aGroupMapIter->first; + try{ + myInput->GetMeshOnGroup(aMeshName,aGroupName); + }catch(std::exception& exc){ + INFOS("Follow exception was occured :\n"<myFamilyMap; + VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); + for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ + const string& aFamilyName = aFamilyMapIter->first; + try{ + myInput->GetFamilyOnEntity(aMeshName,anEntity,aFamilyName); + }catch(std::exception& exc){ + INFOS("Follow exception was occured :\n"<GetMeshOnEntity(aMeshName,anEntity); + }catch(std::exception& exc){ + INFOS("Follow exception was occured :\n"<GetID(); + CORBA::String_var anIOR(GetID()); + aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s", + GetComment(), + VISU::TRESULT, + myFileInfo.filePath().latin1(), + myInitFileName.c_str()); // Restoring of Python dump + string aResultEntry = + CreateAttributes(myStudy, + aSComponentEntry.in(), + anIOR.in(), + myName, + "", + aComment.latin1(), + true); + mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str()); + if(!CORBA::is_nil(theSObject)){ + CORBA::String_var aString = theSObject->GetID(); + CreateReference(myStudyDocument,aResultEntry,aString.in()); + } + + myInput->BuildEntities(); + const TMeshMap& aMeshMap = myInput->GetMeshMap(); + TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); + for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ + const string& aMeshName = aMeshMapIter->first; + const PMesh& aMesh = aMeshMapIter->second; + const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + if(aMeshOnEntityMap.empty()) + continue; + + aComment.sprintf("myComment=MESH;myName=%s;myDim=%d", + aMeshName.c_str(), + aMesh->myDim); + aMesh->myEntry = + CreateAttributes(myStudy, + aResultEntry, + "", + aMeshName, + "", + aComment.latin1(), + true); + + aComment.sprintf("myComment=FAMILIES;myMeshName=%s", + aMeshName.c_str()); + string aSubMeshesEntry = + CreateAttributes(myStudy, + aMesh->myEntry, + "", + "Families", + "", + aComment.latin1(), + true); + //Import entities + TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ + const TEntity& anEntity = aMeshOnEntityMapIter->first; + const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + + string anEntityName; + switch(anEntity){ + case NODE_ENTITY: + anEntityName = "onNodes"; + break; + case EDGE_ENTITY: + anEntityName = "onEdges"; + break; + case FACE_ENTITY: + anEntityName = "onFaces"; + break; + case CELL_ENTITY: + anEntityName = "onCells"; + break; + default: + continue; + } + + aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d", + VISU::TENTITY, + aMeshName.c_str(), + anEntity); + + aMeshOnEntity->myEntry = + CreateAttributes(myStudy, + aSubMeshesEntry, + "", + anEntityName.c_str(), + "", + aComment.latin1(), + true); + } } + CORBA::Boolean anIsEntitiesDone; + ProcessVoidEvent(new TUpdateObjBrowser(myStudy->StudyId(),&anIsEntitiesDone)); } @@ -678,32 +823,16 @@ VISU::Result_i if(isBuildAll) return BuildAll(theSObject); else{ - SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder(); - aStudyBuilder->NewCommand(); // There is a transaction - BuildEntities(theSObject); - std::string aRefFatherEntry = GetRefFatherEntry(); - - { - // To start build of the fields and min/max calculation - boost::thread aThread(boost::bind(&BuildMinMaxFields, - this, - myInput, - &myIsFieldsDone, - &myIsMinMaxDone, - myStudyDocument, - aRefFatherEntry)); - } - { - // To start build of the groups - boost::thread aThread(boost::bind(&BuildGroups, - this, - myInput, - &myIsGroupsDone, - myStudyDocument, - aRefFatherEntry)); - } + // To start build of the fields, groups and perfrom min/max calculation + boost::thread aThread(boost::bind(&BuildDataTree, + this, + myInput, + &myIsFieldsDone, + &myIsMinMaxDone, + &myIsGroupsDone, + myStudy)); return this; } } @@ -718,13 +847,10 @@ VISU::Result_i try{ BuildEntities(theSObject); - std::string aRefFatherEntry = GetRefFatherEntry(); - BuildFields(this, myInput, &myIsFieldsDone, - myStudyDocument, - aRefFatherEntry); + myStudy); BuildMinMax(this, myInput, @@ -733,8 +859,7 @@ VISU::Result_i BuildGroups(this, myInput, &myIsGroupsDone, - myStudyDocument, - aRefFatherEntry); + myStudy); BuildAll(); }catch(std::exception& exc){ diff --git a/src/VISU_I/VISU_Result_i.hh b/src/VISU_I/VISU_Result_i.hh index af6c757b..d414ff0b 100644 --- a/src/VISU_I/VISU_Result_i.hh +++ b/src/VISU_I/VISU_Result_i.hh @@ -108,6 +108,7 @@ namespace VISU{ const ECreationId& GetCreationId() const { return myCreationId;} private: + _PTR(Study) myStudy; SALOMEDS::SObject_var mySObject; SALOMEDS::Study_var myStudyDocument; SALOMEDS::SComponent_var mySComponent; -- 2.39.2