mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-02-11 09:33:08 +05:00
21382: EDF 1985 SMESH: Read/write of .mesh files (GMF format)
Add an option to read/write or not groups of required entities
This commit is contained in:
parent
e1524c66bc
commit
e867938e10
@ -240,8 +240,11 @@ module SMESH
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Create Mesh object importing data from given GMF file
|
* Create 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 CreateMeshesFromGMF( in string theFileName,
|
SMESH_Mesh CreateMeshesFromGMF( in string theFileName,
|
||||||
|
in boolean theMakeRequiredGroups,
|
||||||
out SMESH::ComputeError theError)
|
out SMESH::ComputeError theError)
|
||||||
raises ( SALOME::SALOME_Exception );
|
raises ( SALOME::SALOME_Exception );
|
||||||
|
|
||||||
|
@ -663,7 +663,8 @@ module SMESH
|
|||||||
in string file,
|
in string file,
|
||||||
in boolean overwrite ) raises (SALOME::SALOME_Exception);
|
in boolean overwrite ) raises (SALOME::SALOME_Exception);
|
||||||
void ExportGMF( in SMESH_IDSource meshPart,
|
void ExportGMF( in SMESH_IDSource meshPart,
|
||||||
in string file ) raises (SALOME::SALOME_Exception);
|
in string file,
|
||||||
|
in boolean withRequiredGroups) raises (SALOME::SALOME_Exception);
|
||||||
void ExportPartToDAT( in SMESH_IDSource meshPart,
|
void ExportPartToDAT( in SMESH_IDSource meshPart,
|
||||||
in string file ) raises (SALOME::SALOME_Exception);
|
in string file ) raises (SALOME::SALOME_Exception);
|
||||||
void ExportPartToUNV( in SMESH_IDSource meshPart,
|
void ExportPartToUNV( in SMESH_IDSource meshPart,
|
||||||
|
@ -46,7 +46,8 @@ DriverGMF_MeshCloser::~DriverGMF_MeshCloser()
|
|||||||
}
|
}
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
DriverGMF_Read::DriverGMF_Read():
|
DriverGMF_Read::DriverGMF_Read():
|
||||||
Driver_SMESHDS_Mesh()
|
Driver_SMESHDS_Mesh(),
|
||||||
|
_makeRequiredGroups( true )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
@ -277,40 +278,43 @@ Driver_Mesh::Status DriverGMF_Read::Perform()
|
|||||||
|
|
||||||
// Read required entities into groups
|
// Read required entities into groups
|
||||||
|
|
||||||
// get ids of existing groups
|
if ( _makeRequiredGroups )
|
||||||
std::set< int > groupIDs;
|
|
||||||
const std::set<SMESHDS_GroupBase*>& groups = myMesh->GetGroups();
|
|
||||||
std::set<SMESHDS_GroupBase*>::const_iterator grIter = groups.begin();
|
|
||||||
for ( ; grIter != groups.end(); ++grIter )
|
|
||||||
groupIDs.insert( (*grIter)->GetID() );
|
|
||||||
if ( groupIDs.empty() ) groupIDs.insert( 0 );
|
|
||||||
|
|
||||||
const int kes[4][3] = { { GmfRequiredVertices, SMDSAbs_Node, nodeIDShift },
|
|
||||||
{ GmfRequiredEdges, SMDSAbs_Edge, edgeIDShift },
|
|
||||||
{ GmfRequiredTriangles, SMDSAbs_Face, triaIDShift },
|
|
||||||
{ GmfRequiredQuadrilaterals,SMDSAbs_Face, quadIDShift }};
|
|
||||||
const char* names[4] = { "_required_Vertices" ,
|
|
||||||
"_required_Edges" ,
|
|
||||||
"_required_Triangles" ,
|
|
||||||
"_required_Quadrilaterals" };
|
|
||||||
for ( int i = 0; i < 4; ++i )
|
|
||||||
{
|
{
|
||||||
int gmfKwd = kes[i][0];
|
// get ids of existing groups
|
||||||
SMDSAbs_ElementType entity = (SMDSAbs_ElementType) kes[i][1];
|
std::set< int > groupIDs;
|
||||||
int shift = kes[i][2];
|
const std::set<SMESHDS_GroupBase*>& groups = myMesh->GetGroups();
|
||||||
if ( int nb = GmfStatKwd(meshID, gmfKwd))
|
std::set<SMESHDS_GroupBase*>::const_iterator grIter = groups.begin();
|
||||||
{
|
for ( ; grIter != groups.end(); ++grIter )
|
||||||
const int newID = *groupIDs.rbegin() + 1;
|
groupIDs.insert( (*grIter)->GetID() );
|
||||||
groupIDs.insert( newID );
|
if ( groupIDs.empty() ) groupIDs.insert( 0 );
|
||||||
SMESHDS_Group* group = new SMESHDS_Group( newID, myMesh, entity );
|
|
||||||
group->SetStoreName( names[i] );
|
|
||||||
myMesh->AddGroup( group );
|
|
||||||
|
|
||||||
GmfGotoKwd(meshID, gmfKwd);
|
const int kes[4][3] = { { GmfRequiredVertices, SMDSAbs_Node, nodeIDShift },
|
||||||
for ( int i = 0; i < nb; ++i )
|
{ GmfRequiredEdges, SMDSAbs_Edge, edgeIDShift },
|
||||||
|
{ GmfRequiredTriangles, SMDSAbs_Face, triaIDShift },
|
||||||
|
{ GmfRequiredQuadrilaterals,SMDSAbs_Face, quadIDShift }};
|
||||||
|
const char* names[4] = { "_required_Vertices" ,
|
||||||
|
"_required_Edges" ,
|
||||||
|
"_required_Triangles" ,
|
||||||
|
"_required_Quadrilaterals" };
|
||||||
|
for ( int i = 0; i < 4; ++i )
|
||||||
|
{
|
||||||
|
int gmfKwd = kes[i][0];
|
||||||
|
SMDSAbs_ElementType entity = (SMDSAbs_ElementType) kes[i][1];
|
||||||
|
int shift = kes[i][2];
|
||||||
|
if ( int nb = GmfStatKwd(meshID, gmfKwd))
|
||||||
{
|
{
|
||||||
GmfGetLin(meshID, gmfKwd, &iN[0] );
|
const int newID = *groupIDs.rbegin() + 1;
|
||||||
group->Add( shift + iN[0] );
|
groupIDs.insert( newID );
|
||||||
|
SMESHDS_Group* group = new SMESHDS_Group( newID, myMesh, entity );
|
||||||
|
group->SetStoreName( names[i] );
|
||||||
|
myMesh->AddGroup( group );
|
||||||
|
|
||||||
|
GmfGotoKwd(meshID, gmfKwd);
|
||||||
|
for ( int i = 0; i < nb; ++i )
|
||||||
|
{
|
||||||
|
GmfGetLin(meshID, gmfKwd, &iN[0] );
|
||||||
|
group->Add( shift + iN[0] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,12 +45,19 @@ public:
|
|||||||
DriverGMF_Read();
|
DriverGMF_Read();
|
||||||
~DriverGMF_Read();
|
~DriverGMF_Read();
|
||||||
|
|
||||||
|
void SetMakeRequiredGroups( bool theMakeRequiredGroups )
|
||||||
|
{
|
||||||
|
_makeRequiredGroups = theMakeRequiredGroups;
|
||||||
|
}
|
||||||
|
|
||||||
virtual Status Perform();
|
virtual Status Perform();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Status storeBadNodeIds(const char* gmfKwd, int elemNb, int nb, ...);
|
Status storeBadNodeIds(const char* gmfKwd, int elemNb, int nb, ...);
|
||||||
|
|
||||||
|
bool _makeRequiredGroups;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ extern "C"
|
|||||||
|
|
||||||
|
|
||||||
DriverGMF_Write::DriverGMF_Write():
|
DriverGMF_Write::DriverGMF_Write():
|
||||||
Driver_SMESHDS_Mesh()
|
Driver_SMESHDS_Mesh(), _exportRequiredGroups( true )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
DriverGMF_Write::~DriverGMF_Write()
|
DriverGMF_Write::~DriverGMF_Write()
|
||||||
@ -233,85 +233,88 @@ Driver_Mesh::Status DriverGMF_Write::Perform()
|
|||||||
END_ELEM_WRITE( prism );
|
END_ELEM_WRITE( prism );
|
||||||
|
|
||||||
|
|
||||||
// required entities
|
if ( _exportRequiredGroups )
|
||||||
SMESH_Comment badGroups;
|
|
||||||
const std::set<SMESHDS_GroupBase*>& groupSet = myMesh->GetGroups();
|
|
||||||
std::set<SMESHDS_GroupBase*>::const_iterator grIt = groupSet.begin();
|
|
||||||
for ( ; grIt != groupSet.end(); ++grIt )
|
|
||||||
{
|
{
|
||||||
const SMESHDS_GroupBase* group = *grIt;
|
// required entities
|
||||||
std::string groupName = group->GetStoreName();
|
SMESH_Comment badGroups;
|
||||||
std::string::size_type pos = groupName.find( "_required_" );
|
const std::set<SMESHDS_GroupBase*>& groupSet = myMesh->GetGroups();
|
||||||
if ( pos == std::string::npos ) continue;
|
std::set<SMESHDS_GroupBase*>::const_iterator grIt = groupSet.begin();
|
||||||
|
for ( ; grIt != groupSet.end(); ++grIt )
|
||||||
int gmfKwd;
|
|
||||||
SMDSAbs_EntityType smdsEntity;
|
|
||||||
std::string entity = groupName.substr( pos + strlen("_required_"));
|
|
||||||
if ( entity == "Vertices" ) {
|
|
||||||
gmfKwd = GmfRequiredVertices;
|
|
||||||
smdsEntity = SMDSEntity_Node;
|
|
||||||
}
|
|
||||||
else if ( entity == "Edges" ) {
|
|
||||||
gmfKwd = GmfRequiredEdges;
|
|
||||||
smdsEntity = SMDSEntity_Edge;
|
|
||||||
}
|
|
||||||
else if ( entity == "Triangles" ) {
|
|
||||||
gmfKwd = GmfRequiredTriangles;
|
|
||||||
smdsEntity = SMDSEntity_Triangle;
|
|
||||||
}
|
|
||||||
else if ( entity == "Quadrilaterals" ) {
|
|
||||||
gmfKwd = GmfRequiredQuadrilaterals;
|
|
||||||
smdsEntity = SMDSEntity_Quadrangle;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addMessage( SMESH_Comment("Invalig gmf entity name: ") << entity, /*fatal=*/false );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check elem type in the group
|
|
||||||
int nbOkElems = 0;
|
|
||||||
SMDS_ElemIteratorPtr elemIt = group->GetElements();
|
|
||||||
while ( elemIt->more() )
|
|
||||||
nbOkElems += ( elemIt->next()->GetEntityType() == smdsEntity );
|
|
||||||
|
|
||||||
if ( nbOkElems != group->Extent() && nbOkElems == 0 )
|
|
||||||
{
|
{
|
||||||
badGroups << " " << groupName;
|
const SMESHDS_GroupBase* group = *grIt;
|
||||||
continue;
|
std::string groupName = group->GetStoreName();
|
||||||
}
|
std::string::size_type pos = groupName.find( "_required_" );
|
||||||
|
if ( pos == std::string::npos ) continue;
|
||||||
|
|
||||||
// choose a TElem2IDMap
|
int gmfKwd;
|
||||||
TElem2IDMap* elem2IDMap = 0;
|
SMDSAbs_EntityType smdsEntity;
|
||||||
if ( smdsEntity == SMDSEntity_Quadrangle && nbOkElems != myMesh->NbFaces() )
|
std::string entity = groupName.substr( pos + strlen("_required_"));
|
||||||
elem2IDMap = & quad2IDMap;
|
if ( entity == "Vertices" ) {
|
||||||
else if ( smdsEntity == SMDSEntity_Triangle && nbOkElems != myMesh->NbFaces() )
|
gmfKwd = GmfRequiredVertices;
|
||||||
elem2IDMap = & tria2IDMap;
|
smdsEntity = SMDSEntity_Node;
|
||||||
else if ( smdsEntity == SMDSEntity_Edge && nbOkElems != myMesh->NbEdges() )
|
|
||||||
elem2IDMap = & edge2IDMap;
|
|
||||||
|
|
||||||
// write the group
|
|
||||||
GmfSetKwd( meshID, gmfKwd, nbOkElems );
|
|
||||||
elemIt = group->GetElements();
|
|
||||||
if ( elem2IDMap )
|
|
||||||
for ( ; elemIt->more(); )
|
|
||||||
{
|
|
||||||
const SMDS_MeshElement* elem = elemIt->next();
|
|
||||||
if ( elem->GetEntityType() == smdsEntity )
|
|
||||||
GmfSetLin( meshID, gmfKwd, (*elem2IDMap)[ elem ] );
|
|
||||||
}
|
}
|
||||||
else
|
else if ( entity == "Edges" ) {
|
||||||
for ( int gmfID = 1; elemIt->more(); ++gmfID)
|
gmfKwd = GmfRequiredEdges;
|
||||||
{
|
smdsEntity = SMDSEntity_Edge;
|
||||||
const SMDS_MeshElement* elem = elemIt->next();
|
}
|
||||||
if ( elem->GetEntityType() == smdsEntity )
|
else if ( entity == "Triangles" ) {
|
||||||
GmfSetLin( meshID, gmfKwd, gmfID );
|
gmfKwd = GmfRequiredTriangles;
|
||||||
|
smdsEntity = SMDSEntity_Triangle;
|
||||||
|
}
|
||||||
|
else if ( entity == "Quadrilaterals" ) {
|
||||||
|
gmfKwd = GmfRequiredQuadrilaterals;
|
||||||
|
smdsEntity = SMDSEntity_Quadrangle;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addMessage( SMESH_Comment("Invalig gmf entity name: ") << entity, /*fatal=*/false );
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // loop on groups
|
// check elem type in the group
|
||||||
|
int nbOkElems = 0;
|
||||||
|
SMDS_ElemIteratorPtr elemIt = group->GetElements();
|
||||||
|
while ( elemIt->more() )
|
||||||
|
nbOkElems += ( elemIt->next()->GetEntityType() == smdsEntity );
|
||||||
|
|
||||||
if ( !badGroups.empty() )
|
if ( nbOkElems != group->Extent() && nbOkElems == 0 )
|
||||||
addMessage( SMESH_Comment("Groups of elements of inappropriate geometry:")
|
{
|
||||||
<< badGroups, /*fatal=*/false );
|
badGroups << " " << groupName;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// choose a TElem2IDMap
|
||||||
|
TElem2IDMap* elem2IDMap = 0;
|
||||||
|
if ( smdsEntity == SMDSEntity_Quadrangle && nbOkElems != myMesh->NbFaces() )
|
||||||
|
elem2IDMap = & quad2IDMap;
|
||||||
|
else if ( smdsEntity == SMDSEntity_Triangle && nbOkElems != myMesh->NbFaces() )
|
||||||
|
elem2IDMap = & tria2IDMap;
|
||||||
|
else if ( smdsEntity == SMDSEntity_Edge && nbOkElems != myMesh->NbEdges() )
|
||||||
|
elem2IDMap = & edge2IDMap;
|
||||||
|
|
||||||
|
// write the group
|
||||||
|
GmfSetKwd( meshID, gmfKwd, nbOkElems );
|
||||||
|
elemIt = group->GetElements();
|
||||||
|
if ( elem2IDMap )
|
||||||
|
for ( ; elemIt->more(); )
|
||||||
|
{
|
||||||
|
const SMDS_MeshElement* elem = elemIt->next();
|
||||||
|
if ( elem->GetEntityType() == smdsEntity )
|
||||||
|
GmfSetLin( meshID, gmfKwd, (*elem2IDMap)[ elem ] );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
for ( int gmfID = 1; elemIt->more(); ++gmfID)
|
||||||
|
{
|
||||||
|
const SMDS_MeshElement* elem = elemIt->next();
|
||||||
|
if ( elem->GetEntityType() == smdsEntity )
|
||||||
|
GmfSetLin( meshID, gmfKwd, gmfID );
|
||||||
|
}
|
||||||
|
|
||||||
|
} // loop on groups
|
||||||
|
|
||||||
|
if ( !badGroups.empty() )
|
||||||
|
addMessage( SMESH_Comment("Groups of elements of inappropriate geometry:")
|
||||||
|
<< badGroups, /*fatal=*/false );
|
||||||
|
}
|
||||||
|
|
||||||
return DRS_OK;
|
return DRS_OK;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,16 @@ public:
|
|||||||
DriverGMF_Write();
|
DriverGMF_Write();
|
||||||
~DriverGMF_Write();
|
~DriverGMF_Write();
|
||||||
|
|
||||||
|
void SetExportRequiredGroups( bool toExport )
|
||||||
|
{
|
||||||
|
_exportRequiredGroups = toExport;
|
||||||
|
}
|
||||||
|
|
||||||
virtual Status Perform();
|
virtual Status Perform();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool _exportRequiredGroups;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -545,11 +545,13 @@ int SMESH_Mesh::CGNSToMesh(const char* theFileName,
|
|||||||
*/
|
*/
|
||||||
//================================================================================
|
//================================================================================
|
||||||
|
|
||||||
SMESH_ComputeErrorPtr SMESH_Mesh::GMFToMesh(const char* theFileName)
|
SMESH_ComputeErrorPtr SMESH_Mesh::GMFToMesh(const char* theFileName,
|
||||||
|
bool theMakeRequiredGroups)
|
||||||
{
|
{
|
||||||
DriverGMF_Read myReader;
|
DriverGMF_Read myReader;
|
||||||
myReader.SetMesh(_myMeshDS);
|
myReader.SetMesh(_myMeshDS);
|
||||||
myReader.SetFile(theFileName);
|
myReader.SetFile(theFileName);
|
||||||
|
myReader.SetMakeRequiredGroups( theMakeRequiredGroups );
|
||||||
myReader.Perform();
|
myReader.Perform();
|
||||||
//theMeshName = myReader.GetMeshName();
|
//theMeshName = myReader.GetMeshName();
|
||||||
|
|
||||||
@ -1419,11 +1421,14 @@ void SMESH_Mesh::ExportCGNS(const char * file,
|
|||||||
//================================================================================
|
//================================================================================
|
||||||
|
|
||||||
void SMESH_Mesh::ExportGMF(const char * file,
|
void SMESH_Mesh::ExportGMF(const char * file,
|
||||||
const SMESHDS_Mesh* meshDS)
|
const SMESHDS_Mesh* meshDS,
|
||||||
|
bool withRequiredGroups)
|
||||||
{
|
{
|
||||||
DriverGMF_Write myWriter;
|
DriverGMF_Write myWriter;
|
||||||
myWriter.SetFile( file );
|
myWriter.SetFile( file );
|
||||||
myWriter.SetMesh( const_cast<SMESHDS_Mesh*>( meshDS ));
|
myWriter.SetMesh( const_cast<SMESHDS_Mesh*>( meshDS ));
|
||||||
|
myWriter.SetExportRequiredGroups( withRequiredGroups );
|
||||||
|
|
||||||
myWriter.Perform();
|
myWriter.Perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,8 @@ public:
|
|||||||
|
|
||||||
int CGNSToMesh(const char* theFileName, const int theMeshIndex, std::string& theMeshName);
|
int CGNSToMesh(const char* theFileName, const int theMeshIndex, std::string& theMeshName);
|
||||||
|
|
||||||
SMESH_ComputeErrorPtr GMFToMesh(const char* theFileName);
|
SMESH_ComputeErrorPtr GMFToMesh(const char* theFileName,
|
||||||
|
bool theMakeRequiredGroups);
|
||||||
|
|
||||||
SMESH_Hypothesis::Hypothesis_Status
|
SMESH_Hypothesis::Hypothesis_Status
|
||||||
AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
|
AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
|
||||||
@ -244,7 +245,8 @@ public:
|
|||||||
void ExportCGNS(const char * file,
|
void ExportCGNS(const char * file,
|
||||||
const SMESHDS_Mesh* mesh);
|
const SMESHDS_Mesh* mesh);
|
||||||
void ExportGMF(const char * file,
|
void ExportGMF(const char * file,
|
||||||
const SMESHDS_Mesh* mesh);
|
const SMESHDS_Mesh* mesh,
|
||||||
|
bool withRequiredGroups);
|
||||||
void ExportSAUV(const char *file,
|
void ExportSAUV(const char *file,
|
||||||
const char* theMeshName = NULL,
|
const char* theMeshName = NULL,
|
||||||
bool theAutoGroups = true) throw(SALOME_Exception);
|
bool theAutoGroups = true) throw(SALOME_Exception);
|
||||||
|
@ -226,10 +226,28 @@
|
|||||||
if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
|
if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
|
||||||
anInitialPath = QDir::currentPath();
|
anInitialPath = QDir::currentPath();
|
||||||
|
|
||||||
QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
|
QStringList filenames;
|
||||||
anInitialPath,
|
bool toCreateGroups = true;
|
||||||
filter,
|
|
||||||
QObject::tr( "SMESH_IMPORT_MESH" ) );
|
// if ( theCommandID == 118 ) { // GMF
|
||||||
|
// SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
|
||||||
|
// ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
|
||||||
|
// fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
|
||||||
|
// fd->setNameFilters( filter );
|
||||||
|
// fd->SetChecked( true );
|
||||||
|
// if ( fd->exec() )
|
||||||
|
// filenames << fd->selectedFile();
|
||||||
|
// toCreateGroups = fd->IsChecked();
|
||||||
|
|
||||||
|
// delete fd;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
{
|
||||||
|
filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
|
||||||
|
anInitialPath,
|
||||||
|
filter,
|
||||||
|
QObject::tr( "SMESH_IMPORT_MESH" ) );
|
||||||
|
}
|
||||||
if ( filenames.count() > 0 ) {
|
if ( filenames.count() > 0 ) {
|
||||||
SUIT_OverrideCursor wc;
|
SUIT_OverrideCursor wc;
|
||||||
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||||
@ -308,7 +326,9 @@
|
|||||||
// GMF format
|
// GMF format
|
||||||
SMESH::ComputeError_var res;
|
SMESH::ComputeError_var res;
|
||||||
aMeshes->length( 1 );
|
aMeshes->length( 1 );
|
||||||
aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toLatin1().constData(), res.out() );
|
aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toLatin1().constData(),
|
||||||
|
toCreateGroups,
|
||||||
|
res.out() );
|
||||||
if ( res->code != SMESH::DRS_OK ) {
|
if ( res->code != SMESH::DRS_OK ) {
|
||||||
errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
|
errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
|
||||||
arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
|
arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
|
||||||
@ -598,11 +618,37 @@
|
|||||||
else if ( isGMF )
|
else if ( isGMF )
|
||||||
aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
|
aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
|
||||||
";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
|
";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
|
||||||
if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
|
if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
|
||||||
aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
|
aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
|
||||||
anInitialPath + QString("/") + aMeshName,
|
anInitialPath + QString("/") + aMeshName,
|
||||||
aFilter, aTitle, false);
|
aFilter, aTitle, false);
|
||||||
}
|
}
|
||||||
|
// else if ( isGMF )// Export to GMF
|
||||||
|
// {
|
||||||
|
// SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
|
||||||
|
// ( SMESHGUI::desktop(), false, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
|
||||||
|
// QStringList filters;
|
||||||
|
// filters << QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)"
|
||||||
|
// << QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
|
||||||
|
// fd->setWindowTitle( aTitle );
|
||||||
|
// fd->setNameFilters( filters );
|
||||||
|
|
||||||
|
// if ( !aMeshOrGroup->_is_equivalent( aMesh ))
|
||||||
|
// toCreateGroups = false;
|
||||||
|
// else
|
||||||
|
// toCreateGroups = ( aMesh->NbGroups() > 0 );
|
||||||
|
|
||||||
|
// fd->SetChecked( true );
|
||||||
|
// if ( !anInitialPath.isEmpty() )
|
||||||
|
// fd->setDirectory( anInitialPath );
|
||||||
|
// fd->selectFile(aMeshName);
|
||||||
|
|
||||||
|
// if ( fd->exec() )
|
||||||
|
// aFilename = fd->selectedFile();
|
||||||
|
// toCreateGroups = fd->IsChecked();
|
||||||
|
|
||||||
|
// delete fd;
|
||||||
|
// }
|
||||||
else if ( isCGNS )// Export to CGNS
|
else if ( isCGNS )// Export to CGNS
|
||||||
{
|
{
|
||||||
SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
|
SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
|
||||||
@ -848,7 +894,8 @@
|
|||||||
}
|
}
|
||||||
else if ( isGMF )
|
else if ( isGMF )
|
||||||
{
|
{
|
||||||
aMesh->ExportGMF( aMeshOrGroup, aFilename.toLatin1().data() );
|
toCreateGroups = true;
|
||||||
|
aMesh->ExportGMF( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const SALOME::SALOME_Exception& S_ex){
|
catch (const SALOME::SALOME_Exception& S_ex){
|
||||||
@ -3046,8 +3093,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
|
|||||||
type = SMDSEntity_TriQuad_Hexa; break;
|
type = SMDSEntity_TriQuad_Hexa; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
if ( type != SMDSEntity_Last )
|
if ( type != SMDSEntity_Last )
|
||||||
( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
|
( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SUIT_MessageBox::warning(SMESHGUI::desktop(),
|
SUIT_MessageBox::warning(SMESHGUI::desktop(),
|
||||||
|
@ -1273,6 +1273,10 @@ Please enter correct values and try again</translation>
|
|||||||
<source>SMESH_AUTO_GROUPS</source>
|
<source>SMESH_AUTO_GROUPS</source>
|
||||||
<translation>Automatically create groups</translation>
|
<translation>Automatically create groups</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>SMESH_REQUIRED_GROUPS</source>
|
||||||
|
<translation>Create groups of required entities</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>SMESH_AVAILABLE</source>
|
<source>SMESH_AVAILABLE</source>
|
||||||
<translation>Available</translation>
|
<translation>Available</translation>
|
||||||
|
@ -1232,6 +1232,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromCGNS( const char* theFileName,
|
|||||||
|
|
||||||
SMESH::SMESH_Mesh_ptr
|
SMESH::SMESH_Mesh_ptr
|
||||||
SMESH_Gen_i::CreateMeshesFromGMF( const char* theFileName,
|
SMESH_Gen_i::CreateMeshesFromGMF( const char* theFileName,
|
||||||
|
CORBA::Boolean theMakeRequiredGroups,
|
||||||
SMESH::ComputeError_out theError)
|
SMESH::ComputeError_out theError)
|
||||||
throw ( SALOME::SALOME_Exception )
|
throw ( SALOME::SALOME_Exception )
|
||||||
{
|
{
|
||||||
@ -1254,12 +1255,14 @@ SMESH_Gen_i::CreateMeshesFromGMF( const char* theFileName,
|
|||||||
aStudyBuilder->CommitCommand();
|
aStudyBuilder->CommitCommand();
|
||||||
if ( !aSO->_is_nil() ) {
|
if ( !aSO->_is_nil() ) {
|
||||||
// Update Python script
|
// Update Python script
|
||||||
TPythonDump() << "("<< aSO << ", error) = " << this << ".CreateMeshesFromGMF(r'" << theFileName << "')";
|
TPythonDump() << "("<< aSO << ", error) = " << this << ".CreateMeshesFromGMF(r'"
|
||||||
|
<< theFileName << "', "
|
||||||
|
<< theMakeRequiredGroups << " )";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SMESH_Mesh_i* aServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( aMesh ).in() );
|
SMESH_Mesh_i* aServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( aMesh ).in() );
|
||||||
ASSERT( aServant );
|
ASSERT( aServant );
|
||||||
theError = aServant->ImportGMFFile( theFileName );
|
theError = aServant->ImportGMFFile( theFileName, theMakeRequiredGroups );
|
||||||
aServant->GetImpl().GetMeshDS()->Modified();
|
aServant->GetImpl().GetMeshDS()->Modified();
|
||||||
return aMesh._retn();
|
return aMesh._retn();
|
||||||
}
|
}
|
||||||
|
@ -263,6 +263,7 @@ public:
|
|||||||
|
|
||||||
// Create a mesh and import data from a GMF file
|
// Create a mesh and import data from a GMF file
|
||||||
SMESH::SMESH_Mesh_ptr CreateMeshesFromGMF( const char* theFileName,
|
SMESH::SMESH_Mesh_ptr CreateMeshesFromGMF( const char* theFileName,
|
||||||
|
CORBA::Boolean theMakeRequiredGroups,
|
||||||
SMESH::ComputeError_out theError)
|
SMESH::ComputeError_out theError)
|
||||||
throw ( SALOME::SALOME_Exception );
|
throw ( SALOME::SALOME_Exception );
|
||||||
|
|
||||||
|
@ -483,12 +483,13 @@ int SMESH_Mesh_i::ImportSTLFile( const char* theFileName )
|
|||||||
*/
|
*/
|
||||||
//================================================================================
|
//================================================================================
|
||||||
|
|
||||||
SMESH::ComputeError* SMESH_Mesh_i::ImportGMFFile( const char* theFileName )
|
SMESH::ComputeError* SMESH_Mesh_i::ImportGMFFile( const char* theFileName,
|
||||||
|
bool theMakeRequiredGroups )
|
||||||
throw (SALOME::SALOME_Exception)
|
throw (SALOME::SALOME_Exception)
|
||||||
{
|
{
|
||||||
SMESH_ComputeErrorPtr error;
|
SMESH_ComputeErrorPtr error;
|
||||||
try {
|
try {
|
||||||
error = _impl->GMFToMesh( theFileName );
|
error = _impl->GMFToMesh( theFileName, theMakeRequiredGroups );
|
||||||
}
|
}
|
||||||
catch ( std::bad_alloc& exc ) {
|
catch ( std::bad_alloc& exc ) {
|
||||||
error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, "std::bad_alloc raised" );
|
error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, "std::bad_alloc raised" );
|
||||||
@ -3039,7 +3040,8 @@ void SMESH_Mesh_i::ExportCGNS(::SMESH::SMESH_IDSource_ptr meshPart,
|
|||||||
//================================================================================
|
//================================================================================
|
||||||
|
|
||||||
void SMESH_Mesh_i::ExportGMF(::SMESH::SMESH_IDSource_ptr meshPart,
|
void SMESH_Mesh_i::ExportGMF(::SMESH::SMESH_IDSource_ptr meshPart,
|
||||||
const char* file)
|
const char* file,
|
||||||
|
bool withRequiredGroups)
|
||||||
throw (SALOME::SALOME_Exception)
|
throw (SALOME::SALOME_Exception)
|
||||||
{
|
{
|
||||||
Unexpect aCatch(SALOME_SalomeException);
|
Unexpect aCatch(SALOME_SalomeException);
|
||||||
@ -3049,9 +3051,12 @@ void SMESH_Mesh_i::ExportGMF(::SMESH::SMESH_IDSource_ptr meshPart,
|
|||||||
PrepareForWriting(file,/*overwrite=*/true);
|
PrepareForWriting(file,/*overwrite=*/true);
|
||||||
|
|
||||||
SMESH_MeshPartDS partDS( meshPart );
|
SMESH_MeshPartDS partDS( meshPart );
|
||||||
_impl->ExportGMF(file, &partDS);
|
_impl->ExportGMF(file, &partDS, withRequiredGroups);
|
||||||
|
|
||||||
TPythonDump() << _this() << ".ExportGMF( " << meshPart<< ", r'" << file << "')";
|
TPythonDump() << _this() << ".ExportGMF( "
|
||||||
|
<< meshPart<< ", r'"
|
||||||
|
<< file << "', "
|
||||||
|
<< withRequiredGroups << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
@ -198,7 +198,8 @@ public:
|
|||||||
int ImportSTLFile( const char* theFileName )
|
int ImportSTLFile( const char* theFileName )
|
||||||
throw (SALOME::SALOME_Exception);
|
throw (SALOME::SALOME_Exception);
|
||||||
|
|
||||||
SMESH::ComputeError* ImportGMFFile( const char* theFileName )
|
SMESH::ComputeError* ImportGMFFile( const char* theFileName,
|
||||||
|
bool theMakeRequiredGroups)
|
||||||
throw (SALOME::SALOME_Exception);
|
throw (SALOME::SALOME_Exception);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -249,7 +250,8 @@ public:
|
|||||||
const char* file,
|
const char* file,
|
||||||
CORBA::Boolean overwrite) throw (SALOME::SALOME_Exception);
|
CORBA::Boolean overwrite) throw (SALOME::SALOME_Exception);
|
||||||
void ExportGMF(SMESH::SMESH_IDSource_ptr meshPart,
|
void ExportGMF(SMESH::SMESH_IDSource_ptr meshPart,
|
||||||
const char* file) throw (SALOME::SALOME_Exception);
|
const char* file,
|
||||||
|
CORBA::Boolean withRequiredGroups) throw (SALOME::SALOME_Exception);
|
||||||
|
|
||||||
void ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
|
void ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
|
||||||
const char* file,
|
const char* file,
|
||||||
|
@ -255,8 +255,7 @@ def TreatHypoStatus(status, hypName, geomName, isAlgo):
|
|||||||
def AssureGeomPublished(mesh, geom, name=''):
|
def AssureGeomPublished(mesh, geom, name=''):
|
||||||
if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
|
if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
|
||||||
return
|
return
|
||||||
if not geom.IsSame( mesh.geom ) and \
|
if not geom.GetStudyEntry() and \
|
||||||
not geom.GetStudyEntry() and \
|
|
||||||
mesh.smeshpyD.GetCurrentStudy():
|
mesh.smeshpyD.GetCurrentStudy():
|
||||||
## set the study
|
## set the study
|
||||||
studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
|
studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
|
||||||
@ -508,7 +507,9 @@ class smeshDC(SMESH._objref_SMESH_Gen):
|
|||||||
# @return [ an instance of Mesh class, SMESH::ComputeError ]
|
# @return [ an instance of Mesh class, SMESH::ComputeError ]
|
||||||
# @ingroup l2_impexp
|
# @ingroup l2_impexp
|
||||||
def CreateMeshesFromGMF( self, theFileName ):
|
def CreateMeshesFromGMF( self, theFileName ):
|
||||||
aSmeshMesh, error = SMESH._objref_SMESH_Gen.CreateMeshesFromGMF(self,theFileName)
|
aSmeshMesh, error = SMESH._objref_SMESH_Gen.CreateMeshesFromGMF(self,
|
||||||
|
theFileName,
|
||||||
|
True)
|
||||||
if error.comment: print "*** CreateMeshesFromGMF() errors:\n", error.comment
|
if error.comment: print "*** CreateMeshesFromGMF() errors:\n", error.comment
|
||||||
return Mesh(self, self.geompyD, aSmeshMesh), error
|
return Mesh(self, self.geompyD, aSmeshMesh), error
|
||||||
|
|
||||||
@ -1482,7 +1483,7 @@ class Mesh:
|
|||||||
meshPart = meshPart.mesh
|
meshPart = meshPart.mesh
|
||||||
elif not meshPart:
|
elif not meshPart:
|
||||||
meshPart = self.mesh
|
meshPart = self.mesh
|
||||||
self.mesh.ExportGMF(meshPart, f)
|
self.mesh.ExportGMF(meshPart, f, True)
|
||||||
|
|
||||||
## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
|
## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
|
||||||
# Exports the mesh in a file in MED format and chooses the \a version of MED format
|
# Exports the mesh in a file in MED format and chooses the \a version of MED format
|
||||||
|
Loading…
Reference in New Issue
Block a user