Salome HOME
0021559: EDF 2175 SMESH: Hexa/Tetra mixed meshes
authoreap <eap@opencascade.com>
Thu, 6 Sep 2012 13:49:43 +0000 (13:49 +0000)
committereap <eap@opencascade.com>
Thu, 6 Sep 2012 13:49:43 +0000 (13:49 +0000)
+  // return true if given order of sub-meshes is OK
+  bool IsOrderOK( const SMESH_subMesh* smBefore,
+                  const SMESH_subMesh* smAfter ) const;

src/SMESH/SMESH_Mesh.cxx
src/SMESH/SMESH_Mesh.hxx

index 2b41f59a30294f76d46980c21fbf5d8818325694..4e12bc9c140155eed9e214bc9053e771f9d83a53 100644 (file)
@@ -2006,9 +2006,9 @@ bool SMESH_Mesh::SortByMeshOrder(list<SMESH_subMesh*>& theListToSort) const
   typedef list<SMESH_subMesh*>::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<SMESH_subMesh*>& 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<SMESH_subMesh*>& theListToSort) const
  */
 //=============================================================================
 
-list<SMESH_subMesh*> SMESH_Mesh::getAncestorsSubMeshes
-  (const TopoDS_Shape& theSubShape) const
+list<SMESH_subMesh*>
+SMESH_Mesh::getAncestorsSubMeshes (const TopoDS_Shape& theSubShape) const
 {
   list<SMESH_subMesh*> listOfSubMesh;
   TopTools_ListIteratorOfListOfShape it( GetAncestors( theSubShape ));
index 3f719496fa290be87e42ddabeb5fc9ae1f72a423..272bcea7d6f454b0f322d6061d52a74bd6223cd2 100644 (file)
@@ -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<SMESH_subMesh*>& 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: