From 4ceb984f738107c7ca9604849fa2a91335c2ccea Mon Sep 17 00:00:00 2001 From: David Kaufman Date: Mon, 8 Jan 2024 19:44:22 -0500 Subject: [PATCH] cleanup --- src/Mod/Path/App/Area.cpp | 67 ---------------------------- src/Mod/Path/App/AreaPyImp.cpp | 2 +- src/Mod/Path/Path/Op/Area.py | 9 +--- src/Mod/Path/libarea/AreaClipper.cpp | 10 ++--- 4 files changed, 7 insertions(+), 81 deletions(-) diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index 5b13bd75cc..39fbc884af 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -508,7 +508,6 @@ private: void point(const Base::Vector3d &p) { - printf("Point? (%.0f, %.0f, %.0f) ", p.x, p.y, p.z); if (p.z <= maxZ) { if (bbox.MinX <= p.x && p.x <= bbox.MaxX && bbox.MinY <= p.y && p.y <= bbox.MaxY) { CCurve curve; @@ -516,10 +515,8 @@ private: curve.append(CVertex{1, {p.x - radius, p.y}, {p.x, p.y}}); curve.append(CVertex{1, {p.x + radius, p.y}, {p.x, p.y}}); holes.append(curve); - printf("accepted"); } } - printf("\n"); } void line(const Base::Vector3d &last, const Base::Vector3d &next) @@ -554,42 +551,20 @@ public: { (void)id; (void)pts; - // printf("g0 [ "); - //processPt(last); - // printf("] "); - //processPts(pts); - // printf("_ "); - //processPt(next); - line(last, next); - // printf("\n"); } void g1(int id, const Base::Vector3d &last, const Base::Vector3d &next, const std::deque &pts) override { (void)id; (void)pts; - // printf("g1 [ "); - //processPt(last); - // printf("] "); - //processPts(pts); - // printf("_ "); - //processPt(next); - line(last, next); - // printf("\n"); } void g23(int id, const Base::Vector3d &last, const Base::Vector3d &next, const std::deque &pts, const Base::Vector3d ¢er) override { (void)id; (void)center; - // printf("g23 [ "); - // processPt(last); - // printf("] "); - // processPts(pts); - // printf("_ "); - // processPt(next); // Compute cw vs ccw const Base::Vector3d vdirect = next - last; @@ -601,13 +576,6 @@ public: curve.append(CVertex{{last.x, last.y}}); curve.append(CVertex{ccw ? 1 : -1, {next.x, next.y}, {center.x, center.y}}); pathSegments.append(curve); - // Base::Vector3d prev = last; - // for (Base::Vector3d p : pts) { - // line(prev, p); - // prev = p; - // } - // line(prev, next); - // printf("\n"); } void g8x(int id, const Base::Vector3d &last, const Base::Vector3d &next, const std::deque &pts, @@ -633,17 +601,6 @@ public: (void)last; (void)next; } - -private: - void processPts(const std::deque &pts) { - for (std::deque::const_iterator it=pts.begin(); pts.end() != it; ++it) { - processPt(*it); - } - } - - void processPt(const Base::Vector3d &pt) { - printf("(%7.3f, %7.3f, %7.3f) ", pt.x, pt.y, pt.z); - } }; std::shared_ptr Area::getClearedArea(const Toolpath *path, double diameter, double zmax, Base::BoundBox3d bbox) { @@ -665,30 +622,13 @@ std::shared_ptr Area::getClearedArea(const Toolpath *path, double diameter // those arcs will be converted back to segments again for clipper differencing in getRestArea anyway CAreaConfig conf(params, /*no_fit_arcs*/ true); - Base::Vector3d pos = Base::Vector3d(0, 0, zmax + 1); - printf("getClearedArea(path, diameter=%g, zmax=%g:\n", diameter, zmax); - // printf("Gcode:\n"); - for (auto c : path->getCommands()) { - // printf("\t%s ", c->Name.c_str()); - for (std::map::iterator i = c->Parameters.begin(); i != c->Parameters.end(); ++i) { - // printf("%s%g ", i->first.c_str(), i->second); - } - // printf("\n"); - } - - printf("\n"); - printf("GCode walker:\n"); ClearedAreaSegmentVisitor visitor(zmax, diameter/2 + buffer, bbox); PathSegmentWalker walker(*path); walker.walk(visitor, Base::Vector3d(0, 0, zmax + 1)); - printf("\n"); - printf("\n"); - std::shared_ptr clearedArea = make_shared(¶ms); clearedArea->myTrsf = {}; const CArea ca = visitor.getClearedArea(); - printf("Cleared area segments: %ld\n", ca.m_curves.size()); if (ca.m_curves.size() > 0) { TopoDS_Shape clearedAreaShape = Area::toShape(ca, false); clearedArea->add(clearedAreaShape, OperationCompound); @@ -721,8 +661,6 @@ std::shared_ptr Area::getRestArea(std::vector> clear // transform all clearedAreas into our workplane Area clearedAreasInPlane(¶ms); clearedAreasInPlane.myArea.reset(new CArea()); - printf("getRestArea\n"); - printf("\n"); for (std::shared_ptr clearedArea : clearedAreas) { gp_Trsf trsf = clearedArea->myTrsf; trsf.Invert(); @@ -733,24 +671,20 @@ std::shared_ptr Area::getRestArea(std::vector> clear } // clearable = offset(offset(A, -dTool/2), dTool/2) - printf("Compute clearable\n"); CArea clearable(*myArea); clearable.OffsetWithClipper(-diameter/2, JoinType, EndType, params.MiterLimit, roundPrecision); clearable.OffsetWithClipper(diameter/2, JoinType, EndType, params.MiterLimit, roundPrecision); // remaining = clearable - prevCleared - printf("Compute remaining\n"); CArea remaining(clearable); remaining.Clip(toClipperOp(Area::OperationDifference), &*(clearedAreasInPlane.myArea), SubjectFill, ClipFill); // rest = intersect(clearable, offset(remaining, dTool)) // add buffer to dTool to compensate for oversizing in getClearedArea - printf("Compute rest\n"); CArea restCArea(remaining); restCArea.OffsetWithClipper(diameter + buffer, JoinType, EndType, params.MiterLimit, roundPrecision); restCArea.Clip(toClipperOp(Area::OperationIntersection), &clearable, SubjectFill, ClipFill); - printf("Convert CArea to Area (num curves: %d)\n", (int)restCArea.m_curves.size()); if(restCArea.m_curves.size() == 0) { return {}; } @@ -760,7 +694,6 @@ std::shared_ptr Area::getRestArea(std::vector> clear TopoDS_Shape restShape = Area::toShape(restCArea, false, &trsf); restArea->add(restShape, OperationCompound); - printf("return\n"); return restArea; } diff --git a/src/Mod/Path/App/AreaPyImp.cpp b/src/Mod/Path/App/AreaPyImp.cpp index bbe4182c23..bbfb1b5088 100644 --- a/src/Mod/Path/App/AreaPyImp.cpp +++ b/src/Mod/Path/App/AreaPyImp.cpp @@ -152,7 +152,7 @@ static const PyMethodDef areaOverrides[] = { { "getClearedArea",nullptr,0, "getClearedArea(path, diameter, zmax, bbox):\n" - "Gets the area cleared when a tool of the specified diameter follows the gcode represented in the path, ignoring cleared space above zmax and path segments that don't affect space within bbox.\n", + "Gets the area cleared when a tool of the specified diameter follows the gcode represented in the path, ignoring cleared space above zmax and path segments that don't affect space within the x/y space of bbox.\n", }, { "getRestArea",nullptr,0, diff --git a/src/Mod/Path/Path/Op/Area.py b/src/Mod/Path/Path/Op/Area.py index 5ec88b640f..fd831341b2 100644 --- a/src/Mod/Path/Path/Op/Area.py +++ b/src/Mod/Path/Path/Op/Area.py @@ -246,20 +246,13 @@ class ObjectOp(PathOp.ObjectOp): z = bbox.ZMin sectionClearedAreas = [] for op in self.job.Operations.Group: - print(op.Name) if self in [x.Proxy for x in [op] + op.OutListRecursive if hasattr(x, "Proxy")]: - print("found self") break if hasattr(op, "Active") and op.Active and op.Path: tool = op.Proxy.tool if hasattr(op.Proxy, "tool") else op.ToolController.Proxy.getTool(op.ToolController) diameter = tool.Diameter.getValueAs("mm") - dz = 0 if not hasattr(tool, "TipAngle") else -PathUtils.drillTipLength(tool) # for drills, dz moves to the full width part of the tool + dz = 0 if not hasattr(tool, "TipAngle") else -PathUtils.drillTipLength(tool) # for drills, dz translates to the full width part of the tool sectionClearedAreas.append(section.getClearedArea(op.Path, diameter, z+dz+0.001, bbox)) - # debugZ = -1.5 - # if debugZ -.1 < z and z < debugZ + .1: - # debugObj = obj.Document.addObject("Part::Feature", "Debug_{}_{}".format(debugZ, op.Name)) - # debugObj.Label = "Debug_{}_{}".format(debugZ, op.Label) - # debugObj.Shape = sectionClearedAreas[-1].getShape() restSection = section.getRestArea(sectionClearedAreas, self.tool.Diameter.getValueAs("mm")) if (restSection is not None): restSections.append(restSection) diff --git a/src/Mod/Path/libarea/AreaClipper.cpp b/src/Mod/Path/libarea/AreaClipper.cpp index 48f3dc93af..1ee608bbba 100644 --- a/src/Mod/Path/libarea/AreaClipper.cpp +++ b/src/Mod/Path/libarea/AreaClipper.cpp @@ -252,14 +252,14 @@ static void MakeObround(const Point &pt0, const CVertex &vt1, double radius) static void OffsetSpansWithObrounds(const CArea& area, TPolyPolygon &pp_new, double radius) { Clipper c; - c.StrictlySimple(CArea::m_clipper_simple); + c.StrictlySimple(CArea::m_clipper_simple); pp_new.clear(); for(std::list::const_iterator It = area.m_curves.begin(); It != area.m_curves.end(); It++) { - c.Clear(); - c.AddPaths(pp_new, ptSubject, true); - pp_new.clear(); + c.Clear(); + c.AddPaths(pp_new, ptSubject, true); + pp_new.clear(); pts_for_AddVertex.clear(); const CCurve& curve = *It; @@ -282,7 +282,7 @@ static void OffsetSpansWithObrounds(const CArea& area, TPolyPolygon &pp_new, dou } prev_vertex = &vertex; } - c.Execute(ctUnion, pp_new, pftNonZero, pftNonZero); + c.Execute(ctUnion, pp_new, pftNonZero, pftNonZero); }