cleanup
This commit is contained in:
@@ -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<Base::Vector3d> &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<Base::Vector3d> &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<Base::Vector3d> &pts,
|
||||
@@ -633,17 +601,6 @@ public:
|
||||
(void)last;
|
||||
(void)next;
|
||||
}
|
||||
|
||||
private:
|
||||
void processPts(const std::deque<Base::Vector3d> &pts) {
|
||||
for (std::deque<Base::Vector3d>::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> Area::getClearedArea(const Toolpath *path, double diameter, double zmax, Base::BoundBox3d bbox) {
|
||||
@@ -665,30 +622,13 @@ std::shared_ptr<Area> 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<std::string, double>::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<Area> clearedArea = make_shared<Area>(¶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> Area::getRestArea(std::vector<std::shared_ptr<Area>> clear
|
||||
// transform all clearedAreas into our workplane
|
||||
Area clearedAreasInPlane(¶ms);
|
||||
clearedAreasInPlane.myArea.reset(new CArea());
|
||||
printf("getRestArea\n");
|
||||
printf("\n");
|
||||
for (std::shared_ptr<Area> clearedArea : clearedAreas) {
|
||||
gp_Trsf trsf = clearedArea->myTrsf;
|
||||
trsf.Invert();
|
||||
@@ -733,24 +671,20 @@ std::shared_ptr<Area> Area::getRestArea(std::vector<std::shared_ptr<Area>> 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> Area::getRestArea(std::vector<std::shared_ptr<Area>> clear
|
||||
TopoDS_Shape restShape = Area::toShape(restCArea, false, &trsf);
|
||||
restArea->add(restShape, OperationCompound);
|
||||
|
||||
printf("return\n");
|
||||
return restArea;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<CCurve>::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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user