From 224dbbb87e8a3111149df8e5a347e9e759a0a0d7 Mon Sep 17 00:00:00 2001 From: asozinov Date: Wed, 26 Jun 2024 14:17:19 +0100 Subject: [PATCH] Reload from file Small refactoring --- idl/SMESH_Gen.idl | 52 +--------------------------------- src/SMESHGUI/SMESHGUI.cxx | 5 ++-- src/SMESH_I/SMESH_2smeshpy.cxx | 8 ++++++ src/SMESH_I/SMESH_Gen_i.cxx | 9 +++--- src/SMESH_I/SMESH_Gen_i.hxx | 3 +- src/SMESH_SWIG/smeshBuilder.py | 6 ++-- 6 files changed, 20 insertions(+), 63 deletions(-) diff --git a/idl/SMESH_Gen.idl b/idl/SMESH_Gen.idl index 4973505c3..aaaf38007 100644 --- a/idl/SMESH_Gen.idl +++ b/idl/SMESH_Gen.idl @@ -258,8 +258,7 @@ module SMESH SMESH_Mesh CreateEmptyMesh() raises ( SALOME::SALOME_Exception ); - SMESH_Mesh ReloadMeshFromFile( in string theFileName, - in SMESH_Mesh sourceMesh) + SMESH_Mesh ReloadMeshFromFile(in SMESH_Mesh sourceMesh) raises(SALOME::SALOME_Exception); /*! @@ -269,14 +268,6 @@ module SMESH SMESH_Mesh CreateMeshesFromUNV( in string theFileName ) raises ( SALOME::SALOME_Exception ); - /*! - * Reload Mesh object importing data from given UNV file - * (UNV supported version is I-DEAS 10) - * - SMESH_Mesh ReloadMeshesFromUNV( in string theFileName, - in SMESH_Mesh sourceMesh ) - raises(SALOME::SALOME_Exception);*/ - /*! * Create Mesh object(s) importing data from given MED file */ @@ -284,27 +275,12 @@ module SMESH out SMESH::DriverMED_ReadStatus theStatus ) raises ( SALOME::SALOME_Exception ); - /*! - * Reload Mesh object(s) importing data from given MED file - * - mesh_array ReloadMeshesFromMED( in string theFileName, - in SMESH_Mesh sourceMesh, - out SMESH::DriverMED_ReadStatus theStatus ) - raises(SALOME::SALOME_Exception);*/ - /*! * Create Mesh object importing data from given STL file */ SMESH_Mesh CreateMeshesFromSTL( in string theFileName ) raises ( SALOME::SALOME_Exception ); - /*! - * Reload Mesh object importing data from given STL file - * - SMESH_Mesh ReloadMeshesFromSTL( in string theFileName, - in SMESH_Mesh sourceMesh ) - raises(SALOME::SALOME_Exception);*/ - /*! * Create Mesh object(s) importing data from given CGNS file */ @@ -312,14 +288,6 @@ module SMESH out SMESH::DriverMED_ReadStatus theStatus ) raises ( SALOME::SALOME_Exception ); - /*! - * Reload Mesh object(s) importing data from given CGNS file - * - mesh_array ReloadMeshesFromCGNS( in string theFileName, - in SMESH_Mesh sourceMesh, - out SMESH::DriverMED_ReadStatus theStatus ) - raises(SALOME::SALOME_Exception);*/ - /*! * Create Mesh object importing data from given GMF file * \param theFileName - a name of file to import @@ -330,17 +298,6 @@ module SMESH out SMESH::ComputeError theError) raises ( SALOME::SALOME_Exception ); - /*! - * Reload Mesh object importing data from given GMF file - * \param theFileName - a name of file to import - * \param theMakeRequiredGroups - if true, groups of required entities will be created - * - SMESH_Mesh ReloadMeshesFromGMF( in string theFileName, - in SMESH_Mesh sourceMesh, - in boolean theMakeRequiredGroups, - out SMESH::ComputeError theError ) - raises(SALOME::SALOME_Exception);*/ - /*! * Create a mesh and import data from any file supported by meshio library */ @@ -348,13 +305,6 @@ module SMESH out SMESH::DriverMED_ReadStatus theStatus) raises (SALOME::SALOME_Exception); - /*! - * Reload a mesh and import data from any file supported by meshio library - * - mesh_array ReloadMeshesFromMESHIO( in string theFileName, - in SMESH_Mesh sourceMesh, - out SMESH::DriverMED_ReadStatus theStatus ) - raises(SALOME::SALOME_Exception);*/ /*! * Create a dual mesh of a Tetrahedron mesh diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 52ac08c07..aff8bf130 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -1123,9 +1123,8 @@ namespace SMESH::mesh_array_var aMeshes = new SMESH::mesh_array; { - // Get file path and re-import mesh - QString aPath = anInfo.fileName(); - SMESH::SMESH_Mesh_var aReloadedMesh = SMESHGUI::GetSMESHGen()->ReloadMeshFromFile(aPath.toUtf8().constData(), aMeshByIO); + // re-import mesh + SMESH::SMESH_Mesh_var aReloadedMesh = SMESHGUI::GetSMESHGen()->ReloadMeshFromFile(aMeshByIO); QStringList anEntryList; diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 1e73de97a..3883d30b3 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -1013,6 +1013,7 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) { // there are methods to convert: // CreateMesh( shape ) + // ReloadMesh( shape ) // Concatenate( [mesh1, ...], ... ) // CreateHypothesis( theHypType, theLibName ) // Compute( mesh, geom ) @@ -1067,6 +1068,13 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) Handle(_pyMesh) mesh = new _pyMesh( theCommand, entries.front() ); AddObject( mesh ); } + if (method == "ReloadMeshFromFile") + { + std::cout << "WhatIS" << std::endl; + Handle(_pyMesh) mesh = new _pyMesh(theCommand, theCommand->GetResultValue()); + AddObject(mesh); + return; + } // CreateHypothesis() if ( method == "CreateHypothesis" ) diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 2257cf708..57d4b1c17 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -1331,16 +1331,17 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateEmptyMesh() return mesh._retn(); } -SMESH::SMESH_Mesh_ptr SMESH_Gen_i::ReloadMeshFromFile(const char* theFileName, - SMESH::SMESH_Mesh_ptr theMesh) +SMESH::SMESH_Mesh_ptr SMESH_Gen_i::ReloadMeshFromFile(SMESH::SMESH_Mesh_ptr theMesh) { SMESH::mesh_array_var aMeshes = new SMESH::mesh_array; + + SMESH::MedFileInfo* aMedInfo = theMesh->GetMEDFileInfo(); + // Get file path and re-import mesh - QString aPath = QString(theFileName); + QString aPath = QString(aMedInfo->fileName); QStringList aSplit = aPath.split('.'); QStringList anEntryList; - auto aStudy = getStudyServant(); SMESH::SMESH_Mesh_ptr aNewMesh; diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index a8a247177..6f7da2ba0 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -237,8 +237,7 @@ public: // Create empty mesh SMESH::SMESH_Mesh_ptr CreateEmptyMesh(); - SMESH::SMESH_Mesh_ptr ReloadMeshFromFile( const char* theFileName, - SMESH::SMESH_Mesh_ptr theMesh); + SMESH::SMESH_Mesh_ptr ReloadMeshFromFile(SMESH::SMESH_Mesh_ptr theMesh); // Create a mesh and import data from an UNV file SMESH::SMESH_Mesh_ptr CreateMeshesFromUNV( const char* theFileName ); diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index 114c59b4c..5d3c4bb06 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -675,13 +675,13 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ): global notebook notebook = salome_notebook.NoteBook( theIsEnablePublish ) - def ReloadMeshFromFile(self, theFileName, theMesh): + def ReloadMeshFromFile(self, theMesh): """ Desc for method, """ - aSmeshMesh = SMESH._objref_SMESH_Gen.ReloadMeshFromFile(self,theFileName) - aMesh = Mesh(self, self.geompyD, theFileName, aSmeshMesh) + aSmeshMesh = SMESH._objref_SMESH_Gen.ReloadMeshFromFile(self, theMesh) + aMesh = Mesh(self, self.geompyD, aSmeshMesh) return aMesh def CreateMeshesFromUNV( self,theFileName ): -- 2.39.2