#endif
-//---------------------------------------------------------------
-VISU::Result_var
-VISU::FindResult (SALOMEDS::SObject_ptr theSObject)
+namespace VISU
{
- SALOMEDS::SComponent_var aSComponent = theSObject->GetFatherComponent();
- SALOMEDS::SObject_var aFather = theSObject->GetFather();
- CORBA::String_var aComponentID (aSComponent->GetID());
- CORBA::String_var aFatherID (aFather->GetID());
- VISU::Result_var aResult;
- while (strcmp(aComponentID, aFatherID) != 0) {
- CORBA::Object_var anObject = VISU::SObjectToObject(aFather);
- if (!CORBA::is_nil(anObject)) {
- aResult = VISU::Result::_narrow(anObject);
- if (!aResult->_is_nil()) return aResult;
+ //---------------------------------------------------------------
+ Result_var
+ FindResult (SALOMEDS::SObject_ptr theSObject)
+ {
+ SALOMEDS::SComponent_var aSComponent = theSObject->GetFatherComponent();
+ SALOMEDS::SObject_var aFather = theSObject->GetFather();
+ CORBA::String_var aComponentID (aSComponent->GetID());
+ CORBA::String_var aFatherID (aFather->GetID());
+ Result_var aResult;
+ while (strcmp(aComponentID, aFatherID) != 0) {
+ CORBA::Object_var anObject = SObjectToObject(aFather);
+ if (!CORBA::is_nil(anObject)) {
+ aResult = Result::_narrow(anObject);
+ if (!aResult->_is_nil()) return aResult;
+ }
+ aFather = aFather->GetFather();
+ aFatherID = aFather->GetID();
}
- aFather = aFather->GetFather();
- aFatherID = aFather->GetID();
+ return aResult;
}
- return aResult;
-}
-namespace VISU
-{
//---------------------------------------------------------------
typedef boost::recursive_mutex TMutex;
typedef TMutex::scoped_lock TLock;
aMap[theName] = 0;
tmp = theName;
} else {
- tmp = VISU::GenerateName(theName,++aMap[theName]);
+ tmp = GenerateName(theName,++aMap[theName]);
}
if(MYDEBUG) MESSAGE("GenerateName - "<<tmp<<" from - "<<theName<<"; " <<aMap[theName]);
return tmp;
//---------------------------------------------------------------
struct TResultManager
{
- VISU::Result_i* myResult;
+ Result_i* myResult;
- TResultManager(VISU::Result_i* theResult):
+ TResultManager(Result_i* theResult):
myResult(theResult)
{
myResult->Register();
//---------------------------------------------------------------
void
- BuildGroups(VISU::Result_i* theResult,
+ BuildEntities(Result_i* theResult,
+ VISU_Convertor* theInput,
+ CORBA::Boolean* theIsDone,
+ std::string theResultEntry,
+ _PTR(Study) theStudy)
+ {
+ if(*theIsDone)
+ return;
+
+ TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildEntities");
+ TResultManager aResultManager(theResult);
+ TTransactionManager aTransactionManager(theStudy);
+
+ {
+ TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildEntities");
+ theInput->BuildEntities();
+ }
+
+ QString aComment;
+ const TMeshMap& aMeshMap = theInput->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(theStudy,
+ theResultEntry,
+ "",
+ aMeshName,
+ "",
+ aComment.latin1(),
+ true);
+
+ aComment.sprintf("myComment=FAMILIES;myMeshName=%s",
+ aMeshName.c_str());
+ string aSubMeshesEntry =
+ CreateAttributes(theStudy,
+ 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(theStudy,
+ aSubMeshesEntry,
+ "",
+ anEntityName.c_str(),
+ "",
+ aComment.latin1(),
+ true);
+ }
+ }
+
+ ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
+ }
+
+ //---------------------------------------------------------------
+ void
+ BuildGroups(Result_i* theResult,
VISU_Convertor* theInput,
CORBA::Boolean* theIsDone,
+ CORBA::Boolean theIsBuild,
_PTR(Study) theStudy)
{
+ if(!theIsBuild || *theIsDone)
+ return;
+
TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildGroups");
TResultManager aResultManager(theResult);
TTransactionManager aTransactionManager(theStudy);
//---------------------------------------------------------------
void
- BuildFields(VISU::Result_i* theResult,
+ BuildFields(Result_i* theResult,
VISU_Convertor* theInput,
CORBA::Boolean* theIsDone,
+ CORBA::Boolean theIsBuild,
_PTR(Study) theStudy)
{
+ if(!theIsBuild || *theIsDone)
+ return;
+
TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildFields");
TResultManager aResultManager(theResult);
TTransactionManager aTransactionManager(theStudy);
const 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,
+ TFIELD,
aMeshName.c_str(),
anEntity,
aFieldName.c_str(),
int aTimeStamp = aValFieldIter->first;
const PValForTime& aValForTime = aValFieldIter->second;
aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
- VISU::TTIMESTAMP,
+ TTIMESTAMP,
aMeshName.c_str(),
anEntity,
aFieldName.c_str(),
//---------------------------------------------------------------
void
- BuildMinMax(VISU::Result_i* theResult,
+ BuildMinMax(Result_i* theResult,
VISU_Convertor* theInput,
- CORBA::Boolean* theIsDone)
+ CORBA::Boolean* theIsDone,
+ CORBA::Boolean theIsBuild)
{
+ if(!theIsBuild || *theIsDone)
+ return;
+
TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildMinMax");
TResultManager aResultManager(theResult);
//---------------------------------------------------------------
void
- BuildDataTree(VISU::Result_i* theResult,
- VISU_Convertor* theInput,
- CORBA::Boolean* theIsFieldsDone,
- CORBA::Boolean* theIsMinMaxDone,
- CORBA::Boolean* theIsGroupsDone,
- _PTR(Study) theStudy)
+ BuildFieldDataTree(Result_i* theResult,
+ VISU_Convertor* theInput,
+ CORBA::Boolean* theIsFieldsDone,
+ CORBA::Boolean theIsBuildFields,
+ CORBA::Boolean* theIsMinMaxDone,
+ CORBA::Boolean theIsBuildMinMax,
+ _PTR(Study) theStudy)
{
BuildFields(theResult,
theInput,
theIsFieldsDone,
+ theIsBuildFields,
theStudy);
BuildMinMax(theResult,
theInput,
- theIsMinMaxDone);
+ theIsMinMaxDone,
+ theIsBuildMinMax);
+ }
+
- BuildGroups(theResult,
- theInput,
- theIsGroupsDone,
- theStudy);
+ //---------------------------------------------------------------
+ struct TBuildArgs
+ {
+ Result_i* myResult;
+ VISU_Convertor* myInput;
+ CORBA::Boolean* myIsEntitiesDone;
+ std::string myResultEntry;
+ CORBA::Boolean* myIsFieldsDone;
+ CORBA::Boolean myIsBuildFields;
+ CORBA::Boolean* myIsMinMaxDone;
+ CORBA::Boolean myIsBuildMinMax;
+ CORBA::Boolean* myIsGroupsDone;
+ CORBA::Boolean myIsBuildGroups;
+ _PTR(Study) myStudy;
+
+ TBuildArgs(Result_i* theResult,
+ VISU_Convertor* theInput,
+ CORBA::Boolean* theIsEntitiesDone,
+ std::string theResultEntry,
+ CORBA::Boolean* theIsFieldsDone,
+ CORBA::Boolean theIsBuildFields,
+ CORBA::Boolean* theIsMinMaxDone,
+ CORBA::Boolean theIsBuildMinMax,
+ CORBA::Boolean* theIsGroupsDone,
+ CORBA::Boolean theIsBuildGroups,
+ _PTR(Study) theStudy):
+ myResult(theResult),
+ myInput(theInput),
+ myIsEntitiesDone(theIsEntitiesDone),
+ myResultEntry(theResultEntry),
+ myIsFieldsDone(theIsFieldsDone),
+ myIsBuildFields(theIsBuildFields),
+ myIsMinMaxDone(theIsMinMaxDone),
+ myIsBuildMinMax(theIsBuildMinMax),
+ myIsGroupsDone(theIsGroupsDone),
+ myIsBuildGroups(theIsBuildGroups),
+ myStudy(theStudy)
+ {}
+
+ };
+
+ //---------------------------------------------------------------
+ void
+ BuildDataTree(TBuildArgs theBuildArgs)
+ {
+ BuildEntities(theBuildArgs.myResult,
+ theBuildArgs.myInput,
+ theBuildArgs.myIsEntitiesDone,
+ theBuildArgs.myResultEntry,
+ theBuildArgs.myStudy);
+
+ {
+ boost::thread aThread(boost::bind(&BuildFieldDataTree,
+ theBuildArgs.myResult,
+ theBuildArgs.myInput,
+ theBuildArgs.myIsFieldsDone,
+ theBuildArgs.myIsBuildFields,
+ theBuildArgs.myIsMinMaxDone,
+ theBuildArgs.myIsBuildMinMax,
+ theBuildArgs.myStudy));
+ }
+
+ {
+ boost::thread aThread(boost::bind(&BuildGroups,
+ theBuildArgs.myResult,
+ theBuildArgs.myInput,
+ theBuildArgs.myIsGroupsDone,
+ theBuildArgs.myIsBuildGroups,
+ theBuildArgs.myStudy));
+ }
}
}
VISU::Result_i
::Result_i (SALOMEDS::Study_ptr theStudy,
const ESourceId& theSourceId,
- const ECreationId& theCreationId):
+ const ECreationId& theCreationId,
+ CORBA::Boolean theIsBuildImmediately):
myStudyDocument(SALOMEDS::Study::_duplicate(theStudy)),
myCreationId(theCreationId),
mySourceId(theSourceId),
+ myIsBuildImmediately(theIsBuildImmediately),
myInput(NULL),
- myIsFieldsDone(0),
- myIsGroupsDone(0),
- myIsMinMaxDone(0),
- myIsDone(0)
+ myIsEntitiesDone(false),
+ myIsFieldsDone(false),
+ myIsGroupsDone(false),
+ myIsMinMaxDone(false),
+ myIsBuildFields(true),
+ myIsBuildGroups(true),
+ myIsBuildMinMax(true),
+ myIsAllDone(false)
{
myStudy = ProcessEvent(new TGetStudy(myStudyDocument->StudyId()));
}
VISU::Result_i
::BuildAll()
{
- if(MYDEBUG) MESSAGE("Result_i::Build - myIsDone = "<<myIsDone);
- if(myIsDone) return 1;
- if(!IsPossible()) return 0;
+ if(MYDEBUG) MESSAGE("Result_i::Build - myIsAllDone = "<<myIsAllDone);
+ if(myIsAllDone)
+ return 1;
+ if(!IsPossible())
+ return 0;
try{
const VISU::TMeshMap& aMeshMap = myInput->GetMeshMap();
VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
}
}
}
- myIsDone = 1;
+ myIsAllDone = 1;
}catch(std::exception& exc){
INFOS("Follow exception was occured :\n"<<exc.what());
}catch(...){
INFOS("Unknown exception was occured!!!");
}
- return myIsDone;
+ return myIsAllDone;
}
//---------------------------------------------------------------
-void
+CORBA::Boolean
VISU::Result_i
-::BuildEntities(SALOMEDS::SObject_ptr theSObject)
+::Build(CORBA::Boolean theIsBuildAll,
+ CORBA::Boolean theIsAtOnce)
{
- TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildEntities");
- TResultManager aResultManager(this);
- TTransactionManager aTransactionManager(myStudy);
+ if(theIsBuildAll)
+ theIsAtOnce = true;
- QString aComment;
+ if(Build(SALOMEDS::SObject::_nil(),theIsAtOnce)){
+ if(theIsBuildAll)
+ return BuildAll();
+ return true;
+ }
+
+ return false;
+}
+
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::Result_i
+::Build(SALOMEDS::SObject_ptr theSObject,
+ CORBA::Boolean theIsAtOnce)
+{
+ if(IsDone())
+ return this;
mySComponent = FindOrCreateVisuComponent(myStudyDocument);
CORBA::String_var aSComponentEntry = mySComponent->GetID();
CORBA::String_var anIOR(GetID());
+ QString aComment;
aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s",
GetComment(),
VISU::TRESULT,
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;
+ if(theIsAtOnce){
+ BuildEntities(this,
+ myInput,
+ &myIsEntitiesDone,
+ aResultEntry,
+ myStudy);
- aComment.sprintf("myComment=MESH;myName=%s;myDim=%d",
- aMeshName.c_str(),
- aMesh->myDim);
- aMesh->myEntry =
- CreateAttributes(myStudy,
- aResultEntry,
- "",
- aMeshName,
- "",
- aComment.latin1(),
- true);
+ BuildFields(this,
+ myInput,
+ &myIsFieldsDone,
+ myIsBuildFields,
+ myStudy);
- 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));
-}
-
-
-//---------------------------------------------------------------
-VISU::Storable*
-VISU::Result_i
-::Build(SALOMEDS::SObject_ptr theSObject)
-{
- bool isBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false);
- if(isBuildAll)
- return BuildAll(theSObject);
- else{
- BuildEntities(theSObject);
-
- // To start build of the fields, groups and perfrom min/max calculation
+ BuildMinMax(this,
+ myInput,
+ &myIsMinMaxDone,
+ myIsBuildMinMax);
+
+ BuildGroups(this,
+ myInput,
+ &myIsGroupsDone,
+ myIsBuildGroups,
+ myStudy);
+ }else{
+ TBuildArgs aBuildArgs(this,
+ myInput,
+ &myIsEntitiesDone,
+ aResultEntry,
+ &myIsFieldsDone,
+ myIsBuildFields,
+ &myIsMinMaxDone,
+ myIsBuildMinMax,
+ &myIsGroupsDone,
+ myIsBuildGroups,
+ myStudy);
boost::thread aThread(boost::bind(&BuildDataTree,
- this,
- myInput,
- &myIsFieldsDone,
- &myIsMinMaxDone,
- &myIsGroupsDone,
- myStudy));
- return this;
+ aBuildArgs));
}
+
+ return this;
}
{
if(MYDEBUG) MESSAGE("Result_i::Build");
try{
- BuildEntities(theSObject);
-
- BuildFields(this,
- myInput,
- &myIsFieldsDone,
- myStudy);
-
- BuildMinMax(this,
- myInput,
- &myIsMinMaxDone);
-
- BuildGroups(this,
- myInput,
- &myIsGroupsDone,
- myStudy);
-
+ Build(theSObject);
BuildAll();
}catch(std::exception& exc){
INFOS("Follow exception was occured :\n"<<exc.what());
myFileInfo.setFile(QString(aTmpDir.c_str()) + myFileInfo.fileName());
}
myInput = CreateConvertor(myFileInfo.absFilePath().latin1());
- if(!myInput)
- throw std::runtime_error("Create - Cannot create a Convertor for this file!!!");
- return Build();
+ if(myInput){
+ if(myIsBuildImmediately)
+ Build(SALOMEDS::SObject::_nil(),false); //apo
+ return this;
+ }
}catch(std::exception& exc){
INFOS("Follow exception was occured :\n"<<exc.what());
}catch(...){
if(myInput == NULL)
return NULL;
+ myInput->Build();
+
string aCompDataType = GetComponentDataType(theMedSObject);
myFileInfo.setFile(aCompDataType.c_str());
myInitFileName = aCompDataType;
myName = ::GenerateName("aResult").latin1();
- VISU::Storable* aStorable = Build(theMedSObject);
- return aStorable;
+ return Build(theMedSObject);
}catch(std::exception& exc){
INFOS("Follow exception was occured :\n"<<exc.what());
}catch(...){
if(myInput == NULL)
return NULL;
+ myInput->Build();
+
string aCompDataType = "MED";
myFileInfo.setFile(aCompDataType.c_str());
myInitFileName = aCompDataType;
CORBA::String_var anIOR = myStudyDocument->ConvertObjectToIOR(theField);
SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR);
- VISU::Storable* aStorable = Build(aFieldSObject);
- return aStorable;
+ return Build(aFieldSObject);
}catch(std::exception& exc){
INFOS("Follow exception was occured :\n"<<exc.what());
}catch(...){
SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp);
aStudyBuilder->LoadWith(aCompRefSObj, aDriver);
- if (strcmp(aDataType, "MED") == 0)
+ if (strcmp(aDataType, "MED") == 0){
myInput = CreateMEDConvertor(aTargetRefSObj);
- else
+ myInput->Build();
+ }else
throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!");
} else {
myFileInfo.setFile(thePrefix.c_str());
}
if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = " << mySourceId);
myInput = CreateConvertor(myFileInfo.filePath().latin1());
+ myInput->Build();
QString aComment;
aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s",
GetComment(), VISU::TRESULT, myFileInfo.filePath().latin1(),
}
//---------------------------------------------------------------
+CORBA::Boolean
+VISU::Result_i
+::IsDone()
+{
+ return
+ myIsEntitiesDone &&
+ (myIsBuildFields && myIsFieldsDone) &&
+ (myIsBuildMinMax && myIsMinMaxDone) &&
+ (myIsBuildGroups && myIsGroupsDone);
+}
+
+CORBA::Boolean
+VISU::Result_i
+::IsEntitiesDone()
+{
+ return myIsEntitiesDone;
+}
+
+void
+VISU::Result_i
+::SetBuildFields(CORBA::Boolean theIsBuildFields,
+ CORBA::Boolean theIsCalculateMinMax)
+{
+ myIsBuildFields = theIsBuildFields;
+ if(theIsBuildFields)
+ myIsBuildMinMax = theIsCalculateMinMax;
+ else
+ myIsBuildMinMax = false;
+}
+
+void
+VISU::Result_i
+::SetBuildGroups(CORBA::Boolean theIsBuildGroups)
+{
+ myIsBuildGroups = theIsBuildGroups;
+}
+
CORBA::Boolean
VISU::Result_i
::IsFieldsDone()
VISU::Result_i
::GetRefFatherEntry()
{
- //return QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry();
return "";
}