mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-13 18:20:34 +05:00
23413: [CEA 2025] bug SMESH orientation
Add a flag to MED driver to make all element belong to some group
This commit is contained in:
parent
6e5b6a69fa
commit
5d0b75d9d1
@ -152,7 +152,8 @@ DriverMED_Family
|
||||
const bool doGroupOfFaces,
|
||||
const bool doGroupOfVolumes,
|
||||
const bool doGroupOf0DElems,
|
||||
const bool doGroupOfBalls)
|
||||
const bool doGroupOfBalls,
|
||||
const bool doAllInGroups)
|
||||
{
|
||||
DriverMED_FamilyPtrList aFamilies;
|
||||
|
||||
@ -330,10 +331,38 @@ DriverMED_Family
|
||||
}
|
||||
|
||||
DriverMED_FamilyPtr aNullFam (new DriverMED_Family);
|
||||
aNullFam->SetId(0);
|
||||
aNullFam->SetId( 0 );
|
||||
aNullFam->myType = SMDSAbs_All;
|
||||
aFamilies.push_back(aNullFam);
|
||||
|
||||
if ( doAllInGroups )
|
||||
{
|
||||
if ( !doGroupOfEdges )
|
||||
{
|
||||
DriverMED_FamilyPtr aNigEdgeFam (new DriverMED_Family);
|
||||
aNigEdgeFam->SetId( NIG_EDGES_FAMILY );
|
||||
aNigEdgeFam->myType = SMDSAbs_Edge;
|
||||
aNigEdgeFam->myGroupNames.insert( NIG_GROUP_PREFIX "_EDGES" );
|
||||
aFamilies.push_back(aNigEdgeFam);
|
||||
}
|
||||
if ( !doGroupOfFaces )
|
||||
{
|
||||
DriverMED_FamilyPtr aNigFaceFam (new DriverMED_Family);
|
||||
aNigFaceFam->SetId( NIG_FACES_FAMILY );
|
||||
aNigFaceFam->myType = SMDSAbs_Face;
|
||||
aNigFaceFam->myGroupNames.insert( NIG_GROUP_PREFIX "_FACES" );
|
||||
aFamilies.push_back(aNigFaceFam);
|
||||
}
|
||||
if ( !doGroupOfVolumes )
|
||||
{
|
||||
DriverMED_FamilyPtr aNigVolFam (new DriverMED_Family);
|
||||
aNigVolFam->SetId( NIG_VOLS_FAMILY );
|
||||
aNigVolFam->myType = SMDSAbs_Volume;
|
||||
aNigVolFam->myGroupNames.insert( NIG_GROUP_PREFIX "_VOLS" );
|
||||
aFamilies.push_back(aNigVolFam);
|
||||
}
|
||||
}
|
||||
|
||||
return aFamilies;
|
||||
}
|
||||
|
||||
@ -445,9 +474,8 @@ void DriverMED_Family::Init (SMESHDS_GroupBase* theGroup)
|
||||
*/
|
||||
//=============================================================================
|
||||
DriverMED_FamilyPtrList
|
||||
DriverMED_Family
|
||||
::SplitByType (SMESHDS_SubMesh* theSubMesh,
|
||||
const int theId)
|
||||
DriverMED_Family::SplitByType (SMESHDS_SubMesh* theSubMesh,
|
||||
const int theId)
|
||||
{
|
||||
DriverMED_FamilyPtrList aFamilies;
|
||||
DriverMED_FamilyPtr aNodesFamily (new DriverMED_Family);
|
||||
|
@ -38,6 +38,7 @@
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <set>
|
||||
#include <limits>
|
||||
|
||||
#define REST_NODES_FAMILY 1
|
||||
#define FIRST_NODE_FAMILY 2
|
||||
@ -49,6 +50,14 @@
|
||||
#define REST_BALL_FAMILY -5
|
||||
#define FIRST_ELEM_FAMILY -6
|
||||
|
||||
// Not In Group families
|
||||
#define NIG_EDGES_FAMILY INT_MAX-1
|
||||
#define NIG_FACES_FAMILY INT_MAX-2
|
||||
#define NIG_VOLS_FAMILY INT_MAX-3
|
||||
#define NIG_0DELEM_FAMILY INT_MAX-4
|
||||
#define NIG_BALL_FAMILY INT_MAX-5
|
||||
#define NIG_GROUP_PREFIX "NOT_IN_GRP"
|
||||
|
||||
typedef std::list<DriverMED_FamilyPtr > DriverMED_FamilyPtrList;
|
||||
typedef std::map<int,SMESHDS_SubMesh* > SMESHDS_SubMeshPtrMap;
|
||||
typedef std::list<SMESHDS_GroupBase* > SMESHDS_GroupBasePtrList;
|
||||
@ -76,7 +85,8 @@ class MESHDRIVERMED_EXPORT DriverMED_Family
|
||||
const bool doGroupOfFaces,
|
||||
const bool doGroupOfVolumes,
|
||||
const bool doGroupOf0DElems,
|
||||
const bool doGroupOfBalls);
|
||||
const bool doGroupOfBalls,
|
||||
const bool doAllInGroups);
|
||||
|
||||
//! Create TFamilyInfo for this family
|
||||
MED::PFamilyInfo
|
||||
|
@ -155,7 +155,8 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
|
||||
aFamily->SetGroupAttributVal(anAttrVal);
|
||||
}
|
||||
if(MYDEBUG) MESSAGE(aGroupName);
|
||||
aFamily->AddGroupName(aGroupName);
|
||||
if ( strncmp( aGroupName.c_str(), NIG_GROUP_PREFIX, strlen(NIG_GROUP_PREFIX) ) != 0 )
|
||||
aFamily->AddGroupName(aGroupName);
|
||||
}
|
||||
aFamily->SetId( aFamId );
|
||||
myFamilies[aFamId] = aFamily;
|
||||
|
@ -61,7 +61,8 @@ DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh():
|
||||
myDoGroupOf0DElems(false),
|
||||
myDoGroupOfBalls(false),
|
||||
myAutoDimension(false),
|
||||
myAddODOnVertices(false)
|
||||
myAddODOnVertices(false),
|
||||
myDoAllInGroups(false)
|
||||
{}
|
||||
|
||||
void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName,
|
||||
@ -129,6 +130,32 @@ void DriverMED_W_SMESHDS_Mesh::AddGroupOfVolumes()
|
||||
myDoGroupOfVolumes = true;
|
||||
}
|
||||
|
||||
void DriverMED_W_SMESHDS_Mesh::AddGroupOf0DElems()
|
||||
{
|
||||
myDoGroupOf0DElems = true;
|
||||
}
|
||||
|
||||
void DriverMED_W_SMESHDS_Mesh::AddGroupOfBalls()
|
||||
{
|
||||
myDoGroupOfBalls = true;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Set up a flag to add all elements not belonging to any group to
|
||||
* some auxiliary group. This is needed for SMESH -> SAUVE -> SMESH conversion,
|
||||
* which since PAL0023285 reads only SAUVE elements belonging to any group,
|
||||
* and hence can lose some elements. That auxiliary group is ignored while
|
||||
* reading a MED file.
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void DriverMED_W_SMESHDS_Mesh::AddAllToGroup()
|
||||
{
|
||||
myDoAllInGroups = true;
|
||||
}
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef double (SMDS_MeshNode::* TGetCoord)() const;
|
||||
@ -449,12 +476,20 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
|
||||
int nbEdges = myMesh->NbEdges();
|
||||
int nbFaces = myMesh->NbFaces();
|
||||
int nbVolumes = myMesh->NbVolumes();
|
||||
if (myDoGroupOfNodes && nbNodes) myNodesDefaultFamilyId = REST_NODES_FAMILY;
|
||||
if (myDoGroupOfEdges && nbEdges) myEdgesDefaultFamilyId = REST_EDGES_FAMILY;
|
||||
if (myDoGroupOfFaces && nbFaces) myFacesDefaultFamilyId = REST_FACES_FAMILY;
|
||||
if (myDoGroupOfVolumes && nbVolumes) myVolumesDefaultFamilyId = REST_VOLUMES_FAMILY;
|
||||
if (myDoGroupOf0DElems && nb0DElements) my0DElementsDefaultFamilyId = REST_0DELEM_FAMILY;
|
||||
if (myDoGroupOfBalls && nbBalls) myBallsDefaultFamilyId = REST_BALL_FAMILY;
|
||||
if (myDoGroupOfNodes) myNodesDefaultFamilyId = REST_NODES_FAMILY;
|
||||
if (myDoGroupOfEdges) myEdgesDefaultFamilyId = REST_EDGES_FAMILY;
|
||||
if (myDoGroupOfFaces) myFacesDefaultFamilyId = REST_FACES_FAMILY;
|
||||
if (myDoGroupOfVolumes) myVolumesDefaultFamilyId = REST_VOLUMES_FAMILY;
|
||||
if (myDoGroupOf0DElems) my0DElementsDefaultFamilyId = REST_0DELEM_FAMILY;
|
||||
if (myDoGroupOfBalls) myBallsDefaultFamilyId = REST_BALL_FAMILY;
|
||||
if (myDoAllInGroups )
|
||||
{
|
||||
if (!myDoGroupOfEdges) myEdgesDefaultFamilyId = NIG_EDGES_FAMILY ;
|
||||
if (!myDoGroupOfFaces) myFacesDefaultFamilyId = NIG_FACES_FAMILY ;
|
||||
if (!myDoGroupOfVolumes) myVolumesDefaultFamilyId = NIG_VOLS_FAMILY ;
|
||||
if (!myDoGroupOf0DElems) my0DElementsDefaultFamilyId = NIG_0DELEM_FAMILY ;
|
||||
if (!myDoGroupOfBalls) myBallsDefaultFamilyId = NIG_BALL_FAMILY ;
|
||||
}
|
||||
|
||||
//MESSAGE("Perform - aFamilyInfo");
|
||||
list<DriverMED_FamilyPtr> aFamilies;
|
||||
@ -466,7 +501,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
|
||||
myDoGroupOfFaces && nbFaces,
|
||||
myDoGroupOfVolumes && nbVolumes,
|
||||
myDoGroupOf0DElems && nb0DElements,
|
||||
myDoGroupOfBalls && nbBalls);
|
||||
myDoGroupOfBalls && nbBalls,
|
||||
myDoAllInGroups);
|
||||
}
|
||||
else {
|
||||
aFamilies = DriverMED_Family::MakeFamilies
|
||||
@ -476,7 +512,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
|
||||
myDoGroupOfFaces && nbFaces,
|
||||
myDoGroupOfVolumes && nbVolumes,
|
||||
myDoGroupOf0DElems && nb0DElements,
|
||||
myDoGroupOfBalls && nbBalls);
|
||||
myDoGroupOfBalls && nbBalls,
|
||||
myDoAllInGroups);
|
||||
}
|
||||
list<DriverMED_FamilyPtr>::iterator aFamsIter;
|
||||
for (aFamsIter = aFamilies.begin(); aFamsIter != aFamilies.end(); aFamsIter++)
|
||||
|
@ -59,6 +59,7 @@ class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh
|
||||
void AddGroupOfVolumes();
|
||||
void AddGroupOf0DElems();
|
||||
void AddGroupOfBalls();
|
||||
void AddAllToGroup();
|
||||
|
||||
/*! functions to prepare adding one mesh
|
||||
*/
|
||||
@ -88,6 +89,7 @@ class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh
|
||||
bool myDoGroupOfBalls;
|
||||
bool myAutoDimension;
|
||||
bool myAddODOnVertices;
|
||||
bool myDoAllInGroups;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1386,6 +1386,8 @@ bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
|
||||
* - 2D if all mesh nodes lie on XOY coordinate plane, or
|
||||
* - 3D in the rest cases.
|
||||
* If \a theAutoDimension is \c false, the space dimension is always 3.
|
||||
* \param [in] theAddODOnVertices - to create 0D elements on all vertices
|
||||
* \param [in] theAllElemsToGroup - to make every element to belong to any group (PAL23413)
|
||||
* \return int - mesh index in the file
|
||||
*/
|
||||
//================================================================================
|
||||
@ -1396,7 +1398,8 @@ void SMESH_Mesh::ExportMED(const char * file,
|
||||
int theVersion,
|
||||
const SMESHDS_Mesh* meshPart,
|
||||
bool theAutoDimension,
|
||||
bool theAddODOnVertices)
|
||||
bool theAddODOnVertices,
|
||||
bool theAllElemsToGroup)
|
||||
throw(SALOME_Exception)
|
||||
{
|
||||
SMESH_TRY;
|
||||
@ -1419,6 +1422,8 @@ void SMESH_Mesh::ExportMED(const char * file,
|
||||
myWriter.AddGroupOfFaces();
|
||||
myWriter.AddGroupOfVolumes();
|
||||
}
|
||||
if ( theAllElemsToGroup )
|
||||
myWriter.AddAllToGroup();
|
||||
|
||||
// Pass groups to writer. Provide unique group names.
|
||||
//set<string> aGroupNames; // Corrected for Mantis issue 0020028
|
||||
@ -1474,7 +1479,9 @@ void SMESH_Mesh::ExportSAUV(const char *file,
|
||||
cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
|
||||
cmd += "\"";
|
||||
system(cmd.c_str());
|
||||
ExportMED(medfilename.c_str(), theMeshName, theAutoGroups, 1);
|
||||
ExportMED(medfilename.c_str(), theMeshName, theAutoGroups, /*theVersion=*/1,
|
||||
/*meshPart=*/NULL, /*theAutoDimension=*/false, /*theAddODOnVertices=*/false,
|
||||
/*theAllElemsToGroup=*/true ); // theAllElemsToGroup is for PAL0023413
|
||||
#ifdef WIN32
|
||||
cmd = "%PYTHONBIN% ";
|
||||
#else
|
||||
|
@ -253,7 +253,8 @@ class SMESH_EXPORT SMESH_Mesh
|
||||
int theVersion = 0,
|
||||
const SMESHDS_Mesh* theMeshPart = 0,
|
||||
bool theAutoDimension = false,
|
||||
bool theAddODOnVertices = false)
|
||||
bool theAddODOnVertices = false,
|
||||
bool theAllElemsToGroup = false)
|
||||
throw(SALOME_Exception);
|
||||
|
||||
void ExportDAT(const char * file,
|
||||
|
@ -686,6 +686,7 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand
|
||||
_AString indent = aCommand->GetIndentation();
|
||||
_AString tryStr = indent + "try:";
|
||||
_AString newCmd = indent + tab + ( aCommand->GetString().ToCString() + indent.Length() );
|
||||
_AString pasCmd = indent + tab + "pass"; // to keep valid if newCmd is erased
|
||||
_AString excStr = indent + "except:";
|
||||
_AString msgStr = indent + "\tprint '"; msgStr += method + "() failed. Invalid file name?'";
|
||||
|
||||
@ -693,6 +694,7 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand
|
||||
aCommand->Clear();
|
||||
aCommand->GetString() = newCmd;
|
||||
aCommand->SetOrderNb( ++myNbCommands );
|
||||
myCommands.push_back( new _pyCommand( pasCmd, ++myNbCommands ));
|
||||
myCommands.push_back( new _pyCommand( excStr, ++myNbCommands ));
|
||||
myCommands.push_back( new _pyCommand( msgStr, ++myNbCommands ));
|
||||
}
|
||||
|
@ -1217,11 +1217,11 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMEDorSAUV( const char* theFileNa
|
||||
// - as names of meshes are stored in MED file, we use them for data publishing
|
||||
// - as mesh name is not stored in UNV file, we use file name as name of mesh when publishing data
|
||||
aSO = PublishMesh( myCurrentStudy, mesh.in(), ( theFileName == theFileNameForPython ) ? (*it).c_str() : aFileName.c_str() );
|
||||
|
||||
// Python Dump
|
||||
if ( !aSO->_is_nil() ) {
|
||||
// Python Dump
|
||||
aPythonDump << aSO;
|
||||
} else {
|
||||
// Python Dump
|
||||
aPythonDump << "mesh_" << i;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user