* **1D**: if all mesh nodes lie on OX coordinate axis.
* **2D**: if all mesh nodes lie in XOY coordinate plane.
+* :ref:`Save cell/node numbers to MED file <med_export_numbers_pref>` preference controls whether node and cell numbers are saved.
+
**See Also** a sample TUI Script of an :ref:`Export Mesh <tui_export_mesh>` operation.
* **Show warning when exporting group** - if activated, a warning is displayed when exporting a group.
+.. _med_export_numbers_pref:
+
+ * **Save cell/node numbers to MED file** - if activated, optional node and cell numbers are saved to MED file.
+
.. _medexport_z_tolerance_pref:
* **Z tolerance for MED export** - defines Z tolerance in :ref:`MED Export <export_auto_groups>` dialog.
* - 3D in the rest cases.
* If @a autoDimension is @c false, the space dimension is always 3.
*/
- void ExportMED( in string fileName,
- in boolean auto_groups,
- in long version,
- in boolean overwrite,
- in boolean autoDimension) raises (SALOME::SALOME_Exception);
+ void ExportMED( in string fileName,
+ in boolean auto_groups,
+ in long version,
+ in boolean overwrite,
+ in boolean autoDimension) raises (SALOME::SALOME_Exception);
- long long ExportMEDCoupling(in boolean auto_groups,
- in boolean autoDimension) raises (SALOME::SALOME_Exception);
+ long long ExportMEDCoupling(in boolean auto_groups,
+ in boolean autoDimension) raises (SALOME::SALOME_Exception);
/*!
* Export a [part of] Mesh into a MED file
* - ZTolerance : tolerance in Z direction. If Z coordinate of a node is close to zero
* within a given tolerance, the coordinate is set to zero.
* If @a ZTolerance is negative, the node coordinates are kept as is.
+ * - saveNumbers : enable saving numbers of nodes and cells.
*/
void ExportPartToMED( in SMESH_IDSource meshPart,
in string fileName,
in boolean autoDimension,
in GEOM::ListOfFields fields,
in string geomAssocFields,
- in double ZTolerance) raises (SALOME::SALOME_Exception);
+ in double ZTolerance,
+ in boolean saveNumbers) raises (SALOME::SALOME_Exception);
long long ExportPartToMEDCoupling( in SMESH_IDSource meshPart,
- in boolean auto_groups,
- in boolean autoDimension,
- in GEOM::ListOfFields fields,
- in string geomAssocFields,
- in double ZTolerance) raises (SALOME::SALOME_Exception);
+ in boolean auto_groups,
+ in boolean autoDimension,
+ in GEOM::ListOfFields fields,
+ in string geomAssocFields,
+ in double ZTolerance,
+ in boolean saveNumbers) raises (SALOME::SALOME_Exception);
/*!
* Export Mesh to SAUV formatted file
* Export Mesh to different Formats
* (UNV supported version is I-DEAS 10)
*/
- void ExportDAT( in string file ) raises (SALOME::SALOME_Exception);
- void ExportUNV( in string file ) raises (SALOME::SALOME_Exception);
+ void ExportDAT( in string file,
+ in boolean renumer) raises (SALOME::SALOME_Exception);
+ void ExportUNV( in string file,
+ in boolean renumer ) raises (SALOME::SALOME_Exception);
void ExportSTL( in string file,
in boolean isascii ) raises (SALOME::SALOME_Exception);
void ExportCGNS( in SMESH_IDSource meshPart,
in string file,
in boolean withRequiredGroups) raises (SALOME::SALOME_Exception);
void ExportPartToDAT( in SMESH_IDSource meshPart,
- in string file ) raises (SALOME::SALOME_Exception);
+ in string file,
+ in boolean renumer ) raises (SALOME::SALOME_Exception);
void ExportPartToUNV( in SMESH_IDSource meshPart,
- in string file ) raises (SALOME::SALOME_Exception);
+ in string file,
+ in boolean renumer ) raises (SALOME::SALOME_Exception);
void ExportPartToSTL( in SMESH_IDSource meshPart,
in string file,
in boolean isascii ) raises (SALOME::SALOME_Exception);
raises (SALOME::SALOME_Exception);
/*!
- * Get the internal Id
+ * Get the internal persisten Id
*/
long GetId();
};
<parameter name="auto_groups" value="false"/>
<parameter name="med_ztolerance" value="0.0"/>
<parameter name="show_warning" value="true"/>
+ <parameter name="med_save_numbers" value="true"/>
<parameter name="show_result_notification" value="2"/>
<parameter name="mesh_elem_info" value="1"/>
<parameter name="elem_info_grp_details" value="false"/>
using namespace std;
+//================================================================================
+/*!
+ * \brief Write mesh data to a file
+ * \param [in] renumber - if true, renumber nodes and cell starting from 1
+ * \return Driver_Mesh::Status - Ok or not
+ */
+//================================================================================
+
Driver_Mesh::Status DriverDAT_W_SMDS_Mesh::Perform()
{
Kernel_Utils::Localizer loc;
SCRUTE(nb_of_volumes);
//fprintf(stdout, "%d %d\n", nbNodes, nbCells);
- fprintf(aFileId, "%ld %ld\n", nbNodes, static_cast< long >( nbCells ));
+ fprintf(aFileId, "%ld %ld\n", static_cast< long >( nbNodes ), static_cast< long >( nbCells ));
/****************************************************************************
* ECRITURE DES NOEUDS *
****************************************************************************/
std::vector< size_t > nodeNumByID;
- if ( myMesh->HasNumerationHoles() )
+ if ( myRenumber && myMesh->HasNumerationHoles() )
nodeNumByID.resize( myMesh->MaxNodeID() + 1 );
- int num;
+ smIdType num;
SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator();
for ( num = 1; itNodes->more(); ++num )
{
const SMDS_MeshNode * node = itNodes->next();
+ if ( !myRenumber )
+ num = node->GetID();
+
fprintf(aFileId, "%d %.14e %.14e %.14e\n", num, node->X(), node->Y(), node->Z());
if ( !nodeNumByID.empty() )
for ( SMDS_EdgeIteratorPtr itEdges = myMesh->edgesIterator(); itEdges->more(); ++num )
{
const SMDS_MeshElement * elem = itEdges->next();
+ if ( !myRenumber )
+ num = elem->GetID();
+
fprintf(aFileId, "%d %d ", num, 100 + elem->NbNodes());
for ( SMDS_ElemIteratorPtr it = elem->nodesIterator(); it->more(); )
for ( SMDS_FaceIteratorPtr itFaces = myMesh->facesIterator(); itFaces->more(); ++num )
{
const SMDS_MeshElement * elem = itFaces->next();
+ if ( !myRenumber )
+ num = elem->GetID();
fprintf(aFileId, "%d %d ", num, (elem->IsPoly() ? 400 : 200 ) + elem->NbNodes() );
for ( SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator(); itVolumes->more(); ++num )
{
const SMDS_MeshElement * elem = itVolumes->next();
+ if ( !myRenumber )
+ num = elem->GetID();
+
if ( elem->IsPoly() )
{
fprintf(aFileId, "%d %d ", num, 500 + elem->NbNodes());
class MESHDRIVERDAT_EXPORT DriverDAT_W_SMDS_Mesh: public Driver_SMDS_Mesh
{
public:
- virtual Status Perform();
+ virtual Status Perform() override;
+ void SetRenumber( bool renumber ) { myRenumber = renumber; }
+
+ private:
+
+ bool myRenumber;
};
#endif
using namespace MED;
+//================================================================================
+/*!
+ * \brief Constructor
+ */
+//================================================================================
+
DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh():
myAllSubMeshes (false),
myDoGroupOfNodes (false),
myAddODOnVertices(false),
myDoAllInGroups(false),
myVersion(-1),
- myZTolerance(-1.)
+ myZTolerance(-1.),
+ mySaveNumbers(true)
{}
+//================================================================================
+/*!
+ * \brief Set a file name and a version
+ * \param [in] theFileName - output file name
+ * \param [in] theVersion - desired MED file version == major * 10 + minor
+ */
+//================================================================================
+
void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName, int theVersion)
{
myVersion = theVersion;
Driver_SMESHDS_Mesh::SetFile(theFileName);
}
+//================================================================================
/*!
* MED version is either the latest available, or with an inferior minor,
* to ensure backward compatibility on writing med files.
*/
+//================================================================================
+
string DriverMED_W_SMESHDS_Mesh::GetVersionString(int theMinor, int theNbDigits)
{
TInt majeur, mineur, release;
namespace
{
+ //---------------------------------------------
+ /*!
+ * \brief Retrieving node coordinates utilities
+ */
+ //---------------------------------------------
+
typedef double (SMDS_MeshNode::* TGetCoord)() const;
typedef const char* TName;
typedef const char* TUnit;
}
}
+//================================================================================
+/*!
+ * \brief Write my mesh to a file
+ */
+//================================================================================
+
Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
{
MED::PWrapper myMed = CrWrapperW(myFile, myVersion);
return this->PerformInternal<MED::PWrapper>(myMed);
}
+//================================================================================
+/*!
+ * \brief Write my mesh to a MEDCoupling DS
+ */
+//================================================================================
+
Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh_Mem::Perform()
{
void *ptr(nullptr);
#endif
const EModeSwitch theMode = eFULL_INTERLACE;
const ERepere theSystem = eCART;
- const EBooleen theIsElemNum = eVRAI;
+ const EBooleen theIsElemNum = mySaveNumbers ? eVRAI : eFAUX;
const EBooleen theIsElemNames = eFAUX;
const EConnectivite theConnMode = eNOD;
class SMESHDS_SubMesh;
class SMDS_MeshElement;
+/*!
+ * \brief Write a mesh to a MED file
+ */
class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh
{
public:
void SetFile(const std::string& theFileName, int theVersion=-1);
void SetAutoDimension(bool toFindOutDimension) { myAutoDimension = toFindOutDimension; }
void SetZTolerance(double tol) { myZTolerance = tol; }
+ void SetSaveNumbers(bool toSave) { mySaveNumbers = toSave; }
static std::string GetVersionString(int theMinor, int theNbDigits=2);
private:
std::list<SMESHDS_GroupBase*> myGroups;
- bool myAllSubMeshes;
+ bool myAllSubMeshes;
std::vector<SMESHDS_SubMesh*> mySubMeshes;
- bool myDoGroupOfNodes;
- bool myDoGroupOfEdges;
- bool myDoGroupOfFaces;
- bool myDoGroupOfVolumes;
- bool myDoGroupOf0DElems;
- bool myDoGroupOfBalls;
- bool myAutoDimension;
- bool myAddODOnVertices;
- bool myDoAllInGroups;
- int myVersion;
- double myZTolerance;
+ bool myDoGroupOfNodes;
+ bool myDoGroupOfEdges;
+ bool myDoGroupOfFaces;
+ bool myDoGroupOfVolumes;
+ bool myDoGroupOf0DElems;
+ bool myDoGroupOfBalls;
+ bool myAutoDimension;
+ bool myAddODOnVertices;
+ bool myDoAllInGroups;
+ int myVersion;
+ double myZTolerance;
+ bool mySaveNumbers;
};
#include "MEDCouplingMemArray.hxx"
+/*!
+ * \brief Write a mesh to a MEDCoupling DS
+ */
class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh_Mem : public DriverMED_W_SMESHDS_Mesh
{
public:
#else
std::ofstream out_stream(myFile.c_str());
#endif
- try{
-
+ try
+ {
UNV164::Write( out_stream ); // unit system
UNV2420::Write( out_stream, myMeshName ); // Coordinate system
std::vector< size_t > nodeLabelByID;
- if ( myMesh->HasNumerationHoles() )
+ if ( myMesh->HasNumerationHoles() && myRenumber )
nodeLabelByID.resize( myMesh->MaxNodeID() + 1 );
{
for ( aRec.label = 1; aNodesIter->more(); ++aRec.label )
{
const SMDS_MeshNode* aNode = aNodesIter->next();
- // aRec.label = aNode->GetID(); -- IPAL54452
+ if ( !myRenumber )
+ aRec.label = aNode->GetID(); //-- IPAL54452
if ( !nodeLabelByID.empty() )
nodeLabelByID[ aNode->GetID() ] = aRec.label;
aRec.coord[0] = aNode->X();
while ( anIter->more() )
{
const SMDS_MeshEdge* anElem = anIter->next();
- // aRec.label = anElem->GetID(); -- IPAL54452
- ++aRec.label;
+ if ( myRenumber ) // -- IPAL54452
+ ++aRec.label;
+ else
+ aRec.label = anElem->GetID();
if ( !elemLabelByID.empty() )
elemLabelByID[ anElem->GetID() ] = aRec.label;
if ( anElem->IsPoly() ) continue;
SMDS_NodeIteratorPtr aNodesIter = anElem->nodesIteratorToUNV();
- for ( aRec.node_labels.clear(); aNodesIter->more(); ) {
+ for ( aRec.node_labels.clear(); aNodesIter->more(); )
+ {
const SMDS_MeshNode* aNode = aNodesIter->next();
if ( nodeLabelByID.empty() )
aRec.node_labels.push_back( FromSmIdType<int>(aNode->GetID()) );
default:
continue;
}
- // aRec.label = anElem->GetID(); -- IPAL54452
- ++aRec.label;
+ if ( myRenumber )
+ ++aRec.label;
+ else
+ aRec.label = anElem->GetID(); // -- IPAL54452
if ( !elemLabelByID.empty() )
elemLabelByID[ anElem->GetID() ] = aRec.label;
default:
continue;
}
- // aRec.label = anElem->GetID(); -- IPAL54452
- ++aRec.label;
+ if ( myRenumber )
+ ++aRec.label; // -- IPAL54452
+ else
+ aRec.label = anElem->GetID();
if ( !elemLabelByID.empty() )
elemLabelByID[ anElem->GetID() ] = aRec.label;
// --------------------
{
using namespace UNV2417;
- if ( myGroups.size() > 0 ) {
+ if ( myGroups.size() > 0 )
+ {
TRecord aRec;
TDataSet aDataSet2417;
TGroupList::const_iterator aIter = myGroups.begin();
while ( aIter->more() ) {
const SMDS_MeshElement* aNode = aIter->next();
if ( nodeLabelByID.empty() )
- aRec.NodeList.push_back( FromSmIdType<int>(aNode->GetID()) );
+ aRec.NodeList.push_back( FromSmIdType<int>( aNode->GetID()) );
else
aRec.NodeList.push_back( nodeLabelByID[ aNode->GetID() ]);
}
virtual Status Perform() override;
void AddGroup(SMESHDS_GroupBase* theGroup) { myGroups.push_back(theGroup); }
+ void SetRenumber( bool renumber ) { myRenumber = renumber; }
private:
TGroupList myGroups;
+ bool myRenumber;
};
med_int wantedMajor = MED_MAJOR_NUM;
med_int wantedMinor = MED_MINOR_NUM;
// when non managed version of file is requested : ignore it and take the latest version
- std::vector<int> versionsOK(GetMEDVersionsAppendCompatible());
- bool isVersionRequestedOK(std::find(versionsOK.begin(),versionsOK.end(),theVersion)!=versionsOK.end());
+ std::vector<int> versionsOK = GetMEDVersionsAppendCompatible();
+ bool isVersionRequestedOK = std::find(versionsOK.begin(),versionsOK.end(),theVersion)!=versionsOK.end();
if (isCreated && isVersionRequestedOK)
{
- wantedMajor = theVersion/10;
- wantedMinor = theVersion%10;
+ wantedMajor = theVersion / 10;
+ wantedMinor = theVersion % 10;
}
return new MED::TWrapper(fileName, true, tfileInst, wantedMajor, wantedMinor);
}
TElemInfo
::SetElemNum(TInt theId, TInt theVal)
{
- (*myElemNum)[theId] = theVal;
+ if ( IsElemNum() )
+ (*myElemNum)[theId] = theVal;
}
//---------------------------------------------------------------
}
}
- TTFamilyInfo(const PMeshInfo& theMeshInfo,
- TInt theNbGroup,
- TInt theNbAttr,
- TInt theId,
+ TTFamilyInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbGroup,
+ TInt theNbAttr,
+ TInt theId,
const std::string& theValue):
TNameInfoBase(theValue)
{
myAttrDesc.resize(theNbAttr*GetDESCLength()+1);
}
- TTFamilyInfo(const PMeshInfo& theMeshInfo,
- const std::string& theValue,
- TInt theId,
- const TStringSet& theGroupNames,
- const TStringVector& theAttrDescs,
- const TIntVector& theAttrIds,
- const TIntVector& theAttrVals):
+ TTFamilyInfo(const PMeshInfo& theMeshInfo,
+ const std::string& theValue,
+ TInt theId,
+ const TStringSet& theGroupNames,
+ const TStringVector& theAttrDescs,
+ const TIntVector& theAttrIds,
+ const TIntVector& theAttrVals):
TNameInfoBase(theValue)
{
myMeshInfo = theMeshInfo;
virtual
std::string
- GetGroupName(TInt theId) const
- {
+ GetGroupName(TInt theId) const
+ {
return GetString(theId, GetLNOMLength(), myGroupNames);
}
}
}
- TTElemInfo(const PMeshInfo& theMeshInfo,
- TInt theNbElem,
- EBooleen theIsElemNum,
- EBooleen theIsElemNames)
+ TTElemInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames)
{
myMeshInfo = theMeshInfo;
myElemNames.reset(new TString(theNbElem*GetPNOMLength() + 1));
else
myElemNames.reset(new TString());
- }
-
- TTElemInfo(const PMeshInfo& theMeshInfo,
- TInt theNbElem,
- const TIntVector& theFamilyNums,
- const TIntVector& theElemNums,
+ }
+
+ TTElemInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
const TStringVector& theElemNames)
{
myMeshInfo = theMeshInfo;
-
+
myNbElem = theNbElem;
myFamNum.reset(new TElemNum(theNbElem));
myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum()
-
+
myIsElemNum = theElemNums.size()? eVRAI: eFAUX;
if(myIsElemNum)
myElemNum.reset(new TElemNum(theNbElem));
else
myElemNum.reset(new TElemNum());
-
+
myIsElemNames = theElemNames.size()? eVRAI: eFAUX;
if(myIsElemNames)
myElemNames.reset(new TString(theNbElem*GetPNOMLength() + 1));
myEntity = theInfo->GetEntity();
myGeom = theInfo->GetGeom();
myConnMode = theInfo->GetConnMode();
-
+
TInt aConnDim = GetNbNodes(myGeom);
TInt aNbConn = GetNbConn(myGeom, myEntity, myMeshInfo->myDim);
myConn.reset(new TElemNum(myNbElem * aNbConn));
}
}
- TTCellInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
+ TTCellInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
EGeometrieElement theGeom,
- TInt theNbElem,
- EConnectivite theConnMode,
- EBooleen theIsElemNum,
- EBooleen theIsElemNames,
- EModeSwitch theMode):
+ TInt theNbElem,
+ EConnectivite theConnMode,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames,
+ EModeSwitch theMode):
TModeSwitchInfo(theMode),
TElemInfoBase(theMeshInfo,
theNbElem,
TInt aNbConn = GetNbConn(theGeom, myEntity, theMeshInfo->myDim);
myConn.reset(new TElemNum(theNbElem * aNbConn));
}
-
- TTCellInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- const TIntVector& theConnectivities,
- EConnectivite theConnMode,
- const TIntVector& theFamilyNums,
- const TIntVector& theElemNums,
+
+ TTCellInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ const TIntVector& theConnectivities,
+ EConnectivite theConnMode,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
const TStringVector& theElemNames,
- EModeSwitch theMode):
+ EModeSwitch theMode):
TModeSwitchInfo(theMode),
TElemInfoBase(theMeshInfo,
(TInt)theConnectivities.size() / GetNbNodes(theGeom),
}
}
- virtual
+ virtual
TInt
- GetConnDim() const
- {
+ GetConnDim() const
+ {
return GetNbConn(myGeom, myEntity, myMeshInfo->myDim);
}
myDiameters.resize( theNbElem );
}
- TTBallInfo(const PMeshInfo& theMeshInfo,
+ TTBallInfo(const PMeshInfo& theMeshInfo,
const TIntVector& theNodes,
TFloatVector& theDiameters,
const TIntVector& theFamilyNums,
};
//---------------------------------------------------------------
- struct TTFieldInfo:
- virtual TFieldInfo,
+ struct TTFieldInfo:
+ virtual TFieldInfo,
virtual TTNameInfo
{
typedef TTNameInfo TNameInfoBase;
myNbRef = theInfo->GetNbRef();
}
- TTFieldInfo(const PMeshInfo& theMeshInfo,
- TInt theNbComp,
- ETypeChamp theType,
+ TTFieldInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbComp,
+ ETypeChamp theType,
const std::string& theValue,
- EBooleen theIsLocal,
- TInt theNbRef):
+ EBooleen theIsLocal,
+ TInt theNbRef):
TNameInfoBase(theValue)
{
myMeshInfo = theMeshInfo;
myGeom2Gauss = theInfo->GetGeom2Gauss();
}
- TTTimeStampInfo(const PFieldInfo& theFieldInfo,
- EEntiteMaillage theEntity,
- const TGeom2Size& theGeom2Size,
+ TTTimeStampInfo(const PFieldInfo& theFieldInfo,
+ EEntiteMaillage theEntity,
+ const TGeom2Size& theGeom2Size,
const TGeom2NbGauss& theGeom2NbGauss,
- TInt theNumDt,
- TInt /*theNumOrd*/,
- TFloat theDt,
- const std::string& theUnitDt,
- const TGeom2Gauss& theGeom2Gauss)
+ TInt theNumDt,
+ TInt /*theNumOrd*/,
+ TFloat theDt,
+ const std::string& theUnitDt,
+ const TGeom2Gauss& theGeom2Gauss)
{
myFieldInfo = theFieldInfo;
myGeom2Gauss = theGeom2Gauss;
}
- virtual
+ virtual
std::string
GetUnitDt() const
- {
+ {
return GetString(0,GetPNOMLength(),myUnitDt);
}
typedef TTNameInfo TNameInfoBase;
TTProfileInfo(const TProfileInfo::TInfo& theInfo,
- EModeProfil theMode):
+ EModeProfil theMode):
TNameInfoBase(boost::get<0>(theInfo))
{
TInt aSize = boost::get<1>(theInfo);
template<class TMeshValueType>
struct TTTimeStampValue: virtual TTimeStampValue<TMeshValueType>
{
- TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
const PTimeStampValueBase& theInfo,
- ETypeChamp theTypeChamp)
+ ETypeChamp theTypeChamp)
{
typedef TTimeStampValue<TMeshValueType> TCompatible;
if(TCompatible* aCompatible = dynamic_cast<TCompatible*>(theInfo.get())){
}
TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
- ETypeChamp theTypeChamp,
- const TGeom2Profile& theGeom2Profile,
- EModeSwitch theMode):
+ ETypeChamp theTypeChamp,
+ const TGeom2Profile& theGeom2Profile,
+ EModeSwitch theMode):
TModeSwitchInfo(theMode)
{
this->myTimeStampInfo = theTimeStampInfo;
aNbElem = aProfileInfo->GetSize();
TInt aNbGauss = theTimeStampInfo->GetNbGauss(aGeom);
-
+
this->GetMeshValue(aGeom).Allocate(aNbElem,aNbGauss,aNbComp);
}
}
- virtual
+ virtual
size_t
GetValueSize(EGeometrieElement theGeom) const
{
return this->GetMeshValue(theGeom).GetSize();
}
- virtual
+ virtual
size_t
GetNbVal(EGeometrieElement theGeom) const
{
return this->GetMeshValue(theGeom).GetNbVal();
}
- virtual
+ virtual
size_t
GetNbGauss(EGeometrieElement theGeom) const
{
return this->GetMeshValue(theGeom).GetNbGauss();
}
- virtual
+ virtual
void
AllocateValue(EGeometrieElement theGeom,
- TInt theNbElem,
- TInt theNbGauss,
- TInt theNbComp,
- EModeSwitch theMode = eFULL_INTERLACE)
+ TInt theNbElem,
+ TInt theNbGauss,
+ TInt theNbComp,
+ EModeSwitch theMode = eFULL_INTERLACE)
{
this->GetMeshValue(theGeom).Allocate(theNbElem,theNbGauss,theNbComp,theMode);
}
-
- virtual
+
+ virtual
unsigned char*
GetValuePtr(EGeometrieElement theGeom)
{
struct TTGrilleInfo:
virtual TGrilleInfo
{
- TTGrilleInfo(const PMeshInfo& theMeshInfo,
+ TTGrilleInfo(const PMeshInfo& theMeshInfo,
const PGrilleInfo& theInfo)
{
myMeshInfo = theMeshInfo;
myCoord = theInfo->GetNodeCoord();
-
+
myGrilleType = theInfo->GetGrilleType();
myCoordNames = theInfo->myCoordNames;
myFamNum = theInfo->myFamNum;
}
- TTGrilleInfo(const PMeshInfo& theMeshInfo,
+ TTGrilleInfo(const PMeshInfo& theMeshInfo,
const EGrilleType& type,
- const TInt nnoeuds)
+ const TInt nnoeuds)
{
myMeshInfo = theMeshInfo;
TInt aSpaceDim = theMeshInfo->GetSpaceDim();
myFamNumNode.resize(nnoeuds);
}
- TTGrilleInfo(const PMeshInfo& theMeshInfo,
+ TTGrilleInfo(const PMeshInfo& theMeshInfo,
const EGrilleType& type)
{
myMeshInfo = theMeshInfo;
myGrilleStructure.resize(aSpaceDim);
}
- TTGrilleInfo(const PMeshInfo& theMeshInfo,
- const EGrilleType& type,
+ TTGrilleInfo(const PMeshInfo& theMeshInfo,
+ const EGrilleType& type,
const MED::TIntVector& nbNodeVec)
{
myMeshInfo = theMeshInfo;
}
virtual
- std::string
- GetCoordUnit(TInt theId) const
- {
+ std::string
+ GetCoordUnit(TInt theId) const
+ {
return GetString(theId,GetPNOMLength(),myCoordUnits);
}
public:
TFileWrapper(const PFileInternal& theFile,
- EModeAcces theMode,
- TErr* theErr = NULL,
- TInt theMinor=-1):
+ EModeAcces theMode,
+ TErr* theErr = NULL,
+ TInt theMinor=-1):
myFile(theFile),
myMinor(theMinor)
{
//----------------------------------------------------------------------------
void
TWrapper
- ::GetMeshInfo(TInt theMeshId,
+ ::GetMeshInfo(TInt theMeshId,
MED::TMeshInfo& theInfo,
- TErr* theErr)
+ TErr* theErr)
{
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
void
TWrapper
::SetMeshInfo(const MED::TMeshInfo& theInfo,
- TErr* theErr)
+ TErr* theErr)
{
TErr aRet;
SetMeshInfo(theInfo, eLECTURE_ECRITURE, &aRet);
void
TWrapper
::SetMeshInfo(const MED::TMeshInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr)
+ EModeAcces theMode,
+ TErr* theErr)
{
TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
//----------------------------------------------------------------------------
PMeshInfo
TWrapper
- ::CrMeshInfo(TInt theDim,
- TInt theSpaceDim,
+ ::CrMeshInfo(TInt theDim,
+ TInt theSpaceDim,
const std::string& theValue,
- EMaillage theType,
+ EMaillage theType,
const std::string& theDesc)
{
return PMeshInfo(new TTMeshInfo
//----------------------------------------------------------------------------
PMeshInfo
TWrapper
- ::GetPMeshInfo(TInt theId,
+ ::GetPMeshInfo(TInt theId,
TErr* theErr)
{
PMeshInfo anInfo = CrMeshInfo();
TInt
TWrapper
::GetNbFamilies(const MED::TMeshInfo& theInfo,
- TErr* theErr)
+ TErr* theErr)
{
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
//----------------------------------------------------------------------------
TInt
TWrapper
- ::GetNbFamAttr(TInt theFamId,
+ ::GetNbFamAttr(TInt theFamId,
const MED::TMeshInfo& theInfo,
- TErr* theErr)
+ TErr* theErr)
{
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
//----------------------------------------------------------------------------
TInt
TWrapper
- ::GetNbFamGroup(TInt theFamId,
+ ::GetNbFamGroup(TInt theFamId,
const MED::TMeshInfo& theInfo,
- TErr* theErr)
+ TErr* theErr)
{
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
//----------------------------------------------------------------------------
void
TWrapper
- ::GetFamilyInfo(TInt theFamId,
+ ::GetFamilyInfo(TInt theFamId,
MED::TFamilyInfo& theInfo,
- TErr* theErr)
+ TErr* theErr)
{
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
void
TWrapper
::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
- TErr* theErr)
+ TErr* theErr)
{
TErr aRet;
SetFamilyInfo(theInfo, eLECTURE_ECRITURE, &aRet);
void
TWrapper
::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr)
+ EModeAcces theMode,
+ TErr* theErr)
{
TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
//----------------------------------------------------------------------------
PFamilyInfo
TWrapper
- ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
- TInt theNbGroup,
- TInt theNbAttr,
- TInt theId,
+ ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbGroup,
+ TInt theNbAttr,
+ TInt theId,
const std::string& theValue)
{
return PFamilyInfo(new TTFamilyInfo
//----------------------------------------------------------------------------
PFamilyInfo
TWrapper
- ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
- const std::string& theValue,
- TInt theId,
- const MED::TStringSet& theGroupNames,
+ ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
+ const std::string& theValue,
+ TInt theId,
+ const MED::TStringSet& theGroupNames,
const MED::TStringVector& theAttrDescs,
- const MED::TIntVector& theAttrIds,
- const MED::TIntVector& theAttrVals)
+ const MED::TIntVector& theAttrIds,
+ const MED::TIntVector& theAttrVals)
{
return PFamilyInfo(new TTFamilyInfo
(theMeshInfo,
//----------------------------------------------------------------------------
PFamilyInfo
TWrapper
- ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
+ ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
const PFamilyInfo& theInfo)
{
return PFamilyInfo(new TTFamilyInfo
PFamilyInfo
TWrapper
::GetPFamilyInfo(const PMeshInfo& theMeshInfo,
- TInt theId,
- TErr* theErr)
+ TInt theId,
+ TErr* theErr)
{
// must be reimplemented in connection with mesh type eSTRUCTURE
// if (theMeshInfo->GetType() != eNON_STRUCTURE)
//----------------------------------------------------------------------------
void
TWrapper
- ::GetNames(TElemInfo& theInfo,
- TInt /*theNb*/,
- EEntiteMaillage theEntity,
+ ::GetNames(TElemInfo& theInfo,
+ TInt /*theNb*/,
+ EEntiteMaillage theEntity,
EGeometrieElement theGeom,
- TErr* theErr)
+ TErr* theErr)
{
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
//----------------------------------------------------------------------------
void
TWrapper
- ::SetNames(const TElemInfo& theInfo,
- EEntiteMaillage theEntity,
+ ::SetNames(const TElemInfo& theInfo,
+ EEntiteMaillage theEntity,
EGeometrieElement theGeom,
- TErr* theErr)
+ TErr* theErr)
{
SetNames(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
}
//----------------------------------------------------------------------------
void
TWrapper
- ::SetNames(const TElemInfo& theInfo,
- EModeAcces theMode,
- EEntiteMaillage theEntity,
+ ::SetNames(const TElemInfo& theInfo,
+ EModeAcces theMode,
+ EEntiteMaillage theEntity,
EGeometrieElement theGeom,
- TErr* theErr)
+ TErr* theErr)
{
TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
MED_NO_DT,
MED_NO_IT,
anEntity,
- aGeom,
+ aGeom,
(TInt)anInfo.myElemNames->size(),
&anElemNames);
if (theErr)
//----------------------------------------------------------------------------
void
TWrapper
- ::GetNumeration(TElemInfo& theInfo,
- TInt /*theNb*/,
- EEntiteMaillage theEntity,
+ ::GetNumeration(TElemInfo& theInfo,
+ TInt /*theNb*/,
+ EEntiteMaillage theEntity,
EGeometrieElement theGeom,
- TErr* theErr)
+ TErr* theErr)
{
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
//----------------------------------------------------------------------------
void
TWrapper
- ::SetNumeration(const TElemInfo& theInfo,
- EEntiteMaillage theEntity,
+ ::SetNumeration(const TElemInfo& theInfo,
+ EEntiteMaillage theEntity,
EGeometrieElement theGeom,
- TErr* theErr)
+ TErr* theErr)
{
SetNumeration(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
}
//----------------------------------------------------------------------------
void
TWrapper
- ::SetNumeration(const TElemInfo& theInfo,
- EModeAcces theMode,
- EEntiteMaillage theEntity,
+ ::SetNumeration(const TElemInfo& theInfo,
+ EModeAcces theMode,
+ EEntiteMaillage theEntity,
EGeometrieElement theGeom,
- TErr* theErr)
+ TErr* theErr)
{
TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
//----------------------------------------------------------------------------
void
TWrapper
- ::GetFamilies(TElemInfo& theInfo,
- TInt /*theNb*/,
- EEntiteMaillage theEntity,
+ ::GetFamilies(TElemInfo& theInfo,
+ TInt /*theNb*/,
+ EEntiteMaillage theEntity,
EGeometrieElement theGeom,
- TErr* theErr)
+ TErr* theErr)
{
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
//----------------------------------------------------------------------------
void
TWrapper
- ::SetFamilies(const TElemInfo& theInfo,
- EEntiteMaillage theEntity,
+ ::SetFamilies(const TElemInfo& theInfo,
+ EEntiteMaillage theEntity,
EGeometrieElement theGeom,
- TErr* theErr)
+ TErr* theErr)
{
SetFamilies(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
}
//----------------------------------------------------------------------------
void
TWrapper
- ::SetFamilies(const TElemInfo& theInfo,
- EModeAcces theMode,
- EEntiteMaillage theEntity,
+ ::SetFamilies(const TElemInfo& theInfo,
+ EModeAcces theMode,
+ EEntiteMaillage theEntity,
EGeometrieElement theGeom,
- TErr* theErr)
+ TErr* theErr)
{
TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
TInt
TWrapper
::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
- TErr* theErr)
+ TErr* theErr)
{
return GetNbNodes(theMeshInfo, eCOOR, theErr);
}
//----------------------------------------------------------------------------
PCellInfo
TWrapper
- ::CrCellInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
+ ::CrCellInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
EGeometrieElement theGeom,
- TInt theNbElem,
- EConnectivite theConnMode,
- EBooleen theIsElemNum,
- EBooleen theIsElemNames,
- EModeSwitch theMode)
+ TInt theNbElem,
+ EConnectivite theConnMode,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames,
+ EModeSwitch theMode)
{
return PCellInfo(new TTCellInfo
(theMeshInfo,
#include <iostream>
#include <fstream>
-#include <boost/make_shared.hpp>
+//#include <boost/make_shared.hpp>
+#include <boost/container/flat_set.hpp>
#if !defined WIN32 && !defined __APPLE__
#include <sys/sysinfo.h>
// keep current nodes of element
std::set<const SMDS_MeshNode*> oldNodes( element->begin_nodes(), element->end_nodes() );
- // change nodes
bool Ok = false;
+
+ // change vtkUnstructuredGrid::Faces
if ( const SMDS_MeshVolume* vol = DownCast<SMDS_MeshVolume>( element ))
Ok = vol->ChangeNodes( nodes, quantities );
+ // change vtkUnstructuredGrid::Connectivity and inverse connectivity
if ( Ok )
- {
- setMyModified();
- updateInverseElements( element, &nodes[0], nodes.size(), oldNodes );
- }
+ if ( SMDS_MeshCell* cell = dynamic_cast<SMDS_MeshCell*>((SMDS_MeshElement*) element))
+ {
+ boost::container::flat_set< const SMDS_MeshNode* > uniqueNodes( nodes.begin(), nodes.end() );
+ const SMDS_MeshNode** nodesPtr = &( *uniqueNodes.begin());
+ const int nbNodes = (int) uniqueNodes.size();
+ Ok = cell->ChangeNodes( nodesPtr, nbNodes );
+ if ( Ok )
+ {
+ updateInverseElements( element, nodesPtr, nbNodes, oldNodes );
+ setMyModified();
+ }
+ }
+
return Ok;
}
}
MgAdapt::Status MgAdapt::addMessage(const std::string& msg,
- const bool isFatal/*=false*/)
+ const bool isFatal/*=false*/)
{
if ( isFatal )
- _myErrorMessages.clear(); // warnings are useless if a fatal error encounters
+ _errorMessages.clear(); // warnings are useless if a fatal error encounters
- _myErrorMessages.push_back( msg );
+ _errorMessages.push_back( msg );
-//~MESSAGE(msg);
+ //~MESSAGE(msg);
#ifdef _DEBUG_
std::cout << msg << std::endl;
#endif
- return ( _myStatus = isFatal ? MgAdapt::DRS_FAIL : MgAdapt::DRS_WARN_SKIP_ELEM );
+ return ( _status = isFatal ? MgAdapt::DRS_FAIL : MgAdapt::DRS_WARN_SKIP_ELEM );
}
void MgAdapt::updateTimeStepRank()
TOptionValues _defaultOptionValues; // default values
TOptionNames _doubleOptions, _charOptions, _boolOptions; // to find a type of option
- std::vector <std::string> _myErrorMessages;
- Status _myStatus;
+ std::vector <std::string> _errorMessages;
+ Status _status;
std::string meshFormatOutputMesh;
std::vector< std::string> solFormatOutput;
std::vector <group> groupVec;
//purpose : Find a mesh with given persistent ID
//=======================================================================
-SMESH_Mesh* SMESH_Hypothesis::GetMeshByPersistentID(int id)
+SMESH_Mesh* SMESH_Hypothesis::GetMeshByPersistentID(int id) const
{
StudyContextStruct* myStudyContext = _gen->GetStudyContext();
map<int, SMESH_Mesh*>::iterator itm = myStudyContext->mapMesh.begin();
/*!
* \brief Find a mesh with given persistent ID
*/
- SMESH_Mesh* GetMeshByPersistentID(int id);
+ SMESH_Mesh* GetMeshByPersistentID(int id) const;
protected:
SMESH_Gen* _gen;
*/
//=============================================================================
-SMESH_Mesh::SMESH_Mesh(int theLocalId,
+SMESH_Mesh::SMESH_Mesh(int theLocalId,
SMESH_Gen* theGen,
bool theIsEmbeddedMode,
SMESHDS_Document* theDocument):
if(MYDEBUG) MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)");
_id = theLocalId;
_gen = theGen;
- _myDocument = theDocument;
- _myMeshDS = theDocument->NewMesh(theIsEmbeddedMode,theLocalId);
+ _document = theDocument;
+ _meshDS = theDocument->NewMesh(theIsEmbeddedMode,theLocalId);
_isShapeToMesh = false;
_isAutoColor = false;
_isModified = false;
_shapeDiagonal = 0.0;
_callUp = NULL;
- _myMeshDS->ShapeToMesh( PseudoShape() );
+ _meshDS->ShapeToMesh( PseudoShape() );
_subMeshHolder = new SubMeshHolder;
+
+ // assure unique persistent ID
+ if ( _document->NbMeshes() > 1 )
+ {
+ std::set< int > ids;
+ for ( _document->InitMeshesIterator(); _document->MoreMesh(); )
+ {
+ SMESHDS_Mesh * meshDS =_document->NextMesh();
+ if ( meshDS != _meshDS )
+ ids.insert( meshDS->GetPersistentId() );
+ }
+
+ if ( ids.count( _meshDS->GetPersistentId() ))
+ {
+ int uniqueID = *ids.rbegin() + 1;
+ _meshDS->SetPersistentId( uniqueID );
+ }
+ }
}
//================================================================================
_groupId( 0 ),
_nbSubShapes( 0 ),
_isShapeToMesh( false ),
- _myDocument( 0 ),
- _myMeshDS( 0 ),
+ _document( 0 ),
+ _meshDS( 0 ),
_gen( 0 ),
_isAutoColor( false ),
_isModified( false ),
{
if(MYDEBUG) MESSAGE("SMESH_Mesh::~SMESH_Mesh");
- if ( _myDocument ) // avoid destructing _myMeshDS from ~SMESH_Gen()
- _myDocument->RemoveMesh( _id );
- _myDocument = 0;
+ if ( _document ) // avoid destructing _meshDS from ~SMESH_Gen()
+ _document->RemoveMesh( _id );
+ _document = 0;
// remove self from studyContext
if ( _gen )
studyContext->mapMesh.erase( _id );
}
- _myMeshDS->ClearMesh();
+ _meshDS->ClearMesh();
// issue 0020340: EDF 1022 SMESH : Crash with FindNodeClosestTo in a second new study
// Notify event listeners at least that something happens
if ( _callUp) delete _callUp;
_callUp = 0;
- if ( _myMeshDS ) {
- // delete _myMeshDS, in a thread in order not to block closing a study with large meshes
+ if ( _meshDS ) {
+ // delete _meshDS, in a thread in order not to block closing a study with large meshes
#ifndef WIN32
- boost::thread aThread(boost::bind( & deleteMeshDS, _myMeshDS ));
+ boost::thread aThread(boost::bind( & deleteMeshDS, _meshDS ));
#else
pthread_t thread;
- int result=pthread_create(&thread, NULL, deleteMeshDS, (void*)_myMeshDS);
+ int result=pthread_create(&thread, NULL, deleteMeshDS, (void*)_meshDS);
#endif
}
}
bool SMESH_Mesh::MeshExists( int meshId ) const
{
- return _myDocument ? bool( _myDocument->GetMesh( meshId )) : false;
+ return _document ? bool( _document->GetMesh( meshId )) : false;
}
//================================================================================
if ( !aShape.IsNull() && _isShapeToMesh ) {
if ( aShape.ShapeType() != TopAbs_COMPOUND && // group contents is allowed to change
- _myMeshDS->ShapeToMesh().ShapeType() != TopAbs_COMPOUND )
+ _meshDS->ShapeToMesh().ShapeType() != TopAbs_COMPOUND )
throw SALOME_Exception(LOCALIZED ("a shape to mesh has already been defined"));
}
// clear current data
- if ( !_myMeshDS->ShapeToMesh().IsNull() )
+ if ( !_meshDS->ShapeToMesh().IsNull() )
{
// removal of a shape to mesh, delete objects referring to sub-shapes:
// - sub-meshes
std::map <int, SMESH_Group *>::iterator i_gr = _mapGroup.begin();
while ( i_gr != _mapGroup.end() ) {
if ( dynamic_cast<SMESHDS_GroupOnGeom*>( i_gr->second->GetGroupDS() )) {
- _myMeshDS->RemoveGroup( i_gr->second->GetGroupDS() );
+ _meshDS->RemoveGroup( i_gr->second->GetGroupDS() );
delete i_gr->second;
_mapGroup.erase( i_gr++ );
}
// clear SMESHDS
TopoDS_Shape aNullShape;
- _myMeshDS->ShapeToMesh( aNullShape );
+ _meshDS->ShapeToMesh( aNullShape );
_shapeDiagonal = 0.0;
}
// set a new geometry
if ( !aShape.IsNull() )
{
- _myMeshDS->ShapeToMesh(aShape);
+ _meshDS->ShapeToMesh(aShape);
_isShapeToMesh = true;
- _nbSubShapes = _myMeshDS->MaxShapeIndex();
+ _nbSubShapes = _meshDS->MaxShapeIndex();
// fill map of ancestors
fillAncestorsMap(aShape);
{
_isShapeToMesh = false;
_shapeDiagonal = 0.0;
- _myMeshDS->ShapeToMesh( PseudoShape() );
+ _meshDS->ShapeToMesh( PseudoShape() );
}
_isModified = false;
}
TopoDS_Shape SMESH_Mesh::GetShapeToMesh() const
{
- return _myMeshDS->ShapeToMesh();
+ return _meshDS->ShapeToMesh();
}
//=======================================================================
if ( HasShapeToMesh() ) // remove all nodes and elements
{
// clear mesh data
- _myMeshDS->ClearMesh();
+ _meshDS->ClearMesh();
// update compute state of submeshes
if ( SMESH_subMesh *sm = GetSubMeshContaining( GetShapeToMesh() ) )
_isShapeToMesh = false;
DriverUNV_R_SMDS_Mesh myReader;
- myReader.SetMesh(_myMeshDS);
+ myReader.SetMesh(_meshDS);
myReader.SetFile(theFileName);
myReader.SetMeshId(-1);
myReader.Perform();
{
SMDS_MeshGroup* aGroup = gr2names->first;
const std::string& aName = gr2names->second;
- SMESHDS_Group* aGroupDS = new SMESHDS_Group( anId++, _myMeshDS, aGroup->GetType() );
+ SMESHDS_Group* aGroupDS = new SMESHDS_Group( anId++, _meshDS, aGroup->GetType() );
aGroupDS->SMDSGroup() = std::move( *aGroup );
aGroupDS->SetStoreName( aName.c_str() );
AddGroup( aGroupDS );
_isShapeToMesh = false;
DriverMED_R_SMESHDS_Mesh myReader;
- myReader.SetMesh(_myMeshDS);
+ myReader.SetMesh(_meshDS);
myReader.SetMeshId(-1);
myReader.SetFile(theFileName);
myReader.SetMeshName(theMeshName);
}
}
- _myMeshDS->Modified();
- _myMeshDS->CompactMesh();
+ _meshDS->Modified();
+ _meshDS->CompactMesh();
return (int) status;
}
_isShapeToMesh = false;
DriverSTL_R_SMDS_Mesh myReader;
- myReader.SetMesh(_myMeshDS);
+ myReader.SetMesh(_meshDS);
myReader.SetFile(theFileName);
myReader.SetMeshId(-1);
myReader.Perform();
#ifdef WITH_CGNS
DriverCGNS_Read myReader;
- myReader.SetMesh(_myMeshDS);
+ myReader.SetMesh(_meshDS);
myReader.SetFile(theFileName);
myReader.SetMeshId(theMeshIndex);
res = myReader.Perform();
bool theMakeRequiredGroups)
{
DriverGMF_Read myReader;
- myReader.SetMesh(_myMeshDS);
+ myReader.SetMesh(_meshDS);
myReader.SetFile(theFileName);
myReader.SetMakeRequiredGroups( theMakeRequiredGroups );
myReader.Perform();
int anHypId,
std::string* anError )
{
- Unexpect aCatch(SalomeException);
if(MYDEBUG) MESSAGE("SMESH_Mesh::AddHypothesis");
if ( anError )
SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape,
int anHypId)
{
- Unexpect aCatch(SalomeException);
if(MYDEBUG) MESSAGE("SMESH_Mesh::RemoveHypothesis");
StudyContextStruct *sc = _gen->GetStudyContext();
const std::list<const SMESHDS_Hypothesis*>&
SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape) const
{
- return _myMeshDS->GetHypothesis(aSubShape);
+ return _meshDS->GetHypothesis(aSubShape);
}
//=======================================================================
{
const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape();
- const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
+ const std::list<const SMESHDS_Hypothesis*>& hypList = _meshDS->GetHypothesis(aSubShape);
std::list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
for ( ; hyp != hypList.end(); hyp++ ) {
const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp );
for ( ; smIt != ancestors.end(); smIt++ )
{
const TopoDS_Shape& curSh = (*smIt)->GetSubShape();
- const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(curSh);
+ const std::list<const SMESHDS_Hypothesis*>& hypList = _meshDS->GetHypothesis(curSh);
std::list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
for ( ; hyp != hypList.end(); hyp++ ) {
const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp );
// get hypos from aSubShape
{
const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape();
- const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
+ const std::list<const SMESHDS_Hypothesis*>& hypList = _meshDS->GetHypothesis(aSubShape);
for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
{
const SMESH_Hypothesis* h = cSMESH_Hyp( *hyp );
for ( ; smIt != ancestors.end(); smIt++ )
{
const TopoDS_Shape& curSh = (*smIt)->GetSubShape();
- const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(curSh);
+ const std::list<const SMESHDS_Hypothesis*>& hypList = _meshDS->GetHypothesis(curSh);
for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
{
const SMESH_Hypothesis* h = cSMESH_Hyp( *hyp );
const std::list<SMESHDS_Command*> & SMESH_Mesh::GetLog()
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetScript()->GetCommands();
+ return _meshDS->GetScript()->GetCommands();
}
//=============================================================================
//=============================================================================
void SMESH_Mesh::ClearLog()
{
- Unexpect aCatch(SalomeException);
- _myMeshDS->GetScript()->Clear();
+ _meshDS->GetScript()->Clear();
}
//=============================================================================
SMESH_subMesh * SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
{
- int index = _myMeshDS->ShapeToIndex(aSubShape);
+ int index = _meshDS->ShapeToIndex(aSubShape);
if ( !index && aSubShape.IsNull() )
return 0;
TopoDS_Iterator it( aSubShape );
if ( it.More() )
{
- index = _myMeshDS->AddCompoundSubmesh( aSubShape, it.Value().ShapeType() );
+ index = _meshDS->AddCompoundSubmesh( aSubShape, it.Value().ShapeType() );
// fill map of Ancestors
while ( _nbSubShapes < index )
- fillAncestorsMap( _myMeshDS->IndexToShape( ++_nbSubShapes ));
+ fillAncestorsMap( _meshDS->IndexToShape( ++_nbSubShapes ));
}
}
// if ( !index )
SMESH_subMesh* aSubMesh = _subMeshHolder->Get( index );
if ( !aSubMesh )
{
- aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
+ aSubMesh = new SMESH_subMesh(index, this, _meshDS, aSubShape);
_subMeshHolder->Add( index, aSubMesh );
// include non-computable sub-meshes in SMESH_subMesh::_ancestors of sub-submeshes
SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape) const
{
- int index = _myMeshDS->ShapeToIndex(aSubShape);
+ int index = _meshDS->ShapeToIndex(aSubShape);
return GetSubMeshContaining( index );
}
void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* hyp)
{
- Unexpect aCatch(SalomeException);
if ( !GetMeshDS()->IsUsedHypothesis( hyp ))
return;
- smIdType nbEntities = ( _myMeshDS->NbNodes() + _myMeshDS->NbElements() );
+ smIdType nbEntities = ( _meshDS->NbNodes() + _meshDS->NbElements() );
if ( hyp && _callUp && !_callUp->IsLoaded() ) // for not loaded mesh (#16648)
{
_callUp->HypothesisModified( hyp->GetID(), /*updateIcons=*/true );
- nbEntities = ( _myMeshDS->NbNodes() + _myMeshDS->NbElements() ); // after loading mesh
+ nbEntities = ( _meshDS->NbNodes() + _meshDS->NbElements() ); // after loading mesh
}
SMESH_Algo *algo;
HasModificationsToDiscard(); // to reset _isModified flag if mesh becomes empty
GetMeshDS()->Modified();
- smIdType newNbEntities = ( _myMeshDS->NbNodes() + _myMeshDS->NbElements() );
+ smIdType newNbEntities = ( _meshDS->NbNodes() + _meshDS->NbElements() );
if ( hyp && _callUp )
_callUp->HypothesisModified( hyp->GetID(), newNbEntities != nbEntities );
}
//=============================================================================
void SMESH_Mesh::SetAutoColor(bool theAutoColor)
{
- Unexpect aCatch(SalomeException);
_isAutoColor = theAutoColor;
}
bool SMESH_Mesh::GetAutoColor()
{
- Unexpect aCatch(SalomeException);
return _isAutoColor;
}
return false;
}
-void SMESH_Mesh::ExportMEDCommmon(DriverMED_W_SMESHDS_Mesh& myWriter,
- const char* theMeshName,
- bool theAutoGroups,
- const SMESHDS_Mesh* meshPart,
- bool theAutoDimension,
- bool theAddODOnVertices,
- double theZTolerance,
- bool theAllElemsToGroup)
+//================================================================================
+/*!
+ * \brief Export the mesh to a writer
+ */
+//================================================================================
+
+void SMESH_Mesh::exportMEDCommmon(DriverMED_W_SMESHDS_Mesh& theWriter,
+ const char* theMeshName,
+ bool theAutoGroups,
+ const SMESHDS_Mesh* theMeshPart,
+ bool theAutoDimension,
+ bool theAddODOnVertices,
+ double theZTolerance,
+ bool theSaveNumbers,
+ bool theAllElemsToGroup)
{
Driver_Mesh::Status status = Driver_Mesh::DRS_OK;
+
SMESH_TRY;
- myWriter.SetMesh ( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS );
- myWriter.SetAutoDimension( theAutoDimension );
- myWriter.AddODOnVertices ( theAddODOnVertices );
- myWriter.SetZTolerance ( theZTolerance );
+
+ theWriter.SetMesh ( theMeshPart ? (SMESHDS_Mesh*) theMeshPart : _meshDS );
+ theWriter.SetAutoDimension( theAutoDimension );
+ theWriter.AddODOnVertices ( theAddODOnVertices );
+ theWriter.SetZTolerance ( theZTolerance );
+ theWriter.SetSaveNumbers ( theSaveNumbers );
if ( !theMeshName )
- myWriter.SetMeshId ( _id );
+ theWriter.SetMeshId ( _id );
else {
- myWriter.SetMeshId ( -1 );
- myWriter.SetMeshName ( theMeshName );
+ theWriter.SetMeshId ( -1 );
+ theWriter.SetMeshName ( theMeshName );
}
if ( theAutoGroups ) {
- myWriter.AddGroupOfNodes();
- myWriter.AddGroupOfEdges();
- myWriter.AddGroupOfFaces();
- myWriter.AddGroupOfVolumes();
- myWriter.AddGroupOf0DElems();
- myWriter.AddGroupOfBalls();
+ theWriter.AddGroupOfNodes();
+ theWriter.AddGroupOfEdges();
+ theWriter.AddGroupOfFaces();
+ theWriter.AddGroupOfVolumes();
+ theWriter.AddGroupOf0DElems();
+ theWriter.AddGroupOfBalls();
}
if ( theAllElemsToGroup )
- myWriter.AddAllToGroup();
+ theWriter.AddAllToGroup();
// Pass groups to writer. Provide unique group names.
//set<string> aGroupNames; // Corrected for Mantis issue 0020028
- if ( !meshPart )
+ if ( !theMeshPart )
{
std::map< SMDSAbs_ElementType, std::set<std::string> > aGroupNames;
char aString [256];
aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
}
aGroupDS->SetStoreName( aGroupName.c_str() );
- myWriter.AddGroup( aGroupDS );
+ theWriter.AddGroup( aGroupDS );
}
}
}
// Perform export
- status = myWriter.Perform();
+ status = theWriter.Perform();
SMESH_CATCH( SMESH::throwSalomeEx );
throw TooLargeForExport("MED");
}
+//================================================================================
/*!
* Same as SMESH_Mesh::ExportMED except for \a file and \a theVersion
*/
-MEDCoupling::MCAuto<MEDCoupling::DataArrayByte> SMESH_Mesh::ExportMEDCoupling(
- const char* theMeshName,
- bool theAutoGroups,
- const SMESHDS_Mesh* meshPart,
- bool theAutoDimension,
- bool theAddODOnVertices,
- double theZTolerance,
- bool theAllElemsToGroup)
+//================================================================================
+
+MEDCoupling::MCAuto<MEDCoupling::DataArrayByte>
+SMESH_Mesh::ExportMEDCoupling(const char* theMeshName,
+ bool theAutoGroups,
+ const SMESHDS_Mesh* theMeshPart,
+ bool theAutoDimension,
+ bool theAddODOnVertices,
+ double theZTolerance,
+ bool theSaveNumbers)
{
- DriverMED_W_SMESHDS_Mesh_Mem myWriter;
- this->ExportMEDCommmon(myWriter,theMeshName,theAutoGroups,meshPart,theAutoDimension,theAddODOnVertices,theZTolerance,theAllElemsToGroup);
- return myWriter.getData();
+ DriverMED_W_SMESHDS_Mesh_Mem writer;
+ this->exportMEDCommmon( writer, theMeshName, theAutoGroups, theMeshPart, theAutoDimension,
+ theAddODOnVertices, theZTolerance, theSaveNumbers,
+ /*AllElemsToGroup(for ExportSAUV())=*/false);
+ return writer.getData();
}
//================================================================================
/*!
* \brief Export the mesh to a med file
- * \param [in] file - name of the MED file
+ * \param [in] theFile - name of the MED file
* \param [in] theMeshName - name of this mesh
* \param [in] theAutoGroups - boolean parameter for creating/not creating
* the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
* the typical use is auto_groups=false.
* \param [in] theVersion - define the minor (xy, where version is x.y.z) of MED file format.
* If theVersion is equal to -1, the minor version is not changed (default).
- * \param [in] meshPart - mesh data to export
+ * \param [in] theMeshPart - mesh data to export
* \param [in] theAutoDimension - if \c true, a space dimension of a MED mesh can be either
* - 1D if all mesh nodes lie on OX coordinate axis, or
* - 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)
- * \param [in] ZTolerance - tolerance in Z direction. If Z coordinate of a node is close to zero
+ * \param [in] theZTolerance - tolerance in Z direction. If Z coordinate of a node is close to zero
* within a given tolerance, the coordinate is set to zero.
* If \a ZTolerance is negative, the node coordinates are kept as is.
+ * \param [in] theSaveNumbers : enable saving numbers of nodes and cells.
+ * \param [in] theAllElemsToGroup - to make every element to belong to any group (PAL23413).
+ * It is used by ExportSAUV() only
* \return int - mesh index in the file
*/
//================================================================================
-void SMESH_Mesh::ExportMED(const char * file,
+void SMESH_Mesh::ExportMED(const char * theFile,
const char* theMeshName,
bool theAutoGroups,
int theVersion,
- const SMESHDS_Mesh* meshPart,
+ const SMESHDS_Mesh* theMeshPart,
bool theAutoDimension,
bool theAddODOnVertices,
double theZTolerance,
+ bool theSaveNumbers,
bool theAllElemsToGroup)
{
MESSAGE("MED_VERSION:"<< theVersion);
- DriverMED_W_SMESHDS_Mesh myWriter;
- myWriter.SetFile( file , theVersion );
- this->ExportMEDCommmon(myWriter,theMeshName,theAutoGroups,meshPart,theAutoDimension,theAddODOnVertices,theZTolerance,theAllElemsToGroup);
+ DriverMED_W_SMESHDS_Mesh writer;
+ writer.SetFile( theFile, theVersion );
+ this->exportMEDCommmon( writer, theMeshName, theAutoGroups, theMeshPart, theAutoDimension, theAddODOnVertices, theZTolerance, theSaveNumbers, theAllElemsToGroup );
}
//================================================================================
*/
//================================================================================
-void SMESH_Mesh::ExportSAUV(const char *file,
- const char* theMeshName,
- bool theAutoGroups)
+void SMESH_Mesh::ExportSAUV(const char *theFile,
+ const char* theMeshName,
+ bool theAutoGroups)
{
- std::string medfilename(file);
+ std::string medfilename( theFile );
medfilename += ".med";
std::string cmd;
#ifdef WIN32
cmd += "\"";
system(cmd.c_str());
try {
- ExportMED(medfilename.c_str(), theMeshName, theAutoGroups, /*minor=*/-1,
- /*meshPart=*/NULL, /*theAutoDimension=*/false, /*theAddODOnVertices=*/false,
- /*zTol=*/-1, /*theAllElemsToGroup=*/true ); // theAllElemsToGroup is for PAL0023413
+ ExportMED( medfilename.c_str(), theMeshName, theAutoGroups, /*minor=*/-1,
+ /*meshPart=*/NULL, /*theAutoDimension=*/false, /*theAddODOnVertices=*/false,
+ /*zTol=*/-1, /*theSaveNumbers=*/false,
+ /*theAllElemsToGroup=*/true ); // theAllElemsToGroup is for PAL0023413
}
catch ( TooLargeForExport )
{
cmd = "python3 ";
#endif
cmd += "-c \"";
- cmd += "from medutilities import convert ; convert(r'" + medfilename + "', 'MED', 'GIBI', 1, r'" + file + "')";
+ cmd += "from medutilities import convert ; convert(r'" + medfilename + "', 'MED', 'GIBI', 1, r'" + theFile + "')";
cmd += "\"";
system(cmd.c_str());
#ifdef WIN32
//================================================================================
void SMESH_Mesh::ExportDAT(const char * file,
- const SMESHDS_Mesh* meshPart)
+ const SMESHDS_Mesh* meshPart,
+ const bool renumber)
{
Driver_Mesh::Status status;
SMESH_TRY;
- DriverDAT_W_SMDS_Mesh myWriter;
- myWriter.SetFile( file );
- myWriter.SetMesh( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS );
- myWriter.SetMeshId(_id);
- status = myWriter.Perform();
+ DriverDAT_W_SMDS_Mesh writer;
+ writer.SetFile( file );
+ writer.SetMesh( meshPart ? (SMESHDS_Mesh*) meshPart : _meshDS );
+ writer.SetMeshId(_id);
+ writer.SetRenumber( renumber );
+ status = writer.Perform();
SMESH_CATCH( SMESH::throwSalomeEx );
//================================================================================
void SMESH_Mesh::ExportUNV(const char * file,
- const SMESHDS_Mesh* meshPart)
+ const SMESHDS_Mesh* meshPart,
+ const bool renumber)
{
Driver_Mesh::Status status;
SMESH_TRY;
- DriverUNV_W_SMDS_Mesh myWriter;
- myWriter.SetFile( file );
- myWriter.SetMesh( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS );
- myWriter.SetMeshId(_id);
- // myWriter.SetGroups(_mapGroup);
+ DriverUNV_W_SMDS_Mesh writer;
+ writer.SetFile( file );
+ writer.SetMesh( meshPart ? (SMESHDS_Mesh*) meshPart : _meshDS );
+ writer.SetMeshId(_id);
+ writer.SetRenumber( renumber );
// pass group names to SMESHDS
if ( !meshPart )
if ( aGroupDS ) {
std::string aGroupName = aGroup->GetName();
aGroupDS->SetStoreName( aGroupName.c_str() );
- myWriter.AddGroup( aGroupDS );
+ writer.AddGroup( aGroupDS );
}
}
}
- status = myWriter.Perform();
+ status = writer.Perform();
SMESH_CATCH( SMESH::throwSalomeEx );
Driver_Mesh::Status status;
SMESH_TRY;
- DriverSTL_W_SMDS_Mesh myWriter;
- myWriter.SetFile( file );
- myWriter.SetIsAscii( isascii );
- myWriter.SetMesh( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS);
- myWriter.SetMeshId(_id);
- if ( name ) myWriter.SetName( name );
- status = myWriter.Perform();
+ DriverSTL_W_SMDS_Mesh writer;
+ writer.SetFile( file );
+ writer.SetIsAscii( isascii );
+ writer.SetMesh( meshPart ? (SMESHDS_Mesh*) meshPart : _meshDS);
+ writer.SetMeshId(_id);
+ if ( name ) writer.SetName( name );
+ status = writer.Perform();
SMESH_CATCH( SMESH::throwSalomeEx );
}
#ifdef WITH_CGNS
- DriverCGNS_Write myWriter;
- myWriter.SetFile( file );
- myWriter.SetMesh( const_cast<SMESHDS_Mesh*>( meshDS ));
- myWriter.SetMeshName( SMESH_Comment("Mesh_") << meshDS->GetPersistentId());
+ DriverCGNS_Write writer;
+ writer.SetFile( file );
+ writer.SetMesh( const_cast<SMESHDS_Mesh*>( meshDS ));
+ writer.SetMeshName( SMESH_Comment("Mesh_") << meshDS->GetPersistentId());
if ( meshName && meshName[0] )
- myWriter.SetMeshName( meshName );
- myWriter.SetElementsByType( groupElemsByType );
- res = myWriter.Perform();
+ writer.SetMeshName( meshName );
+ writer.SetElementsByType( groupElemsByType );
+ res = writer.Perform();
if ( res != Driver_Mesh::DRS_OK )
{
- SMESH_ComputeErrorPtr err = myWriter.GetError();
+ SMESH_ComputeErrorPtr err = writer.GetError();
if ( err && !err->IsOK() && !err->myComment.empty() )
throw SALOME_Exception(("Export failed: " + err->myComment ).c_str() );
}
Driver_Mesh::Status status;
SMESH_TRY;
- DriverGMF_Write myWriter;
- myWriter.SetFile( file );
- myWriter.SetMesh( const_cast<SMESHDS_Mesh*>( meshDS ));
- myWriter.SetExportRequiredGroups( withRequiredGroups );
+ DriverGMF_Write writer;
+ writer.SetFile( file );
+ writer.SetMesh( const_cast<SMESHDS_Mesh*>( meshDS ));
+ writer.SetExportRequiredGroups( withRequiredGroups );
- status = myWriter.Perform();
+ status = writer.Perform();
SMESH_CATCH( SMESH::throwSalomeEx );
smIdType SMESH_Mesh::NbNodes() const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->NbNodes();
+ return _meshDS->NbNodes();
}
//================================================================================
smIdType SMESH_Mesh::Nb0DElements() const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().Nb0DElements();
+ return _meshDS->GetMeshInfo().Nb0DElements();
}
//================================================================================
smIdType SMESH_Mesh::NbEdges(SMDSAbs_ElementOrder order) const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbEdges(order);
+ return _meshDS->GetMeshInfo().NbEdges(order);
}
//================================================================================
smIdType SMESH_Mesh::NbFaces(SMDSAbs_ElementOrder order) const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbFaces(order);
+ return _meshDS->GetMeshInfo().NbFaces(order);
}
//================================================================================
smIdType SMESH_Mesh::NbTriangles(SMDSAbs_ElementOrder order) const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbTriangles(order);
+ return _meshDS->GetMeshInfo().NbTriangles(order);
}
//================================================================================
smIdType SMESH_Mesh::NbBiQuadTriangles() const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbBiQuadTriangles();
+ return _meshDS->GetMeshInfo().NbBiQuadTriangles();
}
//================================================================================
smIdType SMESH_Mesh::NbQuadrangles(SMDSAbs_ElementOrder order) const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbQuadrangles(order);
+ return _meshDS->GetMeshInfo().NbQuadrangles(order);
}
//================================================================================
smIdType SMESH_Mesh::NbBiQuadQuadrangles() const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbBiQuadQuadrangles();
+ return _meshDS->GetMeshInfo().NbBiQuadQuadrangles();
}
//================================================================================
smIdType SMESH_Mesh::NbPolygons(SMDSAbs_ElementOrder order) const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbPolygons(order);
+ return _meshDS->GetMeshInfo().NbPolygons(order);
}
//================================================================================
smIdType SMESH_Mesh::NbVolumes(SMDSAbs_ElementOrder order) const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbVolumes(order);
+ return _meshDS->GetMeshInfo().NbVolumes(order);
}
//================================================================================
smIdType SMESH_Mesh::NbTetras(SMDSAbs_ElementOrder order) const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbTetras(order);
+ return _meshDS->GetMeshInfo().NbTetras(order);
}
//================================================================================
smIdType SMESH_Mesh::NbHexas(SMDSAbs_ElementOrder order) const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbHexas(order);
+ return _meshDS->GetMeshInfo().NbHexas(order);
}
//================================================================================
smIdType SMESH_Mesh::NbTriQuadraticHexas() const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbTriQuadHexas();
+ return _meshDS->GetMeshInfo().NbTriQuadHexas();
}
//================================================================================
smIdType SMESH_Mesh::NbPyramids(SMDSAbs_ElementOrder order) const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbPyramids(order);
+ return _meshDS->GetMeshInfo().NbPyramids(order);
}
//================================================================================
smIdType SMESH_Mesh::NbPrisms(SMDSAbs_ElementOrder order) const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbPrisms(order);
+ return _meshDS->GetMeshInfo().NbPrisms(order);
}
smIdType SMESH_Mesh::NbQuadPrisms() const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbQuadPrisms();
+ return _meshDS->GetMeshInfo().NbQuadPrisms();
}
smIdType SMESH_Mesh::NbBiQuadPrisms() const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbBiQuadPrisms();
+ return _meshDS->GetMeshInfo().NbBiQuadPrisms();
}
smIdType SMESH_Mesh::NbHexagonalPrisms() const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbHexPrisms();
+ return _meshDS->GetMeshInfo().NbHexPrisms();
}
//================================================================================
smIdType SMESH_Mesh::NbPolyhedrons() const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbPolyhedrons();
+ return _meshDS->GetMeshInfo().NbPolyhedrons();
}
//================================================================================
smIdType SMESH_Mesh::NbBalls() const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->GetMeshInfo().NbBalls();
+ return _meshDS->GetMeshInfo().NbBalls();
}
//================================================================================
smIdType SMESH_Mesh::NbSubMesh() const
{
- Unexpect aCatch(SalomeException);
- return _myMeshDS->NbSubMesh();
+ return _meshDS->NbSubMesh();
}
//================================================================================
int SMESH_Mesh::NbMeshes() const // nb meshes in the Study
{
- return _myDocument->NbMeshes();
+ return _document->NbMeshes();
}
//=======================================================================
if(MYDEBUG) MESSAGE("SMESH_Mesh::IsNotConformAllowed");
static SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( "NotConformAllowed" ));
- return GetHypothesis( _myMeshDS->ShapeToMesh(), filter, false );
+ return GetHypothesis( _meshDS->ShapeToMesh(), filter, false );
}
//=======================================================================
bool SMESH_Mesh::IsMainShape(const TopoDS_Shape& theShape) const
{
- return theShape.IsSame(_myMeshDS->ShapeToMesh() );
+ return theShape.IsSame(_meshDS->ShapeToMesh() );
}
//=======================================================================
bool SMESH_Mesh::SynchronizeGroups()
{
const size_t nbGroups = _mapGroup.size();
- const std::set<SMESHDS_GroupBase*>& groups = _myMeshDS->GetGroups();
+ const std::set<SMESHDS_GroupBase*>& groups = _meshDS->GetGroups();
std::set<SMESHDS_GroupBase*>::const_iterator gIt = groups.begin();
for ( ; gIt != groups.end(); ++gIt )
{
save << clause << ".2) Number of " << orderStr << " quadrangles:\t" << nb4 << endl;
if ( nb3 + nb4 != NbFaces(order) ) {
std::map<int,int> myFaceMap;
- SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
+ SMDS_FaceIteratorPtr itFaces=_meshDS->facesIterator();
while( itFaces->more( ) ) {
int nbNodes = itFaces->next()->NbNodes();
if ( myFaceMap.find( nbNodes ) == myFaceMap.end() )
save << clause << ".4) Number of " << orderStr << " pyramids: \t" << nb5 << endl;
if ( nb8 + nb4 + nb5 + nb6 != NbVolumes(order) ) {
std::map<int,int> myVolumesMap;
- SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
+ SMDS_VolumeIteratorPtr itVolumes=_meshDS->volumesIterator();
while( itVolumes->more( ) ) {
int nbNodes = itVolumes->next()->NbNodes();
if ( myVolumesMap.find( nbNodes ) == myVolumesMap.end() )
SMDSAbs_ElementType SMESH_Mesh::GetElementType( const smIdType id, const bool iselem )
{
- return _myMeshDS->GetElementType( id, iselem );
+ return _meshDS->GetElementType( id, iselem );
}
//=============================================================================
void SMESH_Mesh::ClearMeshOrder()
{
- _mySubMeshOrder.clear();
+ _subMeshOrder.clear();
}
//=============================================================================
void SMESH_Mesh::SetMeshOrder(const TListOfListOfInt& theOrder )
{
- _mySubMeshOrder = theOrder;
+ _subMeshOrder = theOrder;
}
//=============================================================================
const TListOfListOfInt& SMESH_Mesh::GetMeshOrder() const
{
- return _mySubMeshOrder;
+ return _subMeshOrder;
}
//=============================================================================
bool SMESH_Mesh::SortByMeshOrder(std::vector<SMESH_subMesh*>& theListToSort) const
{
- if ( _mySubMeshOrder.empty() || theListToSort.size() < 2 )
+ if ( _subMeshOrder.empty() || theListToSort.size() < 2 )
return true;
typedef std::vector<SMESH_subMesh*>::iterator TPosInList;
std::map< size_t, size_t > sortedPos; // index in theListToSort to order
TPosInList smBeg = theListToSort.begin(), smEnd = theListToSort.end();
- TListOfListOfInt::const_iterator listIdsIt = _mySubMeshOrder.begin();
+ TListOfListOfInt::const_iterator listIdsIt = _subMeshOrder.begin();
bool needSort = false;
- for( ; listIdsIt != _mySubMeshOrder.end(); listIdsIt++)
+ for( ; listIdsIt != _subMeshOrder.end(); listIdsIt++)
{
const TListOfInt& listOfId = *listIdsIt;
// convert sm ids to sm's
bool SMESH_Mesh::IsOrderOK( const SMESH_subMesh* smBefore,
const SMESH_subMesh* smAfter ) const
{
- TListOfListOfInt::const_iterator listIdsIt = _mySubMeshOrder.begin();
- for( ; listIdsIt != _mySubMeshOrder.end(); listIdsIt++)
+ TListOfListOfInt::const_iterator listIdsIt = _subMeshOrder.begin();
+ for( ; listIdsIt != _subMeshOrder.end(); listIdsIt++)
{
const TListOfInt& listOfId = *listIdsIt;
int iB = -1, iA = -1, i = 0;
SMESH_Mesh* FindMesh( int meshId ) const;
- SMESHDS_Mesh * GetMeshDS() { return _myMeshDS; }
+ SMESHDS_Mesh * GetMeshDS() { return _meshDS; }
- const SMESHDS_Mesh * GetMeshDS() const { return _myMeshDS; }
+ const SMESHDS_Mesh * GetMeshDS() const { return _meshDS; }
SMESH_Gen *GetGen() { return _gen; }
TooLargeForExport(const char* format):runtime_error(format) {}
};
- MEDCoupling::MCAuto<MEDCoupling::DataArrayByte> ExportMEDCoupling(
- const char* theMeshName = NULL,
- bool theAutoGroups = true,
- const SMESHDS_Mesh* theMeshPart = 0,
- bool theAutoDimension = false,
- bool theAddODOnVertices = false,
- double theZTolerance = -1.,
- bool theAllElemsToGroup = false);
+ MEDCoupling::MCAuto<MEDCoupling::DataArrayByte>
+ ExportMEDCoupling(const char* theMeshName = NULL,
+ bool theAutoGroups = true,
+ const SMESHDS_Mesh* theMeshPart = 0,
+ bool theAutoDimension = false,
+ bool theAddODOnVertices = false,
+ double theZTolerance = -1.,
+ bool theSaveNumbers = true);
void ExportMED(const char * theFile,
const char* theMeshName = NULL,
bool theAutoDimension = false,
bool theAddODOnVertices = false,
double theZTolerance = -1.,
+ bool theSaveNumbers = true,
bool theAllElemsToGroup = false);
void ExportDAT(const char * file,
- const SMESHDS_Mesh* meshPart = 0);
+ const SMESHDS_Mesh* meshPart = 0,
+ const bool renumber = true);
void ExportUNV(const char * file,
- const SMESHDS_Mesh* meshPart = 0);
+ const SMESHDS_Mesh* meshPart = 0,
+ const bool renumber = true);
void ExportSTL(const char * file,
const bool isascii,
const char * name = 0,
private:
- void ExportMEDCommmon(DriverMED_W_SMESHDS_Mesh& myWriter,
- const char* theMeshName,
- bool theAutoGroups,
- const SMESHDS_Mesh* meshPart,
- bool theAutoDimension,
- bool theAddODOnVertices,
- double theZTolerance,
- bool theAllElemsToGroup);
-
-private:
+ void exportMEDCommmon(DriverMED_W_SMESHDS_Mesh& myWriter,
+ const char* theMeshName,
+ bool theAutoGroups,
+ const SMESHDS_Mesh* meshPart,
+ bool theAutoDimension,
+ bool theAddODOnVertices,
+ double theZTolerance,
+ bool theSaveNumbers,
+ bool theAllElemsToGroup);
+
+ private:
void fillAncestorsMap(const TopoDS_Shape& theShape);
void getAncestorsSubMeshes(const TopoDS_Shape& theSubShape,
std::vector< SMESH_subMesh* >& theSubMeshes) const;
int _groupId; // id generator for group objects
int _nbSubShapes; // initial nb of subshapes in the shape to mesh
bool _isShapeToMesh;// set to true when a shape is given (only once)
- SMESHDS_Document * _myDocument;
- SMESHDS_Mesh * _myMeshDS;
+ SMESHDS_Document * _document;
+ SMESHDS_Mesh * _meshDS;
SMESH_Gen * _gen;
std::map <int, SMESH_Group*> _mapGroup;
mutable std::vector<SMESH_subMesh*> _ancestorSubMeshes; // to speed up GetHypothes[ei]s()
- TListOfListOfInt _mySubMeshOrder;
+ TListOfListOfInt _subMeshOrder;
// Struct calling methods at CORBA API implementation level, used to
// 1) make an upper level (SMESH_I) be consistent with a lower one (SMESH)
{
return _name == other._name;
}
+
+//================================================================================
+/*!
+ * \brief Save a string to a stream
+ */
+//================================================================================
+
+void SMESHDS_Hypothesis::SaveString(std::ostream & save, const std::string& txt )
+{
+ save << " " << txt.size() << " " << txt;
+}
+
+//================================================================================
+/*!
+ * \brief Load a string from a stream
+ */
+//================================================================================
+
+bool SMESHDS_Hypothesis::LoadString(std::istream & load, std::string& txt )
+{
+ txt.clear();
+ int size = -1;
+ if ( static_cast<bool>( load >> size ) && size > 0 )
+ {
+ txt.resize( size, '\0' );
+ load.get( txt[0] ); // remove a white-space
+ load.get( & txt[0], size + 1 );
+ }
+ return (int)txt.size() == size;
+}
virtual std::ostream & SaveTo(std::ostream & save)=0;
virtual std::istream & LoadFrom(std::istream & load)=0;
+ static void SaveString(std::ostream & save, const std::string& txt );
+ static bool LoadString(std::istream & load, std::string& txt );
+
bool IsSameName( const SMESHDS_Hypothesis& other) const;
virtual bool operator==(const SMESHDS_Hypothesis& other) const;
bool operator!=(const SMESHDS_Hypothesis& other) const { return !(*this==other); }
//=======================================================================
//function : Create
-//purpose :
+//purpose :
//=======================================================================
SMESHDS_Mesh::SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode):
- myMeshID(theMeshID),
mySubMeshHolder( new SubMeshHolder ),
myIsEmbeddedMode(theIsEmbeddedMode)
{
myScript = new SMESHDS_Script(theIsEmbeddedMode);
+
SetPersistentId(theMeshID);
}
//function : AddNode
//purpose :
//=======================================================================
-SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z){
+SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z)
+{
SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
return node;
}
-SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, smIdType ID){
+SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, smIdType ID)
+{
SMDS_MeshNode* node = SMDS_Mesh::AddNodeWithID(x,y,z,ID);
if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
return node;
//function : ChangePolygonNodes
//purpose :
//=======================================================================
-bool SMESHDS_Mesh::ChangePolygonNodes
-(const SMDS_MeshElement * elem,
- std::vector<const SMDS_MeshNode*> nodes)
+bool SMESHDS_Mesh::ChangePolygonNodes (const SMDS_MeshElement * elem,
+ std::vector<const SMDS_MeshNode*>& nodes)
{
ASSERT(nodes.size() > 3);
bool ChangeElementNodes(const SMDS_MeshElement * elem,
const SMDS_MeshNode * nodes[],
const int nbnodes);
- bool ChangePolygonNodes(const SMDS_MeshElement * elem,
- std::vector<const SMDS_MeshNode*> nodes);
+ bool ChangePolygonNodes(const SMDS_MeshElement * elem,
+ std::vector<const SMDS_MeshNode*>& nodes);
bool ChangePolyhedronNodes(const SMDS_MeshElement * elem,
const std::vector<const SMDS_MeshNode*>& nodes,
const std::vector<int>& quantities);
ShapeToHypothesis myShapeToHypothesis;
- int myMeshID, myPersistentID;
+ int myPersistentID;
TopoDS_Shape myShape;
class SubMeshHolder;
bool aCheckWarn = true;
if ( resMgr )
aCheckWarn = resMgr->booleanValue( "SMESH", "show_warning", false );
+
// get mesh object from selection and check duplication of their names
bool hasDuplicatedMeshNames = false;
QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
"SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
};
// is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
- const int nbTypes = sizeof( typeMsg ) / sizeof( const char* );
- int _assert[( nbTypes == SMESH::Entity_Last ) ? 2 : -1 ]; _assert[0]=_assert[1]=0;
+ static_assert( sizeof(typeMsg) / sizeof(const char*) == SMESH::Entity_Last,
+ "Update names of EntityType's!!!" );
QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
// Init the parameters with the default values
bool aIsASCII_STL = true;
- bool toCreateGroups = false;
- if ( resMgr )
- toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
- bool toOverwrite = true;
- bool toFindOutDim = true;
- double zTol = resMgr ? resMgr->doubleValue( "SMESH", "med_ztolerance", 0. ) : 0.;
+ bool toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
+ bool toOverwrite = true;
+ bool toFindOutDim = true;
+ bool toRenumber = true;
+ double zTol = resMgr->doubleValue( "SMESH", "med_ztolerance", 0. );
QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
QString anInitialPath = "";
QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
// Get a file name to write in and additional options
- if ( isUNV || isDAT || isGMF ) // Export w/o options
+ if ( isGMF ) // Export w/o options
{
- if ( isUNV )
- aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
- else if ( isDAT )
- aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
- else if ( isGMF )
- aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
- ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
- if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
+ aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
+ ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
+ if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
+
aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
anInitialPath + QString("/") + aMeshName,
aFilter, aTitle, false);
}
- else if ( isCGNS )// Export to CGNS
+ else if ( isCGNS || isUNV || isDAT ) // Export to [ CGNS | UNV | DAT ] - one option
{
- const char* theByTypeResource = "cgns_group_elems_by_type";
- toCreateGroups = SMESHGUI::resourceMgr()->booleanValue( "SMESH", theByTypeResource, false );
+ const char* theOptionResource = isCGNS ? "cgns_group_elems_by_type" : "export_renumber";
+ bool option = resMgr->booleanValue( "SMESH", theOptionResource, false );
QStringList checkBoxes;
- checkBoxes << QObject::tr("CGNS_EXPORT_ELEMS_BY_TYPE");
+ checkBoxes << QObject::tr( isCGNS ? "CGNS_EXPORT_ELEMS_BY_TYPE" : "SMESH_RENUMBER" );
SalomeApp_CheckFileDlg* fd =
new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
fd->setWindowTitle( aTitle );
- fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
+ if ( isCGNS )
+ fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
+ else if ( isUNV )
+ fd->setNameFilter( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
+ else if ( isDAT )
+ fd->setNameFilter( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
if ( !anInitialPath.isEmpty() )
fd->setDirectory( anInitialPath );
- fd->selectFile(aMeshName);
+ fd->selectFile( aMeshName );
SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
fd->setValidator( fv );
- fd->SetChecked( toCreateGroups, 0 );
+ fd->SetChecked( option, 0 );
if ( fd->exec() )
aFilename = fd->selectedFile();
- toOverwrite = fv->isOverwrite(aFilename);
- toCreateGroups = fd->IsChecked(0);
- SMESHGUI::resourceMgr()->setValue("SMESH", theByTypeResource, toCreateGroups );
+ toOverwrite = fv->isOverwrite( aFilename );
+ option = fd->IsChecked( 0 );
+ SMESHGUI::resourceMgr()->setValue("SMESH", theOptionResource, option );
+ ( isCGNS ? toCreateGroups : toRenumber ) = option;
delete fd;
}
for ( CORBA::ULong i = 0; i < mvok->length(); ++i )
{
QString vs = (char*)( SMESH_Comment( mvok[i]/10 ) << "." << mvok[i]%10 );
- MESSAGE("MED version: " << vs.toStdString());
aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( vs ) + " (*.med)", mvok[i]);
}
}
// if ( SMESHGUI::automaticUpdate() )
// SMESH::UpdateView();
// }
- if ( isMED && isOkToWrite)
+ if ( isMED && isOkToWrite )
{
- MESSAGE("OK to write MED file "<< aFilename.toUtf8().constData());
+ const bool saveNumbers = resMgr->booleanValue( "SMESH", "med_save_numbers", true );
aMeshIter = aMeshList.begin();
for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
{
SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
- const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
- if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ) && zTol < 0 )
- aMeshItem->ExportMED( aFilename.toUtf8().data(), toCreateGroups, aFormat,
- toOverwrite && aMeshIndex == 0, toFindOutDim );
- else
- aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(),
- toCreateGroups, aFormat,
- toOverwrite && aMeshIndex == 0, toFindOutDim,
- fields, geoAssFields.toLatin1().data(), zTol );
+
+ aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(),
+ toCreateGroups, aFormat,
+ toOverwrite && aMeshIndex == 0, toFindOutDim,
+ fields, geoAssFields.toLatin1().data(), zTol, saveNumbers );
}
}
else if ( isSAUV )
else if ( isDAT )
{
if ( aMeshOrGroup->_is_equivalent( aMesh ))
- aMesh->ExportDAT( aFilename.toUtf8().data() );
+ aMesh->ExportDAT( aFilename.toUtf8().data(), toRenumber );
else
- aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
+ aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
}
else if ( isUNV )
{
if ( aMeshOrGroup->_is_equivalent( aMesh ))
- aMesh->ExportUNV( aFilename.toUtf8().data() );
+ aMesh->ExportUNV( aFilename.toUtf8().data(), toRenumber );
else
- aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
+ aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
}
else if ( isSTL )
{
setPreferenceProperty( exportgroup, "columns", 2 );
addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
+ addPreference( tr( "PREF_MED_SAVE_NUMS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "med_save_numbers" );
int zTol = addPreference( tr( "PREF_ZTOLERANCE" ), exportgroup, LightApp_Preferences::DblSpin, "SMESH", "med_ztolerance" );
setPreferenceProperty( zTol, "precision", 10 );
setPreferenceProperty( zTol, "min", 0.0000000001 );
{
myMeshType->clear();
myMeshType->addItems(theTypeMesh);
+ myMeshType->setEnabled( theTypeMesh.size() > 1 );
}
//================================================================================
/*!
_PTR(SObject) FindSObject( CORBA::Object_ptr );
SMESHGUI_EXPORT
- void SetName( _PTR(SObject), const QString& );
+ void SetName( _PTR(SObject), const QString& name );
SMESHGUI_EXPORT
- void SetValue( _PTR(SObject), const QString& );
- void setFileType( _PTR(SObject), const QString& );
- void setFileName( _PTR(SObject), const QString& );
+ void SetValue ( _PTR(SObject), const QString& value );
+ void setFileType( _PTR(SObject), const QString& fileType );
+ void setFileName( _PTR(SObject), const QString& fileName );
SMESHGUI_EXPORT
CORBA::Object_var SObjectToObject( _PTR(SObject) );
}
SMESHGUI_EXPORT
- CORBA::Object_var IORToObject( const QString& );
+ CORBA::Object_var IORToObject( const QString& ior );
template<class TInterface> typename TInterface::_var_type
IORToInterface( const QString& theIOR )
}
SMESHGUI_EXPORT
- CORBA::Object_var EntryToObject( const QString& );
+ CORBA::Object_var EntryToObject( const QString& entry );
template<class TInterface> typename TInterface::_var_type
EntryToInterface( const QString& theEntry )
}
SMESHGUI_EXPORT
- int GetNameOfSelectedIObjects( LightApp_SelectionMgr*, QString& );
+ int GetNameOfSelectedIObjects( LightApp_SelectionMgr*, QString& name );
SMESHGUI_EXPORT
QString GetName( const Handle(SALOME_InteractiveObject)& theIO );
_PTR(SObject) GetMeshOrSubmesh( _PTR(SObject) );
SMESHGUI_EXPORT
- void ShowHelpFile( const QString& );
+ void ShowHelpFile( const QString& helpFileName);
/*!
* \brief Return the normal to a face
<source>SMESH_RENUMBERING</source>
<translation>Renumbering</translation>
</message>
+ <message>
+ <source>SMESH_RENUMBER</source>
+ <translation>Renumber</translation>
+ </message>
<message>
<source>SMESH_RENUMBERING_ELEMENTS_TITLE</source>
<translation>Renumbering elements</translation>
<source>PREF_SHOW_WARN</source>
<translation>Show warning when exporting group</translation>
</message>
+ <message>
+ <source>PREF_MED_SAVE_NUMS</source>
+ <translation>Save cell/node numbers to MED file</translation>
+ </message>
<message>
<source>PREF_ZTOLERANCE</source>
<translation>Z tolerance for MED export</translation>
return txt;
}
+void SMESH::printErrorInDebugMode(const char* txt)
+{
+#ifdef _DEBUG_
+ std::cerr << txt << " " << __FILE__ << ": " << __LINE__ << std::endl;
+#else
+ (void)txt; // unused in release mode
+#endif
+}
+
// ------------------------------------------------------------------
#include "SMESH_ComputeError.hxx"
SMESHUtils_EXPORT void throwSalomeEx(const char* txt);
SMESHUtils_EXPORT void doNothing(const char* txt);
SMESHUtils_EXPORT const char* returnError(const char* txt);
+ SMESHUtils_EXPORT void printErrorInDebugMode(const char* txt);
}
#endif
"FT_LogicalOR",
"FT_Undefined"};
- #ifdef _DEBUG_
// check if functName is complete, compilation failure means that enum FunctorType changed
- const int nbFunctors = sizeof(functName) / sizeof(const char*);
- int _assert[( nbFunctors == SMESH::FT_Undefined + 1 ) ? 2 : -1 ]; _assert[0]=_assert[1]=0;
- #endif
+ static_assert( sizeof(functName) / sizeof(const char*) == SMESH::FT_Undefined + 1,
+ "Update names of FunctorType's!!!" );
return functName;
}
{
// type names
const char* typeNames[] = { "All","Nodes","Edges","Faces","Volumes","0DElems","Balls" };
- { // check of typeNames: compilation failure mains that NB_ELEMENT_TYPES changed:
- const int nbNames = sizeof(typeNames) / sizeof(const char*);
- int _assert[( nbNames == SMESH::NB_ELEMENT_TYPES ) ? 2 : -1 ]; _assert[0]=_assert[1]=0;
- }
+
+ // check of typeNames: compilation failure mains that NB_ELEMENT_TYPES changed:
+ static_assert( sizeof(typeNames) / sizeof(const char*) ==SMESH::NB_ELEMENT_TYPES,
+ "Update names of ElementType's!!!" );
SMESH::smIdType_array_var curState = newMesh->GetNbElementsByType();
system(cmd.ToCString());
// MED writer to be used by storage process
- DriverMED_W_SMESHDS_Mesh myWriter;
- myWriter.SetFile( meshfile.ToCString() );
+ DriverMED_W_SMESHDS_Mesh writer;
+ writer.SetFile( meshfile.ToCString() );
+ writer.SetSaveNumbers( false ); // bos #24400
// IMP issue 20918
// SetStoreName() to groups before storing hypotheses to let them refer to
// check if the mesh is not empty
if ( mySMESHDSMesh->NbNodes() > 0 ) {
// write mesh data to med file
- myWriter.SetMesh( mySMESHDSMesh );
- myWriter.SetMeshId( id );
+ writer.SetMesh( mySMESHDSMesh );
+ writer.SetMeshId( id );
strHasData = "1";
}
aSize[ 0 ] = strHasData.length() + 1;
// Pass SMESHDS_Group to MED writer
SMESHDS_Group* aGrpDS = dynamic_cast<SMESHDS_Group*>( aGrpBaseDS );
if ( aGrpDS )
- myWriter.AddGroup( aGrpDS );
+ writer.AddGroup( aGrpDS );
// write reference on a shape if exists
SMESHDS_GroupOnGeom* aGeomGrp =
else // shape ref is invalid:
{
// save a group on geometry as ordinary group
- myWriter.AddGroup( aGeomGrp );
+ writer.AddGroup( aGeomGrp );
}
}
else if ( SMESH_GroupOnFilter_i* aFilterGrp_i =
if ( strcmp( strHasData.c_str(), "1" ) == 0 )
{
// Flush current mesh information into MED file
- myWriter.Perform();
+ writer.Perform();
// save info on nb of elements
SMESH_PreMeshInfo::SaveToFile( myImpl, id, aFile );
}
} // reading MESHes
- // As all object that can be referred by hypothesis are created,
+ // As all objects that can be referred by hypothesis are created,
// we can restore hypothesis data
list< pair< SMESH_Hypothesis_i*, string > >::iterator hyp_data;
//=============================================================================
/*!
- *
+ * Return ID of theIndex-th group item
*/
//=============================================================================
// Internal C++ interface
- int GetLocalID() const { return myLocalID; }
+ int GetLocalID() const { return myLocalID; } // return group persistent ID
SMESH_Mesh_i* GetMeshServant() const { return myMeshServant; }
SMESH_Group* GetSmeshGroup() const;
SMESHDS_GroupBase* GetGroupDS() const;
//!< Constructor
TPreviewMesh(SMDSAbs_ElementType previewElements = SMDSAbs_All) {
_isShapeToMesh = (_id = 0);
- _myMeshDS = new SMESHDS_Mesh( _id, true );
+ _meshDS = new SMESHDS_Mesh( _id, true );
myPreviewType = previewElements;
}
//!< Copy a set of elements
//!< Copy a node
SMDS_MeshNode* Copy( const SMDS_MeshNode* anElemNode )
{
- return _myMeshDS->AddNodeWithID(anElemNode->X(), anElemNode->Y(), anElemNode->Z(),
- anElemNode->GetID());
+ return _meshDS->AddNodeWithID(anElemNode->X(), anElemNode->Y(), anElemNode->Z(),
+ anElemNode->GetID());
}
void RemoveAll()
{
*/
//================================================================================
-void SMESH_Mesh_i::ExportDAT (const char *file)
+void SMESH_Mesh_i::ExportDAT (const char *file, CORBA::Boolean renumber )
{
SMESH_TRY;
if ( _preMeshInfo )
// check names of groups
checkGroupNames();
// Update Python script
- TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportDAT( r'" << file << "' )";
+ TPythonDump() << SMESH::SMESH_Mesh_var(_this())
+ << ".ExportDAT( r'" << file<< ", " << renumber << "' )";
// Perform Export
- PrepareForWriting(file);
- _impl->ExportDAT(file);
+ PrepareForWriting( file );
+ _impl->ExportDAT( file, /*part=*/nullptr, renumber );
SMESH_CATCH( SMESH::throwCorbaException );
}
*/
//================================================================================
-void SMESH_Mesh_i::ExportUNV (const char *file)
+void SMESH_Mesh_i::ExportUNV (const char *file, CORBA::Boolean renumber)
{
SMESH_TRY;
if ( _preMeshInfo )
// check names of groups
checkGroupNames();
// Update Python script
- TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportUNV( r'" << file << "' )";
+ TPythonDump() << SMESH::SMESH_Mesh_var(_this())
+ << ".ExportUNV( r'" << file << "' " << renumber << "' )";
// Perform Export
- PrepareForWriting(file);
- _impl->ExportUNV(file);
+ PrepareForWriting( file );
+ _impl->ExportUNV( file, /*part=*/nullptr, renumber );
SMESH_CATCH( SMESH::throwCorbaException );
}
SMESH_CATCH( SMESH::throwCorbaException );
}
+//================================================================================
+
class MEDFileSpeCls
{
public:
- MEDFileSpeCls(const char *file, CORBA::Boolean overwrite, CORBA::Long version):_file(file),_overwrite(overwrite),_version(version) { }
- std::string prepareMeshNameAndGroups(SMESH_Mesh_i& self) { return self.prepareMeshNameAndGroups(_file.c_str(),_overwrite); }
+ MEDFileSpeCls(const char * file,
+ CORBA::Boolean overwrite,
+ CORBA::Long version)
+ :_file(file), _overwrite(overwrite), _version(version)
+ {}
+ std::string prepareMeshNameAndGroups(SMESH_Mesh_i& self)
+ {
+ return self.prepareMeshNameAndGroups(_file.c_str(),_overwrite);
+ }
+
void exportTo(SMESH_Mesh *mesh, const std::string& aMeshName, CORBA::Boolean auto_groups,
- SMESH_MeshPartDS* partDS,
- CORBA::Boolean autoDimension, bool have0dField,
- CORBA::Double ZTolerance)
+ SMESH_MeshPartDS* partDS, CORBA::Boolean autoDimension, bool have0dField,
+ CORBA::Double ZTolerance, CORBA::Boolean saveNumbers )
{
mesh->ExportMED( _file.c_str(), aMeshName.c_str(), auto_groups, _version,
- partDS, autoDimension,have0dField,ZTolerance);
-
+ partDS, autoDimension, have0dField, ZTolerance, saveNumbers );
}
- void exportField(SMESH_Mesh_i& self, const std::string& aMeshName, bool have0dField, SMESHDS_Mesh *meshDS, const GEOM::ListOfFields& fields, const char*geomAssocFields)
+ void exportField(SMESH_Mesh_i& self, const std::string& aMeshName, bool have0dField,
+ SMESHDS_Mesh *meshDS, const GEOM::ListOfFields& fields,
+ const char*geomAssocFields)
{
DriverMED_W_Field fieldWriter;
fieldWriter.SetFile( _file.c_str() );
}
void prepareForWriting(SMESH_Mesh_i& self) { self.PrepareForWriting(_file.c_str(), _overwrite); }
+
private:
- std::string _file;
+ std::string _file;
CORBA::Boolean _overwrite;
- CORBA::Long _version;
+ CORBA::Long _version;
};
+//================================================================================
+/*!
+ * \brief Export a part of mesh to a med file
+ */
+//================================================================================
template<class SPECLS>
-void SMESH_Mesh_i::ExportPartToMEDCommon(SPECLS& speCls,
- SMESH::SMESH_IDSource_ptr meshPart,
- CORBA::Boolean auto_groups,
- CORBA::Boolean autoDimension,
- const GEOM::ListOfFields& fields,
- const char* geomAssocFields,
- CORBA::Double ZTolerance)
+void SMESH_Mesh_i::ExportPartToMEDCommon(SPECLS& speCls,
+ SMESH::SMESH_IDSource_ptr meshPart,
+ CORBA::Boolean auto_groups,
+ CORBA::Boolean autoDimension,
+ const GEOM::ListOfFields& fields,
+ const char* geomAssocFields,
+ CORBA::Double ZTolerance,
+ CORBA::Boolean saveNumbers)
{
SMESH_TRY;
if ( _preMeshInfo )
if ( fieldShape->_is_nil() )
THROW_SALOME_CORBA_EXCEPTION( "Null shape under a field", SALOME::INTERNAL_ERROR );
if ( !fieldShape->IsSame( shapeToMesh ) )
- THROW_SALOME_CORBA_EXCEPTION
- ( "Field defined not on shape", SALOME::BAD_PARAM);
+ THROW_SALOME_CORBA_EXCEPTION( "Field defined not on shape", SALOME::BAD_PARAM);
if ( fields[i]->GetDimension() == 0 )
have0dField = true;
}
SMESH::DownCast< SMESH_Mesh_i* >( meshPart ))
{
aMeshName = speCls.prepareMeshNameAndGroups(*this);
- speCls.exportTo(_impl, aMeshName, auto_groups, nullptr, autoDimension, have0dField, ZTolerance);
+ speCls.exportTo(_impl, aMeshName, auto_groups, nullptr, autoDimension,
+ have0dField, ZTolerance, saveNumbers );
meshDS = _impl->GetMeshDS();
}
else
}
SMESH_MeshPartDS* partDS = new SMESH_MeshPartDS( meshPart );
- speCls.exportTo(_impl, aMeshName, auto_groups, partDS, autoDimension, have0dField, ZTolerance);
+ speCls.exportTo(_impl, aMeshName, auto_groups, partDS, autoDimension,
+ have0dField, ZTolerance, saveNumbers);
meshDS = tmpDSDeleter._obj = partDS;
}
if ( _impl->HasShapeToMesh() )
{
- speCls.exportField(*this,aMeshName,have0dField,meshDS,fields,geomAssocFields);
+ speCls.exportField( *this, aMeshName, have0dField, meshDS, fields, geomAssocFields);
}
SMESH_CATCH( SMESH::throwCorbaException );
}
CORBA::Boolean autoDimension,
const GEOM::ListOfFields& fields,
const char* geomAssocFields,
- CORBA::Double ZTolerance)
+ CORBA::Double ZTolerance,
+ CORBA::Boolean saveNumbers)
{
MESSAGE("MED version: "<< version);
- MEDFileSpeCls spe(file,overwrite,version);
- this->ExportPartToMEDCommon<MEDFileSpeCls>(spe,meshPart,auto_groups,autoDimension,fields,geomAssocFields,ZTolerance);
+
+ MEDFileSpeCls spe( file, overwrite, version );
+ this->ExportPartToMEDCommon( spe, meshPart, auto_groups, autoDimension, fields,
+ geomAssocFields, ZTolerance, saveNumbers );
// dump
SMESH_TRY;
GEOM::ListOfGBO_var goList = new GEOM::ListOfGBO;
<< autoDimension << ", "
<< goList << ", '"
<< ( geomAssocFields ? geomAssocFields : "" ) << "',"
- << TVar( ZTolerance )
+ << TVar( ZTolerance ) << ", "
+ << saveNumbers
<< " )";
SMESH_CATCH( SMESH::throwCorbaException );
}
+//================================================================================
+
class MEDFileMemSpeCls
{
public:
std::string prepareMeshNameAndGroups(SMESH_Mesh_i& self) { return self.generateMeshName(); }
+
void exportTo(SMESH_Mesh *mesh, const std::string& aMeshName, CORBA::Boolean auto_groups,
- SMESH_MeshPartDS* partDS,
- CORBA::Boolean autoDimension, bool have0dField,
- CORBA::Double ZTolerance)
+ SMESH_MeshPartDS* partDS, CORBA::Boolean autoDimension, bool have0dField,
+ CORBA::Double ZTolerance, CORBA::Boolean saveNumbers )
{
- _res = mesh->ExportMEDCoupling(aMeshName.c_str(),auto_groups,partDS,autoDimension,have0dField,ZTolerance);
+ _res = mesh->ExportMEDCoupling(aMeshName.c_str(), auto_groups, partDS,
+ autoDimension, have0dField, ZTolerance, saveNumbers );
}
- void prepareForWriting(SMESH_Mesh_i& self) { /* nothing here */ }
- void exportField(SMESH_Mesh_i& self, const std::string& aMeshName, bool have0dField, SMESHDS_Mesh *meshDS, const GEOM::ListOfFields& fields, const char*geomAssocFields)
+ void prepareForWriting(SMESH_Mesh_i& /*self*/) { /* nothing here */ }
+
+ void exportField(SMESH_Mesh_i& self, const std::string& aMeshName, bool have0dField,
+ SMESHDS_Mesh *meshDS, const GEOM::ListOfFields& fields,
+ const char*geomAssocFields)
{
DriverMED_W_Field_Mem fieldWriter(_res);
fieldWriter.SetMeshName( aMeshName );
}
public:
MEDCoupling::MCAuto<MEDCoupling::DataArrayByte> getData() { return _res; }
+
private:
MEDCoupling::MCAuto<MEDCoupling::DataArrayByte> _res;
};
+//================================================================================
+/*!
+ * \brief Export a part of mesh to a MEDCoupling DS
+ */
+//================================================================================
+
CORBA::LongLong SMESH_Mesh_i::ExportPartToMEDCoupling(SMESH::SMESH_IDSource_ptr meshPart,
- CORBA::Boolean auto_groups,
- CORBA::Boolean autoDimension,
- const GEOM::ListOfFields& fields,
- const char* geomAssocFields,
- CORBA::Double ZTolerance)
+ CORBA::Boolean auto_groups,
+ CORBA::Boolean autoDimension,
+ const GEOM::ListOfFields& fields,
+ const char* geomAssocFields,
+ CORBA::Double ZTolerance,
+ CORBA::Boolean saveNumbers)
{
MEDCoupling::MCAuto<MEDCoupling::DataArrayByte> data;
+
SMESH_TRY;
if( !this->_gen_i->isSSLMode() )
SMESH::throwCorbaException("SMESH_Mesh_i::ExportPartToMEDCoupling : only for embedded mode !");
+
MEDFileMemSpeCls spe;
- this->ExportPartToMEDCommon<MEDFileMemSpeCls>(spe,meshPart,auto_groups,autoDimension,fields,geomAssocFields,ZTolerance);
+ this->ExportPartToMEDCommon( spe, meshPart, auto_groups, autoDimension, fields, geomAssocFields,
+ ZTolerance, saveNumbers );
data = spe.getData();
+
SMESH_CATCH( SMESH::throwCorbaException );
+
MEDCoupling::DataArrayByte *ret(data.retn());
return reinterpret_cast<CORBA::LongLong>(ret);
}
*/
//================================================================================
-void SMESH_Mesh_i::ExportPartToDAT(::SMESH::SMESH_IDSource_ptr meshPart,
- const char* file)
+void SMESH_Mesh_i::ExportPartToDAT(SMESH::SMESH_IDSource_ptr meshPart,
+ const char* file,
+ CORBA::Boolean renumber )
{
SMESH_TRY;
- if ( _preMeshInfo )
- _preMeshInfo->FullLoadFromFile();
-
- PrepareForWriting(file);
SMESH_MeshPartDS partDS( meshPart );
- _impl->ExportDAT(file,&partDS);
+ _impl->ExportDAT( file, &partDS, renumber );
TPythonDump() << SMESH::SMESH_Mesh_var(_this())
- << ".ExportPartToDAT( " << meshPart << ", r'" << file << "' )";
+ << ".ExportPartToDAT( " << meshPart << ", r'" << file << ", " << renumber << "' )";
SMESH_CATCH( SMESH::throwCorbaException );
}
*/
//================================================================================
-void SMESH_Mesh_i::ExportPartToUNV(::SMESH::SMESH_IDSource_ptr meshPart,
- const char* file)
+void SMESH_Mesh_i::ExportPartToUNV(SMESH::SMESH_IDSource_ptr meshPart,
+ const char* file,
+ CORBA::Boolean renumber)
{
SMESH_TRY;
if ( _preMeshInfo )
PrepareForWriting(file);
SMESH_MeshPartDS partDS( meshPart );
- _impl->ExportUNV(file, &partDS);
+ _impl->ExportUNV(file, &partDS, renumber );
TPythonDump() << SMESH::SMESH_Mesh_var(_this())
- << ".ExportPartToUNV( " << meshPart<< ", r'" << file << "' )";
+ << ".ExportPartToUNV( " << meshPart<< ", r'" << file << ", " << renumber << "' )";
SMESH_CATCH( SMESH::throwCorbaException );
}
if ( const SMDS_MeshElement* elem = aMeshDS->FindElement(id) )
{
aResult->length( elem->NbNodes() );
- for ( SMESH::smIdType i = 0; i < aResult->length(); ++i )
+ for ( CORBA::ULong i = 0; i < aResult->length(); ++i )
if ( const SMDS_MeshNode* n = elem->GetNode( i ))
aResult[ i ] = n->GetID();
}
{
aResult->length( vtool.NbFaceNodes( faceIndex ));
const SMDS_MeshNode** nn = vtool.GetFaceNodes( faceIndex );
- for ( SMESH::smIdType i = 0; i < aResult->length(); ++i )
+ for ( CORBA::ULong i = 0; i < aResult->length(); ++i )
aResult[ i ] = nn[ i ]->GetID();
}
}
if ( SMESHDS_Mesh* mesh = _impl->GetMeshDS() )
{
vector< const SMDS_MeshNode * > nn( nodes.length() );
- for ( SMESH::smIdType i = 0; i < nodes.length(); ++i )
+ for ( CORBA::ULong i = 0; i < nodes.length(); ++i )
nn[i] = mesh->FindNode( nodes[i] );
std::vector<const SMDS_MeshElement *> elems;
CORBA::Boolean overwrite,
CORBA::Boolean autoDimension = true);
- CORBA::LongLong ExportMEDCoupling(CORBA::Boolean auto_groups,
- CORBA::Boolean autoDimension = true
- );
+ CORBA::LongLong ExportMEDCoupling(CORBA::Boolean auto_groups,
+ CORBA::Boolean autoDimension = true);
void ExportSAUV( const char* file, CORBA::Boolean auto_groups );
- void ExportDAT( const char* file );
- void ExportUNV( const char* file );
+ void ExportDAT( const char* file, const CORBA::Boolean renumber );
+ void ExportUNV( const char* file, const CORBA::Boolean renumber );
void ExportSTL( const char* file, bool isascii );
void ExportCGNS(SMESH::SMESH_IDSource_ptr meshPart,
const char* file,
template<class SPECLS>
- void ExportPartToMEDCommon(SPECLS& speCls,
- SMESH::SMESH_IDSource_ptr meshPart,
- CORBA::Boolean auto_groups,
- CORBA::Boolean autoDim,
- const GEOM::ListOfFields& fields,
- const char* geomAssocFields,
- CORBA::Double ZTolerance);
+ void ExportPartToMEDCommon(SPECLS& speCls,
+ SMESH::SMESH_IDSource_ptr meshPart,
+ CORBA::Boolean auto_groups,
+ CORBA::Boolean autoDim,
+ const GEOM::ListOfFields& fields,
+ const char* geomAssocFields,
+ CORBA::Double ZTolerance,
+ CORBA::Boolean saveNumbers );
void ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
const char* file,
CORBA::Boolean autoDim,
const GEOM::ListOfFields& fields,
const char* geomAssocFields,
- CORBA::Double ZTolerance);
+ CORBA::Double ZTolerance,
+ CORBA::Boolean saveNumbers );
CORBA::LongLong ExportPartToMEDCoupling(SMESH::SMESH_IDSource_ptr meshPart,
- CORBA::Boolean auto_groups,
- CORBA::Boolean autoDim,
- const GEOM::ListOfFields& fields,
- const char* geomAssocFields,
- CORBA::Double ZTolerance);
+ CORBA::Boolean auto_groups,
+ CORBA::Boolean autoDim,
+ const GEOM::ListOfFields& fields,
+ const char* geomAssocFields,
+ CORBA::Double ZTolerance,
+ CORBA::Boolean saveNumbers);
void ExportPartToDAT(SMESH::SMESH_IDSource_ptr meshPart,
- const char* file);
+ const char* file,
+ CORBA::Boolean renumber);
void ExportPartToUNV(SMESH::SMESH_IDSource_ptr meshPart,
- const char* file);
+ const char* file,
+ CORBA::Boolean renumber);
void ExportPartToSTL(SMESH::SMESH_IDSource_ptr meshPart,
const char* file,
CORBA::Boolean isascii);
list<const gp_XYZ *> xyzList;
set<const SMDS_MeshFace*> fset;
- for ( SMESH::smIdType i = 0; i < theFacesIDs.length(); i++)
+ for ( CORBA::ULong i = 0; i < theFacesIDs.length(); i++)
{
SMESH::smIdType index = theFacesIDs[i];
const SMDS_MeshElement * elem = aMesh->GetMeshDS()->FindElement(index);
list<const gp_XYZ *> xyzList;
set<const SMDS_MeshVolume*> vset;
- for ( SMESH::smIdType i = 0; i < theVolumesIDs.length(); i++)
+ for ( CORBA::ULong i = 0; i < theVolumesIDs.length(); i++)
{
SMESH::smIdType index = theVolumesIDs[i];
const SMDS_MeshElement * elem = aMesh->GetMeshDS()->FindElement(index);
Export the mesh in a memory representation.
Parameters:
- auto_groups (boolean): parameter for creating/not creating
- the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
- the typical use is auto_groups=False.
- overwrite (boolean): parameter for overwriting/not overwriting the file
- meshPart: a part of mesh (:class:`sub-mesh, group or filter <SMESH.SMESH_IDSource>`) to export instead of the mesh
- autoDimension: if *True* (default), a space dimension of a MED mesh can be either
-
- - 1D if all mesh nodes lie on OX coordinate axis, or
- - 2D if all mesh nodes lie on XOY coordinate plane, or
- - 3D in the rest cases.
-
- If *autoDimension* is *False*, the space dimension is always 3.
- fields: list of GEOM fields defined on the shape to mesh.
- geomAssocFields: each character of this string means a need to export a
- corresponding field; correspondence between fields and characters
- is following:
-
- - 'v' stands for "_vertices_" field;
- - 'e' stands for "_edges_" field;
- - 'f' stands for "_faces_" field;
- - 's' stands for "_solids_" field.
-
- zTolerance (float): tolerance in Z direction. If Z coordinate of a node is
- close to zero within a given tolerance, the coordinate is set to zero.
- If *ZTolerance* is negative (default), the node coordinates are kept as is.
- """
+ auto_groups (boolean): parameter for creating/not creating
+ the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
+ the typical use is auto_groups=False.
+ overwrite (boolean): parameter for overwriting/not overwriting the file
+ meshPart: a part of mesh (:class:`sub-mesh, group or filter <SMESH.SMESH_IDSource>`)
+ to export instead of the mesh
+ autoDimension: if *True* (default), a space dimension of a MED mesh can be either
+
+ - 1D if all mesh nodes lie on OX coordinate axis, or
+ - 2D if all mesh nodes lie on XOY coordinate plane, or
+ - 3D in the rest cases.
+
+ If *autoDimension* is *False*, the space dimension is always 3.
+ fields: list of GEOM fields defined on the shape to mesh.
+ geomAssocFields: each character of this string means a need to export a
+ corresponding field; correspondence between fields and characters
+ is following:
+
+ - 'v' stands for "_vertices_" field;
+ - 'e' stands for "_edges_" field;
+ - 'f' stands for "_faces_" field;
+ - 's' stands for "_solids_" field.
+
+ zTolerance (float): tolerance in Z direction. If Z coordinate of a node is
+ close to zero within a given tolerance, the coordinate is set to zero.
+ If *ZTolerance* is negative (default), the node coordinates are kept as is.
+ saveNumbers(boolean) : enable saving numbers of nodes and cells.
+ """
auto_groups = args[0] if len(args) > 0 else False
meshPart = args[1] if len(args) > 1 else None
autoDimension = args[2] if len(args) > 2 else True
fields = args[3] if len(args) > 3 else []
geomAssocFields = args[4] if len(args) > 4 else ''
z_tolerance = args[5] if len(args) > 5 else -1.
+ saveNumbers = args[6] if len(args) > 6 else True
# process keywords arguments
auto_groups = kwargs.get("auto_groups", auto_groups)
meshPart = kwargs.get("meshPart", meshPart)
fields = kwargs.get("fields", fields)
geomAssocFields = kwargs.get("geomAssocFields", geomAssocFields)
z_tolerance = kwargs.get("zTolerance", z_tolerance)
+ saveNumbers = kwargs.get("saveNumbers", saveNumbers)
# invoke engine's function
- if meshPart or fields or geomAssocFields or z_tolerance > 0:
+ if meshPart or fields or geomAssocFields or z_tolerance > 0 or not saveNumbers:
unRegister = genObjUnRegister()
if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL )
z_tolerance,Parameters,hasVars = ParseParameters(z_tolerance)
self.mesh.SetParameters(Parameters)
- intPtr = self.mesh.ExportPartToMEDCoupling(meshPart, auto_groups, autoDimension, fields, geomAssocFields, z_tolerance)
+ intPtr = self.mesh.ExportPartToMEDCoupling(meshPart, auto_groups, autoDimension,
+ fields, geomAssocFields, z_tolerance,
+ saveNumbers )
import medcoupling
dab = medcoupling.FromPyIntPtrToDataArrayByte(intPtr)
return medcoupling.MEDFileData.New(dab)
or 3.2.1 or 3.3.1 formats.
If the version is equal to -1, the version is not changed (default).
overwrite (boolean): parameter for overwriting/not overwriting the file
- meshPart: a part of mesh (:class:`sub-mesh, group or filter <SMESH.SMESH_IDSource>`) to export instead of the mesh
+ meshPart: a part of mesh (:class:`sub-mesh, group or filter <SMESH.SMESH_IDSource>`)
+ to export instead of the mesh
autoDimension: if *True* (default), a space dimension of a MED mesh can be either
- 1D if all mesh nodes lie on OX coordinate axis, or
zTolerance (float): tolerance in Z direction. If Z coordinate of a node is
close to zero within a given tolerance, the coordinate is set to zero.
If *ZTolerance* is negative (default), the node coordinates are kept as is.
+ saveNumbers (boolean) : enable saving numbers of nodes and cells.
"""
# process positional arguments
#args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
fields = args[6] if len(args) > 6 else []
geomAssocFields = args[7] if len(args) > 7 else ''
z_tolerance = args[8] if len(args) > 8 else -1.
+ saveNumbers = args[9] if len(args) > 9 else True
# process keywords arguments
auto_groups = kwargs.get("auto_groups", auto_groups)
version = kwargs.get("version", version)
fields = kwargs.get("fields", fields)
geomAssocFields = kwargs.get("geomAssocFields", geomAssocFields)
z_tolerance = kwargs.get("zTolerance", z_tolerance)
+ saveNumbers = kwargs.get("saveNumbers", saveNumbers)
+
+ if isinstance( meshPart, Mesh):
+ meshPart = meshPart.GetMesh()
# invoke engine's function
- if meshPart or fields or geomAssocFields or z_tolerance > 0:
+ if meshPart or fields or geomAssocFields or z_tolerance > 0 or not saveNumbers:
unRegister = genObjUnRegister()
if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL )
self.mesh.ExportPartToMED( meshPart, fileName, auto_groups,
version, overwrite, autoDimension,
- fields, geomAssocFields, z_tolerance)
+ fields, geomAssocFields, z_tolerance, saveNumbers )
else:
self.mesh.ExportMED(fileName, auto_groups, version, overwrite, autoDimension)
self.mesh.ExportSAUV(f, auto_groups)
- def ExportDAT(self, f, meshPart=None):
+ def ExportDAT(self, f, meshPart=None, renumber=True):
"""
Export the mesh in a file in DAT format
Parameters:
f: the file name
meshPart: a part of mesh (:class:`sub-mesh, group or filter <SMESH.SMESH_IDSource>`) to export instead of the mesh
+ renumber(boolean): enable renumbering nodes and cells in order to eliminate holes in numbering
"""
- if meshPart:
+ if meshPart or not renumber:
unRegister = genObjUnRegister()
if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL )
unRegister.set( meshPart )
- self.mesh.ExportPartToDAT( meshPart, f )
+ self.mesh.ExportPartToDAT( meshPart, f, renumber )
else:
- self.mesh.ExportDAT(f)
+ self.mesh.ExportDAT( f, renumber )
- def ExportUNV(self, f, meshPart=None):
+ def ExportUNV(self, f, meshPart=None, renumber=True):
"""
Export the mesh in a file in UNV format
Parameters:
f: the file name
meshPart: a part of mesh (:class:`sub-mesh, group or filter <SMESH.SMESH_IDSource>`) to export instead of the mesh
+ renumber(boolean): enable renumbering nodes and cells in order to eliminate holes in numbering
"""
- if meshPart:
+ if meshPart or not renumber:
unRegister = genObjUnRegister()
if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL )
unRegister.set( meshPart )
- self.mesh.ExportPartToUNV( meshPart, f )
+ self.mesh.ExportPartToUNV( meshPart, f, renumber )
else:
- self.mesh.ExportUNV(f)
+ self.mesh.ExportUNV( f, renumber )
def ExportSTL(self, f, ascii=1, meshPart=None):
"""
while len(args2) < 5: # !!!! nb of parameters for ExportToMED IDL's method
args2.append(True)
SMESH._objref_SMESH_Mesh.ExportMED(self, *args2)
+ def ExportUNV(self, *args): # renumber arg added
+ if len( args ) == 1:
+ args += True,
+ return SMESH._objref_SMESH_Mesh.ExportUNV(self, *args)
+ def ExportDAT(self, *args): # renumber arg added
+ if len( args ) == 1:
+ args += True,
+ return SMESH._objref_SMESH_Mesh.ExportDAT(self, *args)
pass
omniORB.registerObjref(SMESH._objref_SMESH_Mesh._NP_RepositoryId, meshProxy)
{
TmpMesh() {
_isShapeToMesh = (_id = 0);
- _myMeshDS = new SMESHDS_Mesh( _id, true );
+ _meshDS = new SMESHDS_Mesh( _id, true );
}
};
//=======================================================================
{
TmpMesh()
{
- _myMeshDS = new SMESHDS_Mesh(/*id=*/0, /*isEmbeddedMode=*/true);
+ _meshDS = new SMESHDS_Mesh(/*id=*/0, /*isEmbeddedMode=*/true);
}
};
{
Q_OBJECT
-public:
- StdMeshersGUI_ObjectReferenceParamWdg( SUIT_SelectionFilter* filter,
+ public:
+ StdMeshersGUI_ObjectReferenceParamWdg( SUIT_SelectionFilter* filter,
QWidget* parent,
bool multiSelection=false
/* ,bool stretch=true*/);
void SetObjects(SMESH::string_array_var& objEntries);
- template<class TInterface>
+ template<class TInterface>
typename TInterface::_var_type GetObject(size_t i=0) const {
if ( IsObjectSelected(i) ) return TInterface::_narrow(myObjects[i]);
return TInterface::_nil();
size_t NbObjects() const { return myObjects.size(); }
+ // Return object entries
QString GetValue() const { return myParamValue; }
bool IsObjectSelected(size_t i=0) const
/*!
* \brief Get the selection status
- *
- * Useful to know which Object Reference param widget is activated
- * to be able to activate the next one when the content of this
- * one has been modified
+ *
+ * Useful to know which Object Reference param widget is activated
+ * to be able to activate the next one when the content of this
+ * one has been modified
*/
bool IsSelectionActivated() const { return mySelectionActivated; }
void AvoidSimultaneousSelection( StdMeshersGUI_ObjectReferenceParamWdg* other);
-
+
void SetDefaultText(QString defaultText="", QString styleSheet="");
-public slots:
+ public slots:
/*!
* \brief Activates selection (if not yet done), emits selectionActivated()
- *
- * Useful to deactivate one Object Reference param widget when an other
- * one is activated
+ *
+ * Useful to deactivate one Object Reference param widget when an other
+ * one is activated
*/
void activateSelection();
void deactivateSelection();
-signals:
+ signals:
/*!
* \brief Emitted when selection is activated
- *
- * Useful to deactivate one Object Reference param widget when an other
- * one is activated
+ *
+ * Useful to deactivate one Object Reference param widget when an other
+ * one is activated
*/
void selectionActivated();
void contentModified();
-
-private slots:
- void onSelectionDone();
-private:
+ private slots:
+ void onSelectionDone();
+
+ private:
void init();
-
-private:
+
+ private:
bool myMultiSelection;
std::vector<CORBA::Object_var> myObjects;
- SUIT_SelectionFilter* myFilter;
- bool mySelectionActivated;
- bool myStretchActivated;
+ SUIT_SelectionFilter* myFilter;
+ bool mySelectionActivated;
+ bool myStretchActivated;
- SMESHGUI* mySMESHGUI;
- LightApp_SelectionMgr* mySelectionMgr;
+ SMESHGUI* mySMESHGUI;
+ LightApp_SelectionMgr* mySelectionMgr;
- QLineEdit* myObjNameLineEdit;
- QPushButton* mySelButton;
- QString myParamValue;
- QString myEmptyText;
- QString myEmptyStyleSheet;
+ QLineEdit* myObjNameLineEdit;
+ QPushButton* mySelButton;
+ QString myParamValue;
+ QString myEmptyText;
+ QString myEmptyStyleSheet;
};
#endif // STDMESHERSGUI_OBJECTREFERENCEPARAMWDG_H