X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2FSMESH_I%2FSMESH_Mesh_i.cxx;h=99e45c66eec7ad7036eafd8818750c32cf5d043e;hb=063116fae29b1028d31042b8bb2ed15f1f7de41e;hp=2fc681ef523f0e0e9d29c4fbe88f5d1c78b79b53;hpb=0a447a3701c9274833f0964516261bcdfe7bbbb5;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 2fc681ef5..99e45c66e 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -3785,8 +3785,8 @@ CORBA::LongLong SMESH_Mesh_i::ExportMEDCoupling(CORBA::Boolean auto_groups, CORB MEDCoupling::MCAuto data; SMESH_TRY; // TODO : Fix me ! 2 next lines are required - //if( !this->_gen_i->IsEmbeddedMode() ) - // SMESH::throwCorbaException("SMESH_Mesh_i::ExportMEDCoupling : only for embedded mode !"); + if( !this->_gen_i->isSSLMode() ) + SMESH::throwCorbaException("SMESH_Mesh_i::ExportMEDCoupling : only for embedded mode !"); if ( _preMeshInfo ) _preMeshInfo->FullLoadFromFile(); @@ -3797,34 +3797,13 @@ CORBA::LongLong SMESH_Mesh_i::ExportMEDCoupling(CORBA::Boolean auto_groups, CORB return reinterpret_cast(ret); } -//================================================================================ -/*! - * \brief Export a mesh to a SAUV file - */ -//================================================================================ - -void SMESH_Mesh_i::ExportSAUV( const char* file, CORBA::Boolean auto_groups ) -{ - SMESH_TRY; - 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); - - SMESH_CATCH( SMESH::throwCorbaException ); -} - - //================================================================================ /*! * \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 ) @@ -3833,11 +3812,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 ); } @@ -3848,7 +3828,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 ) @@ -3857,11 +3837,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 ); } @@ -3896,22 +3877,32 @@ 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); } + 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) + 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); - + 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) + 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() ); @@ -3921,21 +3912,28 @@ public: } void prepareForWriting(SMESH_Mesh_i& self) { self.PrepareForWriting(_file.c_str(), _overwrite); } + private: - std::string _file; + std::string _file; CORBA::Boolean _overwrite; - CORBA::Long _version; + CORBA::Long _version; }; +//================================================================================ +/*! + * \brief Export a part of mesh to a med file + */ +//================================================================================ 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) +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) { SMESH_TRY; if ( _preMeshInfo ) @@ -3958,8 +3956,7 @@ void SMESH_Mesh_i::ExportPartToMEDCommon(SPECLS& speCls, 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; } @@ -3983,7 +3980,8 @@ void SMESH_Mesh_i::ExportPartToMEDCommon(SPECLS& speCls, SMESH::DownCast< SMESH_Mesh_i* >( meshPart )) { aMeshName = speCls.prepareMeshNameAndGroups(*this); - speCls.exportTo(_impl, aMeshName, auto_groups, nullptr, autoDimension, have0dField, ZTolerance); + speCls.exportTo(_impl, aMeshName, auto_groups, nullptr, autoDimension, + have0dField, ZTolerance, saveNumbers ); meshDS = _impl->GetMeshDS(); } else @@ -4000,7 +3998,8 @@ void SMESH_Mesh_i::ExportPartToMEDCommon(SPECLS& speCls, } SMESH_MeshPartDS* partDS = new SMESH_MeshPartDS( meshPart ); - speCls.exportTo(_impl, aMeshName, auto_groups, partDS, autoDimension, have0dField, ZTolerance); + speCls.exportTo(_impl, aMeshName, auto_groups, partDS, autoDimension, + have0dField, ZTolerance, saveNumbers); meshDS = tmpDSDeleter._obj = partDS; } @@ -4008,7 +4007,7 @@ void SMESH_Mesh_i::ExportPartToMEDCommon(SPECLS& speCls, if ( _impl->HasShapeToMesh() ) { - speCls.exportField(*this,aMeshName,have0dField,meshDS,fields,geomAssocFields); + speCls.exportField( *this, aMeshName, have0dField, meshDS, fields, geomAssocFields); } SMESH_CATCH( SMESH::throwCorbaException ); } @@ -4027,11 +4026,14 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, CORBA::Boolean autoDimension, const GEOM::ListOfFields& fields, const char* geomAssocFields, - CORBA::Double ZTolerance) + 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); + + 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; @@ -4050,44 +4052,73 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, << autoDimension << ", " << goList << ", '" << ( geomAssocFields ? geomAssocFields : "" ) << "'," - << TVar( ZTolerance ) + << TVar( ZTolerance ) << ", " + << saveNumbers << " )"; 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) + 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); + _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) + 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) { - THROW_IK_EXCEPTION("exportField Not implemented yet for full memory !"); + 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 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); - MEDCoupling::MCAuto res( spe.getData() ); - MEDCoupling::DataArrayByte *ret(res.retn()); + 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); } @@ -4366,20 +4397,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 ); } @@ -4389,8 +4417,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 ) @@ -4399,10 +4428,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 ); } @@ -5444,7 +5473,7 @@ SMESH::smIdType_array* SMESH_Mesh_i::GetElemNodes(const SMESH::smIdType id) if ( const SMDS_MeshElement* elem = aMeshDS->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(); } @@ -5568,7 +5597,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(); } } @@ -5651,7 +5680,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;