X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_PreMeshInfo.cxx;h=989de27e6cb69b2d448f6111801c6b570addde79;hp=0a3d58614a4a37e466e9c35517af8492cc6d9f0b;hb=074862c21362ffeb5556c4f16c843aacda569121;hpb=f5016d85b7b4b88623723027a1585c6414c4dc66 diff --git a/src/SMESH_I/SMESH_PreMeshInfo.cxx b/src/SMESH_I/SMESH_PreMeshInfo.cxx index 0a3d58614..989de27e6 100644 --- a/src/SMESH_I/SMESH_PreMeshInfo.cxx +++ b/src/SMESH_I/SMESH_PreMeshInfo.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,13 +26,16 @@ #include "SMESH_PreMeshInfo.hxx" +#include "DriverMED.hxx" #include "DriverMED_R_SMESHDS_Mesh.h" +#include "MED_Factory.hxx" #include "SMDS_EdgePosition.hxx" #include "SMDS_FacePosition.hxx" #include "SMDS_SpacePosition.hxx" #include "SMDS_VertexPosition.hxx" #include "SMESHDS_Group.hxx" #include "SMESHDS_GroupOnFilter.hxx" +#include "SMESHDS_Mesh.hxx" #include "SMESH_Gen_i.hxx" #include "SMESH_Group_i.hxx" #include "SMESH_Mesh_i.hxx" @@ -42,40 +45,26 @@ #include #include #include -#include #include +#include -#include -#include #include #include +#include "SMESH_TryCatch.hxx" + #include CORBA_SERVER_HEADER(SALOME_Session) -#define MYDEBUGOUT(msg) //std::cout << msg << std::endl; +using namespace std; -//================================================================================ -#define PreMeshInfo_TRY \ - try { OCC_CATCH_SIGNALS -//================================================================================ -#define PreMeshInfo_CATCH } \ - catch (Standard_Failure& ex) { \ - onExceptionCaught(SMESH_Comment("OCC Exception caught: \t")< theStudyIDToMeshCounter; + // count not yet loaded meshes + static int theMeshCounter = 0; //================================================================================ /*! @@ -85,9 +74,7 @@ namespace void meshInfoLoaded( SMESH_Mesh_i* mesh ) { - map< int, int >::iterator id2counter = - theStudyIDToMeshCounter.insert( make_pair( (int) mesh->GetStudyId(), 0 )).first; - id2counter->second++; + theMeshCounter++; } //================================================================================ /*! @@ -99,33 +86,21 @@ namespace std::string medFile, std::string hdfFile) { - if ( --theStudyIDToMeshCounter[ (int) mesh->GetStudyId() ] == 0 ) + if ( --theMeshCounter == 0 ) { - string tmpDir = SALOMEDS_Tool::GetDirFromPath( hdfFile ); + std::string tmpDir = SALOMEDS_Tool::GetDirFromPath( hdfFile ); - SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames; - aFiles->length(2); + SALOMEDS_Tool::ListOfFiles aFiles; + aFiles.reserve(2); medFile = SALOMEDS_Tool::GetNameFromPath( medFile ) + ".med"; hdfFile = SALOMEDS_Tool::GetNameFromPath( hdfFile ) + ".hdf"; - aFiles[0] = medFile.c_str(); - aFiles[1] = hdfFile.c_str(); + aFiles.push_back(medFile.c_str()); + aFiles.push_back(hdfFile.c_str()); - SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.c_str(), aFiles.in(), true ); + SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.c_str(), aFiles, true ); } } - //================================================================================ - /*! - * \brief Method useful only to set a breakpoint to debug in case of exception - */ - //================================================================================ - - void onExceptionCaught(const string& msg) - { - INFOS( msg ); - MYDEBUGOUT( msg ); - } - //============================================================================= /*! * \brief Class sending signals on start and finish of loading @@ -134,38 +109,35 @@ namespace class SignalToGUI { - string _messagePrefix; + std::string _messagePrefix; SALOME::Session_var _session; public: SignalToGUI( SMESH_Mesh_i* mesh ) { SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen(); - SALOMEDS::Study_var study = gen->GetCurrentStudy(); - if ( !study->_is_nil() && study->StudyId() == mesh->GetStudyId() ) + + SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject( mesh->_this() ); + CORBA::Object_var obj = gen->GetNS()->Resolve( "/Kernel/Session" ); + _session = SALOME::Session::_narrow( obj ); + if ( !meshSO->_is_nil() && !_session->_is_nil() ) { - SALOMEDS::SObject_var meshSO = gen->ObjectToSObject(study, mesh->_this() ); - CORBA::Object_var obj = gen->GetNS()->Resolve( "/Kernel/Session" ); - _session = SALOME::Session::_narrow( obj ); - if ( !meshSO->_is_nil() && !_session->_is_nil() ) - { - CORBA::String_var meshEntry = meshSO->GetID(); - _messagePrefix = "SMESH/mesh_loading/"; - _messagePrefix += meshEntry.in(); + CORBA::String_var meshEntry = meshSO->GetID(); + _messagePrefix = "SMESH/mesh_loading/"; + _messagePrefix += meshEntry.in(); - string msgToGUI = _messagePrefix + "/"; - msgToGUI += SMESH_Comment( mesh->NbNodes() ); - msgToGUI += "/"; - msgToGUI += SMESH_Comment( mesh->NbElements() ); + std::string msgToGUI = _messagePrefix + "/"; + msgToGUI += SMESH_Comment( mesh->NbNodes() ); + msgToGUI += "/"; + msgToGUI += SMESH_Comment( mesh->NbElements() ); - _session->emitMessageOneWay( msgToGUI.c_str()); - } + _session->emitMessageOneWay( msgToGUI.c_str()); } } void sendStop() { if ( !_messagePrefix.empty() ) { - string msgToGUI = _messagePrefix + "/stop"; + std::string msgToGUI = _messagePrefix + "/stop"; _session->emitMessageOneWay( msgToGUI.c_str()); _messagePrefix.clear(); } @@ -198,7 +170,7 @@ namespace SMDS_PositionPtr vertexPosition() const { return SMDS_PositionPtr( new SMDS_VertexPosition); } SMDS_PositionPtr defaultPosition() const { return SMDS_SpacePosition::originSpacePosition(); } typedef SMDS_PositionPtr (PositionCreator:: * FmakePos)() const; - vector myFuncTable; + std::vector myFuncTable; }; //================================================================================ @@ -207,12 +179,12 @@ namespace */ //================================================================================ - vector getSimpleSubMeshIds( SMESHDS_Mesh* meshDS, int shapeId ) + std::vector getSimpleSubMeshIds( SMESHDS_Mesh* meshDS, int shapeId ) { - vector ids; + std::vector ids; - list shapeQueue( 1, meshDS->IndexToShape( shapeId )); - list::iterator shape = shapeQueue.begin(); + std::list shapeQueue( 1, meshDS->IndexToShape( shapeId )); + std::list::iterator shape = shapeQueue.begin(); for ( ; shape != shapeQueue.end(); ++shape ) { if ( shape->IsNull() ) continue; @@ -247,59 +219,23 @@ namespace */ //================================================================================ - typedef map< MED::EGeometrieElement, SMDSAbs_EntityType > Tmed2smeshElemTypeMap; + typedef std::map< MED::EGeometrieElement, SMDSAbs_EntityType > Tmed2smeshElemTypeMap; const Tmed2smeshElemTypeMap& med2smeshElemTypeMap() { - static map< MED::EGeometrieElement, SMDSAbs_EntityType> med2smeshTypes; + static Tmed2smeshElemTypeMap med2smeshTypes; if ( med2smeshTypes.empty() ) { - med2smeshTypes[ MED::ePOINT1 ] = SMDSEntity_0D ; - med2smeshTypes[ MED::eSEG2 ] = SMDSEntity_Edge ; - med2smeshTypes[ MED::eSEG3 ] = SMDSEntity_Quad_Edge ; - med2smeshTypes[ MED::eTRIA3 ] = SMDSEntity_Triangle ; - med2smeshTypes[ MED::eTRIA6 ] = SMDSEntity_Quad_Triangle ; - med2smeshTypes[ MED::eQUAD4 ] = SMDSEntity_Quadrangle ; - med2smeshTypes[ MED::eQUAD8 ] = SMDSEntity_Quad_Quadrangle ; - med2smeshTypes[ MED::eQUAD9 ] = SMDSEntity_BiQuad_Quadrangle ; - med2smeshTypes[ MED::eTETRA4 ] = SMDSEntity_Tetra ; - med2smeshTypes[ MED::ePYRA5 ] = SMDSEntity_Pyramid ; - med2smeshTypes[ MED::ePENTA6 ] = SMDSEntity_Penta ; - med2smeshTypes[ MED::eHEXA8 ] = SMDSEntity_Hexa ; - med2smeshTypes[ MED::eOCTA12 ] = SMDSEntity_Hexagonal_Prism ; - med2smeshTypes[ MED::eTETRA10 ] = SMDSEntity_Quad_Tetra ; - med2smeshTypes[ MED::ePYRA13 ] = SMDSEntity_Quad_Pyramid ; - med2smeshTypes[ MED::ePENTA15 ] = SMDSEntity_Quad_Penta ; - med2smeshTypes[ MED::eHEXA20 ] = SMDSEntity_Quad_Hexa ; - med2smeshTypes[ MED::eHEXA27 ] = SMDSEntity_TriQuad_Hexa ; - med2smeshTypes[ MED::ePOLYGONE ] = SMDSEntity_Polygon ; - med2smeshTypes[ MED::ePOLYEDRE ] = SMDSEntity_Polyhedra ; - med2smeshTypes[ MED::eNONE ] = SMDSEntity_Node ; - med2smeshTypes[ MED::eBALL ] = SMDSEntity_Ball ; + for ( int iG = 0; iG < SMDSEntity_Last; ++iG ) + { + SMDSAbs_EntityType smdsType = (SMDSAbs_EntityType) iG; + MED::EGeometrieElement medType = + (MED::EGeometrieElement) DriverMED::GetMedGeoType( smdsType ); + med2smeshTypes.insert( std::make_pair( medType, smdsType )); + } } return med2smeshTypes; } - //================================================================================ - /*! - * \brief Return a vector intended to retrieve - * MED::EGeometrieElement by SMDSAbs_EntityType - */ - //================================================================================ - - const vector& mesh2medElemType() - { - static vector mesh2medElemTypes; - if ( mesh2medElemTypes.empty() ) - { - mesh2medElemTypes.resize( SMDSEntity_Last + 1 ); - Tmed2smeshElemTypeMap::const_iterator me2sme = med2smeshElemTypeMap().begin(); - Tmed2smeshElemTypeMap::const_iterator me2smeEnd = med2smeshElemTypeMap().end(); - for ( ; me2sme != me2smeEnd; ++me2sme ) - mesh2medElemTypes[ me2sme->second ] = me2sme->first; - } - return mesh2medElemTypes; - } - //================================================================================ /*! * \brief Writes meshInfo into a HDF file @@ -310,17 +246,17 @@ namespace const std::string& name, HDFgroup* hdfGroup) { - // we use med identification of element (MED::EGeometrieElement>) types + // we use med identification of element (MED::EGeometrieElement) types // but not enum SMDSAbs_EntityType because values of SMDSAbs_EntityType may // change at insertion of new items in the middle. - const vector& medTypes = mesh2medElemType(); + //const vector& medTypes = mesh2medElemType(); - vector data; + std::vector data; for ( size_t i = 0; i < meshInfo->length(); ++i ) - if ( meshInfo[i] > 0 ) + if ( meshInfo[i] > 0 || meshInfo[i] == GroupOnFilter_OutOfDate ) { - data.push_back( medTypes[ i ] ); + data.push_back( DriverMED::GetMedGeoType( SMDSAbs_EntityType( i ))); //medTypes[ i ] ); data.push_back( meshInfo[ i ] ); } @@ -346,10 +282,12 @@ namespace */ //================================================================================ -void SMESH_PreMeshInfo::hdf2meshInfo( const std::string& name, - HDFgroup* hdfGroup) +void SMESH_PreMeshInfo::hdf2meshInfo( const std::string& name, + HDFgroup* hdfGroup, + const TColStd_MapOfAsciiString& allHdfNames) { - if ( hdfGroup->ExistInternalObject( name.c_str()) ) + //if ( hdfGroup->ExistInternalObject( name.c_str()) ) PAL23514 + if ( allHdfNames.Contains( name.c_str() )) { HDFdataset* dataset = new HDFdataset( name.c_str(), hdfGroup ); dataset->OpenOnDisk(); @@ -359,7 +297,7 @@ void SMESH_PreMeshInfo::hdf2meshInfo( const std::string& name, // // array->GetDim( datasetSize ); // int size = dataset->GetSize(); - vector info( SMDSEntity_Last * 2, 0 ); + std::vector info( SMDSEntity_Last * 2, 0 ); dataset->ReadFromDisk( &info[0] ); dataset->CloseOnDisk(); @@ -430,7 +368,7 @@ void SMESH_PreMeshInfo::LoadFromFile( SMESH_Mesh_i* mesh, const std::string& hdfFile, const bool toRemoveFiles) { - PreMeshInfo_TRY; + SMESH_TRY; SMESH_PreMeshInfo* meshPreInfo = new SMESH_PreMeshInfo( mesh,meshID,medFile,hdfFile ); mesh->changePreMeshInfo() = meshPreInfo; @@ -454,7 +392,7 @@ void SMESH_PreMeshInfo::LoadFromFile( SMESH_Mesh_i* mesh, { meshPreInfo->FullLoadFromFile(); } - PreMeshInfo_CATCH; + SMESH_CATCH( SMESH::doNothing ); } //================================================================================ @@ -478,7 +416,17 @@ bool SMESH_PreMeshInfo::readPreInfoFromHDF() HDFgroup* infoHdfGroup = new HDFgroup( hdfGroupName, aFile ); infoHdfGroup->OpenOnDisk(); - _mesh->changePreMeshInfo()->hdf2meshInfo( "Mesh", infoHdfGroup ); + // PAL23514: get all names from the HDFgroup to avoid iteration on its contents + // within aGroup->ExistInternalObject( name ) + TColStd_MapOfAsciiString mapOfNames; + { + std::vector< std::string > subNames; + infoHdfGroup->GetAllObjects( subNames ); + for ( size_t iN = 0; iN < subNames.size(); ++iN ) + mapOfNames.Add( subNames[ iN ].c_str() ); + } + + _mesh->changePreMeshInfo()->hdf2meshInfo( "Mesh", infoHdfGroup, mapOfNames ); // read SMESH_PreMeshInfo of groups map::const_iterator i2group = _mesh->_mapGroups.begin(); @@ -490,8 +438,8 @@ bool SMESH_PreMeshInfo::readPreInfoFromHDF() group_i->changePreMeshInfo() = newInstance(); if ( SMESHDS_GroupBase* group = group_i->GetGroupDS() ) { - const string name = group->GetStoreName(); - group_i->changePreMeshInfo()->hdf2meshInfo( name, infoHdfGroup ); + const std::string name = group->GetStoreName(); + group_i->changePreMeshInfo()->hdf2meshInfo( name, infoHdfGroup, mapOfNames ); } } } @@ -503,7 +451,9 @@ bool SMESH_PreMeshInfo::readPreInfoFromHDF() if ( SMESH_subMesh_i* sm = SMESH::DownCast( id2sm->second )) { sm->changePreMeshInfo() = newInstance(); - sm->changePreMeshInfo()->hdf2meshInfo( SMESH_Comment( sm->GetId()), infoHdfGroup ); + sm->changePreMeshInfo()->hdf2meshInfo( SMESH_Comment( sm->GetId()), + infoHdfGroup, + mapOfNames ); } } } @@ -524,10 +474,7 @@ bool SMESH_PreMeshInfo::readMeshInfo() { _isInfoOk = true; - MED::PWrapper aMed = MED::CrWrapper(_medFileName,true); - // if ( aMed->GetVersion() != MED::eV2_2 ) - // return false; - + MED::PWrapper aMed = MED::CrWrapperR(_medFileName); MED::PMeshInfo medMeshInfo = aMed->CrMeshInfo(3,3,SMESH_Comment( _meshID )); // read nb nodes @@ -560,7 +507,7 @@ void SMESH_PreMeshInfo::readGroupInfo() if ( _mesh->_mapGroups.empty() ) return; // make SMESH_PreMeshInfo of groups - map< string, SMESH_PreMeshInfo* > name2GroupInfo; + map< std::string, SMESH_PreMeshInfo* > name2GroupInfo; map::const_iterator i2group = _mesh->_mapGroups.begin(); for ( ; i2group != _mesh->_mapGroups.end(); ++i2group ) { @@ -571,8 +518,8 @@ void SMESH_PreMeshInfo::readGroupInfo() group_i->changePreMeshInfo() = info; if ( SMESHDS_Group* group = dynamic_cast< SMESHDS_Group* >( group_i->GetGroupDS() )) { - string name = group->GetStoreName(); - name2GroupInfo.insert( make_pair( name, info )); + std::string name = group->GetStoreName(); + name2GroupInfo.insert( std::make_pair( name, info )); info->_isInfoOk = true; } } @@ -580,7 +527,7 @@ void SMESH_PreMeshInfo::readGroupInfo() map< int, vector< SMESH_PreMeshInfo* > > famId2grInfo; - MED::PWrapper aMed = MED::CrWrapper(_medFileName,false); + MED::PWrapper aMed = MED::CrWrapperR(_medFileName); MED::PMeshInfo medMeshInfo = aMed->CrMeshInfo(3,3,SMESH_Comment( _meshID )); // read families to fill in famId2grInfo @@ -595,8 +542,8 @@ void SMESH_PreMeshInfo::readGroupInfo() vector< SMESH_PreMeshInfo* >& grInfoVec = famId2grInfo[ medFamInfo->GetId() ]; for ( int iG = 0; iG < nbGroups; ++iG ) { - const string grName = medFamInfo->GetGroupName( iG ); - map< string, SMESH_PreMeshInfo* >::iterator n2i = name2GroupInfo.find( grName ); + const std::string grName = medFamInfo->GetGroupName( iG ); + map< std::string, SMESH_PreMeshInfo* >::iterator n2i = name2GroupInfo.find( grName ); if ( n2i != name2GroupInfo.end() ) grInfoVec.push_back( n2i->second ); } @@ -621,14 +568,14 @@ void SMESH_PreMeshInfo::readGroupInfo() f2infos = famId2grInfo.find( famNums[i] ); if ( f2infos == famId2grInfo.end() ) f2infos = famId2grInfo.insert - ( make_pair( famNums[i], vector< SMESH_PreMeshInfo*>())).first; + ( std::make_pair( famNums[i], vector< SMESH_PreMeshInfo*>())).first; } vector< SMESH_PreMeshInfo* >& infoVec = f2infos->second ; for ( size_t j = 0; j < infoVec.size(); ++j ) infoVec[j]->_elemCounter++; } // pass _elemCounter to a real elem type - map< string, SMESH_PreMeshInfo* >::iterator n2i = name2GroupInfo.begin(); + map< std::string, SMESH_PreMeshInfo* >::iterator n2i = name2GroupInfo.begin(); for ( ; n2i != name2GroupInfo.end(); ++n2i ) { SMESH_PreMeshInfo* info = n2i->second; @@ -679,7 +626,7 @@ void SMESH_PreMeshInfo::readSubMeshInfo() for ( int isNode = 0; isNode < 2; ++isNode ) { - string aDSName( isNode ? "Node Submeshes" : "Element Submeshes"); + std::string aDSName( isNode ? "Node Submeshes" : "Element Submeshes"); if ( aGroup->ExistInternalObject( (char*) aDSName.c_str() )) { // read sub-mesh id of all nodes or elems @@ -797,7 +744,7 @@ void SMESH_PreMeshInfo::SaveToFile( SMESH_Mesh_i* mesh, HDFgroup* infoHdfGroup = new HDFgroup( hdfGroupName, hdfFile ); infoHdfGroup->CreateOnDisk(); - PreMeshInfo_TRY; + SMESH_TRY; // info of mesh meshInfo2hdf( mesh->GetMeshInfo(), "Mesh", infoHdfGroup ); @@ -840,7 +787,7 @@ void SMESH_PreMeshInfo::SaveToFile( SMESH_Mesh_i* mesh, } } - PreMeshInfo_CATCH; + SMESH_CATCH( SMESH::doNothing ); infoHdfGroup->CloseOnDisk(); } @@ -861,7 +808,7 @@ void SMESH_PreMeshInfo::FullLoadFromFile() const ::SMESH_Mesh& mesh = _mesh->GetImpl(); SMESHDS_Mesh* meshDS = mesh.GetMeshDS(); - PreMeshInfo_TRY; + SMESH_TRY; MYDEBUGOUT( "BEG FullLoadFromFile() " << _meshID ); @@ -882,7 +829,7 @@ void SMESH_PreMeshInfo::FullLoadFromFile() const // load sub-meshes readSubMeshes( &myReader ); - PreMeshInfo_CATCH; + SMESH_CATCH( SMESH::doNothing ); _mesh->changePreMeshInfo() = meshInfo; @@ -929,6 +876,7 @@ void SMESH_PreMeshInfo::readSubMeshes(DriverMED_R_SMESHDS_Mesh* reader) const aDataset->ReadFromDisk( isModified ); aDataset->CloseOnDisk(); _mesh->GetImpl().SetIsModified( bool(*isModified)); + delete [] isModified; } bool submeshesInFamilies = ( ! aTopGroup->ExistInternalObject( "Submeshes" )); @@ -953,13 +901,13 @@ void SMESH_PreMeshInfo::readSubMeshes(DriverMED_R_SMESHDS_Mesh* reader) const SMDS_ElemIteratorPtr eIt = meshDS->elementsIterator(); for ( int isNode = 0; isNode < 2; ++isNode ) { - string aDSName( isNode ? "Node Submeshes" : "Element Submeshes"); + std::string aDSName( isNode ? "Node Submeshes" : "Element Submeshes"); if ( aGroup->ExistInternalObject( (char*) aDSName.c_str() )) { HDFdataset* aDataset = new HDFdataset( (char*) aDSName.c_str(), aGroup ); aDataset->OpenOnDisk(); // read submesh IDs for all elements sorted by ID - int nbElems = aDataset->GetSize(); + size_t nbElems = aDataset->GetSize(); int* smIDs = new int [ nbElems ]; aDataset->ReadFromDisk( smIDs ); aDataset->CloseOnDisk(); @@ -979,9 +927,9 @@ void SMESH_PreMeshInfo::readSubMeshes(DriverMED_R_SMESHDS_Mesh* reader) const #endif nbElems = elemSet.size(); } - // add elements to submeshes + // add elements to sub-meshes TIDSortedElemSet::iterator iE = elemSet.begin(); - for ( int i = 0; i < nbElems; ++i, ++iE ) + for ( size_t i = 0; i < nbElems; ++i, ++iE ) { int smID = smIDs[ i ]; if ( smID == 0 ) continue; @@ -1002,7 +950,7 @@ void SMESH_PreMeshInfo::readSubMeshes(DriverMED_R_SMESHDS_Mesh* reader) const if ( isNode ) { SMDS_PositionPtr pos = aPositionCreator.MakePosition( smType[ smID ]); SMDS_MeshNode* node = const_cast( static_cast( elem )); - node->SetPosition( pos ); + node->SetPosition( pos, sm->GetID() ); sm->AddNode( node ); } else { sm->AddElement( elem ); @@ -1103,8 +1051,7 @@ void SMESH_PreMeshInfo::readSubMeshes(DriverMED_R_SMESHDS_Mesh* reader) const // -- Most probably a bad study was saved when there were // not fixed bugs in SMDS_MeshInfo if ( aPos->GetTypeOfPosition() == SMDS_TOP_FACE ) { - SMDS_FacePosition* fPos = const_cast - ( static_cast( aPos )); + SMDS_FacePositionPtr fPos = aPos; fPos->SetUParameter( aUPos[ iNode ]); fPos->SetVParameter( aVPos[ iNode ]); } @@ -1112,9 +1059,8 @@ void SMESH_PreMeshInfo::readSubMeshes(DriverMED_R_SMESHDS_Mesh* reader) const else { // ASSERT( aPos->GetTypeOfPosition() == SMDS_TOP_EDGE );-- issue 20182 if ( aPos->GetTypeOfPosition() == SMDS_TOP_EDGE ) { - SMDS_EdgePosition* fPos = const_cast - ( static_cast( aPos )); - fPos->SetUParameter( aUPos[ iNode ]); + SMDS_EdgePositionPtr ePos = aPos; + ePos->SetUParameter( aUPos[ iNode ]); } } } @@ -1144,7 +1090,7 @@ void SMESH_PreMeshInfo::readSubMeshes(DriverMED_R_SMESHDS_Mesh* reader) const void SMESH_PreMeshInfo::ForgetAllData() const { - PreMeshInfo_TRY; + SMESH_TRY; if ( _mesh->changePreMeshInfo() != this ) return _mesh->changePreMeshInfo()->ForgetAllData(); @@ -1165,9 +1111,9 @@ void SMESH_PreMeshInfo::ForgetAllData() const map::iterator id2sm = _mesh->_mapSubMeshIor.begin(); for ( ; id2sm != _mesh->_mapSubMeshIor.end(); ++id2sm ) { - if ( SMESH_subMesh_i* sm = SMESH::DownCast( id2sm->second )) + if ( SMESH_subMesh_i* sm_i = SMESH::DownCast( id2sm->second )) { - SMESH_PreMeshInfo* & info = sm->changePreMeshInfo(); + SMESH_PreMeshInfo* & info = sm_i->changePreMeshInfo(); delete info; info = NULL; } @@ -1176,12 +1122,12 @@ void SMESH_PreMeshInfo::ForgetAllData() const _mesh->changePreMeshInfo() = NULL; delete this; - PreMeshInfo_CATCH; + SMESH_CATCH( SMESH::doNothing ); // Finalize loading - // PreMeshInfo_TRY; + // SMESH_TRY; // ::SMESH_Mesh& mesh = _mesh->GetImpl(); @@ -1192,7 +1138,19 @@ void SMESH_PreMeshInfo::ForgetAllData() const // // hyp->UpdateAsMeshesRestored(); - // PreMeshInfo_CATCH; + // SMESH_CATCH( SMESH::doNothing ); +} + +//================================================================================ +/*! + * \brief remove all SMESH_PreMeshInfo fields from mesh and its child objects w/o data loading + */ +//================================================================================ + +void SMESH_PreMeshInfo::ForgetAllData( SMESH_Mesh_i* mesh ) +{ + if ( mesh && mesh->changePreMeshInfo() ) + mesh->changePreMeshInfo()->ForgetAllData(); } //================================================================================ @@ -1271,13 +1229,12 @@ bool SMESH_PreMeshInfo::IsMeshInfoCorrect() const void SMESH_PreMeshInfo::RemoveStudyFiles_TMP_METHOD(SALOMEDS::SComponent_ptr smeshComp) { - SALOMEDS::Study_var study = smeshComp->GetStudy(); - if ( theStudyIDToMeshCounter[ (int) study->StudyId() ] > 0 ) + if ( theMeshCounter > 0 ) { - SALOMEDS::ChildIterator_var itBig = study->NewChildIterator( smeshComp ); + SALOMEDS::ChildIterator_wrap itBig = SMESH_Gen_i::getStudyServant()->NewChildIterator( smeshComp ); for ( ; itBig->More(); itBig->Next() ) { - SALOMEDS::SObject_var gotBranch = itBig->Value(); - CORBA::Object_var anObject = SMESH_Gen_i::SObjectToObject( gotBranch ); + SALOMEDS::SObject_wrap gotBranch = itBig->Value(); + CORBA::Object_var anObject = SMESH_Gen_i::SObjectToObject( gotBranch ); if ( SMESH_Mesh_i* mesh = SMESH::DownCast( anObject )) { if ( mesh->changePreMeshInfo() )