Save the Id of hypothesis and algos to the study files.

This commit is contained in:
jrt 2004-03-15 17:18:44 +00:00
parent 2d6b256c47
commit 03967e431d
5 changed files with 56 additions and 72 deletions

View File

@ -97,3 +97,7 @@ int SMESHDS_Hypothesis::GetType() const
return _type; return _type;
} }
void SMESHDS_Hypothesis::SetID(int id)
{
_hypId=id;
}

View File

@ -48,6 +48,7 @@ public:
const char* GetName() const; const char* GetName() const;
int GetID() const; int GetID() const;
void SetID(int id);
int GetType() const; int GetType() const;
virtual ostream & SaveTo(ostream & save)=0; virtual ostream & SaveTo(ostream & save)=0;

View File

@ -449,14 +449,18 @@ SALOMEDS::TMPFile * SMESH_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
//**************************** //****************************
itBig = Study->NewChildIterator(theComponent); itBig = Study->NewChildIterator(theComponent);
SCRUTE(Tag_HypothesisRoot);
SCRUTE(Tag_AlgorithmsRoot);
for (; itBig->More(); itBig->Next()) for (; itBig->More(); itBig->Next())
{ {
SALOMEDS::SObject_var gotBranch = itBig->Value(); SALOMEDS::SObject_var gotBranch = itBig->Value();
SCRUTE(gotBranch->Name());
SCRUTE(gotBranch->Tag());
SCRUTE(gotBranch->GetID());
//************branch 1 : hypothesis //************branch 1 : hypothesis
if (gotBranch->Tag() == Tag_HypothesisRoot) if (gotBranch->Tag() == Tag_HypothesisRoot)
{ //hypothesis = tag 1 { //hypothesis = tag 1
double length, maxElementsArea, maxElementsVolume; double length, maxElementsArea, maxElementsVolume;
int numberOfSegments; int numberOfSegments;
@ -474,8 +478,9 @@ SALOMEDS::TMPFile * SMESH_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis_var myHyp =
SMESH::SMESH_Hypothesis::_narrow(_orb-> SMESH::SMESH_Hypothesis::_narrow(_orb->
string_to_object(anIOR->Value())); string_to_object(anIOR->Value()));
SCRUTE(myHyp->GetName());
fprintf(destFile, "%li\n", myHyp->GetId());
fprintf(destFile, "%s\n", myHyp->GetName()); fprintf(destFile, "%s\n", myHyp->GetName());
if (strcmp(myHyp->GetName(), "LocalLength") == 0) if (strcmp(myHyp->GetName(), "LocalLength") == 0)
{ {
SMESH::SMESH_LocalLength_var LL = SMESH::SMESH_LocalLength_var LL =
@ -531,7 +536,6 @@ SALOMEDS::TMPFile * SMESH_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
//************branch 2 : algorithms //************branch 2 : algorithms
else if (gotBranch->Tag() == Tag_AlgorithmsRoot) else if (gotBranch->Tag() == Tag_AlgorithmsRoot)
{ //algos = tag 2 { //algos = tag 2
destFile = fopen(algofile.ToCString(), "w"); destFile = fopen(algofile.ToCString(), "w");
it = Study->NewChildIterator(gotBranch); it = Study->NewChildIterator(gotBranch);
for (; it->More(); it->Next()) for (; it->More(); it->Next())
@ -545,6 +549,9 @@ SALOMEDS::TMPFile * SMESH_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
SMESH::SMESH_Algo_var myAlgo = SMESH::SMESH_Algo_var myAlgo =
SMESH::SMESH_Algo::_narrow(_orb-> SMESH::SMESH_Algo::_narrow(_orb->
string_to_object(anIOR->Value())); string_to_object(anIOR->Value()));
SCRUTE(anIOR->Value());
SCRUTE(myAlgo->_is_nil());
fprintf(destFile, "%i\n", myAlgo->GetId());
fprintf(destFile, "%s\n", myAlgo->GetName()); fprintf(destFile, "%s\n", myAlgo->GetName());
} }
} }
@ -929,16 +936,21 @@ SALOMEDS::TMPFile * SMESH_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
MESSAGE("End of Meshes Save"); MESSAGE("End of Meshes Save");
} }
MESSAGE("hdf_file->CloseOnDisk()");
hdf_file->CloseOnDisk(); hdf_file->CloseOnDisk();
MESSAGE("delete hdf_file");
delete hdf_file; delete hdf_file;
hdf_file = 0; hdf_file = 0;
// Convert temporary files to stream // Convert temporary files to stream
MESSAGE("Convert temporary files to stream");
aStreamFile = aStreamFile =
SALOMEDS_Tool::PutFilesToStream(tmpDir.ToCString(), aFileSeq.in(), SALOMEDS_Tool::PutFilesToStream(tmpDir.ToCString(), aFileSeq.in(),
isMultiFile); isMultiFile);
// Remove temporary files and directory // Remove temporary files and directory
MESSAGE("Remove temporary files and directory");
if (!isMultiFile) if (!isMultiFile)
SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.ToCString(), aFileSeq.in(), SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.ToCString(), aFileSeq.in(),
true); true);
@ -974,75 +986,29 @@ void SMESH_Gen_i::loadHypothesis(char * name, HDFfile * hdf_file,
dataset->ReadFromDisk(name_of_file); dataset->ReadFromDisk(name_of_file);
SCRUTE(name_of_file); SCRUTE(name_of_file);
dataset->CloseOnDisk(); dataset->CloseOnDisk();
hdfGroup->CloseOnDisk(); hdfGroup->CloseOnDisk();
delete[]name_of_file; delete[]name_of_file;
char * aLine = new char[100]; ifstream loadedFile(hypofile);
FILE * loadedFile = fopen(hypofile, "r"); while (!loadedFile.eof())
while (!feof(loadedFile))
{ {
fscanf(loadedFile, "%s", aLine); int hypothesisID;
//SCRUTE(aLine); string hypothesisName;
if (strcmp(aLine, "LocalLength") == 0) loadedFile >> hypothesisID;
{ loadedFile >> hypothesisName;
SMESH::SMESH_Hypothesis_var myHyp = if(hypothesisName.length()==0) break;
this->CreateHypothesis(aLine, studyId); SMESH_Hypothesis_i * corbaHyp =
SMESH::SMESH_LocalLength_var LL = _hypothesisFactory_i.Create(hypothesisName.c_str(), studyId, &_impl);
SMESH::SMESH_LocalLength::_narrow(myHyp); SMESH_Hypothesis * localHyp = corbaHyp->getImpl();
fscanf(loadedFile, "%s", aLine); localHyp->SetID(hypothesisID);
length = atof(aLine); localHyp->LoadFrom(loadedFile);
LL->SetLength(length);
string iorString = _orb->object_to_string(LL); SMESH::SMESH_Hypothesis_var varHyp = corbaHyp->_this();
sprintf(objectId, "%ld", LL->GetId()); string iorString = _orb->object_to_string(varHyp);
_SMESHCorbaObj[string("Hypo_") + string(objectId)] = sprintf(objectId, "%ld", varHyp->GetId());
iorString; _SMESHCorbaObj[string("Hypo_") + string(objectId)] =
} iorString;
else if (strcmp(aLine, "NumberOfSegments") == 0)
{
SMESH::SMESH_Hypothesis_var myHyp =
this->CreateHypothesis(aLine, studyId);
SMESH::SMESH_NumberOfSegments_var NOS =
SMESH::SMESH_NumberOfSegments::_narrow(myHyp);
fscanf(loadedFile, "%s", aLine);
numberOfSegments = atoi(aLine);
NOS->SetNumberOfSegments(numberOfSegments);
string iorString = _orb->object_to_string(NOS);
sprintf(objectId, "%ld", NOS->GetId());
_SMESHCorbaObj[string("Hypo_") + string(objectId)] =
iorString;
}
else if (strcmp(aLine, "MaxElementArea") == 0)
{
SMESH::SMESH_Hypothesis_var myHyp =
this->CreateHypothesis(aLine, studyId);
SMESH::SMESH_MaxElementArea_var MEA =
SMESH::SMESH_MaxElementArea::_narrow(myHyp);
fscanf(loadedFile, "%s", aLine);
maxElementsArea = atof(aLine);
MEA->SetMaxElementArea(maxElementsArea);
string iorString = _orb->object_to_string(MEA);
sprintf(objectId, "%ld", MEA->GetId());
_SMESHCorbaObj[string("Hypo_") + string(objectId)] =
iorString;
}
else if (strcmp(aLine, "MaxElementVolume") == 0)
{
SMESH::SMESH_Hypothesis_var myHyp =
this->CreateHypothesis(aLine, studyId);
SMESH::SMESH_MaxElementVolume_var MEV =
SMESH::SMESH_MaxElementVolume::_narrow(myHyp);
fscanf(loadedFile, "%s", aLine);
maxElementsVolume = atof(aLine);
MEV->SetMaxElementVolume(maxElementsVolume);
string iorString = _orb->object_to_string(MEV);
sprintf(objectId, "%ld", MEV->GetId());
_SMESHCorbaObj[string("Hypo_") + string(objectId)] =
iorString;
}
} }
fclose(loadedFile);
delete[]aLine;
MESSAGE("End of Hypos Load"); MESSAGE("End of Hypos Load");
} }
@ -1069,12 +1035,19 @@ void SMESH_Gen_i::loadAlgorithms(char * name, HDFfile * hdf_file,
FILE * loadedFile = fopen(algofile, "r"); FILE * loadedFile = fopen(algofile, "r");
while (!feof(loadedFile)) while (!feof(loadedFile))
{ {
int hypothesisID;
fscanf(loadedFile, "%i", &hypothesisID);
fscanf(loadedFile, "%s\n", aLine); fscanf(loadedFile, "%s\n", aLine);
//SCRUTE(aLine); //SCRUTE(aLine);
if (strcmp(aLine, "") != 0) if (strcmp(aLine, "") != 0)
{ {
SMESH::SMESH_Hypothesis_var myHyp = SMESH_Hypothesis_i * corbaHyp =
this->CreateHypothesis(aLine, studyId); _hypothesisFactory_i.Create(aLine, studyId, &_impl);
SMESH_Hypothesis * localHyp = corbaHyp->getImpl();
localHyp->SetID(hypothesisID);
SMESH::SMESH_Hypothesis_var myHyp = corbaHyp->_this();
SMESH::SMESH_Algo_var myAlgo = SMESH::SMESH_Algo_var myAlgo =
SMESH::SMESH_Algo::_narrow(myHyp); SMESH::SMESH_Algo::_narrow(myHyp);
string iorString = _orb->object_to_string(myAlgo); string iorString = _orb->object_to_string(myAlgo);

View File

@ -81,3 +81,8 @@ CORBA::Long SMESH_Hypothesis_i::GetId()
MESSAGE("GetId"); MESSAGE("GetId");
return _baseImpl->GetID(); return _baseImpl->GetID();
} }
::SMESH_Hypothesis* SMESH_Hypothesis_i::getImpl()
{
return _baseImpl;
}

View File

@ -44,7 +44,8 @@ public:
char* GetName(); char* GetName();
CORBA::Long GetId(); CORBA::Long GetId();
::SMESH_Hypothesis* getImpl();
protected: protected:
::SMESH_Hypothesis* _baseImpl; ::SMESH_Hypothesis* _baseImpl;
::SMESH_Gen* _genImpl; ::SMESH_Gen* _genImpl;