From fc7c34ca41df2ebb2827ff93df32ce69164df936 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Fri, 26 Jan 2018 08:20:52 +0800 Subject: [PATCH] Path.Area: make wire explode respect arc accurarcy --- src/Mod/Path/App/Area.cpp | 49 +++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index 1625319223..b9af96280f 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -337,28 +337,37 @@ void Area::addWire(CArea &area, const TopoDS_Wire& wire, } break; } case GeomAbs_Circle:{ - if(!to_edges) { - double first = curve.FirstParameter(); - double last = curve.LastParameter(); - gp_Circ circle = curve.Circle(); - gp_Dir dir = circle.Axis().Direction(); - gp_Pnt center = circle.Location(); - int type = dir.Z()<0?-1:1; - if(reversed) type = -type; - if(fabs(first-last)>M_PI) { - // Split arc(circle) larger than half circle. Because gcode - // can't handle full circle? - gp_Pnt mid = curve.Value((last-first)*0.5+first); - ccurve.append(CVertex(type,Point(mid.X(),mid.Y()), - Point(center.X(),center.Y()))); - } - ccurve.append(CVertex(type,Point(p.X(),p.Y()), + double first = curve.FirstParameter(); + double last = curve.LastParameter(); + gp_Circ circle = curve.Circle(); + gp_Dir dir = circle.Axis().Direction(); + gp_Pnt center = circle.Location(); + int type = dir.Z()<0?-1:1; + if(reversed) type = -type; + if(fabs(first-last)>M_PI) { + // Split arc(circle) larger than half circle. Because gcode + // can't handle full circle? + gp_Pnt mid = curve.Value((last-first)*0.5+first); + ccurve.append(CVertex(type,Point(mid.X(),mid.Y()), Point(center.X(),center.Y()))); - break; } - } - /* FALLTHRU */ - default: { + ccurve.append(CVertex(type,Point(p.X(),p.Y()), + Point(center.X(),center.Y()))); + if(to_edges) { + ccurve.UnFitArcs(); + CCurve c; + c.append(ccurve.m_vertices.front()); + auto it = ccurve.m_vertices.begin(); + for(++it;it!=ccurve.m_vertices.end();++it) { + c.append(*it); + area.append(c); + c.m_vertices.pop_front(); + } + ccurve.m_vertices.clear(); + ccurve.append(c.m_vertices.front()); + } + break; + } default: { // Discretize all other type of curves GCPnts_QuasiUniformDeflection discretizer(curve, deflection, curve.FirstParameter(), curve.LastParameter());