Salome HOME
[bos #41122][EDF] Quadrangle radial for face which curved edges didn't discretize...
[modules/smesh.git] / src / SMESH_I / SMESH_Mesh_i.cxx
index f00e6eaa61f8cd8a1d9821eb48968312d40bef1a..7f732ae9cf051d3bb220e4e1dcb3bb0941f2c8fb 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2023  CEA, EDF, 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 <SALOMEDS_Attributes_wrap.hxx>
 #include <SALOMEDS_wrap.hxx>
@@ -4052,6 +4053,55 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
   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
@@ -4461,7 +4511,7 @@ void SMESH_Mesh_i::ExportPartToSTL(::SMESH::SMESH_IDSource_ptr meshPart,
 
 //================================================================================
 /*!
- * \brief Export a part of mesh to an STL file
+ * \brief Export a part of mesh to an CGNS file
  */
 //================================================================================
 
@@ -4501,6 +4551,50 @@ void SMESH_Mesh_i::ExportCGNS(::SMESH::SMESH_IDSource_ptr meshPart,
 #endif
 }
 
+//================================================================================
+/*!
+ * \brief Export a part of mesh to an StructuredCGNS file
+ */
+//================================================================================
+
+void SMESH_Mesh_i::ExportStructuredCGNS( SMESH::SMESH_IDSource_ptr meshPart,
+                                          const char*               file,
+                                          CORBA::Boolean            overwrite )
+{
+#ifdef WITH_CGNS
+  SMESH_TRY;
+  if ( _preMeshInfo )
+    _preMeshInfo->FullLoadFromFile();
+
+  PrepareForWriting(file,overwrite);
+
+  std::string meshName("");
+  SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( meshPart );
+  if ( !so->_is_nil() )
+  {
+    CORBA::String_var name = so->GetName();
+    meshName = name.in();
+  }
+  SMESH_TRY;
+  
+  SMESH::SMESH_Mesh_var mesh = meshPart->GetMesh();
+  SMESH_Mesh_i*       mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
+  mesh_i->Load();
+  auto myMesh                = mesh_i->GetImpl().GetMeshDS();
+  _impl->ExportStructuredCGNS(file, myMesh, meshName.c_str());
+
+  SMESH_CATCH( SMESH::throwCorbaException );
+
+  TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportStructuredCGNS( "
+                "r'" << file << "', " << overwrite << ", " << meshPart << ")";
+
+  SMESH_CATCH( SMESH::throwCorbaException );
+
+#else
+  THROW_SALOME_CORBA_EXCEPTION("CGNS library is unavailable", SALOME::INTERNAL_ERROR);
+#endif
+}
+
 //================================================================================
 /*!
  * \brief Export a part of mesh to a GMF file
@@ -5954,7 +6048,7 @@ void SMESH_Mesh_i::CreateGroupServants()
  */
 //=============================================================================
 
-bool SMESH_Mesh_i::IsComputedOK()
+CORBA::Boolean SMESH_Mesh_i::IsComputedOK()
 {
   return _impl->IsComputedOK();
 }
@@ -7028,24 +7122,6 @@ TListOfListOfInt SMESH_Mesh_i::findConcurrentSubMeshes()
   return res;
 }
 
-//=============================================================================
-/*!
- * \brief Set the number of threads for a parallel computation
- */
-//=============================================================================
-void SMESH_Mesh_i::SetNbThreads(CORBA::Long nbThreads){
-  _impl->SetNbThreads(nbThreads);
-}
-
-//=============================================================================
-/*!
- * \brief Get the number of threads for a parallel computation
- */
-//=============================================================================
-CORBA::Long SMESH_Mesh_i::GetNbThreads(){
-  return _impl->GetNbThreads();
-}
-
 
 //=============================================================================
 /*!