mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-26 09:20:34 +05:00
0020511: EDF 1101 SMESH : Add CGNS to Mesh Format Supported
+ SMESH::mesh_array* CreateMeshesFromCGNS( const char* theFileName, + SMESH::DriverMED_ReadStatus& theStatus )
This commit is contained in:
parent
f1b9e57c55
commit
17e2284321
@ -100,6 +100,7 @@
|
|||||||
|
|
||||||
#include "DriverMED_W_SMESHDS_Mesh.h"
|
#include "DriverMED_W_SMESHDS_Mesh.h"
|
||||||
#include "DriverMED_R_SMESHDS_Mesh.h"
|
#include "DriverMED_R_SMESHDS_Mesh.h"
|
||||||
|
#include "DriverCGNS_Read.hxx"
|
||||||
|
|
||||||
#include "SALOMEDS_Tool.hxx"
|
#include "SALOMEDS_Tool.hxx"
|
||||||
#include "SALOME_NamingService.hxx"
|
#include "SALOME_NamingService.hxx"
|
||||||
@ -1023,6 +1024,84 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromSTL( const char* theFileName
|
|||||||
return aMesh._retn();
|
return aMesh._retn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Create meshes and import data from the CGSN file
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromCGNS( const char* theFileName,
|
||||||
|
SMESH::DriverMED_ReadStatus& theStatus)
|
||||||
|
throw ( SALOME::SALOME_Exception )
|
||||||
|
{
|
||||||
|
Unexpect aCatch(SALOME_SalomeException);
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
// Python Dump
|
||||||
|
TPythonDump aPythonDump;
|
||||||
|
aPythonDump << "([";
|
||||||
|
|
||||||
|
if (theStatus == SMESH::DRS_OK)
|
||||||
|
{
|
||||||
|
SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->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
|
||||||
|
SMESH::SMESH_Mesh_var mesh = createMesh();
|
||||||
|
aResult[i] = SMESH::SMESH_Mesh::_duplicate( mesh );
|
||||||
|
|
||||||
|
// Read mesh data (groups are published automatically by ImportMEDFile())
|
||||||
|
SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( mesh ).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_var aSO;
|
||||||
|
if ( CanPublishInStudy( mesh ) )
|
||||||
|
aSO = PublishMesh( myCurrentStudy, mesh.in(), meshName.c_str() );
|
||||||
|
|
||||||
|
// Python Dump
|
||||||
|
if ( !aSO->_is_nil() )
|
||||||
|
aPythonDump << aSO;
|
||||||
|
else
|
||||||
|
aPythonDump << "mesh_" << i;
|
||||||
|
}
|
||||||
|
aStudyBuilder->CommitCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
aPythonDump << "], status) = " << this << ".CreateMeshesFromCGNS(r'" << theFileName << "')";
|
||||||
|
}
|
||||||
|
// Dump creation of groups
|
||||||
|
for ( int i = 0; i < aResult->length(); ++i )
|
||||||
|
SMESH::ListOfGroups_var groups = aResult[ i ]->GetGroups();
|
||||||
|
|
||||||
|
return aResult._retn();
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
* SMESH_Gen_i::IsReadyToCompute
|
* SMESH_Gen_i::IsReadyToCompute
|
||||||
@ -2367,10 +2446,15 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
|
|||||||
if ( elem->GetType() != SMDSAbs_Node )
|
if ( elem->GetType() != SMDSAbs_Node )
|
||||||
{
|
{
|
||||||
int ID = toKeepIDs ? elem->GetID() : 0;
|
int ID = toKeepIDs ? elem->GetID() : 0;
|
||||||
const SMDS_MeshElement * newElem = editor.AddElement( nodes,
|
const SMDS_MeshElement * newElem;
|
||||||
elem->GetType(),
|
if ( elem->GetEntityType() == SMDSEntity_Polyhedra )
|
||||||
elem->IsPoly(),
|
newElem = editor.GetMeshDS()->
|
||||||
ID);
|
AddPolyhedralVolumeWithID( nodes,
|
||||||
|
static_cast<const SMDS_VtkVolume*>(elem)->GetQuantities(),
|
||||||
|
elem->GetID());
|
||||||
|
else
|
||||||
|
newElem = editor.AddElement( nodes,elem->GetType(),elem->IsPoly(),ID);
|
||||||
|
|
||||||
if ( toCopyGroups && !toKeepIDs )
|
if ( toCopyGroups && !toKeepIDs )
|
||||||
e2eMapByType[ elem->GetType() ].insert( make_pair( elem, newElem ));
|
e2eMapByType[ elem->GetType() ].insert( make_pair( elem, newElem ));
|
||||||
}
|
}
|
||||||
|
@ -234,6 +234,11 @@ public:
|
|||||||
SMESH::SMESH_Mesh_ptr CreateMeshesFromSTL( const char* theFileName )
|
SMESH::SMESH_Mesh_ptr CreateMeshesFromSTL( const char* theFileName )
|
||||||
throw ( SALOME::SALOME_Exception );
|
throw ( SALOME::SALOME_Exception );
|
||||||
|
|
||||||
|
// Create mesh(es) and import data from CGNS file
|
||||||
|
SMESH::mesh_array* CreateMeshesFromCGNS( const char* theFileName,
|
||||||
|
SMESH::DriverMED_ReadStatus& theStatus )
|
||||||
|
throw ( SALOME::SALOME_Exception );
|
||||||
|
|
||||||
// Copy a part of mesh
|
// Copy a part of mesh
|
||||||
SMESH::SMESH_Mesh_ptr CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
|
SMESH::SMESH_Mesh_ptr CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
|
||||||
const char* meshName,
|
const char* meshName,
|
||||||
|
Loading…
Reference in New Issue
Block a user