From: eap Date: Thu, 6 Sep 2012 13:49:43 +0000 (+0000) Subject: 0021559: EDF 2175 SMESH: Hexa/Tetra mixed meshes X-Git-Tag: V6_6_0a1~136 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2a7bf64d23884584b2de5b9b84a598cd9f1067fd;p=modules%2Fsmesh.git 0021559: EDF 2175 SMESH: Hexa/Tetra mixed meshes + // return true if given order of sub-meshes is OK + bool IsOrderOK( const SMESH_subMesh* smBefore, + const SMESH_subMesh* smAfter ) const; --- diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index 2b41f59a3..4e12bc9c1 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -2006,9 +2006,9 @@ bool SMESH_Mesh::SortByMeshOrder(list& theListToSort) const typedef list::iterator TPosInList; map< int, TPosInList > sortedPos; TPosInList smBeg = theListToSort.begin(), smEnd = theListToSort.end(); - TListOfListOfInt::const_iterator listIddIt = _mySubMeshOrder.begin(); - for( ; listIddIt != _mySubMeshOrder.end(); listIddIt++) { - const TListOfInt& listOfId = *listIddIt; + TListOfListOfInt::const_iterator listIdsIt = _mySubMeshOrder.begin(); + for( ; listIdsIt != _mySubMeshOrder.end(); listIdsIt++) { + const TListOfInt& listOfId = *listIdsIt; TListOfInt::const_iterator idIt = listOfId.begin(); for ( ; idIt != listOfId.end(); idIt++ ) { if ( SMESH_subMesh * sm = GetSubMeshContaining( *idIt )) { @@ -2035,6 +2035,30 @@ bool SMESH_Mesh::SortByMeshOrder(list& theListToSort) const return res; } +//================================================================================ +/*! + * \brief Return true if given order of sub-meshes is OK + */ +//================================================================================ + +bool SMESH_Mesh::IsOrderOK( const SMESH_subMesh* smBefore, + const SMESH_subMesh* smAfter ) const +{ + TListOfListOfInt::const_iterator listIdsIt = _mySubMeshOrder.begin(); + TListOfInt::const_iterator idBef, idAft; + for( ; listIdsIt != _mySubMeshOrder.end(); listIdsIt++) + { + const TListOfInt& listOfId = *listIdsIt; + idBef = std::find( listOfId.begin(), listOfId.end(), smBefore->GetId() ); + if ( idBef != listOfId.end() ) + idAft = std::find( listOfId.begin(), listOfId.end(), smAfter->GetId() ); + if ( idAft != listOfId.end () ) + return ( std::distance( listOfId.begin(), idBef ) < + std::distance( listOfId.begin(), idAft ) ); + } + return true; // no order imposed to given submeshes +} + //============================================================================= /*! * \brief sort submeshes according to stored mesh order @@ -2043,8 +2067,8 @@ bool SMESH_Mesh::SortByMeshOrder(list& theListToSort) const */ //============================================================================= -list SMESH_Mesh::getAncestorsSubMeshes - (const TopoDS_Shape& theSubShape) const +list +SMESH_Mesh::getAncestorsSubMeshes (const TopoDS_Shape& theSubShape) const { list listOfSubMesh; TopTools_ListIteratorOfListOfShape it( GetAncestors( theSubShape )); diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index 3f719496f..272bcea7d 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -319,15 +319,13 @@ public: void SetMeshOrder(const TListOfListOfInt& theOrder ); const TListOfListOfInt& GetMeshOrder() const; - /*! - * \brief sort submeshes according to stored mesh order - * \param theListToSort in out list to be sorted - * \return FALSE if nothing sorted - */ + // sort submeshes according to stored mesh order bool SortByMeshOrder(std::list& theListToSort) const; - // - + // return true if given order of sub-meshes is OK + bool IsOrderOK( const SMESH_subMesh* smBefore, + const SMESH_subMesh* smAfter ) const; + ostream& Dump(ostream & save); private: