#include "DriverMED_W_SMESHDS_Mesh.h"
#include "DriverMED_R_SMESHDS_Mesh.h"
+#ifdef WITH_CGNS
#include "DriverCGNS_Read.hxx"
+#endif
#include "SALOMEDS_Tool.hxx"
#include "SALOME_NamingService.hxx"
SALOME::Session_var session = SALOME::Session::_narrow( obj ) ;
if ( !session->_is_nil() )
{
- CORBA::String_var s_host = session->getHostname();
+ CORBA::String_var str_host = session->getHostname();
CORBA::Long s_pid = session->getPID();
string my_host = Kernel_Utils::GetHostname();
#ifdef WNT
#else
long my_pid = (long) getpid();
#endif
- SetEmbeddedMode( s_pid == my_pid && my_host == s_host.in() );
+ SetEmbeddedMode( s_pid == my_pid && my_host == str_host.in() );
}
}
}
*/
//=============================================================================
-SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
- SMESH::DriverMED_ReadStatus& theStatus)
- throw ( SALOME::SALOME_Exception )
+SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMEDorSAUV( const char* theFileName,
+ SMESH::DriverMED_ReadStatus& theStatus,
+ const char* theCommandNameForPython,
+ const char* theFileNameForPython)
{
- Unexpect aCatch(SALOME_SalomeException);
- if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" );
-
// Retrieve mesh names from the file
DriverMED_R_SMESHDS_Mesh myReader;
myReader.SetFile( theFileName );
}
// Update Python script
- aPythonDump << "], status) = " << this << ".CreateMeshesFromMED(r'" << theFileName << "')";
+ aPythonDump << "], status) = " << this << "." << theCommandNameForPython << "(r'" << theFileNameForPython << "')";
}
// Dump creation of groups
for ( int i = 0; i < aResult->length(); ++i )
return aResult._retn();
}
+SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
+ SMESH::DriverMED_ReadStatus& theStatus)
+ throw ( SALOME::SALOME_Exception )
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" );
+ SMESH::mesh_array* result = CreateMeshesFromMEDorSAUV(theFileName, theStatus, "CreateMeshesFromMED", theFileName);
+ return result;
+}
+
+//=============================================================================
+/*!
+ * SMESH_Gen_i::CreateMeshFromSAUV
+ *
+ * Create mesh and import data from SAUV file
+ */
+//=============================================================================
+
+SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromSAUV( const char* theFileName,
+ SMESH::DriverMED_ReadStatus& theStatus)
+ throw ( SALOME::SALOME_Exception )
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromSAUV" );
+ std::string sauvfilename(theFileName);
+ std::string medfilename(theFileName);
+ medfilename += ".med";
+ std::string cmd;
+#ifdef WNT
+ cmd = "%PYTHONBIN% ";
+#else
+ cmd = "python ";
+#endif
+ cmd += "-c \"";
+ cmd += "from medutilities import convert ; convert(r'" + sauvfilename + "', 'GIBI', 'MED', 1, r'" + medfilename + "')";
+ cmd += "\"";
+ system(cmd.c_str());
+ SMESH::mesh_array* result = CreateMeshesFromMEDorSAUV(medfilename.c_str(), theStatus, "CreateMeshesFromSAUV", sauvfilename.c_str());
+#ifdef WNT
+ cmd = "%PYTHONBIN% ";
+#else
+ cmd = "python ";
+#endif
+ cmd += "-c \"";
+ cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
+ cmd += "\"";
+ system(cmd.c_str());
+ return result;
+}
+
//=============================================================================
/*!
* SMESH_Gen_i::CreateMeshFromSTL
{
Unexpect aCatch(SALOME_SalomeException);
+ SMESH::mesh_array_var aResult = new SMESH::mesh_array();
+
+#ifdef WITH_CGNS
// Retrieve nb meshes from the file
DriverCGNS_Read myReader;
myReader.SetFile( theFileName );
int nbMeshes = myReader.GetNbMeshes(aStatus);
theStatus = (SMESH::DriverMED_ReadStatus)aStatus;
- SMESH::mesh_array_var aResult = new SMESH::mesh_array();
aResult->length( nbMeshes );
{ // open a new scope to make aPythonDump die before PythonDump in SMESH_Mesh::GetGroups()
// Dump creation of groups
for ( int 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();
}
delete[] smIDs;
}
+ aGroup->CloseOnDisk();
+
// Store node positions on sub-shapes (SMDS_Position):
// ----------------------------------------------------
}
} // loop on meshes
+ // update hyps needing full mesh data restored (issue 20918)
+ for ( hyp_data = hypDataList.begin(); hyp_data != hypDataList.end(); ++hyp_data )
+ {
+ SMESH_Hypothesis_i* hyp = hyp_data->first;
+ hyp->UpdateAsMeshesRestored();
+ }
+
// notify algos on completed restoration
for ( meshi_group = meshGroupList.begin(); meshi_group != meshGroupList.end(); ++meshi_group )
{
ComputeStateEngine (SMESH_subMesh::SUBMESH_RESTORED);
}
- for ( hyp_data = hypDataList.begin(); hyp_data != hypDataList.end(); ++hyp_data )
- {
- SMESH_Hypothesis_i* hyp = hyp_data->first;
- hyp->UpdateAsMeshesRestored(); // for hyps needing full mesh data restored (issue 20918)
- }
-
// close mesh group
if(aTopGroup)
aTopGroup->CloseOnDisk();