X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Mesh.cxx;h=2f7c6efa7599da99586107a7ee7f149bd28567b8;hb=HEAD;hp=ad3d733f07d4525c7565688fa994ef8b1782aee5;hpb=51540539e509f5e21439ddef0d88dba6a45a6679;p=modules%2Fsmesh.git diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index ad3d733f0..8d545cc58 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -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 @@ -53,6 +53,7 @@ #ifdef WITH_CGNS #include "DriverCGNS_Read.hxx" #include "DriverCGNS_Write.hxx" +#include "DriverStructuredCGNS_Write.hxx" #endif #include @@ -1686,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( 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"); +} //================================================================================ /*!