From: nri Date: Thu, 10 Jul 2003 16:57:58 +0000 (+0000) Subject: NRI : Merge from V1_2. X-Git-Tag: V_02092003~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4649fa290ef60fe60df48191ddb42af9739f824c;p=modules%2Fvisu.git NRI : Merge from V1_2. --- diff --git a/src/VISU_I/VISU_Convertor.cxx b/src/VISU_I/VISU_Convertor.cxx index 6f66024f..c0d655c6 100644 --- a/src/VISU_I/VISU_Convertor.cxx +++ b/src/VISU_I/VISU_Convertor.cxx @@ -8,6 +8,8 @@ using namespace std; #include "VISU_Convertor.hxx" +#include +#include #include #include #include @@ -122,26 +124,30 @@ namespace VISU{ } } -const VISU::TMesh* VISU_Convertor::GetMesh(const string& theMeshName) const { - string aMeshName(theMeshName == ""? myMeshMap.begin()->first: theMeshName); - VISU::TMeshMap::const_iterator aMeshMapIter = myMeshMap.find(theMeshName); - if(aMeshMapIter == myMeshMap.end()) return NULL; - return &(aMeshMapIter->second); +const VISU::TMeshMap& VISU_Convertor::GetMeshMap() throw(std::runtime_error&){ + if(!myIsDone) { myIsDone = true; Build();} + return myMeshMap; } -const VISU::TField* VISU_Convertor::GetField(const string& theMeshName, VISU::TEntity theEntity, - const string& theFieldName) const +const VISU::TField& VISU_Convertor::GetField(const string& theMeshName, + VISU::TEntity theEntity, + const string& theFieldName) + throw (std::runtime_error&) { + if(!myIsDone) { myIsDone = true; Build();} VISU::TMeshMap::const_iterator aMeshMapIter = myMeshMap.find(theMeshName); - if(aMeshMapIter == myMeshMap.end()) return NULL; + if(aMeshMapIter == myMeshMap.end()) + throw std::runtime_error("GetField >> There is no mesh with the name !!!"); const VISU::TMesh& aMesh = aMeshMapIter->second; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMesh.myMeshOnEntityMap.find(theEntity); - if(aMeshOnEntityMapIter == aMesh.myMeshOnEntityMap.end()) return NULL; + if(aMeshOnEntityMapIter == aMesh.myMeshOnEntityMap.end()) + throw std::runtime_error("GetField >> There is no mesh with the entity !!!"); const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.find(theFieldName); - if(aFieldMapIter == aFieldMap.end()) return NULL; - return &(aFieldMapIter->second); + if(aFieldMapIter == aFieldMap.end()) + throw std::runtime_error("GetField >> There is no field with the name !!!"); + return aFieldMapIter->second; } string VISU_Convertor::GenerateName(const VISU::TField::TTime& aTime){ @@ -176,7 +182,7 @@ string VISU_Convertor::GenerateName(const string& theName, unsigned int theTimeI void parseFile(const char* theFileName) throw(std::runtime_error&){ try{ auto_ptr aCon(CreateConvertor(theFileName)); - const VISU::TMeshMap& aMeshMap = *(aCon->GetMeshMap()); + const VISU::TMeshMap& aMeshMap = aCon->GetMeshMap(); VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ const string& aMeshName = aMeshMapIter->first; @@ -366,9 +372,9 @@ int main(int argc, char** argv){ return 0; } }catch(std::runtime_error& exc){ - MESSAGE("Follow exception was accured :\n"< class vtk_ptr { private: _Tp* _M_ptr; @@ -169,34 +170,29 @@ class VISU_Convertor{ protected: std::string myName; VISU::TMeshMap myMeshMap; + int myIsDone; public: virtual ~VISU_Convertor(){}; + virtual const string& GetName() { return myName;} + virtual int IsDone() const { return myIsDone;} typedef vtkUnstructuredGridReader OutputType; - const char* GetName() { return myName.c_str();} - + virtual VISU_Convertor* Build() throw (std::runtime_error&) = 0; virtual OutputType* GetMeshOnEntity(const string& theMeshName, const VISU::TEntity& theEntity, const string& theFamilyName = "") throw(std::runtime_error&) = 0; - virtual OutputType* GetMeshOnGroup(const string& theMeshName, const string& theGroupName) throw(std::runtime_error&) = 0; - virtual OutputType* GetFieldOnMesh(const string& theMeshName, const VISU::TEntity& theEntity, const string& theFieldName, int theStampsNum) throw(std::runtime_error&) = 0; - - virtual int ToMedFile(const string& theFileName) throw(std::runtime_error&) = 0; - virtual int ToDatFile(const string& theFileName) throw(std::runtime_error&) = 0; - virtual int ToFile(const string& theFileName) throw(std::runtime_error&) = 0; - - const VISU::TMeshMap* GetMeshMap() const { return &myMeshMap;} - const VISU::TMesh* GetMesh(const string& theMeshName = "") const; - const VISU::TField* GetField(const string& theMeshName, VISU::TEntity theEntity, - const string& theFieldName) const; + virtual const VISU::TMeshMap& GetMeshMap() throw(std::runtime_error&); + virtual const VISU::TField& GetField(const string& theMeshName, VISU::TEntity theEntity, + const string& theFieldName) + throw(std::runtime_error&); static string GenerateName(const VISU::TField::TTime& aTime); static string GenerateName(const string& theName, unsigned int theTimeId); }; diff --git a/src/VISU_I/VISU_Convertor_impl.cxx b/src/VISU_I/VISU_Convertor_impl.cxx index cca6e588..353b12c0 100644 --- a/src/VISU_I/VISU_Convertor_impl.cxx +++ b/src/VISU_I/VISU_Convertor_impl.cxx @@ -72,15 +72,10 @@ extern "C" { } } -int VISU_Convertor_impl::ToFile(const string& theFileName) throw(std::runtime_error&){ - if(QFileInfo(theFileName.c_str()).extension(false) == "med") - return ToMedFile(theFileName); - else - return ToDatFile(theFileName); +VISU_Convertor_impl::VISU_Convertor_impl() { + myIsDone = false; } -VISU_Convertor_impl::VISU_Convertor_impl() : myIsDone(false) {} - VISU_Convertor_impl::~VISU_Convertor_impl() {} VISU_Convertor::OutputType* VISU_Convertor_impl::GetMeshOnEntity(const string& theMeshName, @@ -88,6 +83,7 @@ VISU_Convertor::OutputType* VISU_Convertor_impl::GetMeshOnEntity(const string& t const string& theFamilyName) throw (std::runtime_error&) { + if(!myIsDone) { myIsDone = true; Build();} if(MYDEBUG) MESSAGE("GetMeshOnEntity - theMeshName = '"< aRet(strCellsOut.str()); + strOut<DebugOn(); aReader->ReadFromInputStringOn(); - aReader->SetInputString(strOut.str()); + aRet.reset(strOut.str()); + aReader->SetInputString(aRet.get()); //aReader->Update(); //aReader->Print(cout); if(MYDEBUGWITHFILES){ @@ -136,7 +135,7 @@ VISU_Convertor::OutputType* VISU_Convertor_impl::GetMeshOnEntity(const string& t string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-"; aFileName += aMeshName + dtos("-%d-",theEntity) + aFamilyName + "-Conv.vtk"; ofstream stmOut(aFileName.c_str(),ios::out); - stmOut< aRet(strCellsOut.str()); + strOut<ReadFromInputStringOn(); - aReader->SetInputString(strOut.str()); + aRet.reset(strOut.str()); + aReader->SetInputString(aRet.get()); if(MYDEBUGWITHFILES){ string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1(); string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-"; aFileName += aMeshName + "-" + aGroupName + "-Conv.vtk"; ofstream stmOut(aFileName.c_str(),ios::out); - stmOut< aRet(strCellsOut.str()); + strOut<ReadFromInputStringOn(); - aReader->SetInputString(strOut.str()); + aRet.reset(strOut.str()); + aReader->SetInputString(aRet.get()); if(MYDEBUGWITHFILES){ string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1(); string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-"; aFileName += aMeshName + dtos("-%d-",theEntity) + aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk"; ofstream stmOut(aFileName.c_str(),ios::out); - stmOut<second; - if(MYDEBUG) MESSAGE("GetCells - anArray.size() = "<first; + if(MYDEBUG) MESSAGE("GetCells - aVtkType = "<> There is no elements on the family !!!"); VISU::TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType); + if(aSubMeshIter == aSubMesh.end()) continue; const VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second; + if(MYDEBUG) MESSAGE("GetCells - aSubMeshOnCellType.size() = "< aRet(strOut.str()); + return aRet.get(); } string VISU_Convertor_impl::GetPoints(const VISU::TMesh& theMesh) const @@ -365,7 +377,8 @@ string VISU_Convertor_impl::GetPoints(const VISU::TMesh& theMesh) const break; } strOut< aRet(strOut.str()); + return aRet.get(); } string VISU_Convertor_impl::GetField(const VISU::TField& theField, @@ -418,5 +431,6 @@ string VISU_Convertor_impl::GetField(const VISU::TField& theField, throw std::runtime_error("GetField - There is algorithm for representation the field !!!"); } strOut< aRet(strOut.str()); + return aRet.get(); } diff --git a/src/VISU_I/VISU_Convertor_impl.hxx b/src/VISU_I/VISU_Convertor_impl.hxx index 6550070e..e4442719 100644 --- a/src/VISU_I/VISU_Convertor_impl.hxx +++ b/src/VISU_I/VISU_Convertor_impl.hxx @@ -23,8 +23,6 @@ extern "C"{ using namespace std; class VISU_Convertor_impl: public VISU_Convertor{ - protected: - bool myIsDone; private: string GetHead(const string& theMeshName) const throw (std::runtime_error&); string GetPoints(const VISU::TMesh& theMesh) const throw (std::runtime_error&); @@ -39,10 +37,6 @@ class VISU_Convertor_impl: public VISU_Convertor{ VISU_Convertor_impl(); virtual ~VISU_Convertor_impl(); virtual VISU_Convertor* Build() throw (std::runtime_error&) { return this;}; - virtual int ToMedFile(const string& theFileName) throw(std::runtime_error&); - virtual int ToDatFile(const string& theFileName) throw(std::runtime_error&); - virtual int ToFile(const string& theFileName) throw(std::runtime_error&); - virtual OutputType* GetMeshOnEntity(const string& theMeshName, const VISU::TEntity& theEntity, const string& theFamilyName = "") diff --git a/src/VISU_I/VISU_CorbaMedConvertor.hxx b/src/VISU_I/VISU_CorbaMedConvertor.hxx index 312180c9..e850515d 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.hxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.hxx @@ -16,7 +16,6 @@ extern "C"{ #include } - namespace VISUMED{ struct TFamily{ SALOME_MED::FAMILY_var myFamily; @@ -99,3 +98,4 @@ extern "C" { } #endif + diff --git a/src/VISU_I/VISU_DatConvertor.cxx b/src/VISU_I/VISU_DatConvertor.cxx index 55714d2e..91151aff 100644 --- a/src/VISU_I/VISU_DatConvertor.cxx +++ b/src/VISU_I/VISU_DatConvertor.cxx @@ -153,8 +153,8 @@ int VISU_DatConvertor::ImportCells(ifstream* pStmIn, vector* pCellsType) return 0; } +/* int VISU_Convertor_impl::ToDatFile(const string& theFileName) throw(std::runtime_error&){ - /* if(MYDEBUG) MESSAGE("VISU_Convertor_impl::ToDatFile - "<GetInput()->GetMeshOnEntity(myMeshName,(VISU::TEntity)myEntity); - aComment.sprintf("myComment=ENTITY;myType=%d;myResultName=%s;myMeshName=%s;myId=%d", - VISU::TENTITY,myResult->GetName(),myMeshName.c_str(),myEntity); + aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d", + VISU::TENTITY,myMeshName.c_str(),myEntity); break; case VISU::TFAMILY : myInput = myResult->GetInput()->GetMeshOnEntity(myMeshName,(VISU::TEntity)myEntity,mySubMeshName); - aComment.sprintf("myComment=FAMILY;myType=%d;myResultName=%s;myMeshName=%s;myEntityId=%d;myName=%s", - VISU::TFAMILY,myResult->GetName(),myMeshName.c_str(),myEntity,mySubMeshName.c_str()); + aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", + VISU::TFAMILY,myMeshName.c_str(),myEntity,mySubMeshName.c_str()); break; case VISU::TGROUP : myInput = myResult->GetInput()->GetMeshOnGroup(myMeshName,mySubMeshName); - aComment.sprintf("myComment=GROUP;myType=%d;myResultName=%s;myMeshName=%s;myName=%s", - VISU::TGROUP,myResult->GetName(),myMeshName.c_str(),mySubMeshName.c_str()); + aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s", + VISU::TGROUP,myMeshName.c_str(),mySubMeshName.c_str()); break; } if(myInput == NULL) throw std::runtime_error("Mesh_i::Build - myInput == NULL !!!"); @@ -869,13 +869,19 @@ void VISU::ScalarMap_i::UpdateActor(VISU_Actor* theActor) { } } - //============================================================================== int VISU::DeformedShape_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, double theIteration){ - if(!VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration)) return 0; - const VISU::TField* aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); - return aField->myNbComp > 1; + try{ + if(!VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration)) return 0; + const VISU::TField& aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); + return aField.myNbComp > 1; + }catch(std::runtime_error& exc){ + MESSAGE("Follow exception was accured :\n"<Addreference(newObj,aRefSObj); } +string GetComponentDataType(SALOMEDS::SObject_ptr theSObject){ + SALOMEDS::SComponent_var aCompRefSObj = theSObject->GetFatherComponent(); + CORBA::String_var aDataType = aCompRefSObj->ComponentDataType(); + return aDataType.in(); +} + //============================================================================== const string VISU::Result_i::myComment = "RESULT"; @@ -111,9 +117,12 @@ const char* VISU::Result_i::GetComment() const { return myComment.c_str();} VISU::Result_i::Result_i(SALOMEDS::Study_ptr theStudy) { myStudyDocument = SALOMEDS::Study::_duplicate(theStudy); + myInput = NULL; } -VISU::Storable* VISU::Result_i::Build() { +VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) + throw (std::runtime_error&) +{ if(MYDEBUG) MESSAGE("Result_i::Build"); const TMeshMap& aMeshMap = myInput->GetMeshMap(); if(!aMeshMap.empty()) {//apo @@ -174,31 +183,31 @@ VISU::Storable* VISU::Result_i::Build() { CreateAttributes(myStudyDocument,aEntity2Entry[anEntity].c_str(),aRefFatherEntry.c_str(), "",aFamilyName.c_str(),"",aComment.latin1(),true); } - //Importing groups - const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; - if(aGroupMap.size() > 0){ - aComment.sprintf("myComment=GROUPS;myResultName=%s;myMeshName=%s",myName.c_str(),aMeshName.c_str()); - string aGroupsEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), - "","Groups","",aComment.latin1(),true); - VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); - for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ - const string& aGroupName = aGroupMapIter->first; - aComment.sprintf("myComment=GROUP;myType=%d;myResultName=%s;myMeshName=%s;myName=%s", - VISU::TGROUP,myName.c_str(),aMeshName.c_str(),aGroupName.c_str()); - string aGroupEntry = CreateAttributes(myStudyDocument,aGroupsEntry.c_str(),aRefFatherEntry.c_str(), - "",aGroupName.c_str(),"",aComment.latin1(),true); - const VISU::TGroup& aGroup = aGroupMapIter->second; - const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup.myFamilyAndEntitySet; - VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = aFamilyAndEntitySet.begin(); - for(; aFamilyAndEntitySetIter != aFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){ - const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter; - const string& aFamilyName = aFamilyAndEntity.first; - const VISU::TEntity& anEntity = aFamilyAndEntity.second; - aComment.sprintf("myComment=FAMILY;myType=%d;myResultName=%s;myMeshName=%s;myEntityId=%d;myName=%s", - VISU::TFAMILY,myName.c_str(),aMeshName.c_str(),anEntity,aFamilyName.c_str()); - string anEntry = FindEntryWithComment(myStudyDocument,aEntity2Entry[anEntity].c_str(),aComment); - CreateReference(myStudyDocument,aGroupEntry,anEntry); - } + } + //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); + 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); + const VISU::TGroup& aGroup = aGroupMapIter->second; + const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup.myFamilyAndEntitySet; + VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = aFamilyAndEntitySet.begin(); + for(; aFamilyAndEntitySetIter != aFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){ + const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter; + 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); + CreateReference(myStudyDocument,aGroupEntry,anEntry); } } } @@ -305,7 +314,6 @@ VISU::Storable* VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject, { if(MYDEBUG) MESSAGE("Result_i::Restore - "<GetStudy(); mySComponent = mySObject->GetFatherComponent(); diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index 80ce8c10..5d01988c 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -935,6 +935,8 @@ int getLine(ifstream& theStmIn, QString& theString){ void ImportTables(const char* theFileName, TTableCont& theTableCont){ ifstream aStmIn; + QFileInfo aFileInfo(theFileName); + if(!aFileInfo.isFile() || !aFileInfo.isReadable() || !aFileInfo.size()) return; aStmIn.open(theFileName); QString aTmp; do{ diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index a8dcc57a..d5f4cc64 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -437,7 +437,6 @@ void VISU_TimeAnimation::run() { aName.replace(aPos, 1, "_"); aFile += aName; aFile += ".jpeg"; - //cout<<"### save:"<getStudyDocument(),aSComponentEntry,"","",newName.latin1(),"",ToString().c_str()); return 1; }