Salome HOME
Update of CheckDone
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_PropagationHelperWdg.cxx
index 3369aaa95f133114d16b939ba94e5aa9cda6e2b5..37832e25754977ea28eae8de07cc4b1677c225a0 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -174,15 +174,11 @@ void StdMeshersGUI_PropagationHelperWdg::onShowGeometry(bool toShow)
     BRep_Builder aBuilder;
     aBuilder.MakeCompound( aCompound );
     
     BRep_Builder aBuilder;
     aBuilder.MakeCompound( aCompound );
     
-    SMESH_PreviewActorsCollection* previewActor = mySubSelectWdg->GetActorCollection();
-    if ( !previewActor ) return;
-    const QList<int>& egdeIDs = previewActor->GetIndices();
-    for ( QList<int>::const_iterator ieIt = egdeIDs.begin(); ieIt != egdeIDs.end(); ++ieIt )
-    {
-      TopoDS_Shape E = previewActor->GetShapeByIndex( *ieIt );
-      if ( !E.IsNull() && E.ShapeType() == TopAbs_EDGE )
-        aBuilder.Add( aCompound, E );
-    }
+    TopTools_MapOfShape edgesMap;
+    TopExp_Explorer edge( mainShape, TopAbs_EDGE );
+    for ( ; edge.More(); edge.Next() )
+      if ( edgesMap.Add( edge.Current() ))
+        aBuilder.Add( aCompound, edge.Current() );
 
     myModelActor = GEOM_Actor::New();
     myModelActor->SetShape( aCompound, 0, 0 );
 
     myModelActor = GEOM_Actor::New();
     myModelActor->SetShape( aCompound, 0, 0 );
@@ -223,7 +219,7 @@ bool StdMeshersGUI_PropagationHelperWdg::buildChains()
   // aPreviewActor holds a map od all sub-shapes of mainShape
   SMESH_PreviewActorsCollection* previewActor = mySubSelectWdg->GetActorCollection();
   if ( !previewActor ) return false;
   // aPreviewActor holds a map od all sub-shapes of mainShape
   SMESH_PreviewActorsCollection* previewActor = mySubSelectWdg->GetActorCollection();
   if ( !previewActor ) return false;
-  const QList<int>& egdeIDs = previewActor->GetIndices();
+  const QList<int>& edgeIDs = previewActor->GetIndices();
 
   // Make a 'map' of WIREs of EDGE with quadrilateral WIREs only
 
 
   // Make a 'map' of WIREs of EDGE with quadrilateral WIREs only
 
@@ -233,12 +229,13 @@ bool StdMeshersGUI_PropagationHelperWdg::buildChains()
   typedef std::vector< TEdgeInWire > TWiresOfEdge;// WIREs including an EDGE
 
   std::vector< TWire > quadWires;
   typedef std::vector< TEdgeInWire > TWiresOfEdge;// WIREs including an EDGE
 
   std::vector< TWire > quadWires;
-  quadWires.reserve( egdeIDs.count() );
-  NCollection_DataMap< TGeomID, TWiresOfEdge > wiresOfEdge( egdeIDs.count() );
+  quadWires.reserve( previewActor->NbShapesOfType( TopAbs_FACE ));
+  NCollection_DataMap< TGeomID, TWiresOfEdge >
+    wiresOfEdge( previewActor->NbShapesOfType( TopAbs_EDGE ));
 
   TopExp_Explorer wire;
   TopTools_MapOfShape faceMap;
 
   TopExp_Explorer wire;
   TopTools_MapOfShape faceMap;
-  for ( TopExp_Explorer face( shape, TopAbs_FACE ); face.More(); face.Next() )
+  for ( TopExp_Explorer face( mainShape, TopAbs_FACE ); face.More(); face.Next() )
   {
     if ( !faceMap.Add( face.Current() )) continue;
 
   {
     if ( !faceMap.Add( face.Current() )) continue;
 
@@ -278,8 +275,13 @@ bool StdMeshersGUI_PropagationHelperWdg::buildChains()
 
   TColStd_IndexedMapOfInteger chain, chainedEdges;
 
 
   TColStd_IndexedMapOfInteger chain, chainedEdges;
 
+  TColStd_MapOfInteger shapeEdges;
+  if ( !shape.IsSame( mainShape ))
+    for ( QList<TGeomID>::const_iterator ieIt = edgeIDs.begin(); ieIt != edgeIDs.end(); ++ieIt )
+      shapeEdges.Add( *ieIt );
+
   // loop on all EDGEs in mainShape
   // loop on all EDGEs in mainShape
-  for ( QList<TGeomID>::const_iterator ieIt = egdeIDs.begin(); ieIt != egdeIDs.end(); ++ieIt )
+  for ( QList<TGeomID>::const_iterator ieIt = edgeIDs.begin(); ieIt != edgeIDs.end(); ++ieIt )
   {
     if ( chainedEdges.Contains( *ieIt ))
       continue;
   {
     if ( chainedEdges.Contains( *ieIt ))
       continue;
@@ -319,9 +321,16 @@ bool StdMeshersGUI_PropagationHelperWdg::buildChains()
       myChains.push_back( std::vector< TGeomID >() );
       std::vector< TGeomID > & ch = myChains.back();
       for ( int iC = 1; iC <= chain.Extent(); ++iC )
       myChains.push_back( std::vector< TGeomID >() );
       std::vector< TGeomID > & ch = myChains.back();
       for ( int iC = 1; iC <= chain.Extent(); ++iC )
-        ch.push_back( chain( iC ) );
+      {
+        TGeomID iE = chain( iC );
+        if ( shapeEdges.IsEmpty() || shapeEdges.Contains( Abs( iE )))
+          ch.push_back( iE );
+      }
+      if ( ch.size() < 2 )
+        myChains.pop_back();
     }
     }
-  }
+  } // loop on edgeIDs
+
   return !myChains.empty();
 }
 
   return !myChains.empty();
 }
 
@@ -346,11 +355,11 @@ void StdMeshersGUI_PropagationHelperWdg::updateList(bool enable)
       item->setData( Qt::UserRole, -1 );
     }
     else
       item->setData( Qt::UserRole, -1 );
     }
     else
-      for ( size_t i = 0; i < myChains.size(); ++i )
+      for ( int i = 0; i < (int)myChains.size(); ++i )
       {
         QString text = tr( "CHAIN_NUM_NB_EDGES" ).arg( i+1 ).arg( myChains[i].size() );
         item = new QListWidgetItem( text, myListWidget );
       {
         QString text = tr( "CHAIN_NUM_NB_EDGES" ).arg( i+1 ).arg( myChains[i].size() );
         item = new QListWidgetItem( text, myListWidget );
-        item->setData( Qt::UserRole, (int) i );
+        item->setData( Qt::UserRole, i );
       }
   }
   else
       }
   }
   else
@@ -371,7 +380,7 @@ std::vector< int > * StdMeshersGUI_PropagationHelperWdg::getSelectedChain()
   if ( QListWidgetItem * item = myListWidget->currentItem() )
   {
     int i = item->data( Qt::UserRole ).toInt();
   if ( QListWidgetItem * item = myListWidget->currentItem() )
   {
     int i = item->data( Qt::UserRole ).toInt();
-    if ( 0 <= i && i < myChains.size() )
+    if ( 0 <= i && i < (int)myChains.size() )
       chain = & myChains[i];
   }
   return chain;
       chain = & myChains[i];
   }
   return chain;