mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-13 17:18:35 +05:00
Reload from file
This commit is contained in:
parent
c51e870373
commit
08b75b51fe
BIN
doc/gui/images/reload_mesh_modif_mesh.png
Normal file
BIN
doc/gui/images/reload_mesh_modif_mesh.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.3 KiB |
BIN
doc/gui/images/reload_mesh_modif_mesh_props.png
Normal file
BIN
doc/gui/images/reload_mesh_modif_mesh_props.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
doc/gui/images/reload_mesh_orig_mesh.png
Normal file
BIN
doc/gui/images/reload_mesh_orig_mesh.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
doc/gui/images/reload_mesh_result.png
Normal file
BIN
doc/gui/images/reload_mesh_result.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
41
doc/gui/input/reload_mesh_from_file.rst
Normal file
41
doc/gui/input/reload_mesh_from_file.rst
Normal file
@ -0,0 +1,41 @@
|
||||
.. _reload_mesh_from_file_page:
|
||||
|
||||
*******************
|
||||
Reload mesh from file
|
||||
*******************
|
||||
|
||||
This operation allows reload original imported mesh, which was modified by different dedicated tools
|
||||
|
||||
*Reload mesh from file:*
|
||||
|
||||
|
||||
#. Select a mesh(es) (and display it in the 3D Viewer if you are going to pick elements by mouse).
|
||||
#. From popup menu click on the *Reload from file* item
|
||||
|
||||
Each selected mesh will be updated to orignal state with saving display properties
|
||||
|
||||
.. image:: ../images/reload_mesh_orig_mesh.png
|
||||
:align: center
|
||||
|
||||
.. centered::
|
||||
Original mesh
|
||||
|
||||
|
|
||||
|
||||
.. image:: ../images/reload_mesh_modif_mesh.png
|
||||
:align: center
|
||||
|
||||
.. centered::
|
||||
Same mesh after apply "Merge Nodes"
|
||||
|
||||
.. image:: ../images/reload_mesh_modif_mesh_props.png
|
||||
:align: center
|
||||
|
||||
.. centered::
|
||||
Set display properties
|
||||
|
||||
.. image:: ../images/reload_mesh_result.png
|
||||
:align: center
|
||||
|
||||
.. centered::
|
||||
Result after reload mesh
|
@ -258,6 +258,10 @@ module SMESH
|
||||
SMESH_Mesh CreateEmptyMesh()
|
||||
raises ( SALOME::SALOME_Exception );
|
||||
|
||||
SMESH_Mesh ReloadMeshFromFile( in string theFileName,
|
||||
in SMESH_Mesh sourceMesh)
|
||||
raises(SALOME::SALOME_Exception);
|
||||
|
||||
/*!
|
||||
* Create Mesh object importing data from given UNV file
|
||||
* (UNV supported version is I-DEAS 10)
|
||||
@ -265,6 +269,14 @@ 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
|
||||
*/
|
||||
@ -272,12 +284,27 @@ 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
|
||||
*/
|
||||
@ -285,6 +312,14 @@ 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
|
||||
@ -295,6 +330,17 @@ 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
|
||||
*/
|
||||
@ -302,6 +348,14 @@ 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
|
||||
* \param mesh - TetraHedron mesh to create dual from
|
||||
|
@ -122,6 +122,9 @@
|
||||
|
||||
#include "SMESH_version.h"
|
||||
|
||||
#include "SMESHDS_Mesh.hxx"
|
||||
#include "SMESH_Mesh.hxx"
|
||||
|
||||
#include "SMESH_Actor.h"
|
||||
#include "SMESH_ActorUtils.h"
|
||||
#include "SMESH_Client.hxx"
|
||||
@ -221,6 +224,8 @@ namespace
|
||||
|
||||
void ExportMeshToFile(int theCommandID);
|
||||
|
||||
void ReloadMeshFromFile(int theCommandID);
|
||||
|
||||
void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap);
|
||||
|
||||
void SetDisplayEntity(int theCommandID);
|
||||
@ -1079,6 +1084,69 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Reload selected mesh from file a file
|
||||
*/
|
||||
//================================================================================
|
||||
void ReloadMeshFromFile(int theCommandID)
|
||||
{
|
||||
LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
|
||||
SALOME_ListIO selected;
|
||||
if (aSel)
|
||||
aSel->selectedObjects(selected);
|
||||
|
||||
QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
|
||||
QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
|
||||
SALOME_ListIteratorOfListIO It(selected);
|
||||
|
||||
// Iterate by all selected
|
||||
for (; It.More(); It.Next())
|
||||
{
|
||||
Handle(SALOME_InteractiveObject) anIObject = It.Value();
|
||||
SMESH::SMESH_IDSource_var aMeshItem =
|
||||
SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
|
||||
|
||||
if (aMeshItem->_is_nil()) {
|
||||
SUIT_MessageBox::warning(SMESHGUI::desktop(),
|
||||
QObject::tr("SMESH_WRN_WARNING"),
|
||||
QObject::tr("SMESH_BAD_MESH_SELECTION"));
|
||||
continue;
|
||||
}
|
||||
|
||||
SMESH::SMESH_Mesh_var aMeshByIO = SMESH::GetMeshByIO(anIObject);
|
||||
|
||||
SMESH::SelectionProxy aMesh = SMESH::SelectionProxy(aMeshItem);
|
||||
SMESH::MedInfo anInfo = aMesh.medFileInfo();
|
||||
if (!anInfo.isValid())
|
||||
continue;
|
||||
|
||||
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);
|
||||
|
||||
QStringList anEntryList;
|
||||
|
||||
_PTR(SObject) aMeshSO = SMESH::FindSObject(aReloadedMesh);
|
||||
if (aMeshSO) {
|
||||
anEntryList.append(aMeshSO->GetID().c_str());
|
||||
}
|
||||
SMESHGUI::GetSMESHGUI()->updateObjBrowser();
|
||||
if (LightApp_Application* anApp =
|
||||
dynamic_cast<LightApp_Application*>(SUIT_Session::session()->activeApplication()))
|
||||
anApp->browseObjects(anEntryList);
|
||||
}
|
||||
|
||||
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(aMeshItem);\
|
||||
QString aMeshName = anIObject->getName();
|
||||
aMeshList.append(QPair< SMESH::SMESH_IDSource_var, QString >(aMeshItem, aMeshName));
|
||||
|
||||
}
|
||||
SMESH::UpdateView();
|
||||
}
|
||||
|
||||
inline void InverseEntityMode(unsigned int& theOutputMode,
|
||||
unsigned int theMode)
|
||||
{
|
||||
@ -2691,7 +2759,12 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
|
||||
::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
|
||||
break;
|
||||
}
|
||||
|
||||
case SMESHOp::OpReloadFromFile:
|
||||
{
|
||||
if (isStudyLocked()) break;
|
||||
::ReloadMeshFromFile(theCommandID);
|
||||
break;
|
||||
}
|
||||
case SMESHOp::OpFileInformation:
|
||||
{
|
||||
SALOME_ListIO selected;
|
||||
@ -3484,7 +3557,6 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SMESHOp::OpFindElementByPoint:
|
||||
{
|
||||
startOperation( theCommandID );
|
||||
@ -4320,6 +4392,7 @@ void SMESHGUI::initialize( CAM_Application* app )
|
||||
//createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
|
||||
//createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
|
||||
createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
|
||||
createSMESHAction( SMESHOp::OpReloadFromFile, "RELOAD_FROM_FILE");
|
||||
//update
|
||||
createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
|
||||
createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
|
||||
@ -4548,6 +4621,7 @@ void SMESHGUI::initialize( CAM_Application* app )
|
||||
#endif
|
||||
createMenu( SMESHOp::OpExportGMF, exportId, -1 );
|
||||
createMenu( SMESHOp::OpExportMESHIO, exportId, -1 ); // formats supported by meshio lib
|
||||
createMenu( SMESHOp::OpReloadFromFile, fileId, -1 );
|
||||
createMenu( separator(), fileId, 10 );
|
||||
|
||||
createMenu( SMESHOp::OpDelete, editId, -1 );
|
||||
@ -4932,6 +5006,7 @@ void SMESHGUI::initialize( CAM_Application* app )
|
||||
createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
|
||||
createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
|
||||
createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1 && " + hasElems );
|
||||
createPopupItem( SMESHOp::OpReloadFromFile, OB, mesh, "&& isImported");
|
||||
createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
|
||||
popupMgr()->insert( separator(), -1, 0 );
|
||||
createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
|
||||
@ -4995,6 +5070,7 @@ void SMESHGUI::initialize( CAM_Application* app )
|
||||
createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
|
||||
createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
|
||||
createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh, "&& " + hasElems);
|
||||
createPopupItem( SMESHOp::OpReloadFromFile, View, mesh_part, "&& isImported");
|
||||
popupMgr()->insert( separator(), -1, 0 );
|
||||
|
||||
createPopupItem( SMESHOp::OpUpdate, OB + " " + View, mesh_part );
|
||||
|
@ -94,6 +94,7 @@ namespace SMESHOp {
|
||||
OpWhatIs = 2101, // MENU MESH - MESH ELEMENT INFORMATION
|
||||
OpStdInfo = 2102, // MENU MESH - MESH STANDARD INFORMATION
|
||||
OpFindElementByPoint = 2103, // MENU MESH - FIND ELEMENT BY POINT
|
||||
OpReloadFromFile = 2104, // MENU MESH - RELOAD MESH FROM FILE
|
||||
OpUpdate = 2200, // POPUP MENU - UPDATE
|
||||
// Controls -----------------------//--------------------------------
|
||||
OpFreeNode = 3000, // MENU CONTROLS - FREE NODES
|
||||
|
@ -272,6 +272,10 @@
|
||||
<source>MEN_ADV_INFO</source>
|
||||
<translation>Mesh Information</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_RELOAD_FROM_FILE</source>
|
||||
<translation>Reload from file</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_ALL</source>
|
||||
<translation>All</translation>
|
||||
@ -3332,6 +3336,10 @@ Use Display Entity menu command to show them.
|
||||
<source>STB_ADV_INFO</source>
|
||||
<translation>Show base information about the mesh object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_RELOAD_FROM_FILE</source>
|
||||
<translation>Reload original mesh from file</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_ALL</source>
|
||||
<translation>All</translation>
|
||||
@ -4072,6 +4080,10 @@ Use Display Entity menu command to show them.
|
||||
<source>TOP_ADV_INFO</source>
|
||||
<translation>Mesh Information</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_RELOAD_FROM_FILE</source>
|
||||
<translation>Reload from file</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_ALL</source>
|
||||
<translation>All</translation>
|
||||
|
@ -268,6 +268,10 @@
|
||||
<source>MEN_ADV_INFO</source>
|
||||
<translation>Informations sur le maillage</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_RELOAD_FROM_FILE</source>
|
||||
<translation>Reload from file</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_ALL</source>
|
||||
<translation>Tous</translation>
|
||||
@ -3331,6 +3335,10 @@ Utilisez le menu "Visualiser une entité" pour les afficher.
|
||||
<source>STB_ALL</source>
|
||||
<translation>Tous</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_RELOAD_FROM_FILE</source>
|
||||
<translation>Reload original mesh from file</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_AREA</source>
|
||||
<translation>Aire</translation>
|
||||
@ -4067,6 +4075,10 @@ Utilisez le menu "Visualiser une entité" pour les afficher.
|
||||
<source>TOP_ADV_INFO</source>
|
||||
<translation>Informations sur le maillage</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_RELOAD_FROM_FILE</source>
|
||||
<translation>Reload from file</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_ALL</source>
|
||||
<translation>Tous</translation>
|
||||
|
@ -251,6 +251,10 @@
|
||||
<source>MEN_ADV_INFO</source>
|
||||
<translation>メッシュに関する情報</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_RELOAD_FROM_FILE</source>
|
||||
<translation>Reload from file</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_ALL</source>
|
||||
<translation>すべて</translation>
|
||||
@ -2979,6 +2983,10 @@ pip install meshio[all]</translation>
|
||||
<source>STB_ADV_INFO</source>
|
||||
<translation>メッシュ上の基本的な情報を得る</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_RELOAD_FROM_FILE</source>
|
||||
<translation>Reload original mesh from file</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_ALL</source>
|
||||
<translation>すべて</translation>
|
||||
@ -3663,6 +3671,10 @@ pip install meshio[all]</translation>
|
||||
<source>TOP_ADV_INFO</source>
|
||||
<translation>メッシュに関する情報</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_RELOAD_FROM_FILE</source>
|
||||
<translation>Reload from file</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_ALL</source>
|
||||
<translation>すべて</translation>
|
||||
|
@ -153,6 +153,7 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <QStringList>
|
||||
|
||||
#include <boost/archive/text_oarchive.hpp>
|
||||
#include <boost/serialization/list.hpp>
|
||||
@ -1330,6 +1331,60 @@ 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::mesh_array_var aMeshes = new SMESH::mesh_array;
|
||||
// Get file path and re-import mesh
|
||||
QString aPath = QString(theFileName);
|
||||
QStringList aSplit = aPath.split('.');
|
||||
QStringList anEntryList;
|
||||
|
||||
|
||||
auto aStudy = getStudyServant();
|
||||
|
||||
SMESH::SMESH_Mesh_ptr aNewMesh;
|
||||
|
||||
SMESH_Mesh* aMesh = reinterpret_cast<SMESH_Mesh*> (theMesh->GetMeshPtr());
|
||||
aMesh->GetMeshDS()->ClearMesh();
|
||||
|
||||
if (aSplit.last() == "cgns")
|
||||
{
|
||||
SMESH::DriverMED_ReadStatus res;
|
||||
aMeshes = ReloadMeshesFromCGNS(aPath.toUtf8().constData(), theMesh, res);
|
||||
|
||||
aNewMesh = aMeshes[0];
|
||||
|
||||
}
|
||||
else if (aSplit.last().contains("stl", Qt::CaseSensitivity::CaseInsensitive))
|
||||
{
|
||||
aNewMesh = ReloadMeshesFromSTL(aPath.toUtf8().constData(), theMesh);
|
||||
}
|
||||
else if (aSplit.last().contains("unv", Qt::CaseSensitivity::CaseInsensitive))
|
||||
{
|
||||
aNewMesh = ReloadMeshesFromUNV(aPath.toUtf8().constData(), theMesh);
|
||||
}
|
||||
else if (aSplit.last().contains("mesh", Qt::CaseSensitivity::CaseInsensitive))
|
||||
{
|
||||
SMESH::ComputeError_var res;
|
||||
aNewMesh = ReloadMeshesFromGMF(aPath.toUtf8().constData(), theMesh, true, res.out());
|
||||
}
|
||||
else if (aSplit.last().contains("med", Qt::CaseSensitivity::CaseInsensitive))
|
||||
{
|
||||
SMESH::DriverMED_ReadStatus res;
|
||||
aMeshes = ReloadMeshesFromMED(aPath.toUtf8().constData(), theMesh, res);
|
||||
|
||||
aNewMesh = aMeshes[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
// MeshIO
|
||||
}
|
||||
|
||||
theMesh = SMESH::SMESH_Mesh::_duplicate(aNewMesh);
|
||||
return theMesh;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
//================================================================================
|
||||
@ -1425,6 +1480,36 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromUNV( const char* theFileName
|
||||
return aMesh._retn();
|
||||
}
|
||||
|
||||
SMESH::SMESH_Mesh_ptr SMESH_Gen_i::ReloadMeshesFromUNV(const char* theFileName, SMESH::SMESH_Mesh_ptr sourceMesh)
|
||||
{
|
||||
Unexpect aCatch(SALOME_SalomeException);
|
||||
|
||||
checkFileReadable(theFileName);
|
||||
|
||||
string aFileName;
|
||||
// publish mesh in the study
|
||||
if (CanPublishInStudy(sourceMesh)) {
|
||||
SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
|
||||
aStudyBuilder->NewCommand(); // There is a transaction
|
||||
SALOMEDS::SObject_wrap aSO = PublishMesh(sourceMesh, aFileName.c_str());
|
||||
aStudyBuilder->CommitCommand();
|
||||
if (!aSO->_is_nil()) {
|
||||
// Update Python script
|
||||
TPythonDump(this) << aSO << " = " << this << ".ReloadMeshesFromUNV(r'" << theFileName << "')";
|
||||
}
|
||||
}
|
||||
|
||||
SMESH_Mesh_i* aServant = dynamic_cast<SMESH_Mesh_i*>(GetServant(sourceMesh).in());
|
||||
ASSERT(aServant);
|
||||
aServant->ImportUNVFile(theFileName);
|
||||
|
||||
// Dump creation of groups
|
||||
SMESH::ListOfGroups_var groups = aServant->GetGroups();
|
||||
|
||||
aServant->GetImpl().GetMeshDS()->Modified();
|
||||
return sourceMesh;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* SMESH_Gen_i::CreateMeshFromMED
|
||||
@ -1515,6 +1600,85 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char*
|
||||
return aResult._retn();
|
||||
}
|
||||
|
||||
SMESH::mesh_array* SMESH_Gen_i::ReloadMeshesFromMED(const char* theFileName, SMESH::SMESH_Mesh_ptr sourceMesh, SMESH::DriverMED_ReadStatus& theStatus)
|
||||
{
|
||||
checkFileReadable(theFileName);
|
||||
|
||||
#ifdef WIN32
|
||||
char bname[_MAX_FNAME];
|
||||
_splitpath(theFileName, NULL, NULL, bname, NULL);
|
||||
string aFileName = bname;
|
||||
#else
|
||||
string aFileName = basename(const_cast<char*>(theFileName));
|
||||
#endif
|
||||
// Retrieve mesh names from the file
|
||||
DriverMED_R_SMESHDS_Mesh myReader;
|
||||
myReader.SetFile(theFileName);
|
||||
myReader.SetMeshId(-1);
|
||||
Driver_Mesh::Status aStatus;
|
||||
list<string> aNames = myReader.GetMeshNames(aStatus);
|
||||
SMESH::mesh_array_var aResult = new SMESH::mesh_array();
|
||||
theStatus = (SMESH::DriverMED_ReadStatus)aStatus;
|
||||
|
||||
{ // open a new scope to make aPythonDump die before PythonDump in SMESH_Mesh::GetGroups()
|
||||
|
||||
// Python Dump
|
||||
TPythonDump aPythonDump(this);
|
||||
aPythonDump << "([";
|
||||
|
||||
if (theStatus == SMESH::DRS_OK)
|
||||
{
|
||||
SALOMEDS::StudyBuilder_var aStudyBuilder;
|
||||
aStudyBuilder = getStudyServant()->NewBuilder();
|
||||
aStudyBuilder->NewCommand(); // There is a transaction
|
||||
|
||||
aResult->length(aNames.size());
|
||||
int i = 0;
|
||||
|
||||
// Iterate through all meshes and create mesh objects
|
||||
for (const std::string& meshName : aNames)
|
||||
{
|
||||
// Python Dump
|
||||
if (i > 0) aPythonDump << ", ";
|
||||
|
||||
// publish mesh in the study
|
||||
SALOMEDS::SObject_wrap aSO;
|
||||
if (CanPublishInStudy(sourceMesh))
|
||||
aSO = PublishMesh(sourceMesh, meshName.c_str());
|
||||
|
||||
// Python Dump
|
||||
if (!aSO->_is_nil()) {
|
||||
aPythonDump << aSO;
|
||||
}
|
||||
else {
|
||||
aPythonDump << "mesh_" << i;
|
||||
}
|
||||
|
||||
// Read mesh data (groups are published automatically by ImportMEDFile())
|
||||
SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>(GetServant(sourceMesh).in());
|
||||
ASSERT(meshServant);
|
||||
SMESH::DriverMED_ReadStatus status1 =
|
||||
meshServant->ImportMEDFile(theFileName, meshName.c_str());
|
||||
if (status1 > theStatus)
|
||||
theStatus = status1;
|
||||
|
||||
aResult[i++] = SMESH::SMESH_Mesh::_duplicate(sourceMesh);
|
||||
meshServant->GetImpl().GetMeshDS()->Modified();
|
||||
}
|
||||
if (!aStudyBuilder->_is_nil())
|
||||
aStudyBuilder->CommitCommand();
|
||||
}
|
||||
|
||||
// Update Python script
|
||||
aPythonDump << "], status) = " << this << ".ReloadMeshesFromMED( r'" << theFileName << "' )";
|
||||
}
|
||||
// Dump creation of groups
|
||||
for (CORBA::ULong i = 0; i < aResult->length(); ++i)
|
||||
SMESH::ListOfGroups_var groups = aResult[i]->GetGroups();
|
||||
|
||||
return aResult._retn();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* SMESH_Gen_i::CreateMeshFromSTL
|
||||
@ -1556,6 +1720,37 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromSTL( const char* theFileName
|
||||
return aMesh._retn();
|
||||
}
|
||||
|
||||
SMESH::SMESH_Mesh_ptr SMESH_Gen_i::ReloadMeshesFromSTL(const char* theFileName, SMESH::SMESH_Mesh_ptr sourceMesh)
|
||||
{
|
||||
Unexpect aCatch(SALOME_SalomeException);
|
||||
checkFileReadable(theFileName);
|
||||
|
||||
#ifdef WIN32
|
||||
char bname[_MAX_FNAME];
|
||||
_splitpath(theFileName, NULL, NULL, bname, NULL);
|
||||
string aFileName = bname;
|
||||
#else
|
||||
string aFileName = basename(const_cast<char*>(theFileName));
|
||||
#endif
|
||||
// publish mesh in the study
|
||||
if (CanPublishInStudy(sourceMesh)) {
|
||||
SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
|
||||
aStudyBuilder->NewCommand(); // There is a transaction
|
||||
SALOMEDS::SObject_wrap aSO = PublishInStudy(SALOMEDS::SObject::_nil(), sourceMesh, aFileName.c_str());
|
||||
aStudyBuilder->CommitCommand();
|
||||
if (!aSO->_is_nil()) {
|
||||
// Update Python script
|
||||
TPythonDump(this) << aSO << " = " << this << ".ReloadMeshFromSTL(r'" << theFileName << "')";
|
||||
}
|
||||
}
|
||||
|
||||
SMESH_Mesh_i* aServant = dynamic_cast<SMESH_Mesh_i*>(GetServant(sourceMesh).in());
|
||||
ASSERT(aServant);
|
||||
aServant->ImportSTLFile(theFileName);
|
||||
aServant->GetImpl().GetMeshDS()->Modified();
|
||||
return sourceMesh;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Create meshes and import data from the CGSN file
|
||||
@ -1641,6 +1836,85 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromCGNS( const char*
|
||||
return aResult._retn();
|
||||
}
|
||||
|
||||
SMESH::mesh_array* SMESH_Gen_i::ReloadMeshesFromCGNS(const char* theFileName,
|
||||
SMESH::SMESH_Mesh_ptr sourceMesh,
|
||||
SMESH::DriverMED_ReadStatus& theStatus)
|
||||
{
|
||||
Unexpect aCatch(SALOME_SalomeException);
|
||||
checkFileReadable(theFileName);
|
||||
|
||||
SMESH::mesh_array_var aResult = new SMESH::mesh_array();
|
||||
|
||||
#ifdef WITH_CGNS
|
||||
// Retrieve nb meshes from the file
|
||||
DriverCGNS_Read myReader;
|
||||
myReader.SetFile(theFileName);
|
||||
Driver_Mesh::Status aStatus;
|
||||
int nbMeshes = myReader.GetNbMeshes(aStatus);
|
||||
theStatus = (SMESH::DriverMED_ReadStatus)aStatus;
|
||||
|
||||
aResult->length(nbMeshes);
|
||||
|
||||
{ // open a new scope to make aPythonDump die before PythonDump in SMESH_Mesh::GetGroups()
|
||||
|
||||
// Python Dump
|
||||
TPythonDump aPythonDump(this);
|
||||
aPythonDump << "([";
|
||||
|
||||
if (theStatus == SMESH::DRS_OK)
|
||||
{
|
||||
SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
|
||||
aStudyBuilder->NewCommand(); // There is a transaction
|
||||
|
||||
int i = 0;
|
||||
|
||||
// Iterate through all meshes and create mesh objects
|
||||
for (; i < nbMeshes; ++i)
|
||||
{
|
||||
// Python Dump
|
||||
if (i > 0) aPythonDump << ", ";
|
||||
|
||||
// create mesh
|
||||
aResult[i] = SMESH::SMESH_Mesh::_duplicate(sourceMesh);
|
||||
|
||||
// Read mesh data (groups are published automatically by ImportMEDFile())
|
||||
SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>(GetServant(sourceMesh).in());
|
||||
ASSERT(meshServant);
|
||||
string meshName;
|
||||
SMESH::DriverMED_ReadStatus status1 =
|
||||
meshServant->ImportCGNSFile(theFileName, i, meshName);
|
||||
if (status1 > theStatus)
|
||||
theStatus = status1;
|
||||
|
||||
meshServant->GetImpl().GetMeshDS()->Modified();
|
||||
// publish mesh in the study
|
||||
SALOMEDS::SObject_wrap aSO;
|
||||
if (CanPublishInStudy(sourceMesh))
|
||||
aSO = PublishMesh(sourceMesh, meshName.c_str());
|
||||
|
||||
// Python Dump
|
||||
if (!aSO->_is_nil()) {
|
||||
aPythonDump << aSO;
|
||||
}
|
||||
else {
|
||||
aPythonDump << "mesh_" << i;
|
||||
}
|
||||
}
|
||||
aStudyBuilder->CommitCommand();
|
||||
}
|
||||
|
||||
aPythonDump << "], status) = " << this << ".ReloadMeshesFromCGNS(r'" << theFileName << "')";
|
||||
}
|
||||
// Dump creation of groups
|
||||
for (CORBA::ULong i = 0; i < aResult->length(); ++i)
|
||||
SMESH::ListOfGroups_var groups = aResult[i]->GetGroups();
|
||||
#else
|
||||
THROW_SALOME_CORBA_EXCEPTION("CGNS library is unavailable", SALOME::INTERNAL_ERROR);
|
||||
#endif
|
||||
|
||||
return aResult._retn();
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Create a mesh and import data from a GMF file
|
||||
@ -1683,6 +1957,38 @@ SMESH_Gen_i::CreateMeshesFromGMF( const char* theFileName,
|
||||
return aMesh._retn();
|
||||
}
|
||||
|
||||
SMESH::SMESH_Mesh_ptr SMESH_Gen_i::ReloadMeshesFromGMF(const char* theFileName, SMESH::SMESH_Mesh_ptr sourceMesh, CORBA::Boolean theMakeRequiredGroups, SMESH::ComputeError_out theError)
|
||||
{
|
||||
Unexpect aCatch(SALOME_SalomeException);
|
||||
checkFileReadable(theFileName);
|
||||
|
||||
#ifdef WIN32
|
||||
char bname[_MAX_FNAME];
|
||||
_splitpath(theFileName, NULL, NULL, bname, NULL);
|
||||
string aFileName = bname;
|
||||
#else
|
||||
string aFileName = basename(const_cast<char*>(theFileName));
|
||||
#endif
|
||||
// publish mesh in the study
|
||||
if (CanPublishInStudy(sourceMesh)) {
|
||||
SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
|
||||
aStudyBuilder->NewCommand(); // There is a transaction
|
||||
SALOMEDS::SObject_wrap aSO = PublishInStudy(SALOMEDS::SObject::_nil(), sourceMesh, aFileName.c_str());
|
||||
aStudyBuilder->CommitCommand();
|
||||
if (!aSO->_is_nil()) {
|
||||
// Update Python script
|
||||
TPythonDump(this) << "(" << aSO << ", error) = " << this << ".ReloadMeshesFromGMF(r'"
|
||||
<< theFileName << "', "
|
||||
<< theMakeRequiredGroups << " )";
|
||||
}
|
||||
}
|
||||
SMESH_Mesh_i* aServant = dynamic_cast<SMESH_Mesh_i*>(GetServant(sourceMesh).in());
|
||||
ASSERT(aServant);
|
||||
theError = aServant->ImportGMFFile(theFileName, theMakeRequiredGroups);
|
||||
aServant->GetImpl().GetMeshDS()->Modified();
|
||||
return sourceMesh;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Create a mesh and import data from any file supported by meshio library
|
||||
@ -1769,6 +2075,82 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMESHIO(const char* theFileName,
|
||||
return aResult._retn();
|
||||
}
|
||||
|
||||
SMESH::mesh_array* SMESH_Gen_i::ReloadMeshesFromMESHIO(const char* theFileName, SMESH::SMESH_Mesh_ptr sourceMesh, SMESH::DriverMED_ReadStatus& theStatus)
|
||||
{
|
||||
Unexpect aCatch(SALOME_SalomeException);
|
||||
checkFileReadable(theFileName);
|
||||
|
||||
MESSAGE("Import part with meshio through an intermediate MED file");
|
||||
|
||||
// Create an object that holds a temp file name and
|
||||
// removes the file when goes out of scope.
|
||||
SMESH_Meshio meshio;
|
||||
const QString tempFileName = meshio.CreateTempFileName(theFileName);
|
||||
|
||||
// Convert temp file into a target one with meshio command
|
||||
meshio.Convert(theFileName, tempFileName);
|
||||
|
||||
// We don't need a python dump from SMESH_Gen_i::CreateMeshesFromMED(), so
|
||||
// we can't use this method as is here. The followed code is an edited part of
|
||||
// copy pasted CreateMeshesFromMED().
|
||||
|
||||
// Retrieve mesh names from the file
|
||||
DriverMED_R_SMESHDS_Mesh myReader;
|
||||
myReader.SetFile(tempFileName.toStdString());
|
||||
myReader.SetMeshId(-1);
|
||||
Driver_Mesh::Status aStatus;
|
||||
list<string> aNames = myReader.GetMeshNames(aStatus);
|
||||
SMESH::mesh_array_var aResult = new SMESH::mesh_array();
|
||||
theStatus = (SMESH::DriverMED_ReadStatus)aStatus;
|
||||
|
||||
if (theStatus == SMESH::DRS_OK)
|
||||
{
|
||||
SALOMEDS::StudyBuilder_var aStudyBuilder;
|
||||
aStudyBuilder = getStudyServant()->NewBuilder();
|
||||
aStudyBuilder->NewCommand(); // There is a transaction
|
||||
|
||||
aResult->length(aNames.size());
|
||||
std::vector<SALOMEDS::SObject_wrap> sobjects;
|
||||
int i = 0;
|
||||
|
||||
// Iterate through all meshes and create mesh objects
|
||||
for (const std::string& meshName : aNames)
|
||||
{
|
||||
// publish mesh in the study
|
||||
SALOMEDS::SObject_wrap aSO;
|
||||
if (CanPublishInStudy(sourceMesh))
|
||||
aSO = PublishMesh(sourceMesh, meshName.c_str());
|
||||
|
||||
// Save SO to use in a python dump
|
||||
sobjects.emplace_back(aSO);
|
||||
|
||||
// Read mesh data (groups are published automatically by ImportMEDFile())
|
||||
SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>(GetServant(sourceMesh).in());
|
||||
ASSERT(meshServant);
|
||||
SMESH::DriverMED_ReadStatus status1 =
|
||||
meshServant->ImportMEDFile(tempFileName.toUtf8().data(), meshName.c_str());
|
||||
if (status1 > theStatus)
|
||||
theStatus = status1;
|
||||
|
||||
aResult[i++] = SMESH::SMESH_Mesh::_duplicate(sourceMesh);
|
||||
meshServant->GetImpl().GetMeshDS()->Modified();
|
||||
}
|
||||
|
||||
if (!aStudyBuilder->_is_nil())
|
||||
aStudyBuilder->CommitCommand();
|
||||
|
||||
// Python dump
|
||||
const std::string functionName = std::string(".ReloadMeshesFromMESHIO(r'") + theFileName + "')";
|
||||
functionToPythonDump(this, functionName, sobjects);
|
||||
}
|
||||
|
||||
// Dump creation of groups
|
||||
for (CORBA::ULong i = 0; i < aResult->length(); ++i)
|
||||
SMESH::ListOfGroups_var groups = aResult[i]->GetGroups();
|
||||
|
||||
return aResult._retn();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* SMESH_Gen_i::IsReadyToCompute
|
||||
|
@ -237,29 +237,55 @@ public:
|
||||
// Create empty mesh
|
||||
SMESH::SMESH_Mesh_ptr CreateEmptyMesh();
|
||||
|
||||
SMESH::SMESH_Mesh_ptr ReloadMeshFromFile( const char* theFileName,
|
||||
SMESH::SMESH_Mesh_ptr theMesh);
|
||||
|
||||
// Create a mesh and import data from an UNV file
|
||||
SMESH::SMESH_Mesh_ptr CreateMeshesFromUNV( const char* theFileName );
|
||||
|
||||
SMESH::SMESH_Mesh_ptr ReloadMeshesFromUNV(const char* theFileName,
|
||||
SMESH::SMESH_Mesh_ptr sourceMesh);
|
||||
|
||||
// Create mesh(es) and import data from MED file
|
||||
SMESH::mesh_array* CreateMeshesFromMED( const char* theFileName,
|
||||
SMESH::DriverMED_ReadStatus& theStatus );
|
||||
|
||||
SMESH::mesh_array* ReloadMeshesFromMED(const char* theFileName,
|
||||
SMESH::SMESH_Mesh_ptr sourceMesh,
|
||||
SMESH::DriverMED_ReadStatus& theStatus);
|
||||
|
||||
// Create a mesh and import data from a STL file
|
||||
SMESH::SMESH_Mesh_ptr CreateMeshesFromSTL( const char* theFileName );
|
||||
|
||||
SMESH::SMESH_Mesh_ptr ReloadMeshesFromSTL(const char* theFileName,
|
||||
SMESH::SMESH_Mesh_ptr sourceMesh);
|
||||
|
||||
// Create mesh(es) and import data from CGNS file
|
||||
SMESH::mesh_array* CreateMeshesFromCGNS( const char* theFileName,
|
||||
SMESH::DriverMED_ReadStatus& theStatus );
|
||||
|
||||
SMESH::mesh_array* ReloadMeshesFromCGNS(const char* theFileName,
|
||||
SMESH::SMESH_Mesh_ptr sourceMesh,
|
||||
SMESH::DriverMED_ReadStatus& theStatus);
|
||||
|
||||
// Create a mesh and import data from a GMF file
|
||||
SMESH::SMESH_Mesh_ptr CreateMeshesFromGMF( const char* theFileName,
|
||||
CORBA::Boolean theMakeRequiredGroups,
|
||||
SMESH::ComputeError_out theError);
|
||||
|
||||
SMESH::SMESH_Mesh_ptr ReloadMeshesFromGMF(const char* theFileName,
|
||||
SMESH::SMESH_Mesh_ptr sourceMesh,
|
||||
CORBA::Boolean theMakeRequiredGroups,
|
||||
SMESH::ComputeError_out theError);
|
||||
|
||||
// Create a mesh and import data from any file supported by meshio library
|
||||
SMESH::mesh_array* CreateMeshesFromMESHIO(const char* theFileName,
|
||||
SMESH::DriverMED_ReadStatus& theStatus);
|
||||
|
||||
SMESH::mesh_array* ReloadMeshesFromMESHIO(const char* theFileName,
|
||||
SMESH::SMESH_Mesh_ptr sourceMesh,
|
||||
SMESH::DriverMED_ReadStatus& theStatus);
|
||||
|
||||
// Create dual mesh of a tetrahedron mesh
|
||||
SMESH::SMESH_Mesh_ptr CreateDualMesh(SMESH::SMESH_IDSource_ptr meshPart,
|
||||
const char* meshName,
|
||||
|
@ -675,6 +675,14 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ):
|
||||
global notebook
|
||||
notebook = salome_notebook.NoteBook( theIsEnablePublish )
|
||||
|
||||
def ReloadMeshFromFile(self, theFileName, theMesh):
|
||||
"""
|
||||
Desc for method,
|
||||
"""
|
||||
|
||||
aSmeshMesh = SMESH._objref_SMESH_Gen.ReloadMeshFromFile(self,theFileName)
|
||||
aMesh = Mesh(self, self.geompyD, theFileName, aSmeshMesh)
|
||||
return aMesh
|
||||
|
||||
def CreateMeshesFromUNV( self,theFileName ):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user