mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-14 02:30:33 +05:00
PAL11563: Naming Policy. Add method HasDuplicatedGroupNamesMED() to check group names on duplications before export to MED.
This commit is contained in:
parent
07dd2b04b9
commit
56ee43a2eb
@ -336,6 +336,11 @@ module SMESH
|
||||
SMESH_MeshEditor GetMeshEditor()
|
||||
raises (SALOME::SALOME_Exception);
|
||||
|
||||
/*! Check group names for duplications.
|
||||
* Consider maximum group name length stored in MED file.
|
||||
*/
|
||||
boolean HasDuplicatedGroupNamesMED();
|
||||
|
||||
/*!
|
||||
* Export Mesh to different MED Formats
|
||||
* @params
|
||||
|
@ -63,6 +63,9 @@
|
||||
|
||||
#include "Utils_ExceptHandlers.hxx"
|
||||
|
||||
// maximum stored group name length in MED file
|
||||
#define MAX_MED_GROUP_NAME_LENGTH 80
|
||||
|
||||
#ifdef _DEBUG_
|
||||
static int MYDEBUG = 0;
|
||||
#else
|
||||
@ -746,11 +749,25 @@ throw(SALOME_Exception)
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
/*! Export* methods.
|
||||
* To store mesh contents on disk in different formats.
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
|
||||
{
|
||||
set<string> aGroupNames;
|
||||
for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
|
||||
SMESH_Group* aGroup = it->second;
|
||||
string aGroupName = aGroup->GetName();
|
||||
aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
|
||||
if (!aGroupNames.insert(aGroupName).second)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void SMESH_Mesh::ExportMED(const char *file,
|
||||
const char* theMeshName,
|
||||
bool theAutoGroups,
|
||||
@ -758,6 +775,7 @@ void SMESH_Mesh::ExportMED(const char *file,
|
||||
throw(SALOME_Exception)
|
||||
{
|
||||
Unexpect aCatch(SalomeException);
|
||||
|
||||
DriverMED_W_SMESHDS_Mesh myWriter;
|
||||
myWriter.SetFile ( file, MED::EVersion(theVersion) );
|
||||
myWriter.SetMesh ( _myMeshDS );
|
||||
@ -775,15 +793,28 @@ void SMESH_Mesh::ExportMED(const char *file,
|
||||
myWriter.AddGroupOfVolumes();
|
||||
}
|
||||
|
||||
// Pass groups to writer. Provide unique group names.
|
||||
set<string> aGroupNames;
|
||||
char aString [256];
|
||||
int maxNbIter = 10000; // to guarantee cycle finish
|
||||
for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
|
||||
SMESH_Group* aGroup = it->second;
|
||||
SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
|
||||
if ( aGroupDS ) {
|
||||
aGroupDS->SetStoreName( aGroup->GetName() );
|
||||
string aGroupName0 = aGroup->GetName();
|
||||
aGroupName0.resize(MAX_MED_GROUP_NAME_LENGTH);
|
||||
string aGroupName = aGroupName0;
|
||||
for (int i = 1; !aGroupNames.insert(aGroupName).second && i < maxNbIter; i++) {
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
// Perform export
|
||||
myWriter.Perform();
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,12 @@ public:
|
||||
const TopTools_ListOfShape& GetAncestors(const TopoDS_Shape& theSubShape) const;
|
||||
// return list of ancestors of theSubShape in the order
|
||||
// that lower dimention shapes come first.
|
||||
|
||||
|
||||
/*! Check group names for duplications.
|
||||
* Consider maximum group name length stored in MED file.
|
||||
*/
|
||||
bool HasDuplicatedGroupNamesMED();
|
||||
|
||||
void ExportMED(const char *file,
|
||||
const char* theMeshName = NULL,
|
||||
bool theAutoGroups = true,
|
||||
|
@ -132,12 +132,11 @@ public:
|
||||
throw (SALOME::SALOME_Exception);
|
||||
|
||||
// --- C++ interface
|
||||
|
||||
void SetImpl(::SMESH_Mesh* impl);
|
||||
::SMESH_Mesh& GetImpl(); // :: force no namespace here
|
||||
|
||||
SMESH_Gen_i* GetGen() { return _gen_i; }
|
||||
|
||||
|
||||
int ImportUNVFile( const char* theFileName )
|
||||
throw (SALOME::SALOME_Exception);
|
||||
|
||||
@ -150,6 +149,11 @@ public:
|
||||
SMESH::DriverMED_ReadStatus ImportMEDFile( const char* theFileName, const char* theMeshName )
|
||||
throw (SALOME::SALOME_Exception);
|
||||
|
||||
/*! Check group names for duplications.
|
||||
* Consider maximum group name length stored in MED file.
|
||||
*/
|
||||
CORBA::Boolean HasDuplicatedGroupNamesMED();
|
||||
|
||||
void ExportToMED( const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION theVersion )
|
||||
throw (SALOME::SALOME_Exception);
|
||||
void ExportMED( const char* file, CORBA::Boolean auto_groups )
|
||||
|
Loading…
Reference in New Issue
Block a user