#include "VISU_Convertor_impl.hxx"
#include "VISU_CorbaMedConvertor.hxx"
+#include "VISU_ConvertorUtils.hxx"
#include "VISU_PipeLine.hxx"
#include "SUIT_ResourceMgr.h"
#include "SalomeApp_Study.h"
#include "SalomeApp_Application.h"
+#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/thread.hpp>
+
+#include <boost/thread/mutex.hpp>
#include <boost/bind.hpp>
// QT Includes
#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();
return aResult;
}
-QString GenerateName (const char* theName)
-{
- typedef map<string,int> 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 - "<<tmp<<" from - "<<theName<<"; " <<aMap[theName]);
- return tmp;
-}
-QString GenerateFieldName (const string& theName, const string& theUnits)
+namespace VISU
{
- static QString aName;
- const string tmp (theUnits.size(),' ');
- if (theUnits == "" || theUnits == tmp)
- aName.sprintf("%s, -",theName.c_str());
- else
- aName.sprintf("%s, %s",theName.c_str(),theUnits.c_str());
- aName = aName.simplifyWhiteSpace();
- return aName.latin1();
-}
+ //---------------------------------------------------------------
+ typedef boost::recursive_mutex TMutex;
+ typedef TMutex::scoped_lock TLock;
-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);
-}
+ 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<SUIT_Application> anApplications = aSession->applications();
+ QPtrListIterator<SUIT_Application> anIter (anApplications);
+ while (SUIT_Application* aSApp = anIter.current()) {
+ if(SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSApp)){
+ if(SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(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<string,int> 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 - "<<tmp<<" from - "<<theName<<"; " <<aMap[theName]);
+ return tmp;
+ }
+
-int
-VISU::Result_i
-::IsPossible()
-{
- try{
- float aSize = myInput->GetSize();
- bool aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
- MESSAGE("Result_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<float(aResult));
- return aResult;
- }catch(std::exception& exc){
- INFOS("Follow exception was occured :\n"<<exc.what());
- }catch(...){
- INFOS("Unknown exception was occured!");
+ //---------------------------------------------------------------
+ QString
+ GenerateFieldName (const string& theName, const string& theUnits)
+ {
+ QString aName;
+ const string tmp (theUnits.size(),' ');
+ if (theUnits == "" || theUnits == tmp)
+ aName.sprintf("%s, -",theName.c_str());
+ else
+ aName.sprintf("%s, %s",theName.c_str(),theUnits.c_str());
+ aName = aName.simplifyWhiteSpace();
+ return aName.latin1();
}
- return 0;
-}
-//---------------------------------------------------------------
-CORBA::Boolean
-VISU::Result_i
-::BuildAll()
-{
- if(MYDEBUG) MESSAGE("Result_i::Build - myIsDone = "<<myIsDone);
- if(myIsDone) return 1;
- if(!IsPossible()) return 0;
- try{
- const VISU::TMeshMap& aMeshMap = myInput->GetMeshMap();
- VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
- for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
- const string& aMeshName = aMeshMapIter->first;
- const VISU::PMesh aMesh = aMeshMapIter->second;
- const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
- VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
- //Import fields
- aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
- for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
- const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
- const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
- const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
- VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
- for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
- const string& aFieldName = aFieldMapIter->first;
- const VISU::PField aField = aFieldMapIter->second;
- const VISU::TValField& aValField = aField->myValField;
- VISU::TValField::const_iterator aValFieldIter = aValField.begin();
- for(; aValFieldIter != aValField.end(); aValFieldIter++){
- int aTimeStamp = aValFieldIter->first;
- try{
- myInput->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
- }catch(std::exception& exc){
- INFOS("Follow exception was occured :\n"<<exc.what());
- }catch(...){
- INFOS("Unknown exception was occured!!!");
- }
- }
- }
- //Importing groups
- const VISU::TGroupMap& aGroupMap = aMesh->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"<<exc.what());
- }catch(...){
- INFOS("Unknown exception was occured!!!");
- }
- }
- //Import families
- const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->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"<<exc.what());
- }catch(...){
- INFOS("Unknown exception was occured!!!");
- }
- }
- //Import mesh on entity
- try{
- myInput->GetMeshOnEntity(aMeshName,anEntity);
- }catch(std::exception& exc){
- INFOS("Follow exception was occured :\n"<<exc.what());
- }catch(...){
- INFOS("Unknown exception was occured!!!");
- }
- }
- }
- myIsDone = 1;
- }catch(std::exception& exc){
- INFOS("Follow exception was occured :\n"<<exc.what());
- }catch(...){
- INFOS("Unknown exception was occured!!!");
+ //---------------------------------------------------------------
+ string
+ GetComponentDataType (SALOMEDS::SObject_ptr theSObject)
+ {
+ SALOMEDS::SComponent_var aCompRefSObj = theSObject->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();
}
};
void
Execute()
{
+ TLock aLock(myMutex);
SUIT_Session* aSession = SUIT_Session::session();
QPtrList<SUIT_Application> anApplications = aSession->applications();
QPtrListIterator<SUIT_Application> anIter (anApplications);
if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(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;
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++){
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);
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",
"",
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);
TFamilySet::const_iterator aFamilyIter = aFamilySet.begin();
for(; aFamilyIter != aFamilySet.end(); aFamilyIter++){
const PFamily& aFamily = *aFamilyIter;
- CreateReference(theStudyDocument,
+ CreateReference(theStudy,
aGroup->myEntry,
aFamily->myEntry);
}
}
}
- aStudyBuilder->CommitCommand();
-
- ProcessVoidEvent(new TUpdateObjBrowser(theStudyDocument->StudyId(),theIsDone));
+ ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
}
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++){
aComment.sprintf("myComment=FIELDS;myMeshName=%s",
aMeshName.c_str());
aFieldsEntry =
- CreateAttributes(theStudyDocument,
- aMesh->myEntry.c_str(),
- theRefFatherEntry.c_str(),
+ CreateAttributes(theStudy,
+ aMesh->myEntry,
"",
"Fields",
"",
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(),
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();
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);
}
}
- aStudyBuilder->CommitCommand();
-
- ProcessVoidEvent(new TUpdateObjBrowser(theStudyDocument->StudyId(),theIsDone));
+ ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
}
VISU_Convertor* theInput,
CORBA::Boolean* theIsDone)
{
- TMemManager aMemManager(theResult);
+ TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildMinMax");
+ TResultManager aResultManager(theResult);
theInput->BuildMinMax();
*theIsDone = true;
//---------------------------------------------------------------
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 = "<<float(aSize)<<"; aResult = "<<float(aResult));
+ return aResult;
+ }catch(std::exception& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was occured!");
+ }
+ return 0;
+}
+
+
+//---------------------------------------------------------------
+CORBA::Boolean
+VISU::Result_i
+::BuildAll()
+{
+ if(MYDEBUG) MESSAGE("Result_i::Build - myIsDone = "<<myIsDone);
+ if(myIsDone) return 1;
+ if(!IsPossible()) return 0;
+ try{
+ const VISU::TMeshMap& aMeshMap = myInput->GetMeshMap();
+ VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+ for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
+ const string& aMeshName = aMeshMapIter->first;
+ const VISU::PMesh aMesh = aMeshMapIter->second;
+ const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
+ //Import fields
+ aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
+ for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
+ const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
+ const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
+ const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+ VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
+ for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
+ const string& aFieldName = aFieldMapIter->first;
+ const VISU::PField aField = aFieldMapIter->second;
+ const VISU::TValField& aValField = aField->myValField;
+ VISU::TValField::const_iterator aValFieldIter = aValField.begin();
+ for(; aValFieldIter != aValField.end(); aValFieldIter++){
+ int aTimeStamp = aValFieldIter->first;
+ try{
+ myInput->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
+ }catch(std::exception& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was occured!!!");
+ }
+ }
+ }
+ //Importing groups
+ const VISU::TGroupMap& aGroupMap = aMesh->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"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was occured!!!");
+ }
+ }
+ //Import families
+ const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->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"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was occured!!!");
+ }
+ }
+ //Import mesh on entity
+ try{
+ myInput->GetMeshOnEntity(aMeshName,anEntity);
+ }catch(std::exception& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was occured!!!");
+ }
+ }
+ }
+ myIsDone = 1;
+ }catch(std::exception& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was occured!!!");
+ }
+ return myIsDone;
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::Result_i
+::BuildEntities(SALOMEDS::SObject_ptr theSObject)
+{
+ TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildEntities");
+ TResultManager aResultManager(this);
+ TTransactionManager aTransactionManager(myStudy);
+
+ QString aComment;
+
+ 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(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));
}
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;
}
}
try{
BuildEntities(theSObject);
- std::string aRefFatherEntry = GetRefFatherEntry();
-
BuildFields(this,
myInput,
&myIsFieldsDone,
- myStudyDocument,
- aRefFatherEntry);
+ myStudy);
BuildMinMax(this,
myInput,
BuildGroups(this,
myInput,
&myIsGroupsDone,
- myStudyDocument,
- aRefFatherEntry);
+ myStudy);
BuildAll();
}catch(std::exception& exc){