const bool doGroupOfFaces,
const bool doGroupOfVolumes,
const bool doGroupOf0DElems,
- const bool doGroupOfBalls)
+ const bool doGroupOfBalls,
+ const bool doAllInGroups)
{
DriverMED_FamilyPtrList aFamilies;
}
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;
}
* Create TFamilyInfo for this family
*/
//=============================================================================
-MED::PFamilyInfo
+MED::PFamilyInfo
DriverMED_Family::GetFamilyInfo(const MED::PWrapper& theWrapper,
const MED::PMeshInfo& theMeshInfo) const
{
*/
//=============================================================================
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);
#include <boost/shared_ptr.hpp>
#include <set>
+#include <limits>
#define REST_NODES_FAMILY 1
#define FIRST_NODE_FAMILY 2
#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;
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
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;
myDoGroupOf0DElems(false),
myDoGroupOfBalls(false),
myAutoDimension(false),
- myAddODOnVertices(false)
+ myAddODOnVertices(false),
+ myDoAllInGroups(false)
{}
void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName,
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;
break;
}
}
-
+
MED::PWrapper myMed = CrWrapper(myFile,myMedVersion);
PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aSpaceDimension,aMeshName);
//MESSAGE("Add - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
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;
myDoGroupOfFaces && nbFaces,
myDoGroupOfVolumes && nbVolumes,
myDoGroupOf0DElems && nb0DElements,
- myDoGroupOfBalls && nbBalls);
+ myDoGroupOfBalls && nbBalls,
+ myDoAllInGroups);
}
else {
aFamilies = DriverMED_Family::MakeFamilies
myDoGroupOfFaces && nbFaces,
myDoGroupOfVolumes && nbVolumes,
myDoGroupOf0DElems && nb0DElements,
- myDoGroupOfBalls && nbBalls);
+ myDoGroupOfBalls && nbBalls,
+ myDoAllInGroups);
}
list<DriverMED_FamilyPtr>::iterator aFamsIter;
for (aFamsIter = aFamilies.begin(); aFamsIter != aFamilies.end(); aFamsIter++)
void AddGroupOfVolumes();
void AddGroupOf0DElems();
void AddGroupOfBalls();
+ void AddAllToGroup();
/*! functions to prepare adding one mesh
*/
bool myDoGroupOfBalls;
bool myAutoDimension;
bool myAddODOnVertices;
+ bool myDoAllInGroups;
};
#endif
* - 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
*/
//================================================================================
int theVersion,
const SMESHDS_Mesh* meshPart,
bool theAutoDimension,
- bool theAddODOnVertices)
+ bool theAddODOnVertices,
+ bool theAllElemsToGroup)
throw(SALOME_Exception)
{
SMESH_TRY;
myWriter.AddGroupOfFaces();
myWriter.AddGroupOfVolumes();
}
+ if ( theAllElemsToGroup )
+ myWriter.AddAllToGroup();
// Pass groups to writer. Provide unique group names.
//set<string> aGroupNames; // Corrected for Mantis issue 0020028
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
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,
_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?'";
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 ));
}
// - 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;
}