diff --git a/src/Mod/TechDraw/App/DrawProjectSplit.cpp b/src/Mod/TechDraw/App/DrawProjectSplit.cpp index 695f8c3c0c..2a6eb78c47 100644 --- a/src/Mod/TechDraw/App/DrawProjectSplit.cpp +++ b/src/Mod/TechDraw/App/DrawProjectSplit.cpp @@ -486,7 +486,7 @@ std::string edgeSortItem::dump() std::vector DrawProjectSplit::scrubEdges(const std::vector& origEdges, std::vector &closedEdges) { -// Base::Console().Message("DPS::scrubEdges() - edges in: %d\n", origEdges.size()); +// Base::Console().Message("DPS::scrubEdges() - BaseGeom in: %d\n", origEdges.size()); //make a copy of the input edges so the loose tolerances of face finding are //not applied to the real edge geometry. See TopoDS_Shape::TShape(). std::vector copyEdges; @@ -505,6 +505,8 @@ std::vector DrawProjectSplit::scrubEdges(const std::vector DrawProjectSplit::scrubEdges(std::vector& origEdges, std::vector &closedEdges) { +// Base::Console().Message("DPS::scrubEdges() - TopoDS_Edges in: %d\n", origEdges.size()); + if (origEdges.empty()) { //how did this happen? if Scale is zero, all the edges will be zero length, //but Scale property has constraint, so this shouldn't happen! @@ -605,7 +607,7 @@ std::vector DrawProjectSplit::pruneUnconnected(vertexMap verts, return newPile; } -bool DrawProjectSplit::sameEndPoints(TopoDS_Edge& e1, TopoDS_Edge& e2) +bool DrawProjectSplit::sameEndPoints(const TopoDS_Edge &e1, const TopoDS_Edge &e2) { TopoDS_Vertex first1 = TopExp::FirstVertex(e1); TopoDS_Vertex last1 = TopExp::LastVertex(e1); @@ -630,7 +632,7 @@ bool DrawProjectSplit::sameEndPoints(TopoDS_Edge& e1, TopoDS_Edge& e2) #define NOTASUBSET 3 //eliminate edges that overlap another edge -std::vector DrawProjectSplit::removeOverlapEdges(std::vector inEdges) +std::vector DrawProjectSplit::removeOverlapEdges(const std::vector &inEdges) { // Base::Console().Message("DPS::removeOverlapEdges() - %d edges in\n", inEdges.size()); std::vector outEdges; @@ -676,11 +678,14 @@ std::vector DrawProjectSplit::removeOverlapEdges(std::vector DrawProjectSplit::fuseEdges(TopoDS_Edge &edge0, TopoDS_Edge &edge1) +std::vector DrawProjectSplit::fuseEdges(const TopoDS_Edge &edge0, const TopoDS_Edge &edge1) { std::vector edgeList; BRepAlgoAPI_Fuse anOp; @@ -864,7 +869,7 @@ std::vector DrawProjectSplit::splitIntersectingEdges(std::vector inEdges); static std::vector pruneUnconnected(vertexMap verts, std::vector edges); - static std::vector removeOverlapEdges(std::vector inEdges); + static std::vector removeOverlapEdges(const std::vector& inEdges); static std::vector splitIntersectingEdges(std::vector& inEdges); - static bool sameEndPoints(TopoDS_Edge& e1, - TopoDS_Edge& e2); - static int isSubset(TopoDS_Edge &e0, - TopoDS_Edge &e1); - static std::vector fuseEdges(TopoDS_Edge& e0, - TopoDS_Edge& e1); - static bool boxesIntersect(TopoDS_Edge& e0, - TopoDS_Edge& e1); + static bool sameEndPoints(const TopoDS_Edge& e1, + const TopoDS_Edge& e2); + static int isSubset(const TopoDS_Edge &e0, + const TopoDS_Edge &e1); + static std::vector fuseEdges(const TopoDS_Edge& e0, + const TopoDS_Edge& e1); + static bool boxesIntersect(const TopoDS_Edge& e0, + const TopoDS_Edge& e1); static void dumpVertexMap(vertexMap verts); protected: diff --git a/src/Mod/TechDraw/App/DrawUtil.cpp b/src/Mod/TechDraw/App/DrawUtil.cpp index a9fc54a36a..9f6c8251f5 100644 --- a/src/Mod/TechDraw/App/DrawUtil.cpp +++ b/src/Mod/TechDraw/App/DrawUtil.cpp @@ -536,7 +536,7 @@ bool DrawUtil::vectorEqual(Base::Vector3d& v1, Base::Vector3d& v2) //TODO: the next 2 could be templated //construct a compound shape from a list of edges -TopoDS_Shape DrawUtil::vectorToCompound(std::vector vecIn) +TopoDS_Shape DrawUtil::vectorToCompound(std::vector vecIn, bool invert) { BRep_Builder builder; TopoDS_Compound compOut; @@ -544,11 +544,14 @@ TopoDS_Shape DrawUtil::vectorToCompound(std::vector vecIn) for (auto& v : vecIn) { builder.Add(compOut, v); } - return TechDraw::mirrorShape(compOut); + if (invert) { + return TechDraw::mirrorShape(compOut); + } + return compOut; } //construct a compound shape from a list of wires -TopoDS_Shape DrawUtil::vectorToCompound(std::vector vecIn) +TopoDS_Shape DrawUtil::vectorToCompound(std::vector vecIn, bool invert) { BRep_Builder builder; TopoDS_Compound compOut; @@ -556,7 +559,10 @@ TopoDS_Shape DrawUtil::vectorToCompound(std::vector vecIn) for (auto& v : vecIn) { builder.Add(compOut, v); } - return TechDraw::mirrorShape(compOut); + if (invert) { + return TechDraw::mirrorShape(compOut); + } + return compOut; } //constructs a list of edges from a shape diff --git a/src/Mod/TechDraw/App/DrawUtil.h b/src/Mod/TechDraw/App/DrawUtil.h index d10cf10b0c..63ad755b05 100644 --- a/src/Mod/TechDraw/App/DrawUtil.h +++ b/src/Mod/TechDraw/App/DrawUtil.h @@ -128,8 +128,8 @@ public: static bool vertexEqual(TopoDS_Vertex& v1, TopoDS_Vertex& v2); static bool vectorEqual(Base::Vector3d& v1, Base::Vector3d& v2); - static TopoDS_Shape vectorToCompound(std::vector vecIn); - static TopoDS_Shape vectorToCompound(std::vector vecIn); + static TopoDS_Shape vectorToCompound(std::vector vecIn, bool invert = true); + static TopoDS_Shape vectorToCompound(std::vector vecIn, bool invert = true); static std::vector shapeToVector(TopoDS_Shape shapeIn); static Base::Vector3d toR3(const gp_Ax2& fromSystem, const Base::Vector3d& fromPoint); diff --git a/src/Mod/TechDraw/App/GeometryObject.cpp b/src/Mod/TechDraw/App/GeometryObject.cpp index 4465bd0e7c..23f6ebecf6 100644 --- a/src/Mod/TechDraw/App/GeometryObject.cpp +++ b/src/Mod/TechDraw/App/GeometryObject.cpp @@ -545,7 +545,9 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca for (int iPass = 0; iPass < passes; iPass++) { edgeVector = DrawProjectSplit::removeOverlapEdges(edgeVector); } - cleanShape = DU::vectorToCompound(edgeVector); + bool invertResult = false; + cleanShape = DU::vectorToCompound(edgeVector, invertResult); + } else { cleanShape = edgeCompound; }