mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-04-25 03:22:04 +05:00
0020743: EDF 1271 SMESH : Create a mesh from a group / export groups
void ExportMED(const char *file, const char* theMeshName = NULL, bool theAutoGroups = true, - int theVersion = 0) + int theVersion = 0, + const SMESHDS_Mesh* meshPart = 0)
This commit is contained in:
parent
77b26c3006
commit
00fdc117cd
@ -1045,7 +1045,7 @@ bool SMESH_Mesh::HasModificationsToDiscard() const
|
|||||||
if ( ! _isModified )
|
if ( ! _isModified )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// return true if there the next Compute() will be partial and
|
// return true if the next Compute() will be partial and
|
||||||
// existing but changed elements may prevent successful re-compute
|
// existing but changed elements may prevent successful re-compute
|
||||||
bool hasComputed = false, hasNotComputed = false;
|
bool hasComputed = false, hasNotComputed = false;
|
||||||
map <int, SMESH_subMesh*>::const_iterator i_sm = _mapSubMesh.begin();
|
map <int, SMESH_subMesh*>::const_iterator i_sm = _mapSubMesh.begin();
|
||||||
@ -1069,11 +1069,11 @@ bool SMESH_Mesh::HasModificationsToDiscard() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//================================================================================
|
||||||
/*! Export* methods.
|
/*!
|
||||||
* To store mesh contents on disk in different formats.
|
* \brief Check if any groups of the same type have equal names
|
||||||
*/
|
*/
|
||||||
//=============================================================================
|
//================================================================================
|
||||||
|
|
||||||
bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
|
bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
|
||||||
{
|
{
|
||||||
@ -1092,17 +1092,24 @@ bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMESH_Mesh::ExportMED(const char *file,
|
//================================================================================
|
||||||
const char* theMeshName,
|
/*!
|
||||||
bool theAutoGroups,
|
* \brief Export the mesh to a med file
|
||||||
int theVersion)
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
void SMESH_Mesh::ExportMED(const char * file,
|
||||||
|
const char* theMeshName,
|
||||||
|
bool theAutoGroups,
|
||||||
|
int theVersion,
|
||||||
|
const SMESHDS_Mesh* meshPart)
|
||||||
throw(SALOME_Exception)
|
throw(SALOME_Exception)
|
||||||
{
|
{
|
||||||
Unexpect aCatch(SalomeException);
|
Unexpect aCatch(SalomeException);
|
||||||
|
|
||||||
DriverMED_W_SMESHDS_Mesh myWriter;
|
DriverMED_W_SMESHDS_Mesh myWriter;
|
||||||
myWriter.SetFile ( file, MED::EVersion(theVersion) );
|
myWriter.SetFile ( file, MED::EVersion(theVersion) );
|
||||||
myWriter.SetMesh ( _myMeshDS );
|
myWriter.SetMesh ( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS );
|
||||||
if ( !theMeshName )
|
if ( !theMeshName )
|
||||||
myWriter.SetMeshId ( _idDoc );
|
myWriter.SetMeshId ( _idDoc );
|
||||||
else {
|
else {
|
||||||
@ -1119,69 +1126,96 @@ void SMESH_Mesh::ExportMED(const char *file,
|
|||||||
|
|
||||||
// Pass groups to writer. Provide unique group names.
|
// Pass groups to writer. Provide unique group names.
|
||||||
//set<string> aGroupNames; // Corrected for Mantis issue 0020028
|
//set<string> aGroupNames; // Corrected for Mantis issue 0020028
|
||||||
map< SMDSAbs_ElementType, set<string> > aGroupNames;
|
if ( !meshPart )
|
||||||
char aString [256];
|
{
|
||||||
int maxNbIter = 10000; // to guarantee cycle finish
|
map< SMDSAbs_ElementType, set<string> > aGroupNames;
|
||||||
for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
|
char aString [256];
|
||||||
SMESH_Group* aGroup = it->second;
|
int maxNbIter = 10000; // to guarantee cycle finish
|
||||||
SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
|
for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
|
||||||
if ( aGroupDS ) {
|
SMESH_Group* aGroup = it->second;
|
||||||
SMDSAbs_ElementType aType = aGroupDS->GetType();
|
SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
|
||||||
string aGroupName0 = aGroup->GetName();
|
if ( aGroupDS ) {
|
||||||
aGroupName0.resize(MAX_MED_GROUP_NAME_LENGTH);
|
SMDSAbs_ElementType aType = aGroupDS->GetType();
|
||||||
string aGroupName = aGroupName0;
|
string aGroupName0 = aGroup->GetName();
|
||||||
for (int i = 1; !aGroupNames[aType].insert(aGroupName).second && i < maxNbIter; i++) {
|
aGroupName0.resize(MAX_MED_GROUP_NAME_LENGTH);
|
||||||
sprintf(&aString[0], "GR_%d_%s", i, aGroupName0.c_str());
|
string aGroupName = aGroupName0;
|
||||||
aGroupName = aString;
|
for (int i = 1; !aGroupNames[aType].insert(aGroupName).second && i < maxNbIter; i++) {
|
||||||
aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
|
sprintf(&aString[0], "GR_%d_%s", i, aGroupName0.c_str());
|
||||||
|
aGroupName = aString;
|
||||||
|
aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
|
||||||
|
}
|
||||||
|
aGroupDS->SetStoreName( aGroupName.c_str() );
|
||||||
|
myWriter.AddGroup( aGroupDS );
|
||||||
}
|
}
|
||||||
aGroupDS->SetStoreName( aGroupName.c_str() );
|
|
||||||
myWriter.AddGroup( aGroupDS );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform export
|
// Perform export
|
||||||
myWriter.Perform();
|
myWriter.Perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMESH_Mesh::ExportDAT(const char *file) throw(SALOME_Exception)
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Export the mesh to a DAT file
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
void SMESH_Mesh::ExportDAT(const char * file,
|
||||||
|
const SMESHDS_Mesh* meshPart) throw(SALOME_Exception)
|
||||||
{
|
{
|
||||||
Unexpect aCatch(SalomeException);
|
Unexpect aCatch(SalomeException);
|
||||||
DriverDAT_W_SMDS_Mesh myWriter;
|
DriverDAT_W_SMDS_Mesh myWriter;
|
||||||
myWriter.SetFile(string(file));
|
myWriter.SetFile( file );
|
||||||
myWriter.SetMesh(_myMeshDS);
|
myWriter.SetMesh( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS );
|
||||||
myWriter.SetMeshId(_idDoc);
|
myWriter.SetMeshId(_idDoc);
|
||||||
myWriter.Perform();
|
myWriter.Perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMESH_Mesh::ExportUNV(const char *file) throw(SALOME_Exception)
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Export the mesh to an UNV file
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
void SMESH_Mesh::ExportUNV(const char * file,
|
||||||
|
const SMESHDS_Mesh* meshPart) throw(SALOME_Exception)
|
||||||
{
|
{
|
||||||
Unexpect aCatch(SalomeException);
|
Unexpect aCatch(SalomeException);
|
||||||
DriverUNV_W_SMDS_Mesh myWriter;
|
DriverUNV_W_SMDS_Mesh myWriter;
|
||||||
myWriter.SetFile(string(file));
|
myWriter.SetFile( file );
|
||||||
myWriter.SetMesh(_myMeshDS);
|
myWriter.SetMesh( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS );
|
||||||
myWriter.SetMeshId(_idDoc);
|
myWriter.SetMeshId(_idDoc);
|
||||||
// myWriter.SetGroups(_mapGroup);
|
// myWriter.SetGroups(_mapGroup);
|
||||||
|
|
||||||
for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
|
if ( !meshPart )
|
||||||
SMESH_Group* aGroup = it->second;
|
{
|
||||||
SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
|
for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
|
||||||
if ( aGroupDS ) {
|
SMESH_Group* aGroup = it->second;
|
||||||
string aGroupName = aGroup->GetName();
|
SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
|
||||||
aGroupDS->SetStoreName( aGroupName.c_str() );
|
if ( aGroupDS ) {
|
||||||
myWriter.AddGroup( aGroupDS );
|
string aGroupName = aGroup->GetName();
|
||||||
|
aGroupDS->SetStoreName( aGroupName.c_str() );
|
||||||
|
myWriter.AddGroup( aGroupDS );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
myWriter.Perform();
|
myWriter.Perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMESH_Mesh::ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception)
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Export the mesh to an STL file
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
void SMESH_Mesh::ExportSTL(const char * file,
|
||||||
|
const bool isascii,
|
||||||
|
const SMESHDS_Mesh* meshPart) throw(SALOME_Exception)
|
||||||
{
|
{
|
||||||
Unexpect aCatch(SalomeException);
|
Unexpect aCatch(SalomeException);
|
||||||
DriverSTL_W_SMDS_Mesh myWriter;
|
DriverSTL_W_SMDS_Mesh myWriter;
|
||||||
myWriter.SetFile(string(file));
|
myWriter.SetFile( file );
|
||||||
myWriter.SetIsAscii( isascii );
|
myWriter.SetIsAscii( isascii );
|
||||||
myWriter.SetMesh(_myMeshDS);
|
myWriter.SetMesh( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS);
|
||||||
myWriter.SetMeshId(_idDoc);
|
myWriter.SetMeshId(_idDoc);
|
||||||
myWriter.Perform();
|
myWriter.Perform();
|
||||||
}
|
}
|
||||||
|
@ -219,12 +219,17 @@ public:
|
|||||||
void ExportMED(const char *file,
|
void ExportMED(const char *file,
|
||||||
const char* theMeshName = NULL,
|
const char* theMeshName = NULL,
|
||||||
bool theAutoGroups = true,
|
bool theAutoGroups = true,
|
||||||
int theVersion = 0)
|
int theVersion = 0,
|
||||||
|
const SMESHDS_Mesh* meshPart = 0)
|
||||||
throw(SALOME_Exception);
|
throw(SALOME_Exception);
|
||||||
|
|
||||||
void ExportDAT(const char *file) throw(SALOME_Exception);
|
void ExportDAT(const char * file,
|
||||||
void ExportUNV(const char *file) throw(SALOME_Exception);
|
const SMESHDS_Mesh* meshPart = 0) throw(SALOME_Exception);
|
||||||
void ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception);
|
void ExportUNV(const char * file,
|
||||||
|
const SMESHDS_Mesh* meshPart = 0) throw(SALOME_Exception);
|
||||||
|
void ExportSTL(const char * file,
|
||||||
|
const bool isascii,
|
||||||
|
const SMESHDS_Mesh* meshPart = 0) throw(SALOME_Exception);
|
||||||
|
|
||||||
int NbNodes() const throw(SALOME_Exception);
|
int NbNodes() const throw(SALOME_Exception);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user