Salome HOME
[bos #41978][EDF] Edit table of density on wire discretization. Load properly the...
[modules/smesh.git] / src / SMESH / SMESH_Mesh.cxx
index 0796cbd8a54cdf595dc4e2e414bc98c2ecf5d917..8d545cc58155d5a2427824b476fa03ca486c54d5 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2022  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
 #ifdef WITH_CGNS
 #include "DriverCGNS_Read.hxx"
 #include "DriverCGNS_Write.hxx"
+#include "DriverStructuredCGNS_Write.hxx"
 #endif
 
 #include <GEOMUtils.hxx>
 
-#undef _Precision_HeaderFile
+//#undef _Precision_HeaderFile
 #include <BRepBndLib.hxx>
 #include <BRepPrimAPI_MakeBox.hxx>
 #include <Bnd_Box.hxx>
@@ -232,8 +233,6 @@ SMESH_Mesh::~SMESH_Mesh()
     int result=pthread_create(&thread, NULL, deleteMeshDS, (void*)_meshDS);
 #endif
   }
-  if(_pool)
-    DeletePoolThreads();
 }
 
 //================================================================================
@@ -1688,6 +1687,51 @@ void SMESH_Mesh::ExportCGNS(const char *        file,
   if ( res != Driver_Mesh::DRS_OK )
     throw SALOME_Exception("Export failed");
 }
+//================================================================================
+/*!
+ * \brief Export the mesh to the StructuredCGNS file
+ */
+//================================================================================
+
+void SMESH_Mesh::ExportStructuredCGNS(const char * file, const SMESHDS_Mesh* meshPart, const char * meshName)
+{
+
+  int res = Driver_Mesh::DRS_OK;
+  SMESH_TRY;
+
+#ifdef WITH_CGNS
+  auto myMesh =  meshPart ? (SMESHDS_Mesh*) meshPart : _meshDS;
+  
+  if ( myMesh->HasSomeStructuredGridFilled() )
+  {
+    DriverStructuredCGNS_Write writer;
+    writer.SetFile( file );
+    writer.SetMesh( const_cast<SMESHDS_Mesh*>( myMesh ));
+    writer.SetMeshName( SMESH_Comment("Mesh_") << myMesh->GetPersistentId());
+    if ( meshName && meshName[0] )
+      writer.SetMeshName( meshName );
+
+    res = writer.Perform();
+    if ( res != Driver_Mesh::DRS_OK )
+    {
+      SMESH_ComputeErrorPtr err = writer.GetError();
+      if ( err && !err->IsOK() && !err->myComment.empty() )
+        throw SALOME_Exception(("Export failed: " + err->myComment ).c_str() );
+    }
+  }
+
+#endif
+  SMESH_CATCH( SMESH::throwSalomeEx );
+
+  if ( res == Driver_Mesh::DRS_TOO_LARGE_MESH )
+  {
+    std::cout << "\n\n\n Going into too large mesh file path\n\n\n\n";
+    throw TooLargeForExport("CGNS");
+  }
+
+  if ( res != Driver_Mesh::DRS_OK )
+    throw SALOME_Exception("Export failed");
+}
 
 //================================================================================
 /*!
@@ -2564,30 +2608,3 @@ void SMESH_Mesh::getAncestorsSubMeshes (const TopoDS_Shape&            theSubSha
   // sort submeshes according to stored mesh order
   SortByMeshOrder( theSubMeshes );
 }
-
-
-//=============================================================================
-/*!
- * \brief Build folder for parallel computation
- */
-//=============================================================================
-void SMESH_Mesh::CreateTmpFolder()
-{
-#ifndef WIN32
-  // Temporary folder that will be used by parallel computation
-  tmp_folder = fs::temp_directory_path()/fs::unique_path(fs::path("SMESH_%%%%-%%%%"));
-  fs::create_directories(tmp_folder);
-#endif
-}
-//
-//=============================================================================
-/*!
- * \brief Delete temporary folder used for parallel computation
- */
-//=============================================================================
-void SMESH_Mesh::DeleteTmpFolder()
-{
-#ifndef WIN32
-    fs::remove_all(tmp_folder);
-#endif
-}