Salome HOME
untabify
[modules/smesh.git] / src / SMESH_I / SMESH_Mesh_i.cxx
index 36604c7f8509de6d8e9f0bf73a73a4f91ed26f32..b8635aadf7c8528efb4ec347806d9cab1336fc75 100644 (file)
@@ -665,6 +665,42 @@ throw(SALOME::SALOME_Exception)
   return aList._retn();
 }
 
+SMESH::submesh_array* SMESH_Mesh_i::GetSubMeshes() throw (SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  if (MYDEBUG) MESSAGE("GetSubMeshes");
+
+  SMESH::submesh_array_var aList = new SMESH::submesh_array();
+
+  // Python Dump
+  TPythonDump aPythonDump;
+  if ( !_mapSubMeshIor.empty() )
+    aPythonDump << "[ ";
+
+  try {
+    aList->length( _mapSubMeshIor.size() );
+    int i = 0;
+    map<int, SMESH::SMESH_subMesh_ptr>::iterator it = _mapSubMeshIor.begin();
+    for ( ; it != _mapSubMeshIor.end(); it++ ) {
+      if ( CORBA::is_nil( it->second )) continue;
+      aList[i++] = SMESH::SMESH_subMesh::_duplicate( it->second );
+      // Python Dump
+      if (i > 1) aPythonDump << ", ";
+      aPythonDump << it->second;
+    }
+    aList->length( i );
+  }
+  catch(SALOME_Exception & S_ex) {
+    THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+  }
+
+  // Update Python script
+  if ( !_mapSubMeshIor.empty() )
+    aPythonDump << " ] = " << _this() << ".GetSubMeshes()";
+
+  return aList._retn();
+}
+
 //=============================================================================
 /*!
  *
@@ -2512,14 +2548,9 @@ void SMESH_Mesh_i::PrepareForWriting (const char* file, bool overwrite)
   }
 }
 
-void SMESH_Mesh_i::ExportToMEDX (const char* file,
-                                 CORBA::Boolean auto_groups,
-                                 SMESH::MED_VERSION theVersion,
-                                 CORBA::Boolean overwrite)
-  throw(SALOME::SALOME_Exception)
+string SMESH_Mesh_i::PrepareMeshNameAndGroups(const char* file,
+                                              CORBA::Boolean overwrite)
 {
-  Unexpect aCatch(SALOME_SalomeException);
-
   // Perform Export
   PrepareForWriting(file, overwrite);
   string aMeshName = "Mesh";
@@ -2554,6 +2585,17 @@ void SMESH_Mesh_i::ExportToMEDX (const char* file,
   // check names of groups
   checkGroupNames();
 
+  return aMeshName;
+}
+
+void SMESH_Mesh_i::ExportToMEDX (const char* file,
+                                 CORBA::Boolean auto_groups,
+                                 SMESH::MED_VERSION theVersion,
+                                 CORBA::Boolean overwrite)
+  throw(SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  string aMeshName = PrepareMeshNameAndGroups(file, true);
   TPythonDump() << _this() << ".ExportToMEDX( r'"
                 << file << "', " << auto_groups << ", " << theVersion << ", " << overwrite << " )";
 
@@ -2587,6 +2629,23 @@ void SMESH_Mesh_i::ExportMED (const char* file,
   ExportToMEDX(file,auto_groups,SMESH::MED_V2_2,true);
 }
 
+//================================================================================
+/*!
+ * \brief Export a mesh to a SAUV file
+ */
+//================================================================================
+
+void SMESH_Mesh_i::ExportSAUV (const char* file,
+                               CORBA::Boolean auto_groups)
+  throw(SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  string aMeshName = PrepareMeshNameAndGroups(file, true);
+  TPythonDump() << _this() << ".ExportSAUV( r'" << file << "', " << auto_groups << " )";
+  _impl->ExportSAUV(file, aMeshName.c_str(), auto_groups);
+}
+
+
 //================================================================================
 /*!
  * \brief Export a mesh to a DAT file
@@ -2784,6 +2843,7 @@ void SMESH_Mesh_i::ExportCGNS(::SMESH::SMESH_IDSource_ptr meshPart,
                               CORBA::Boolean              overwrite)
   throw (SALOME::SALOME_Exception)
 {
+#ifdef WITH_CGNS
   Unexpect aCatch(SALOME_SalomeException);
 
   PrepareForWriting(file,overwrite);
@@ -2793,6 +2853,9 @@ void SMESH_Mesh_i::ExportCGNS(::SMESH::SMESH_IDSource_ptr meshPart,
 
   TPythonDump() << _this() << ".ExportCGNS( "
                 << meshPart<< ", r'" << file << "', " << overwrite << ")";
+#else
+  THROW_SALOME_CORBA_EXCEPTION("CGNS library is unavailable", SALOME::INTERNAL_ERROR);
+#endif
 }
 
 //=============================================================================