X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Mesh_i.cxx;h=b5c003e4c3b292fc5764cd60495a741205b11ac3;hp=b2551f73933e5839fe24874b95f3f20e688613de;hb=HEAD;hpb=db83efeef8e138c5871f1a3ca8d5d4a64653b663 diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index b2551f739..e1c8ca916 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -57,6 +57,7 @@ #include "SMESH_PreMeshInfo.hxx" #include "SMESH_PythonDump.hxx" #include "SMESH_subMesh_i.hxx" +#include "SMESH_Meshio.h" #include #include @@ -96,12 +97,6 @@ #include "SMESH_TryCatch.hxx" // include after OCCT headers! -#ifdef _DEBUG_ -static int MYDEBUG = 0; -#else -static int MYDEBUG = 0; -#endif - using namespace std; using SMESH::TPythonDump; using SMESH::TVar; @@ -664,7 +659,7 @@ SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubShape, if ( prevNbMeshEnt > 0 /*newNbMeshEnt != prevNbMeshEnt*/ ) _gen_i->UpdateIcons( mesh ); } - if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status ); + MESSAGE( " AddHypothesis(): status = " << status ); // Update Python script TPythonDump() << "status = " << mesh << ".AddHypothesis( " @@ -684,7 +679,7 @@ SMESH_Mesh_i::addHypothesis(GEOM::GEOM_Object_ptr aSubShape, SMESH::SMESH_Hypothesis_ptr anHyp, std::string* anErrorText) { - if(MYDEBUG) MESSAGE("addHypothesis"); + MESSAGE("addHypothesis"); if (CORBA::is_nil( aSubShape ) && HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION("bad Sub-shape reference",SALOME::BAD_PARAM); @@ -770,7 +765,7 @@ SMESH_Hypothesis::Hypothesis_Status SMESH_Mesh_i::removeHypothesis(GEOM::GEOM_Object_ptr aSubShape, SMESH::SMESH_Hypothesis_ptr anHyp) { - if(MYDEBUG) MESSAGE("removeHypothesis()"); + MESSAGE("removeHypothesis()"); if (CORBA::is_nil( aSubShape ) && HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION("bad Sub-shape reference", SALOME::BAD_PARAM); @@ -816,7 +811,7 @@ SMESH::ListOfHypothesis * SMESH_Mesh_i::GetHypothesisList(GEOM::GEOM_Object_ptr aSubShape) { Unexpect aCatch(SALOME_SalomeException); - if (MYDEBUG) MESSAGE("GetHypothesisList"); + MESSAGE("GetHypothesisList"); if (_impl->HasShapeToMesh() && CORBA::is_nil(aSubShape)) THROW_SALOME_CORBA_EXCEPTION("bad Sub-shape reference", SALOME::BAD_PARAM); @@ -856,7 +851,7 @@ SMESH_Mesh_i::GetHypothesisList(GEOM::GEOM_Object_ptr aSubShape) SMESH::submesh_array* SMESH_Mesh_i::GetSubMeshes() { Unexpect aCatch(SALOME_SalomeException); - if (MYDEBUG) MESSAGE("GetSubMeshes"); + MESSAGE("GetSubMeshes"); SMESH::submesh_array_var aList = new SMESH::submesh_array(); @@ -1220,7 +1215,7 @@ void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup SMESH::ListOfGroups * SMESH_Mesh_i::GetGroups() { Unexpect aCatch(SALOME_SalomeException); - if (MYDEBUG) MESSAGE("GetGroups"); + MESSAGE("GetGroups"); SMESH::ListOfGroups_var aList = new SMESH::ListOfGroups(); @@ -2415,9 +2410,11 @@ void SMESH_Mesh_i::CheckGeomModif( bool theIsBreakLink ) { smIdType nb = NbNodes() + NbElements(); CheckGeomGroupModif(); - if ( nb != NbNodes() + NbElements() ) // something removed due to hypotheses change + bool updated = ( nb != NbNodes() + NbElements() ); + if ( updated ) // something removed due to hypotheses change _gen_i->UpdateIcons( me ); - return; + if ( updated == geomChanged || nb == 0 ) + return; } // Update after shape modification or breakLink w/o geometry change @@ -2504,7 +2501,7 @@ void SMESH_Mesh_i::CheckGeomModif( bool theIsBreakLink ) } old2newShapeMap.Bind( group->GetShape(), groupsData.back()._shape ); } - + } } // store assigned hypotheses @@ -3120,7 +3117,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::ConvertToStandalone( SMESH::SMESH_GroupBase SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject ) { - if(MYDEBUG) MESSAGE( "createSubMesh" ); + MESSAGE( "createSubMesh" ); TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(theSubShapeObject); ::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape); int subMeshId = 0; @@ -3152,8 +3149,7 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Object_ptr theS // register CORBA object for persistence int nextId = _gen_i->RegisterObject( subMesh ); - if(MYDEBUG) { MESSAGE( "Add submesh to map with id = "<< nextId); } - else { (void)nextId; } // avoid "unused variable" warning + MESSAGE( "Add submesh to map with id = "<< nextId); // to track changes of GEOM groups if ( subMeshId > 0 ) @@ -3289,8 +3285,7 @@ SMESH::SMESH_GroupBase_ptr SMESH_Mesh_i::createGroup (SMESH::ElementType // register CORBA object for persistence int nextId = _gen_i->RegisterObject( aGroup ); - if(MYDEBUG) { MESSAGE( "Add group to map with id = "<< nextId); } - else { nextId = ( nextId > 0 ); } // avoid "unused variable" warning in release mode + MESSAGE( "Add group to map with id = "<< nextId); // to track changes of GEOM groups if ( !theShape.IsNull() ) { @@ -3311,7 +3306,7 @@ SMESH::SMESH_GroupBase_ptr SMESH_Mesh_i::createGroup (SMESH::ElementType void SMESH_Mesh_i::removeGroup( const int theId ) { - if(MYDEBUG) MESSAGE("SMESH_Mesh_i::removeGroup()" ); + MESSAGE("SMESH_Mesh_i::removeGroup()"); if ( _mapGroups.find( theId ) != _mapGroups.end() ) { SMESH::SMESH_GroupBase_var group = _mapGroups[theId]; _mapGroups.erase( theId ); @@ -3478,7 +3473,7 @@ void SMESH_Mesh_i::onHypothesisModified(int theHypID, bool theUpdateIcons) void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl) { - if(MYDEBUG) MESSAGE("SMESH_Mesh_i::SetImpl"); + MESSAGE("SMESH_Mesh_i::SetImpl"); _impl = impl; if ( _impl ) _impl->SetCallUp( new TCallUp_i(this)); @@ -3492,7 +3487,7 @@ void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl) ::SMESH_Mesh & SMESH_Mesh_i::GetImpl() { - if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetImpl()"); + MESSAGE("SMESH_Mesh_i::GetImpl()"); return *_impl; } @@ -3684,6 +3679,25 @@ void SMESH_Mesh_i::PrepareForWriting (const char* file, bool overwrite) } } +/*! + Return a MeshName + */ +std::string SMESH_Mesh_i::generateMeshName() +{ + string aMeshName = "Mesh"; + SALOMEDS::Study_var aStudy = SMESH_Gen_i::GetSMESHGen()->getStudyServant(); + if ( !aStudy->_is_nil() ) + { + SALOMEDS::SObject_wrap aMeshSO = _gen_i->ObjectToSObject( _this() ); + if ( !aMeshSO->_is_nil() ) + { + CORBA::String_var name = aMeshSO->GetName(); + aMeshName = name; + } + } + return aMeshName; +} + //================================================================================ /*! * \brief Prepare a file for export and pass names of mesh groups from study to mesh DS @@ -3698,13 +3712,11 @@ string SMESH_Mesh_i::prepareMeshNameAndGroups(const char* file, { // Perform Export PrepareForWriting(file, overwrite); - string aMeshName = "Mesh"; + string aMeshName(this->generateMeshName()); SALOMEDS::Study_var aStudy = SMESH_Gen_i::GetSMESHGen()->getStudyServant(); if ( !aStudy->_is_nil() ) { SALOMEDS::SObject_wrap aMeshSO = _gen_i->ObjectToSObject( _this() ); if ( !aMeshSO->_is_nil() ) { - CORBA::String_var name = aMeshSO->GetName(); - aMeshName = name; // asv : 27.10.04 : fix of 6903: check for StudyLocked before adding attributes if ( !aStudy->GetProperties()->IsLocked() ) { @@ -3763,34 +3775,30 @@ void SMESH_Mesh_i::ExportMED(const char* file, SMESH_CATCH( SMESH::throwCorbaException ); } -//================================================================================ -/*! - * \brief Export a mesh to a SAUV file - */ -//================================================================================ - -void SMESH_Mesh_i::ExportSAUV( const char* file, CORBA::Boolean auto_groups ) +CORBA::LongLong SMESH_Mesh_i::ExportMEDCoupling(CORBA::Boolean auto_groups, CORBA::Boolean autoDimension) { + MEDCoupling::MCAuto data; SMESH_TRY; + // TODO : Fix me ! 2 next lines are required + if( !this->_gen_i->isSSLMode() ) + SMESH::throwCorbaException("SMESH_Mesh_i::ExportMEDCoupling : only for embedded mode !"); if ( _preMeshInfo ) _preMeshInfo->FullLoadFromFile(); - string aMeshName = prepareMeshNameAndGroups(file, true); - TPythonDump() << SMESH::SMESH_Mesh_var( _this()) - << ".ExportSAUV( r'" << file << "', " << auto_groups << " )"; - _impl->ExportSAUV(file, aMeshName.c_str(), auto_groups); - + string aMeshName = this->generateMeshName(); + data = _impl->ExportMEDCoupling( aMeshName.c_str(), auto_groups, 0, autoDimension ); SMESH_CATCH( SMESH::throwCorbaException ); + MEDCoupling::DataArrayByte *ret(data.retn()); + return reinterpret_cast(ret); } - //================================================================================ /*! * \brief Export a mesh to a DAT file */ //================================================================================ -void SMESH_Mesh_i::ExportDAT (const char *file) +void SMESH_Mesh_i::ExportDAT (const char *file, CORBA::Boolean renumber ) { SMESH_TRY; if ( _preMeshInfo ) @@ -3799,11 +3807,12 @@ void SMESH_Mesh_i::ExportDAT (const char *file) // check names of groups checkGroupNames(); // Update Python script - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportDAT( r'" << file << "' )"; + TPythonDump() << SMESH::SMESH_Mesh_var(_this()) + << ".ExportDAT( r'" << file<< ", " << renumber << "' )"; // Perform Export - PrepareForWriting(file); - _impl->ExportDAT(file); + PrepareForWriting( file ); + _impl->ExportDAT( file, /*part=*/nullptr, renumber ); SMESH_CATCH( SMESH::throwCorbaException ); } @@ -3814,7 +3823,7 @@ void SMESH_Mesh_i::ExportDAT (const char *file) */ //================================================================================ -void SMESH_Mesh_i::ExportUNV (const char *file) +void SMESH_Mesh_i::ExportUNV (const char *file, CORBA::Boolean renumber) { SMESH_TRY; if ( _preMeshInfo ) @@ -3823,11 +3832,12 @@ void SMESH_Mesh_i::ExportUNV (const char *file) // check names of groups checkGroupNames(); // Update Python script - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportUNV( r'" << file << "' )"; + TPythonDump() << SMESH::SMESH_Mesh_var(_this()) + << ".ExportUNV( r'" << file << "', " << renumber << " )"; // Perform Export - PrepareForWriting(file); - _impl->ExportUNV(file); + PrepareForWriting( file ); + _impl->ExportUNV( file, /*part=*/nullptr, renumber ); SMESH_CATCH( SMESH::throwCorbaException ); } @@ -3862,23 +3872,64 @@ void SMESH_Mesh_i::ExportSTL (const char *file, const bool isascii) SMESH_CATCH( SMESH::throwCorbaException ); } +//================================================================================ + +class MEDFileSpeCls +{ +public: + MEDFileSpeCls(const char * file, + CORBA::Boolean overwrite, + CORBA::Long version) + :_file(file), _overwrite(overwrite), _version(version) + {} + std::string prepareMeshNameAndGroups(SMESH_Mesh_i& self) + { + return self.prepareMeshNameAndGroups(_file.c_str(),_overwrite); + } + + void exportTo(SMESH_Mesh *mesh, const std::string& aMeshName, CORBA::Boolean auto_groups, + SMESH_MeshPartDS* partDS, CORBA::Boolean autoDimension, bool have0dField, + CORBA::Double ZTolerance, CORBA::Boolean saveNumbers ) + { + mesh->ExportMED( _file.c_str(), aMeshName.c_str(), auto_groups, _version, + partDS, autoDimension, have0dField, ZTolerance, saveNumbers ); + } + + void exportField(SMESH_Mesh_i& self, const std::string& aMeshName, bool have0dField, + SMESHDS_Mesh *meshDS, const GEOM::ListOfFields& fields, + const char*geomAssocFields) + { + DriverMED_W_Field fieldWriter; + fieldWriter.SetFile( _file.c_str() ); + fieldWriter.SetMeshName( aMeshName ); + fieldWriter.AddODOnVertices( have0dField ); + self.exportMEDFields( fieldWriter, meshDS, fields, geomAssocFields ); + } + + void prepareForWriting(SMESH_Mesh_i& self) { self.PrepareForWriting(_file.c_str(), _overwrite); } + +private: + std::string _file; + CORBA::Boolean _overwrite; + CORBA::Long _version; +}; + //================================================================================ /*! * \brief Export a part of mesh to a med file */ //================================================================================ -void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, - const char* file, - CORBA::Boolean auto_groups, - CORBA::Long version, - CORBA::Boolean overwrite, - CORBA::Boolean autoDimension, - const GEOM::ListOfFields& fields, - const char* geomAssocFields, - CORBA::Double ZTolerance) +template +void SMESH_Mesh_i::ExportPartToMEDCommon(SPECLS& speCls, + SMESH::SMESH_IDSource_ptr meshPart, + CORBA::Boolean auto_groups, + CORBA::Boolean autoDimension, + const GEOM::ListOfFields& fields, + const char* geomAssocFields, + CORBA::Double ZTolerance, + CORBA::Boolean saveNumbers) { - MESSAGE("MED version: "<< version); SMESH_TRY; if ( _preMeshInfo ) _preMeshInfo->FullLoadFromFile(); @@ -3900,8 +3951,7 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, if ( fieldShape->_is_nil() ) THROW_SALOME_CORBA_EXCEPTION( "Null shape under a field", SALOME::INTERNAL_ERROR ); if ( !fieldShape->IsSame( shapeToMesh ) ) - THROW_SALOME_CORBA_EXCEPTION - ( "Field defined not on shape", SALOME::BAD_PARAM); + THROW_SALOME_CORBA_EXCEPTION( "Field defined not on shape", SALOME::BAD_PARAM); if ( fields[i]->GetDimension() == 0 ) have0dField = true; } @@ -3924,10 +3974,9 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, if ( CORBA::is_nil( meshPart ) || SMESH::DownCast< SMESH_Mesh_i* >( meshPart )) { - aMeshName = prepareMeshNameAndGroups(file, overwrite); - _impl->ExportMED( file, aMeshName.c_str(), auto_groups, version, - 0, autoDimension, /*addODOnVertices=*/have0dField, - ZTolerance); + aMeshName = speCls.prepareMeshNameAndGroups(*this); + speCls.exportTo(_impl, aMeshName, auto_groups, nullptr, autoDimension, + have0dField, ZTolerance, saveNumbers ); meshDS = _impl->GetMeshDS(); } else @@ -3935,7 +3984,7 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, if ( _preMeshInfo ) _preMeshInfo->FullLoadFromFile(); - PrepareForWriting(file, overwrite); + speCls.prepareForWriting(*this); SALOMEDS::SObject_wrap SO = _gen_i->ObjectToSObject( meshPart ); if ( !SO->_is_nil() ) { @@ -3944,8 +3993,8 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, } SMESH_MeshPartDS* partDS = new SMESH_MeshPartDS( meshPart ); - _impl->ExportMED( file, aMeshName.c_str(), auto_groups, version, - partDS, autoDimension, /*addODOnVertices=*/have0dField, ZTolerance); + speCls.exportTo(_impl, aMeshName, auto_groups, partDS, autoDimension, + have0dField, ZTolerance, saveNumbers); meshDS = tmpDSDeleter._obj = partDS; } @@ -3953,15 +4002,35 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, if ( _impl->HasShapeToMesh() ) { - DriverMED_W_Field fieldWriter; - fieldWriter.SetFile( file ); - fieldWriter.SetMeshName( aMeshName ); - fieldWriter.AddODOnVertices( have0dField ); - - exportMEDFields( fieldWriter, meshDS, fields, geomAssocFields ); + speCls.exportField( *this, aMeshName, have0dField, meshDS, fields, geomAssocFields); } + SMESH_CATCH( SMESH::throwCorbaException ); +} +//================================================================================ +/*! + * \brief Export a part of mesh to a med file + */ +//================================================================================ + +void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, + const char* file, + CORBA::Boolean auto_groups, + CORBA::Long version, + CORBA::Boolean overwrite, + CORBA::Boolean autoDimension, + const GEOM::ListOfFields& fields, + const char* geomAssocFields, + CORBA::Double ZTolerance, + CORBA::Boolean saveNumbers) +{ + MESSAGE("MED version: "<< version); + + MEDFileSpeCls spe( file, overwrite, version ); + this->ExportPartToMEDCommon( spe, meshPart, auto_groups, autoDimension, fields, + geomAssocFields, ZTolerance, saveNumbers ); // dump + SMESH_TRY; GEOM::ListOfGBO_var goList = new GEOM::ListOfGBO; goList->length( fields.length() ); for ( size_t i = 0; i < fields.length(); ++i ) @@ -3978,10 +4047,123 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, << autoDimension << ", " << goList << ", '" << ( geomAssocFields ? geomAssocFields : "" ) << "'," - << TVar( ZTolerance ) + << TVar( ZTolerance ) << ", " + << saveNumbers << " )"; + SMESH_CATCH( SMESH::throwCorbaException ); +} + +//================================================================================ +/*! + * \brief Export a part of mesh to a file with meshio library + */ +//================================================================================ + +void SMESH_Mesh_i::ExportPartToMESHIO(SMESH::SMESH_IDSource_ptr meshPart, + const char* file, + const char* selectedFilter) +{ + // Get default MED version + SMESH::long_array_var medVersions = GetMEDVersionsCompatibleForAppend(); + const CORBA::Long version = medVersions[0]; + MESSAGE("Export part with meshio through MED version: " << version); + + // Default values are the same as for MED export + const bool auto_groups = false; + const bool overwrite = true; + const bool autoDimension = true; + const GEOM::ListOfFields fields; + const char* geomAssocFields = ""; + const double ZTolerance = -1.0; + const bool saveNumbers = true; + + // Create an object that holds a temp file name and + // removes the file when goes out of scope. + SMESH_Meshio meshio(selectedFilter); + const QString tempFileName = meshio.CreateTempFileName(file); + + // Export a given mesh into the temp file + MEDFileSpeCls spe(tempFileName.toUtf8().data(), overwrite, version); + this->ExportPartToMEDCommon(spe, meshPart, auto_groups, autoDimension, fields, + geomAssocFields, ZTolerance, saveNumbers); + + // Convert temp file into a target one with meshio command + meshio.Convert(tempFileName, file); + + // Prepare python dump + SMESH_TRY; + + TPythonDump() << _this() << ".ExportPartToMESHIO(" + << meshPart << ", r'" + << file << "', '" + << selectedFilter << "'" + << ")"; + + SMESH_CATCH(SMESH::throwCorbaException); +} + +//================================================================================ + +class MEDFileMemSpeCls +{ +public: + std::string prepareMeshNameAndGroups(SMESH_Mesh_i& self) { return self.generateMeshName(); } + + void exportTo(SMESH_Mesh *mesh, const std::string& aMeshName, CORBA::Boolean auto_groups, + SMESH_MeshPartDS* partDS, CORBA::Boolean autoDimension, bool have0dField, + CORBA::Double ZTolerance, CORBA::Boolean saveNumbers ) + { + _res = mesh->ExportMEDCoupling(aMeshName.c_str(), auto_groups, partDS, + autoDimension, have0dField, ZTolerance, saveNumbers ); + } + void prepareForWriting(SMESH_Mesh_i& /*self*/) { /* nothing here */ } + + void exportField(SMESH_Mesh_i& self, const std::string& aMeshName, bool have0dField, + SMESHDS_Mesh *meshDS, const GEOM::ListOfFields& fields, + const char*geomAssocFields) + { + DriverMED_W_Field_Mem fieldWriter(_res); + fieldWriter.SetMeshName( aMeshName ); + fieldWriter.AddODOnVertices( have0dField ); + self.exportMEDFields( fieldWriter, meshDS, fields, geomAssocFields ); + _res = fieldWriter.getData(); + } +public: + MEDCoupling::MCAuto getData() { return _res; } + +private: + MEDCoupling::MCAuto _res; +}; + +//================================================================================ +/*! + * \brief Export a part of mesh to a MEDCoupling DS + */ +//================================================================================ + +CORBA::LongLong SMESH_Mesh_i::ExportPartToMEDCoupling(SMESH::SMESH_IDSource_ptr meshPart, + CORBA::Boolean auto_groups, + CORBA::Boolean autoDimension, + const GEOM::ListOfFields& fields, + const char* geomAssocFields, + CORBA::Double ZTolerance, + CORBA::Boolean saveNumbers) +{ + MEDCoupling::MCAuto data; + + SMESH_TRY; + if( !this->_gen_i->isSSLMode() ) + SMESH::throwCorbaException("SMESH_Mesh_i::ExportPartToMEDCoupling : only for embedded mode !"); + + MEDFileMemSpeCls spe; + this->ExportPartToMEDCommon( spe, meshPart, auto_groups, autoDimension, fields, geomAssocFields, + ZTolerance, saveNumbers ); + data = spe.getData(); SMESH_CATCH( SMESH::throwCorbaException ); + + MEDCoupling::DataArrayByte *ret(data.retn()); + return reinterpret_cast(ret); } //================================================================================ @@ -4259,20 +4441,17 @@ void SMESH_Mesh_i::exportMEDFields( DriverMED_W_Field& fieldWriter, */ //================================================================================ -void SMESH_Mesh_i::ExportPartToDAT(::SMESH::SMESH_IDSource_ptr meshPart, - const char* file) +void SMESH_Mesh_i::ExportPartToDAT(SMESH::SMESH_IDSource_ptr meshPart, + const char* file, + CORBA::Boolean renumber ) { SMESH_TRY; - if ( _preMeshInfo ) - _preMeshInfo->FullLoadFromFile(); - - PrepareForWriting(file); SMESH_MeshPartDS partDS( meshPart ); - _impl->ExportDAT(file,&partDS); + _impl->ExportDAT( file, &partDS, renumber ); TPythonDump() << SMESH::SMESH_Mesh_var(_this()) - << ".ExportPartToDAT( " << meshPart << ", r'" << file << "' )"; + << ".ExportPartToDAT( " << meshPart << ", r'" << file << ", " << renumber << "' )"; SMESH_CATCH( SMESH::throwCorbaException ); } @@ -4282,8 +4461,9 @@ void SMESH_Mesh_i::ExportPartToDAT(::SMESH::SMESH_IDSource_ptr meshPart, */ //================================================================================ -void SMESH_Mesh_i::ExportPartToUNV(::SMESH::SMESH_IDSource_ptr meshPart, - const char* file) +void SMESH_Mesh_i::ExportPartToUNV(SMESH::SMESH_IDSource_ptr meshPart, + const char* file, + CORBA::Boolean renumber) { SMESH_TRY; if ( _preMeshInfo ) @@ -4292,10 +4472,10 @@ void SMESH_Mesh_i::ExportPartToUNV(::SMESH::SMESH_IDSource_ptr meshPart, PrepareForWriting(file); SMESH_MeshPartDS partDS( meshPart ); - _impl->ExportUNV(file, &partDS); + _impl->ExportUNV(file, &partDS, renumber ); TPythonDump() << SMESH::SMESH_Mesh_var(_this()) - << ".ExportPartToUNV( " << meshPart<< ", r'" << file << "' )"; + << ".ExportPartToUNV( " << meshPart<< ", r'" << file << ", " << renumber << "' )"; SMESH_CATCH( SMESH::throwCorbaException ); } @@ -5051,7 +5231,7 @@ CORBA::LongLong SMESH_Mesh_i::GetMeshPtr() _preMeshInfo->FullLoadFromFile(); CORBA::LongLong pointeur = CORBA::LongLong(_impl); - if ( MYDEBUG ) MESSAGE("CORBA::LongLong SMESH_Mesh_i::GetMeshPtr() "<FindElement(id) ) { aResult->length( elem->NbNodes() ); - for ( SMESH::smIdType i = 0; i < aResult->length(); ++i ) + for ( CORBA::ULong i = 0; i < aResult->length(); ++i ) if ( const SMDS_MeshNode* n = elem->GetNode( i )) aResult[ i ] = n->GetID(); } @@ -5461,7 +5641,7 @@ SMESH::smIdType_array* SMESH_Mesh_i::GetElemFaceNodes(SMESH::smIdType elemId, { aResult->length( vtool.NbFaceNodes( faceIndex )); const SMDS_MeshNode** nn = vtool.GetFaceNodes( faceIndex ); - for ( SMESH::smIdType i = 0; i < aResult->length(); ++i ) + for ( CORBA::ULong i = 0; i < aResult->length(); ++i ) aResult[ i ] = nn[ i ]->GetID(); } } @@ -5544,7 +5724,7 @@ SMESH::smIdType_array* SMESH_Mesh_i::GetElementsByNodes(const SMESH::smIdType_ar if ( SMESHDS_Mesh* mesh = _impl->GetMeshDS() ) { vector< const SMDS_MeshNode * > nn( nodes.length() ); - for ( SMESH::smIdType i = 0; i < nodes.length(); ++i ) + for ( CORBA::ULong i = 0; i < nodes.length(); ++i ) nn[i] = mesh->FindNode( nodes[i] ); std::vector elems; @@ -5793,8 +5973,7 @@ void SMESH_Mesh_i::CreateGroupServants() // register CORBA object for persistence int nextId = _gen_i->RegisterObject( groupVar ); - if(MYDEBUG) { MESSAGE( "Add group to map with id = "<< nextId); } - else { (void)nextId; } // avoid "unused variable" warning in release mode + MESSAGE( "Add group to map with id = "<< nextId); // publishing the groups in the study GEOM::GEOM_Object_var shapeVar = _gen_i->ShapeToGeomObject( shape ); @@ -5825,7 +6004,7 @@ void SMESH_Mesh_i::CreateGroupServants() */ //============================================================================= -bool SMESH_Mesh_i::IsComputedOK() +CORBA::Boolean SMESH_Mesh_i::IsComputedOK() { return _impl->IsComputedOK(); } @@ -6032,8 +6211,8 @@ SMESH::SMESH_Mesh_ptr SMESH_Mesh_i::GetMesh() /*! * \brief Return false if GetMeshInfo() return incorrect information that may * happen if mesh data is not yet fully loaded from the file of study. - * - * + * + * */ //================================================================================ @@ -6899,6 +7078,7 @@ TListOfListOfInt SMESH_Mesh_i::findConcurrentSubMeshes() return res; } + //============================================================================= /*! * \brief Convert submesh ids into submesh interfaces @@ -7091,7 +7271,7 @@ smIdType SMESH_MeshPartDS::MinNodeID() const { if ( _meshDS ) return _meshDS->MinNodeID(); return NbNodes() == 0 ? 0 : (*_elements[ SMDSAbs_Node ].begin())->GetID(); -} +} // ------------------------------------------------------------------------------------- smIdType SMESH_MeshPartDS::MaxElementID() const {