From 3d0879cd6008311aba524ec147723efec1b134a0 Mon Sep 17 00:00:00 2001 From: dbv Date: Mon, 18 Apr 2016 17:46:09 +0300 Subject: [PATCH] Issue #1369: fix for edges adding to list and to result wire. --- src/BuildPlugin/BuildPlugin_Wire.cpp | 14 +++++--------- src/GeomAlgoAPI/GeomAlgoAPI_WireBuilder.cpp | 11 ++++++++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/BuildPlugin/BuildPlugin_Wire.cpp b/src/BuildPlugin/BuildPlugin_Wire.cpp index a66975f98..5a69e9f49 100644 --- a/src/BuildPlugin/BuildPlugin_Wire.cpp +++ b/src/BuildPlugin/BuildPlugin_Wire.cpp @@ -100,6 +100,7 @@ bool BuildPlugin_Wire::addContour() } // Collect attributes to check. + ListOfShape anAddedEdges; std::list 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::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(aSelection->context()); std::shared_ptr aPlanarEdges = std::dynamic_pointer_cast(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 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; } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_WireBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_WireBuilder.cpp index b6b9dec26..f977184d6 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_WireBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_WireBuilder.cpp @@ -9,21 +9,24 @@ #include #include #include +#include //================================================================================================= std::shared_ptr 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(); 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 GeomAlgoAPI_WireBuilder::wire(const ListOfShape& } } + BRepBuilderAPI_MakeWire aWireBuilder; + aWireBuilder.Add(aListOfEdges); if(aWireBuilder.Error() != BRepBuilderAPI_WireDone) { return GeomShapePtr(); } -- 2.39.2