From 88ff35ddd4a4442397bc5f6ba893aaf9c51b1856 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 22 Jul 2021 14:10:49 +0300 Subject: [PATCH] bos #24400 [CEA] Option in SALOME for not storing in med files the indices (number of nodes) + minor changes: 1) unify member field names: avoid _my*, replace by either _* or my* 2) BUG: mesh persistent ID is not unique 3) arguments alignement 4) Add SMESHDS_Hypothesis::SaveString() and LoadString() 5) In mesh construction dlg disable "Mesh Type" if it contains ANY only 6) Add SMESH::printErrorInDebugMode argument of SMESH_CATCH 7) Use static_assert to check completeness of arrays corresponding to enum 8) Add renumber arg to ExportUNV() and ExportDAT() 9) Fix some warnings --- .../input/importing_exporting_meshes.rst | 2 + .../gui/SMESH/input/mesh_preferences.rst | 4 + idl/SMESH_Mesh.idl | 43 +- resources/SalomeApp.xml.in | 1 + src/DriverDAT/DriverDAT_W_SMDS_Mesh.cxx | 25 +- src/DriverDAT/DriverDAT_W_SMDS_Mesh.h | 7 +- src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx | 40 +- src/DriverMED/DriverMED_W_SMESHDS_Mesh.h | 32 +- src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx | 35 +- src/DriverUNV/DriverUNV_W_SMDS_Mesh.h | 2 + src/MEDWrapper/MED_Factory.cxx | 8 +- src/MEDWrapper/MED_Structures.cxx | 3 +- src/MEDWrapper/MED_TStructures.hxx | 182 ++++---- src/MEDWrapper/MED_Wrapper.cxx | 154 +++---- src/SMDS/SMDS_Mesh.cxx | 24 +- src/SMESH/MG_ADAPT.cxx | 10 +- src/SMESH/MG_ADAPT.hxx | 4 +- src/SMESH/SMESH_Hypothesis.cxx | 2 +- src/SMESH/SMESH_Hypothesis.hxx | 2 +- src/SMESH/SMESH_Mesh.cxx | 408 +++++++++--------- src/SMESH/SMESH_Mesh.hxx | 54 +-- src/SMESHDS/SMESHDS_Hypothesis.cxx | 30 ++ src/SMESHDS/SMESHDS_Hypothesis.hxx | 3 + src/SMESHDS/SMESHDS_Mesh.cxx | 15 +- src/SMESHDS/SMESHDS_Mesh.hxx | 6 +- src/SMESHGUI/SMESHGUI.cxx | 84 ++-- src/SMESHGUI/SMESHGUI_MeshDlg.cxx | 1 + src/SMESHGUI/SMESHGUI_Utils.h | 16 +- src/SMESHGUI/SMESH_msg_en.ts | 8 + src/SMESHUtils/SMESH_TryCatch.cxx | 9 + src/SMESHUtils/SMESH_TryCatch.hxx | 1 + src/SMESH_I/SMESH_Filter_i.cxx | 6 +- src/SMESH_I/SMESH_Gen_i.cxx | 25 +- src/SMESH_I/SMESH_Group_i.cxx | 2 +- src/SMESH_I/SMESH_Group_i.hxx | 2 +- src/SMESH_I/SMESH_MeshEditor_i.cxx | 6 +- src/SMESH_I/SMESH_Mesh_i.cxx | 163 ++++--- src/SMESH_I/SMESH_Mesh_i.hxx | 44 +- src/SMESH_I/SMESH_Pattern_i.cxx | 4 +- src/SMESH_SWIG/smeshBuilder.py | 101 +++-- src/StdMeshers/StdMeshers_Prism_3D.cxx | 2 +- .../StdMeshers_QuadFromMedialAxis_1D2D.cxx | 2 +- .../StdMeshersGUI_ObjectReferenceParamWdg.h | 65 +-- 43 files changed, 939 insertions(+), 698 deletions(-) diff --git a/doc/salome/gui/SMESH/input/importing_exporting_meshes.rst b/doc/salome/gui/SMESH/input/importing_exporting_meshes.rst index a11e36dbb..b4ab4d4bd 100644 --- a/doc/salome/gui/SMESH/input/importing_exporting_meshes.rst +++ b/doc/salome/gui/SMESH/input/importing_exporting_meshes.rst @@ -56,6 +56,8 @@ There are additional parameters available at export to MED and SAUV format files * **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 ` preference controls whether node and cell numbers are saved. + **See Also** a sample TUI Script of an :ref:`Export Mesh ` operation. diff --git a/doc/salome/gui/SMESH/input/mesh_preferences.rst b/doc/salome/gui/SMESH/input/mesh_preferences.rst index 027518e91..c7a516734 100644 --- a/doc/salome/gui/SMESH/input/mesh_preferences.rst +++ b/doc/salome/gui/SMESH/input/mesh_preferences.rst @@ -54,6 +54,10 @@ General Preferences * **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 ` dialog. diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index 28896496b..7ee04ecee 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -657,14 +657,14 @@ module SMESH * - 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 @@ -693,6 +693,7 @@ module SMESH * - 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, @@ -702,14 +703,16 @@ module SMESH 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 @@ -733,8 +736,10 @@ module SMESH * 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, @@ -745,9 +750,11 @@ module SMESH 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); @@ -1098,7 +1105,7 @@ module SMESH raises (SALOME::SALOME_Exception); /*! - * Get the internal Id + * Get the internal persisten Id */ long GetId(); }; diff --git a/resources/SalomeApp.xml.in b/resources/SalomeApp.xml.in index c11851f4f..a6190a675 100644 --- a/resources/SalomeApp.xml.in +++ b/resources/SalomeApp.xml.in @@ -66,6 +66,7 @@ + diff --git a/src/DriverDAT/DriverDAT_W_SMDS_Mesh.cxx b/src/DriverDAT/DriverDAT_W_SMDS_Mesh.cxx index c3be3ad42..70b2d073a 100644 --- a/src/DriverDAT/DriverDAT_W_SMDS_Mesh.cxx +++ b/src/DriverDAT/DriverDAT_W_SMDS_Mesh.cxx @@ -32,6 +32,14 @@ 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; @@ -70,21 +78,24 @@ Driver_Mesh::Status DriverDAT_W_SMDS_Mesh::Perform() 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() ) @@ -100,6 +111,9 @@ Driver_Mesh::Status DriverDAT_W_SMDS_Mesh::Perform() 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(); ) @@ -115,6 +129,8 @@ Driver_Mesh::Status DriverDAT_W_SMDS_Mesh::Perform() 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() ); @@ -133,6 +149,9 @@ Driver_Mesh::Status DriverDAT_W_SMDS_Mesh::Perform() 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()); diff --git a/src/DriverDAT/DriverDAT_W_SMDS_Mesh.h b/src/DriverDAT/DriverDAT_W_SMDS_Mesh.h index 75c3f37fb..481f5b080 100644 --- a/src/DriverDAT/DriverDAT_W_SMDS_Mesh.h +++ b/src/DriverDAT/DriverDAT_W_SMDS_Mesh.h @@ -34,7 +34,12 @@ 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 diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx index cb3be452e..5076ae51d 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx @@ -53,6 +53,12 @@ using namespace std; using namespace MED; +//================================================================================ +/*! + * \brief Constructor + */ +//================================================================================ + DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh(): myAllSubMeshes (false), myDoGroupOfNodes (false), @@ -65,19 +71,31 @@ DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh(): 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; @@ -166,6 +184,12 @@ void DriverMED_W_SMESHDS_Mesh::AddAllToGroup() namespace { + //--------------------------------------------- + /*! + * \brief Retrieving node coordinates utilities + */ + //--------------------------------------------- + typedef double (SMDS_MeshNode::* TGetCoord)() const; typedef const char* TName; typedef const char* TUnit; @@ -344,12 +368,24 @@ namespace } } +//================================================================================ +/*! + * \brief Write my mesh to a file + */ +//================================================================================ + Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() { MED::PWrapper myMed = CrWrapperW(myFile, myVersion); return this->PerformInternal(myMed); } +//================================================================================ +/*! + * \brief Write my mesh to a MEDCoupling DS + */ +//================================================================================ + Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh_Mem::Perform() { void *ptr(nullptr); @@ -571,7 +607,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::PerformInternal(LowLevelWriter myM #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; diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.h b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.h index e9f9d172c..43e5c2745 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.h +++ b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.h @@ -42,6 +42,9 @@ class SMESHDS_GroupBase; 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: @@ -51,6 +54,7 @@ class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh 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); @@ -82,23 +86,27 @@ class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh private: std::list myGroups; - bool myAllSubMeshes; + bool myAllSubMeshes; std::vector 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: diff --git a/src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx b/src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx index 2263c1530..68c33035c 100644 --- a/src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx +++ b/src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx @@ -55,13 +55,13 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform() #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 ); { @@ -75,7 +75,8 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform() 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(); @@ -105,8 +106,10 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform() 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; @@ -138,7 +141,8 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform() 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(aNode->GetID()) ); @@ -155,8 +159,10 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform() 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; @@ -188,8 +194,10 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform() 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; @@ -214,7 +222,8 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform() // -------------------- { using namespace UNV2417; - if ( myGroups.size() > 0 ) { + if ( myGroups.size() > 0 ) + { TRecord aRec; TDataSet aDataSet2417; TGroupList::const_iterator aIter = myGroups.begin(); @@ -230,7 +239,7 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform() while ( aIter->more() ) { const SMDS_MeshElement* aNode = aIter->next(); if ( nodeLabelByID.empty() ) - aRec.NodeList.push_back( FromSmIdType(aNode->GetID()) ); + aRec.NodeList.push_back( FromSmIdType( aNode->GetID()) ); else aRec.NodeList.push_back( nodeLabelByID[ aNode->GetID() ]); } diff --git a/src/DriverUNV/DriverUNV_W_SMDS_Mesh.h b/src/DriverUNV/DriverUNV_W_SMDS_Mesh.h index 00ecb02c5..008123eb5 100644 --- a/src/DriverUNV/DriverUNV_W_SMDS_Mesh.h +++ b/src/DriverUNV/DriverUNV_W_SMDS_Mesh.h @@ -39,9 +39,11 @@ class MESHDRIVERUNV_EXPORT DriverUNV_W_SMDS_Mesh: public Driver_SMDS_Mesh virtual Status Perform() override; void AddGroup(SMESHDS_GroupBase* theGroup) { myGroups.push_back(theGroup); } + void SetRenumber( bool renumber ) { myRenumber = renumber; } private: TGroupList myGroups; + bool myRenumber; }; diff --git a/src/MEDWrapper/MED_Factory.cxx b/src/MEDWrapper/MED_Factory.cxx index 7d03749e6..72f080ca2 100644 --- a/src/MEDWrapper/MED_Factory.cxx +++ b/src/MEDWrapper/MED_Factory.cxx @@ -197,12 +197,12 @@ namespace MED 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 versionsOK(GetMEDVersionsAppendCompatible()); - bool isVersionRequestedOK(std::find(versionsOK.begin(),versionsOK.end(),theVersion)!=versionsOK.end()); + std::vector 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); } diff --git a/src/MEDWrapper/MED_Structures.cxx b/src/MEDWrapper/MED_Structures.cxx index bca82e0ff..c04113bc4 100644 --- a/src/MEDWrapper/MED_Structures.cxx +++ b/src/MEDWrapper/MED_Structures.cxx @@ -141,7 +141,8 @@ namespace MED TElemInfo ::SetElemNum(TInt theId, TInt theVal) { - (*myElemNum)[theId] = theVal; + if ( IsElemNum() ) + (*myElemNum)[theId] = theVal; } //--------------------------------------------------------------- diff --git a/src/MEDWrapper/MED_TStructures.hxx b/src/MEDWrapper/MED_TStructures.hxx index 3c3092d00..3197b6b6d 100644 --- a/src/MEDWrapper/MED_TStructures.hxx +++ b/src/MEDWrapper/MED_TStructures.hxx @@ -204,10 +204,10 @@ namespace MED } } - 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) { @@ -224,13 +224,13 @@ namespace MED 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; @@ -262,8 +262,8 @@ namespace MED virtual std::string - GetGroupName(TInt theId) const - { + GetGroupName(TInt theId) const + { return GetString(theId, GetLNOMLength(), myGroupNames); } @@ -329,10 +329,10 @@ namespace MED } } - TTElemInfo(const PMeshInfo& theMeshInfo, - TInt theNbElem, - EBooleen theIsElemNum, - EBooleen theIsElemNames) + TTElemInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + EBooleen theIsElemNum, + EBooleen theIsElemNames) { myMeshInfo = theMeshInfo; @@ -351,26 +351,26 @@ namespace MED 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)); @@ -671,7 +671,7 @@ namespace MED 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)); @@ -684,14 +684,14 @@ namespace MED } } - 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, @@ -705,16 +705,16 @@ namespace MED 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), @@ -737,10 +737,10 @@ namespace MED } } - virtual + virtual TInt - GetConnDim() const - { + GetConnDim() const + { return GetNbConn(myGeom, myEntity, myMeshInfo->myDim); } @@ -779,7 +779,7 @@ namespace MED myDiameters.resize( theNbElem ); } - TTBallInfo(const PMeshInfo& theMeshInfo, + TTBallInfo(const PMeshInfo& theMeshInfo, const TIntVector& theNodes, TFloatVector& theDiameters, const TIntVector& theFamilyNums, @@ -804,8 +804,8 @@ namespace MED }; //--------------------------------------------------------------- - struct TTFieldInfo: - virtual TFieldInfo, + struct TTFieldInfo: + virtual TFieldInfo, virtual TTNameInfo { typedef TTNameInfo TNameInfoBase; @@ -832,12 +832,12 @@ namespace MED 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; @@ -925,15 +925,15 @@ namespace MED 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; @@ -951,10 +951,10 @@ namespace MED myGeom2Gauss = theGeom2Gauss; } - virtual + virtual std::string GetUnitDt() const - { + { return GetString(0,GetPNOMLength(),myUnitDt); } @@ -974,7 +974,7 @@ namespace MED typedef TTNameInfo TNameInfoBase; TTProfileInfo(const TProfileInfo::TInfo& theInfo, - EModeProfil theMode): + EModeProfil theMode): TNameInfoBase(boost::get<0>(theInfo)) { TInt aSize = boost::get<1>(theInfo); @@ -987,9 +987,9 @@ namespace MED template struct TTTimeStampValue: virtual TTimeStampValue { - TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo, + TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo, const PTimeStampValueBase& theInfo, - ETypeChamp theTypeChamp) + ETypeChamp theTypeChamp) { typedef TTimeStampValue TCompatible; if(TCompatible* aCompatible = dynamic_cast(theInfo.get())){ @@ -1003,9 +1003,9 @@ namespace MED } TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo, - ETypeChamp theTypeChamp, - const TGeom2Profile& theGeom2Profile, - EModeSwitch theMode): + ETypeChamp theTypeChamp, + const TGeom2Profile& theGeom2Profile, + EModeSwitch theMode): TModeSwitchInfo(theMode) { this->myTimeStampInfo = theTimeStampInfo; @@ -1031,44 +1031,44 @@ namespace MED 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) { @@ -1080,13 +1080,13 @@ namespace MED 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; @@ -1105,9 +1105,9 @@ namespace MED 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(); @@ -1123,7 +1123,7 @@ namespace MED myFamNumNode.resize(nnoeuds); } - TTGrilleInfo(const PMeshInfo& theMeshInfo, + TTGrilleInfo(const PMeshInfo& theMeshInfo, const EGrilleType& type) { myMeshInfo = theMeshInfo; @@ -1138,8 +1138,8 @@ namespace MED myGrilleStructure.resize(aSpaceDim); } - TTGrilleInfo(const PMeshInfo& theMeshInfo, - const EGrilleType& type, + TTGrilleInfo(const PMeshInfo& theMeshInfo, + const EGrilleType& type, const MED::TIntVector& nbNodeVec) { myMeshInfo = theMeshInfo; @@ -1175,9 +1175,9 @@ namespace MED } virtual - std::string - GetCoordUnit(TInt theId) const - { + std::string + GetCoordUnit(TInt theId) const + { return GetString(theId,GetPNOMLength(),myCoordUnits); } diff --git a/src/MEDWrapper/MED_Wrapper.cxx b/src/MEDWrapper/MED_Wrapper.cxx index ad18d170c..b0c56200e 100644 --- a/src/MEDWrapper/MED_Wrapper.cxx +++ b/src/MEDWrapper/MED_Wrapper.cxx @@ -147,9 +147,9 @@ namespace MED 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) { @@ -242,9 +242,9 @@ namespace MED //---------------------------------------------------------------------------- void TWrapper - ::GetMeshInfo(TInt theMeshId, + ::GetMeshInfo(TInt theMeshId, MED::TMeshInfo& theInfo, - TErr* theErr) + TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); @@ -285,7 +285,7 @@ namespace MED void TWrapper ::SetMeshInfo(const MED::TMeshInfo& theInfo, - TErr* theErr) + TErr* theErr) { TErr aRet; SetMeshInfo(theInfo, eLECTURE_ECRITURE, &aRet); @@ -304,8 +304,8 @@ namespace MED void TWrapper ::SetMeshInfo(const MED::TMeshInfo& theInfo, - EModeAcces theMode, - TErr* theErr) + EModeAcces theMode, + TErr* theErr) { TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor); @@ -352,10 +352,10 @@ namespace MED //---------------------------------------------------------------------------- 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 @@ -377,7 +377,7 @@ namespace MED //---------------------------------------------------------------------------- PMeshInfo TWrapper - ::GetPMeshInfo(TInt theId, + ::GetPMeshInfo(TInt theId, TErr* theErr) { PMeshInfo anInfo = CrMeshInfo(); @@ -389,7 +389,7 @@ namespace MED TInt TWrapper ::GetNbFamilies(const MED::TMeshInfo& theInfo, - TErr* theErr) + TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); @@ -404,9 +404,9 @@ namespace MED //---------------------------------------------------------------------------- TInt TWrapper - ::GetNbFamAttr(TInt theFamId, + ::GetNbFamAttr(TInt theFamId, const MED::TMeshInfo& theInfo, - TErr* theErr) + TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); @@ -423,9 +423,9 @@ namespace MED //---------------------------------------------------------------------------- TInt TWrapper - ::GetNbFamGroup(TInt theFamId, + ::GetNbFamGroup(TInt theFamId, const MED::TMeshInfo& theInfo, - TErr* theErr) + TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); @@ -442,9 +442,9 @@ namespace MED //---------------------------------------------------------------------------- void TWrapper - ::GetFamilyInfo(TInt theFamId, + ::GetFamilyInfo(TInt theFamId, MED::TFamilyInfo& theInfo, - TErr* theErr) + TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); @@ -485,7 +485,7 @@ namespace MED void TWrapper ::SetFamilyInfo(const MED::TFamilyInfo& theInfo, - TErr* theErr) + TErr* theErr) { TErr aRet; SetFamilyInfo(theInfo, eLECTURE_ECRITURE, &aRet); @@ -501,8 +501,8 @@ namespace MED void TWrapper ::SetFamilyInfo(const MED::TFamilyInfo& theInfo, - EModeAcces theMode, - TErr* theErr) + EModeAcces theMode, + TErr* theErr) { TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor); @@ -540,10 +540,10 @@ namespace MED //---------------------------------------------------------------------------- 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 @@ -557,13 +557,13 @@ namespace MED //---------------------------------------------------------------------------- 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, @@ -578,7 +578,7 @@ namespace MED //---------------------------------------------------------------------------- PFamilyInfo TWrapper - ::CrFamilyInfo(const PMeshInfo& theMeshInfo, + ::CrFamilyInfo(const PMeshInfo& theMeshInfo, const PFamilyInfo& theInfo) { return PFamilyInfo(new TTFamilyInfo @@ -590,8 +590,8 @@ namespace MED 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) @@ -620,11 +620,11 @@ namespace MED //---------------------------------------------------------------------------- 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); @@ -658,10 +658,10 @@ namespace MED //---------------------------------------------------------------------------- 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); } @@ -669,11 +669,11 @@ namespace MED //---------------------------------------------------------------------------- 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); @@ -698,7 +698,7 @@ namespace MED MED_NO_DT, MED_NO_IT, anEntity, - aGeom, + aGeom, (TInt)anInfo.myElemNames->size(), &anElemNames); if (theErr) @@ -711,11 +711,11 @@ namespace MED //---------------------------------------------------------------------------- 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); @@ -749,10 +749,10 @@ namespace MED //---------------------------------------------------------------------------- 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); } @@ -760,11 +760,11 @@ namespace MED //---------------------------------------------------------------------------- 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); @@ -802,11 +802,11 @@ namespace MED //---------------------------------------------------------------------------- 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); @@ -849,10 +849,10 @@ namespace MED //---------------------------------------------------------------------------- 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); } @@ -860,11 +860,11 @@ namespace MED //---------------------------------------------------------------------------- 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); @@ -901,7 +901,7 @@ namespace MED TInt TWrapper ::GetNbNodes(const MED::TMeshInfo& theMeshInfo, - TErr* theErr) + TErr* theErr) { return GetNbNodes(theMeshInfo, eCOOR, theErr); } @@ -2208,14 +2208,14 @@ namespace MED //---------------------------------------------------------------------------- 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, diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index eaaea6803..2e9924295 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -47,7 +47,8 @@ #include #include -#include +//#include +#include #if !defined WIN32 && !defined __APPLE__ #include @@ -1063,16 +1064,27 @@ bool SMDS_Mesh::ChangePolyhedronNodes(const SMDS_MeshElement * e // keep current nodes of element std::set oldNodes( element->begin_nodes(), element->end_nodes() ); - // change nodes bool Ok = false; + + // change vtkUnstructuredGrid::Faces if ( const SMDS_MeshVolume* vol = DownCast( 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_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; } diff --git a/src/SMESH/MG_ADAPT.cxx b/src/SMESH/MG_ADAPT.cxx index 849a3f966..f3ea564e5 100644 --- a/src/SMESH/MG_ADAPT.cxx +++ b/src/SMESH/MG_ADAPT.cxx @@ -1533,18 +1533,18 @@ void MgAdapt::buildBackGroundMeshAndSolFiles(const std::vector& fie } 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() diff --git a/src/SMESH/MG_ADAPT.hxx b/src/SMESH/MG_ADAPT.hxx index 4970ccce5..12629a9da 100644 --- a/src/SMESH/MG_ADAPT.hxx +++ b/src/SMESH/MG_ADAPT.hxx @@ -243,8 +243,8 @@ private : TOptionValues _defaultOptionValues; // default values TOptionNames _doubleOptions, _charOptions, _boolOptions; // to find a type of option - std::vector _myErrorMessages; - Status _myStatus; + std::vector _errorMessages; + Status _status; std::string meshFormatOutputMesh; std::vector< std::string> solFormatOutput; std::vector groupVec; diff --git a/src/SMESH/SMESH_Hypothesis.cxx b/src/SMESH/SMESH_Hypothesis.cxx index 4f217d4b7..e0de00792 100644 --- a/src/SMESH/SMESH_Hypothesis.cxx +++ b/src/SMESH/SMESH_Hypothesis.cxx @@ -146,7 +146,7 @@ void SMESH_Hypothesis::SetLibName(const char* theLibName) //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::iterator itm = myStudyContext->mapMesh.begin(); diff --git a/src/SMESH/SMESH_Hypothesis.hxx b/src/SMESH/SMESH_Hypothesis.hxx index 0558ac6f1..6ae7cdcc9 100644 --- a/src/SMESH/SMESH_Hypothesis.hxx +++ b/src/SMESH/SMESH_Hypothesis.hxx @@ -128,7 +128,7 @@ public: /*! * \brief Find a mesh with given persistent ID */ - SMESH_Mesh* GetMeshByPersistentID(int id); + SMESH_Mesh* GetMeshByPersistentID(int id) const; protected: SMESH_Gen* _gen; diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index d21330b4e..7c634c4de 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -103,7 +103,7 @@ class SMESH_Mesh::SubMeshHolder : public SMESHDS_TSubMeshHolder< SMESH_subMesh > */ //============================================================================= -SMESH_Mesh::SMESH_Mesh(int theLocalId, +SMESH_Mesh::SMESH_Mesh(int theLocalId, SMESH_Gen* theGen, bool theIsEmbeddedMode, SMESHDS_Document* theDocument): @@ -112,15 +112,33 @@ SMESH_Mesh::SMESH_Mesh(int theLocalId, 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 ); + } + } } //================================================================================ @@ -134,8 +152,8 @@ SMESH_Mesh::SMESH_Mesh(): _groupId( 0 ), _nbSubShapes( 0 ), _isShapeToMesh( false ), - _myDocument( 0 ), - _myMeshDS( 0 ), + _document( 0 ), + _meshDS( 0 ), _gen( 0 ), _isAutoColor( false ), _isModified( false ), @@ -176,9 +194,9 @@ SMESH_Mesh::~SMESH_Mesh() { 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 ) @@ -187,7 +205,7 @@ SMESH_Mesh::~SMESH_Mesh() 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 @@ -208,13 +226,13 @@ SMESH_Mesh::~SMESH_Mesh() 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 } } @@ -227,7 +245,7 @@ SMESH_Mesh::~SMESH_Mesh() bool SMESH_Mesh::MeshExists( int meshId ) const { - return _myDocument ? bool( _myDocument->GetMesh( meshId )) : false; + return _document ? bool( _document->GetMesh( meshId )) : false; } //================================================================================ @@ -262,11 +280,11 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape) 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 @@ -275,7 +293,7 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape) std::map ::iterator i_gr = _mapGroup.begin(); while ( i_gr != _mapGroup.end() ) { if ( dynamic_cast( i_gr->second->GetGroupDS() )) { - _myMeshDS->RemoveGroup( i_gr->second->GetGroupDS() ); + _meshDS->RemoveGroup( i_gr->second->GetGroupDS() ); delete i_gr->second; _mapGroup.erase( i_gr++ ); } @@ -286,7 +304,7 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape) // clear SMESHDS TopoDS_Shape aNullShape; - _myMeshDS->ShapeToMesh( aNullShape ); + _meshDS->ShapeToMesh( aNullShape ); _shapeDiagonal = 0.0; } @@ -294,9 +312,9 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape) // 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); @@ -305,7 +323,7 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape) { _isShapeToMesh = false; _shapeDiagonal = 0.0; - _myMeshDS->ShapeToMesh( PseudoShape() ); + _meshDS->ShapeToMesh( PseudoShape() ); } _isModified = false; } @@ -318,7 +336,7 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape) TopoDS_Shape SMESH_Mesh::GetShapeToMesh() const { - return _myMeshDS->ShapeToMesh(); + return _meshDS->ShapeToMesh(); } //======================================================================= @@ -411,7 +429,7 @@ void SMESH_Mesh::Clear() 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() ) ) @@ -474,7 +492,7 @@ int SMESH_Mesh::UNVToMesh(const char* theFileName) _isShapeToMesh = false; DriverUNV_R_SMDS_Mesh myReader; - myReader.SetMesh(_myMeshDS); + myReader.SetMesh(_meshDS); myReader.SetFile(theFileName); myReader.SetMeshId(-1); myReader.Perform(); @@ -486,7 +504,7 @@ int SMESH_Mesh::UNVToMesh(const char* theFileName) { 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 ); @@ -507,7 +525,7 @@ int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName) _isShapeToMesh = false; DriverMED_R_SMESHDS_Mesh myReader; - myReader.SetMesh(_myMeshDS); + myReader.SetMesh(_meshDS); myReader.SetMeshId(-1); myReader.SetFile(theFileName); myReader.SetMeshName(theMeshName); @@ -532,8 +550,8 @@ int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName) } } - _myMeshDS->Modified(); - _myMeshDS->CompactMesh(); + _meshDS->Modified(); + _meshDS->CompactMesh(); return (int) status; } @@ -550,7 +568,7 @@ std::string SMESH_Mesh::STLToMesh(const char* theFileName) _isShapeToMesh = false; DriverSTL_R_SMDS_Mesh myReader; - myReader.SetMesh(_myMeshDS); + myReader.SetMesh(_meshDS); myReader.SetFile(theFileName); myReader.SetMeshId(-1); myReader.Perform(); @@ -574,7 +592,7 @@ int SMESH_Mesh::CGNSToMesh(const char* theFileName, #ifdef WITH_CGNS DriverCGNS_Read myReader; - myReader.SetMesh(_myMeshDS); + myReader.SetMesh(_meshDS); myReader.SetFile(theFileName); myReader.SetMeshId(theMeshIndex); res = myReader.Perform(); @@ -597,7 +615,7 @@ SMESH_ComputeErrorPtr SMESH_Mesh::GMFToMesh(const char* theFileName, bool theMakeRequiredGroups) { DriverGMF_Read myReader; - myReader.SetMesh(_myMeshDS); + myReader.SetMesh(_meshDS); myReader.SetFile(theFileName); myReader.SetMakeRequiredGroups( theMakeRequiredGroups ); myReader.Perform(); @@ -620,7 +638,6 @@ SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId, std::string* anError ) { - Unexpect aCatch(SalomeException); if(MYDEBUG) MESSAGE("SMESH_Mesh::AddHypothesis"); if ( anError ) @@ -715,7 +732,6 @@ SMESH_Hypothesis::Hypothesis_Status SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape, int anHypId) { - Unexpect aCatch(SalomeException); if(MYDEBUG) MESSAGE("SMESH_Mesh::RemoveHypothesis"); StudyContextStruct *sc = _gen->GetStudyContext(); @@ -785,7 +801,7 @@ SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape, const std::list& SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape) const { - return _myMeshDS->GetHypothesis(aSubShape); + return _meshDS->GetHypothesis(aSubShape); } //======================================================================= @@ -828,7 +844,7 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const SMESH_subMesh * aSubM { const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape(); - const std::list& hypList = _myMeshDS->GetHypothesis(aSubShape); + const std::list& hypList = _meshDS->GetHypothesis(aSubShape); std::list::const_iterator hyp = hypList.begin(); for ( ; hyp != hypList.end(); hyp++ ) { const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp ); @@ -849,7 +865,7 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const SMESH_subMesh * aSubM for ( ; smIt != ancestors.end(); smIt++ ) { const TopoDS_Shape& curSh = (*smIt)->GetSubShape(); - const std::list& hypList = _myMeshDS->GetHypothesis(curSh); + const std::list& hypList = _meshDS->GetHypothesis(curSh); std::list::const_iterator hyp = hypList.begin(); for ( ; hyp != hypList.end(); hyp++ ) { const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp ); @@ -921,7 +937,7 @@ int SMESH_Mesh::GetHypotheses(const SMESH_subMesh * aSubMesh, // get hypos from aSubShape { const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape(); - const std::list& hypList = _myMeshDS->GetHypothesis(aSubShape); + const std::list& hypList = _meshDS->GetHypothesis(aSubShape); for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ ) { const SMESH_Hypothesis* h = cSMESH_Hyp( *hyp ); @@ -950,7 +966,7 @@ int SMESH_Mesh::GetHypotheses(const SMESH_subMesh * aSubMesh, for ( ; smIt != ancestors.end(); smIt++ ) { const TopoDS_Shape& curSh = (*smIt)->GetSubShape(); - const std::list& hypList = _myMeshDS->GetHypothesis(curSh); + const std::list& hypList = _meshDS->GetHypothesis(curSh); for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ ) { const SMESH_Hypothesis* h = cSMESH_Hyp( *hyp ); @@ -994,8 +1010,7 @@ SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const int anHypId) const const std::list & SMESH_Mesh::GetLog() { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetScript()->GetCommands(); + return _meshDS->GetScript()->GetCommands(); } //============================================================================= @@ -1005,8 +1020,7 @@ const std::list & SMESH_Mesh::GetLog() //============================================================================= void SMESH_Mesh::ClearLog() { - Unexpect aCatch(SalomeException); - _myMeshDS->GetScript()->Clear(); + _meshDS->GetScript()->Clear(); } //============================================================================= @@ -1017,7 +1031,7 @@ void SMESH_Mesh::ClearLog() 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; @@ -1027,10 +1041,10 @@ SMESH_subMesh * SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape) 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 ) @@ -1039,7 +1053,7 @@ SMESH_subMesh * SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape) 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 @@ -1069,7 +1083,7 @@ SMESH_subMesh * SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape) SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape) const { - int index = _myMeshDS->ShapeToIndex(aSubShape); + int index = _meshDS->ShapeToIndex(aSubShape); return GetSubMeshContaining( index ); } @@ -1178,16 +1192,15 @@ bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp, 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; @@ -1257,7 +1270,7 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h 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 ); } @@ -1269,13 +1282,11 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h //============================================================================= void SMESH_Mesh::SetAutoColor(bool theAutoColor) { - Unexpect aCatch(SalomeException); _isAutoColor = theAutoColor; } bool SMESH_Mesh::GetAutoColor() { - Unexpect aCatch(SalomeException); return _isAutoColor; } @@ -1392,42 +1403,52 @@ bool SMESH_Mesh::HasDuplicatedGroupNamesMED() 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 aGroupNames; // Corrected for Mantis issue 0020028 - if ( !meshPart ) + if ( !theMeshPart ) { std::map< SMDSAbs_ElementType, std::set > aGroupNames; char aString [256]; @@ -1448,12 +1469,12 @@ void SMESH_Mesh::ExportMEDCommmon(DriverMED_W_SMESHDS_Mesh& myWriter, 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 ); @@ -1461,62 +1482,70 @@ void SMESH_Mesh::ExportMEDCommmon(DriverMED_W_SMESHDS_Mesh& myWriter, throw TooLargeForExport("MED"); } +//================================================================================ /*! * Same as SMESH_Mesh::ExportMED except for \a file and \a theVersion */ -MEDCoupling::MCAuto SMESH_Mesh::ExportMEDCoupling( - const char* theMeshName, - bool theAutoGroups, - const SMESHDS_Mesh* meshPart, - bool theAutoDimension, - bool theAddODOnVertices, - double theZTolerance, - bool theAllElemsToGroup) +//================================================================================ + +MEDCoupling::MCAuto +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 ); } //================================================================================ @@ -1525,11 +1554,11 @@ void SMESH_Mesh::ExportMED(const char * file, */ //================================================================================ -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 @@ -1542,9 +1571,10 @@ void SMESH_Mesh::ExportSAUV(const char *file, 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 ) { @@ -1556,7 +1586,7 @@ void SMESH_Mesh::ExportSAUV(const char *file, 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 @@ -1577,16 +1607,18 @@ void SMESH_Mesh::ExportSAUV(const char *file, //================================================================================ 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 ); @@ -1601,16 +1633,17 @@ void SMESH_Mesh::ExportDAT(const char * file, //================================================================================ 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 ) @@ -1622,11 +1655,11 @@ void SMESH_Mesh::ExportUNV(const char * file, 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 ); @@ -1648,13 +1681,13 @@ void SMESH_Mesh::ExportSTL(const char * file, 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 ); @@ -1689,17 +1722,17 @@ void SMESH_Mesh::ExportCGNS(const char * file, } #ifdef WITH_CGNS - DriverCGNS_Write myWriter; - myWriter.SetFile( file ); - myWriter.SetMesh( const_cast( meshDS )); - myWriter.SetMeshName( SMESH_Comment("Mesh_") << meshDS->GetPersistentId()); + DriverCGNS_Write writer; + writer.SetFile( file ); + writer.SetMesh( const_cast( 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() ); } @@ -1727,12 +1760,12 @@ void SMESH_Mesh::ExportGMF(const char * file, Driver_Mesh::Status status; SMESH_TRY; - DriverGMF_Write myWriter; - myWriter.SetFile( file ); - myWriter.SetMesh( const_cast( meshDS )); - myWriter.SetExportRequiredGroups( withRequiredGroups ); + DriverGMF_Write writer; + writer.SetFile( file ); + writer.SetMesh( const_cast( meshDS )); + writer.SetExportRequiredGroups( withRequiredGroups ); - status = myWriter.Perform(); + status = writer.Perform(); SMESH_CATCH( SMESH::throwSalomeEx ); @@ -1822,8 +1855,7 @@ double SMESH_Mesh::GetComputeProgress() const smIdType SMESH_Mesh::NbNodes() const { - Unexpect aCatch(SalomeException); - return _myMeshDS->NbNodes(); + return _meshDS->NbNodes(); } //================================================================================ @@ -1834,8 +1866,7 @@ smIdType SMESH_Mesh::NbNodes() const smIdType SMESH_Mesh::Nb0DElements() const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().Nb0DElements(); + return _meshDS->GetMeshInfo().Nb0DElements(); } //================================================================================ @@ -1846,8 +1877,7 @@ smIdType SMESH_Mesh::Nb0DElements() const smIdType SMESH_Mesh::NbEdges(SMDSAbs_ElementOrder order) const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbEdges(order); + return _meshDS->GetMeshInfo().NbEdges(order); } //================================================================================ @@ -1858,8 +1888,7 @@ smIdType SMESH_Mesh::NbEdges(SMDSAbs_ElementOrder order) const smIdType SMESH_Mesh::NbFaces(SMDSAbs_ElementOrder order) const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbFaces(order); + return _meshDS->GetMeshInfo().NbFaces(order); } //================================================================================ @@ -1870,8 +1899,7 @@ smIdType SMESH_Mesh::NbFaces(SMDSAbs_ElementOrder order) const smIdType SMESH_Mesh::NbTriangles(SMDSAbs_ElementOrder order) const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbTriangles(order); + return _meshDS->GetMeshInfo().NbTriangles(order); } //================================================================================ @@ -1882,8 +1910,7 @@ smIdType SMESH_Mesh::NbTriangles(SMDSAbs_ElementOrder order) const smIdType SMESH_Mesh::NbBiQuadTriangles() const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbBiQuadTriangles(); + return _meshDS->GetMeshInfo().NbBiQuadTriangles(); } //================================================================================ @@ -1894,8 +1921,7 @@ smIdType SMESH_Mesh::NbBiQuadTriangles() const smIdType SMESH_Mesh::NbQuadrangles(SMDSAbs_ElementOrder order) const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbQuadrangles(order); + return _meshDS->GetMeshInfo().NbQuadrangles(order); } //================================================================================ @@ -1906,8 +1932,7 @@ smIdType SMESH_Mesh::NbQuadrangles(SMDSAbs_ElementOrder order) const smIdType SMESH_Mesh::NbBiQuadQuadrangles() const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbBiQuadQuadrangles(); + return _meshDS->GetMeshInfo().NbBiQuadQuadrangles(); } //================================================================================ @@ -1918,8 +1943,7 @@ smIdType SMESH_Mesh::NbBiQuadQuadrangles() const smIdType SMESH_Mesh::NbPolygons(SMDSAbs_ElementOrder order) const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbPolygons(order); + return _meshDS->GetMeshInfo().NbPolygons(order); } //================================================================================ @@ -1930,8 +1954,7 @@ smIdType SMESH_Mesh::NbPolygons(SMDSAbs_ElementOrder order) const smIdType SMESH_Mesh::NbVolumes(SMDSAbs_ElementOrder order) const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbVolumes(order); + return _meshDS->GetMeshInfo().NbVolumes(order); } //================================================================================ @@ -1942,8 +1965,7 @@ smIdType SMESH_Mesh::NbVolumes(SMDSAbs_ElementOrder order) const smIdType SMESH_Mesh::NbTetras(SMDSAbs_ElementOrder order) const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbTetras(order); + return _meshDS->GetMeshInfo().NbTetras(order); } //================================================================================ @@ -1954,8 +1976,7 @@ smIdType SMESH_Mesh::NbTetras(SMDSAbs_ElementOrder order) const smIdType SMESH_Mesh::NbHexas(SMDSAbs_ElementOrder order) const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbHexas(order); + return _meshDS->GetMeshInfo().NbHexas(order); } //================================================================================ @@ -1966,8 +1987,7 @@ smIdType SMESH_Mesh::NbHexas(SMDSAbs_ElementOrder order) const smIdType SMESH_Mesh::NbTriQuadraticHexas() const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbTriQuadHexas(); + return _meshDS->GetMeshInfo().NbTriQuadHexas(); } //================================================================================ @@ -1978,8 +1998,7 @@ smIdType SMESH_Mesh::NbTriQuadraticHexas() const smIdType SMESH_Mesh::NbPyramids(SMDSAbs_ElementOrder order) const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbPyramids(order); + return _meshDS->GetMeshInfo().NbPyramids(order); } //================================================================================ @@ -1990,20 +2009,17 @@ smIdType SMESH_Mesh::NbPyramids(SMDSAbs_ElementOrder order) const 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(); } @@ -2015,8 +2031,7 @@ smIdType SMESH_Mesh::NbBiQuadPrisms() const smIdType SMESH_Mesh::NbHexagonalPrisms() const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbHexPrisms(); + return _meshDS->GetMeshInfo().NbHexPrisms(); } //================================================================================ @@ -2027,8 +2042,7 @@ smIdType SMESH_Mesh::NbHexagonalPrisms() const smIdType SMESH_Mesh::NbPolyhedrons() const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbPolyhedrons(); + return _meshDS->GetMeshInfo().NbPolyhedrons(); } //================================================================================ @@ -2039,8 +2053,7 @@ smIdType SMESH_Mesh::NbPolyhedrons() const smIdType SMESH_Mesh::NbBalls() const { - Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbBalls(); + return _meshDS->GetMeshInfo().NbBalls(); } //================================================================================ @@ -2051,8 +2064,7 @@ smIdType SMESH_Mesh::NbBalls() const smIdType SMESH_Mesh::NbSubMesh() const { - Unexpect aCatch(SalomeException); - return _myMeshDS->NbSubMesh(); + return _meshDS->NbSubMesh(); } //================================================================================ @@ -2064,7 +2076,7 @@ smIdType SMESH_Mesh::NbSubMesh() const int SMESH_Mesh::NbMeshes() const // nb meshes in the Study { - return _myDocument->NbMeshes(); + return _document->NbMeshes(); } //======================================================================= @@ -2077,7 +2089,7 @@ bool SMESH_Mesh::IsNotConformAllowed() const 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 ); } //======================================================================= @@ -2087,7 +2099,7 @@ bool SMESH_Mesh::IsNotConformAllowed() const bool SMESH_Mesh::IsMainShape(const TopoDS_Shape& theShape) const { - return theShape.IsSame(_myMeshDS->ShapeToMesh() ); + return theShape.IsSame(_meshDS->ShapeToMesh() ); } //======================================================================= @@ -2162,7 +2174,7 @@ SMESH_Group* SMESH_Mesh::AddGroup (SMESHDS_GroupBase* groupDS) bool SMESH_Mesh::SynchronizeGroups() { const size_t nbGroups = _mapGroup.size(); - const std::set& groups = _myMeshDS->GetGroups(); + const std::set& groups = _meshDS->GetGroups(); std::set::const_iterator gIt = groups.begin(); for ( ; gIt != groups.end(); ++gIt ) { @@ -2295,7 +2307,7 @@ ostream& SMESH_Mesh::Dump(ostream& save) save << clause << ".2) Number of " << orderStr << " quadrangles:\t" << nb4 << endl; if ( nb3 + nb4 != NbFaces(order) ) { std::map 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() ) @@ -2320,7 +2332,7 @@ ostream& SMESH_Mesh::Dump(ostream& save) save << clause << ".4) Number of " << orderStr << " pyramids: \t" << nb5 << endl; if ( nb8 + nb4 + nb5 + nb6 != NbVolumes(order) ) { std::map 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() ) @@ -2346,7 +2358,7 @@ ostream& SMESH_Mesh::Dump(ostream& save) SMDSAbs_ElementType SMESH_Mesh::GetElementType( const smIdType id, const bool iselem ) { - return _myMeshDS->GetElementType( id, iselem ); + return _meshDS->GetElementType( id, iselem ); } //============================================================================= @@ -2397,7 +2409,7 @@ SMESH_Group* SMESH_Mesh::ConvertToStandalone ( int theGroupID ) void SMESH_Mesh::ClearMeshOrder() { - _mySubMeshOrder.clear(); + _subMeshOrder.clear(); } //============================================================================= @@ -2408,7 +2420,7 @@ void SMESH_Mesh::ClearMeshOrder() void SMESH_Mesh::SetMeshOrder(const TListOfListOfInt& theOrder ) { - _mySubMeshOrder = theOrder; + _subMeshOrder = theOrder; } //============================================================================= @@ -2419,7 +2431,7 @@ void SMESH_Mesh::SetMeshOrder(const TListOfListOfInt& theOrder ) const TListOfListOfInt& SMESH_Mesh::GetMeshOrder() const { - return _mySubMeshOrder; + return _subMeshOrder; } //============================================================================= @@ -2480,7 +2492,7 @@ void SMESH_Mesh::fillAncestorsMap(const TopoDS_Shape& theShape) bool SMESH_Mesh::SortByMeshOrder(std::vector& theListToSort) const { - if ( _mySubMeshOrder.empty() || theListToSort.size() < 2 ) + if ( _subMeshOrder.empty() || theListToSort.size() < 2 ) return true; @@ -2491,9 +2503,9 @@ bool SMESH_Mesh::SortByMeshOrder(std::vector& theListToSort) con typedef std::vector::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 @@ -2571,8 +2583,8 @@ bool SMESH_Mesh::SortByMeshOrder(std::vector& theListToSort) con 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; diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index 66023da8e..81495db9c 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -178,9 +178,9 @@ class SMESH_EXPORT SMESH_Mesh 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; } @@ -265,14 +265,14 @@ class SMESH_EXPORT SMESH_Mesh TooLargeForExport(const char* format):runtime_error(format) {} }; - MEDCoupling::MCAuto 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 + 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, @@ -282,12 +282,15 @@ class SMESH_EXPORT SMESH_Mesh 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, @@ -385,16 +388,17 @@ class SMESH_EXPORT SMESH_Mesh 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; @@ -404,8 +408,8 @@ protected: 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 _mapGroup; @@ -421,7 +425,7 @@ protected: mutable std::vector _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) diff --git a/src/SMESHDS/SMESHDS_Hypothesis.cxx b/src/SMESHDS/SMESHDS_Hypothesis.cxx index b88b3437d..38482c2a2 100644 --- a/src/SMESHDS/SMESHDS_Hypothesis.cxx +++ b/src/SMESHDS/SMESHDS_Hypothesis.cxx @@ -114,3 +114,33 @@ bool SMESHDS_Hypothesis::IsSameName( const SMESHDS_Hypothesis& other) const { 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( 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; +} diff --git a/src/SMESHDS/SMESHDS_Hypothesis.hxx b/src/SMESHDS/SMESHDS_Hypothesis.hxx index 665cb9c13..0c16c46a2 100644 --- a/src/SMESHDS/SMESHDS_Hypothesis.hxx +++ b/src/SMESHDS/SMESHDS_Hypothesis.hxx @@ -48,6 +48,9 @@ class SMESHDS_EXPORT SMESHDS_Hypothesis 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); } diff --git a/src/SMESHDS/SMESHDS_Mesh.cxx b/src/SMESHDS/SMESHDS_Mesh.cxx index df229269b..8854fb40d 100644 --- a/src/SMESHDS/SMESHDS_Mesh.cxx +++ b/src/SMESHDS/SMESHDS_Mesh.cxx @@ -56,14 +56,14 @@ class SMESHDS_Mesh::SubMeshHolder : public SMESHDS_TSubMeshHolder< const SMESHDS //======================================================================= //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); } @@ -188,13 +188,15 @@ bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S, //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; @@ -235,9 +237,8 @@ bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem, //function : ChangePolygonNodes //purpose : //======================================================================= -bool SMESHDS_Mesh::ChangePolygonNodes -(const SMDS_MeshElement * elem, - std::vector nodes) +bool SMESHDS_Mesh::ChangePolygonNodes (const SMDS_MeshElement * elem, + std::vector& nodes) { ASSERT(nodes.size() > 3); diff --git a/src/SMESHDS/SMESHDS_Mesh.hxx b/src/SMESHDS/SMESHDS_Mesh.hxx index ed7852e65..814b3d450 100644 --- a/src/SMESHDS/SMESHDS_Mesh.hxx +++ b/src/SMESHDS/SMESHDS_Mesh.hxx @@ -595,8 +595,8 @@ class SMESHDS_EXPORT SMESHDS_Mesh : public SMDS_Mesh bool ChangeElementNodes(const SMDS_MeshElement * elem, const SMDS_MeshNode * nodes[], const int nbnodes); - bool ChangePolygonNodes(const SMDS_MeshElement * elem, - std::vector nodes); + bool ChangePolygonNodes(const SMDS_MeshElement * elem, + std::vector& nodes); bool ChangePolyhedronNodes(const SMDS_MeshElement * elem, const std::vector& nodes, const std::vector& quantities); @@ -656,7 +656,7 @@ class SMESHDS_EXPORT SMESHDS_Mesh : public SMDS_Mesh ShapeToHypothesis myShapeToHypothesis; - int myMeshID, myPersistentID; + int myPersistentID; TopoDS_Shape myShape; class SubMeshHolder; diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 9f63eaf34..a4714beb7 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -460,6 +460,7 @@ namespace 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; @@ -628,8 +629,8 @@ namespace "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 ) { @@ -655,12 +656,11 @@ namespace // 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 = ""; @@ -670,44 +670,46 @@ namespace 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; } @@ -751,7 +753,6 @@ namespace 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]); } } @@ -924,9 +925,9 @@ namespace // 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++ ) { @@ -934,15 +935,11 @@ namespace 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 ) @@ -957,16 +954,16 @@ namespace 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 ) { @@ -5479,6 +5476,7 @@ void SMESHGUI::createPreferences() 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 ); diff --git a/src/SMESHGUI/SMESHGUI_MeshDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshDlg.cxx index f61406d59..cc8b4b2e7 100644 --- a/src/SMESHGUI/SMESHGUI_MeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshDlg.cxx @@ -891,6 +891,7 @@ void SMESHGUI_MeshDlg::setAvailableMeshType( const QStringList& theTypeMesh ) { myMeshType->clear(); myMeshType->addItems(theTypeMesh); + myMeshType->setEnabled( theTypeMesh.size() > 1 ); } //================================================================================ /*! diff --git a/src/SMESHGUI/SMESHGUI_Utils.h b/src/SMESHGUI/SMESHGUI_Utils.h index 6405448b1..9515099b7 100644 --- a/src/SMESHGUI/SMESHGUI_Utils.h +++ b/src/SMESHGUI/SMESHGUI_Utils.h @@ -106,12 +106,12 @@ SMESHGUI_EXPORT _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) ); @@ -141,7 +141,7 @@ SMESHGUI_EXPORT } SMESHGUI_EXPORT - CORBA::Object_var IORToObject( const QString& ); + CORBA::Object_var IORToObject( const QString& ior ); template typename TInterface::_var_type IORToInterface( const QString& theIOR ) @@ -153,7 +153,7 @@ SMESHGUI_EXPORT } SMESHGUI_EXPORT - CORBA::Object_var EntryToObject( const QString& ); + CORBA::Object_var EntryToObject( const QString& entry ); template typename TInterface::_var_type EntryToInterface( const QString& theEntry ) @@ -165,7 +165,7 @@ SMESHGUI_EXPORT } SMESHGUI_EXPORT - int GetNameOfSelectedIObjects( LightApp_SelectionMgr*, QString& ); + int GetNameOfSelectedIObjects( LightApp_SelectionMgr*, QString& name ); SMESHGUI_EXPORT QString GetName( const Handle(SALOME_InteractiveObject)& theIO ); @@ -174,7 +174,7 @@ SMESHGUI_EXPORT _PTR(SObject) GetMeshOrSubmesh( _PTR(SObject) ); SMESHGUI_EXPORT - void ShowHelpFile( const QString& ); + void ShowHelpFile( const QString& helpFileName); /*! * \brief Return the normal to a face diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 32fb70b88..a4b6cfd7a 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -2840,6 +2840,10 @@ Check algorithm documentation for supported geometry SMESH_RENUMBERING Renumbering + + SMESH_RENUMBER + Renumber + SMESH_RENUMBERING_ELEMENTS_TITLE Renumbering elements @@ -4885,6 +4889,10 @@ Please, create VTK viewer and try again PREF_SHOW_WARN Show warning when exporting group + + PREF_MED_SAVE_NUMS + Save cell/node numbers to MED file + PREF_ZTOLERANCE Z tolerance for MED export diff --git a/src/SMESHUtils/SMESH_TryCatch.cxx b/src/SMESHUtils/SMESH_TryCatch.cxx index 4552a1e7f..48ebcdee2 100644 --- a/src/SMESHUtils/SMESH_TryCatch.cxx +++ b/src/SMESHUtils/SMESH_TryCatch.cxx @@ -39,6 +39,15 @@ const char* SMESH::returnError(const char* txt) 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" diff --git a/src/SMESHUtils/SMESH_TryCatch.hxx b/src/SMESHUtils/SMESH_TryCatch.hxx index 5abfac368..76f4b3378 100644 --- a/src/SMESHUtils/SMESH_TryCatch.hxx +++ b/src/SMESHUtils/SMESH_TryCatch.hxx @@ -108,6 +108,7 @@ namespace SMESH 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 diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index 40b20acbb..954f98cd8 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -4185,11 +4185,9 @@ namespace SMESH { "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; } diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 93c981ec3..8b0f40c39 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -2707,10 +2707,10 @@ SMESH_Gen_i::ConcatenateCommon(const SMESH::ListOfIDSources& theMeshesArray, { // 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(); @@ -4206,8 +4206,9 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, 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 @@ -4414,8 +4415,8 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, // 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; @@ -4889,7 +4890,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, // Pass SMESHDS_Group to MED writer SMESHDS_Group* aGrpDS = dynamic_cast( aGrpBaseDS ); if ( aGrpDS ) - myWriter.AddGroup( aGrpDS ); + writer.AddGroup( aGrpDS ); // write reference on a shape if exists SMESHDS_GroupOnGeom* aGeomGrp = @@ -4914,7 +4915,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, 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 = @@ -4937,7 +4938,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, 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 ); @@ -5547,7 +5548,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, } } // 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; diff --git a/src/SMESH_I/SMESH_Group_i.cxx b/src/SMESH_I/SMESH_Group_i.cxx index 357ae2aa3..1ee929550 100644 --- a/src/SMESH_I/SMESH_Group_i.cxx +++ b/src/SMESH_I/SMESH_Group_i.cxx @@ -439,7 +439,7 @@ SMESH::smIdType SMESH_Group_i::AddFrom( SMESH::SMESH_IDSource_ptr theSource ) //============================================================================= /*! - * + * Return ID of theIndex-th group item */ //============================================================================= diff --git a/src/SMESH_I/SMESH_Group_i.hxx b/src/SMESH_I/SMESH_Group_i.hxx index 676a27ed6..a0f54c3b5 100644 --- a/src/SMESH_I/SMESH_Group_i.hxx +++ b/src/SMESH_I/SMESH_Group_i.hxx @@ -109,7 +109,7 @@ class SMESH_I_EXPORT SMESH_GroupBase_i: // 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; diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index bc5073500..f11615845 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -102,7 +102,7 @@ namespace MeshEditor_I { //!< 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 @@ -155,8 +155,8 @@ namespace MeshEditor_I { //!< 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() { diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index afc798f24..c63eccd3b 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -3824,7 +3824,7 @@ void SMESH_Mesh_i::ExportSAUV( const char* file, CORBA::Boolean auto_groups ) */ //================================================================================ -void SMESH_Mesh_i::ExportDAT (const char *file) +void SMESH_Mesh_i::ExportDAT (const char *file, CORBA::Boolean renumber ) { SMESH_TRY; if ( _preMeshInfo ) @@ -3833,11 +3833,12 @@ void SMESH_Mesh_i::ExportDAT (const char *file) // 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 ); } @@ -3848,7 +3849,7 @@ void SMESH_Mesh_i::ExportDAT (const char *file) */ //================================================================================ -void SMESH_Mesh_i::ExportUNV (const char *file) +void SMESH_Mesh_i::ExportUNV (const char *file, CORBA::Boolean renumber) { SMESH_TRY; if ( _preMeshInfo ) @@ -3857,11 +3858,12 @@ void SMESH_Mesh_i::ExportUNV (const char *file) // 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 ); } @@ -3896,22 +3898,32 @@ void SMESH_Mesh_i::ExportSTL (const char *file, const bool isascii) 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() ); @@ -3921,21 +3933,28 @@ public: } 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 -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 ) @@ -3958,8 +3977,7 @@ void SMESH_Mesh_i::ExportPartToMEDCommon(SPECLS& speCls, 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; } @@ -3983,7 +4001,8 @@ void SMESH_Mesh_i::ExportPartToMEDCommon(SPECLS& speCls, 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 @@ -4000,7 +4019,8 @@ void SMESH_Mesh_i::ExportPartToMEDCommon(SPECLS& speCls, } 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; } @@ -4008,7 +4028,7 @@ void SMESH_Mesh_i::ExportPartToMEDCommon(SPECLS& speCls, if ( _impl->HasShapeToMesh() ) { - speCls.exportField(*this,aMeshName,have0dField,meshDS,fields,geomAssocFields); + speCls.exportField( *this, aMeshName, have0dField, meshDS, fields, geomAssocFields); } SMESH_CATCH( SMESH::throwCorbaException ); } @@ -4027,11 +4047,14 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, 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(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; @@ -4050,24 +4073,31 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, << 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 ); @@ -4077,25 +4107,38 @@ public: } public: MEDCoupling::MCAuto getData() { return _res; } + private: MEDCoupling::MCAuto _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 data; + SMESH_TRY; if( !this->_gen_i->isSSLMode() ) SMESH::throwCorbaException("SMESH_Mesh_i::ExportPartToMEDCoupling : only for embedded mode !"); + MEDFileMemSpeCls spe; - this->ExportPartToMEDCommon(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(ret); } @@ -4375,20 +4418,17 @@ void SMESH_Mesh_i::exportMEDFields( DriverMED_W_Field& fieldWriter, */ //================================================================================ -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 ); } @@ -4398,8 +4438,9 @@ void SMESH_Mesh_i::ExportPartToDAT(::SMESH::SMESH_IDSource_ptr meshPart, */ //================================================================================ -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 ) @@ -4408,10 +4449,10 @@ void SMESH_Mesh_i::ExportPartToUNV(::SMESH::SMESH_IDSource_ptr meshPart, 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 ); } @@ -5453,7 +5494,7 @@ SMESH::smIdType_array* SMESH_Mesh_i::GetElemNodes(const SMESH::smIdType id) 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(); } @@ -5577,7 +5618,7 @@ SMESH::smIdType_array* SMESH_Mesh_i::GetElemFaceNodes(SMESH::smIdType elemId, { 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(); } } @@ -5660,7 +5701,7 @@ SMESH::smIdType_array* SMESH_Mesh_i::GetElementsByNodes(const SMESH::smIdType_ar 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 elems; diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index f17c076de..a2c428656 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -212,14 +212,13 @@ public: 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, @@ -231,13 +230,14 @@ public: template - 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, @@ -247,19 +247,23 @@ public: 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); diff --git a/src/SMESH_I/SMESH_Pattern_i.cxx b/src/SMESH_I/SMESH_Pattern_i.cxx index b5ecf85c9..ab08c61b8 100644 --- a/src/SMESH_I/SMESH_Pattern_i.cxx +++ b/src/SMESH_I/SMESH_Pattern_i.cxx @@ -286,7 +286,7 @@ SMESH::point_array* list xyzList; set 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); @@ -345,7 +345,7 @@ SMESH::point_array* list xyzList; set 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); diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index 43e8f431b..820e2e1af 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -2305,38 +2305,41 @@ class Mesh(metaclass = MeshMeta): 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 `) 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 `) + 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) @@ -2344,9 +2347,10 @@ class Mesh(metaclass = MeshMeta): 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 ) @@ -2355,7 +2359,9 @@ class Mesh(metaclass = MeshMeta): 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) @@ -2383,7 +2389,8 @@ class Mesh(metaclass = MeshMeta): 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 `) to export instead of the mesh + meshPart: a part of mesh (:class:`sub-mesh, group or filter `) + 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 @@ -2404,6 +2411,7 @@ class Mesh(metaclass = MeshMeta): 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 @@ -2416,6 +2424,7 @@ class Mesh(metaclass = MeshMeta): 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) @@ -2426,9 +2435,13 @@ class Mesh(metaclass = MeshMeta): 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 ) @@ -2439,7 +2452,7 @@ class Mesh(metaclass = MeshMeta): 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) @@ -2457,41 +2470,43 @@ class Mesh(metaclass = MeshMeta): 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 `) 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 `) 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): """ @@ -7454,6 +7469,14 @@ class meshProxy(SMESH._objref_SMESH_Mesh): 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) diff --git a/src/StdMeshers/StdMeshers_Prism_3D.cxx b/src/StdMeshers/StdMeshers_Prism_3D.cxx index 962ae75bd..2a8baf1ec 100644 --- a/src/StdMeshers/StdMeshers_Prism_3D.cxx +++ b/src/StdMeshers/StdMeshers_Prism_3D.cxx @@ -99,7 +99,7 @@ namespace { TmpMesh() { _isShapeToMesh = (_id = 0); - _myMeshDS = new SMESHDS_Mesh( _id, true ); + _meshDS = new SMESHDS_Mesh( _id, true ); } }; //======================================================================= diff --git a/src/StdMeshers/StdMeshers_QuadFromMedialAxis_1D2D.cxx b/src/StdMeshers/StdMeshers_QuadFromMedialAxis_1D2D.cxx index 7efd9af5f..3f6730bf9 100644 --- a/src/StdMeshers/StdMeshers_QuadFromMedialAxis_1D2D.cxx +++ b/src/StdMeshers/StdMeshers_QuadFromMedialAxis_1D2D.cxx @@ -240,7 +240,7 @@ namespace { TmpMesh() { - _myMeshDS = new SMESHDS_Mesh(/*id=*/0, /*isEmbeddedMode=*/true); + _meshDS = new SMESHDS_Mesh(/*id=*/0, /*isEmbeddedMode=*/true); } }; diff --git a/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.h b/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.h index 46ac6942c..2e5d3792c 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.h +++ b/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.h @@ -53,8 +53,8 @@ class STDMESHERSGUI_EXPORT StdMeshersGUI_ObjectReferenceParamWdg : public QWidge { Q_OBJECT -public: - StdMeshersGUI_ObjectReferenceParamWdg( SUIT_SelectionFilter* filter, + public: + StdMeshersGUI_ObjectReferenceParamWdg( SUIT_SelectionFilter* filter, QWidget* parent, bool multiSelection=false /* ,bool stretch=true*/); @@ -67,7 +67,7 @@ public: void SetObjects(SMESH::string_array_var& objEntries); - template + template typename TInterface::_var_type GetObject(size_t i=0) const { if ( IsObjectSelected(i) ) return TInterface::_narrow(myObjects[i]); return TInterface::_nil(); @@ -75,6 +75,7 @@ public: size_t NbObjects() const { return myObjects.size(); } + // Return object entries QString GetValue() const { return myParamValue; } bool IsObjectSelected(size_t i=0) const @@ -82,60 +83,60 @@ public: /*! * \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 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 -- 2.39.2