Salome HOME
Premiere implementation complete de ExportMEDCoupling. Go pour le debugging
[modules/smesh.git] / src / SMESH_I / SMESH_Mesh_i.cxx
index b2551f73933e5839fe24874b95f3f20e688613de..ae8012d1eacbfd94a3b21237b3be51937829e5e0 100644 (file)
@@ -3684,6 +3684,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 +3717,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,6 +3780,22 @@ void SMESH_Mesh_i::ExportMED(const char*    file,
   SMESH_CATCH( SMESH::throwCorbaException );
 }
 
+CORBA::LongLong SMESH_Mesh_i::ExportMEDCoupling(CORBA::Boolean auto_groups, CORBA::Boolean autoDimension)
+{
+  MEDCoupling::MCAuto<MEDCoupling::DataArrayByte> data;
+  SMESH_TRY;
+  if( !this->_gen_i->IsEmbeddedMode() )
+    SMESH::throwCorbaException("SMESH_Mesh_i::ExportMEDCoupling : only for embedded mode !");
+  if ( _preMeshInfo )
+    _preMeshInfo->FullLoadFromFile();
+
+  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<CORBA::LongLong>(ret);
+}
+
 //================================================================================
 /*!
  * \brief Export a mesh to a SAUV file