]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1369: fix for edges adding to list and to result wire.
authordbv <dbv@opencascade.com>
Mon, 18 Apr 2016 14:46:09 +0000 (17:46 +0300)
committerdbv <dbv@opencascade.com>
Mon, 18 Apr 2016 14:46:09 +0000 (17:46 +0300)
src/BuildPlugin/BuildPlugin_Wire.cpp
src/GeomAlgoAPI/GeomAlgoAPI_WireBuilder.cpp

index a66975f9871eb30b67ec2151ea6c3f15dd97fba0..5a69e9f490430dabbc0d469dada2e43d94802340 100644 (file)
@@ -100,6 +100,7 @@ bool BuildPlugin_Wire::addContour()
   }
 
   // Collect attributes to check.
+  ListOfShape anAddedEdges;
   std::list<AttributeSelectionPtr> anAttributesToCheck;
   for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
     AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
@@ -130,12 +131,12 @@ bool BuildPlugin_Wire::addContour()
       continue;
     }
 
+    anAddedEdges.push_back(anEdgeInList);
     anAttributesToCheck.push_back(aSelection);
   }
 
   // Check if edges have contours.
-  ListOfShape anAddedEdges;
-  bool isAnyContourFound = false;
+  bool isAnyContourAdded = false;
   for(std::list<AttributeSelectionPtr>::const_iterator aListIt = anAttributesToCheck.cbegin();
       aListIt != anAttributesToCheck.cend();
       ++aListIt) {
@@ -148,10 +149,6 @@ bool BuildPlugin_Wire::addContour()
         break;
       }
     }
-    if(anEdgesIt != anAddedEdges.cend()) {
-      // This edge is already in list.
-      continue;
-    }
 
     ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSelection->context());
     std::shared_ptr<GeomAPI_PlanarEdges> aPlanarEdges = std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aConstruction->shape());
@@ -175,8 +172,6 @@ bool BuildPlugin_Wire::addContour()
 
     // If face with the same edge found. Add all other edges to list.
     if(aFoundFace.get()) {
-      isAnyContourFound = true;
-      anAddedEdges.push_back(anEdgeInList);
       for(GeomAPI_ShapeExplorer anExp(aFoundFace, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) {
         std::shared_ptr<GeomAPI_Edge> anEdgeOnFace(new GeomAPI_Edge(anExp.current()));
         anEdgesIt = anAddedEdges.cbegin();
@@ -186,6 +181,7 @@ bool BuildPlugin_Wire::addContour()
           }
         }
         if(anEdgesIt == anAddedEdges.cend()) {
+          isAnyContourAdded = true;
           anAddedEdges.push_back(anEdgeOnFace);
           aSelectionList->append(aConstruction, anEdgeOnFace);
         }
@@ -193,7 +189,7 @@ bool BuildPlugin_Wire::addContour()
     }
   }
 
-  if(!isAnyContourFound) {
+  if(!isAnyContourAdded) {
     Events_Error::send("Error: Contours already closed or no contours found for selected edges.");
     return false;
   }
index b6b9dec26fcb4e8b66694c35d84a535956e94fe5..f977184d6873e31c61bf6f8d65d9848d756beffe 100644 (file)
@@ -9,21 +9,24 @@
 #include <BRepBuilderAPI_MakeWire.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Wire.hxx>
+#include <TopExp_Explorer.hxx>
 
 //=================================================================================================
 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_WireBuilder::wire(const ListOfShape& theShapes)
 {
-  BRepBuilderAPI_MakeWire aWireBuilder;
+  TopTools_ListOfShape aListOfEdges;
 
   for(ListOfShape::const_iterator anIt = theShapes.cbegin(); anIt != theShapes.cend(); ++anIt) {
     const TopoDS_Shape& aShape = (*anIt)->impl<TopoDS_Shape>();
     switch(aShape.ShapeType()) {
       case TopAbs_EDGE: {
-        aWireBuilder.Add(TopoDS::Edge(aShape));
+        aListOfEdges.Append(aShape);
         break;
       }
       case TopAbs_WIRE: {
-        aWireBuilder.Add(TopoDS::Wire(aShape));
+        for(TopExp_Explorer anExp(aShape, TopAbs_EDGE); anExp.More(); anExp.Next()) {
+          aListOfEdges.Append(anExp.Current());
+        }
         break;
       }
       default: {
@@ -32,6 +35,8 @@ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_WireBuilder::wire(const ListOfShape&
     }
   }
 
+  BRepBuilderAPI_MakeWire aWireBuilder;
+  aWireBuilder.Add(aListOfEdges);
   if(aWireBuilder.Error() != BRepBuilderAPI_WireDone) {
     return GeomShapePtr();
   }