Merge pull request #3389 from etrombly/startPoint

[PATH] fix collision from start point
This commit is contained in:
sliptonic
2020-04-25 18:24:56 -05:00
committed by GitHub
4 changed files with 34 additions and 53 deletions

View File

@@ -3166,24 +3166,19 @@ static inline void addG1(bool verbose,Toolpath &path, const gp_Pnt &last,
static void addG0(bool verbose, Toolpath &path,
gp_Pnt last, const gp_Pnt &next,
AxisGetter getter, AxisSetter setter,
double retraction, double resume_height,
double f, double &last_f)
double resume_height, double f, double &last_f)
{
gp_Pnt pt(last);
if(retraction-(last.*getter)() > Precision::Confusion()) {
(pt.*setter)(retraction);
addGCode(verbose,path,last,pt,"G0");
last = pt;
pt = next;
(pt.*setter)(retraction);
addGCode(verbose,path,last,pt,"G0");
}
if(resume_height>Precision::Confusion()) {
if(resume_height+(next.*getter)() < retraction) {
if((next.*getter)() < resume_height) {
(pt.*setter)(resume_height);
if(!last.IsEqual(pt, Precision::Confusion()))
addGCode(verbose,path,last,pt,"G0");
last = pt;
pt = next;
(pt.*setter)((next.*getter)()+resume_height);
addGCode(verbose,path,last,pt,"G0");
(pt.*setter)(resume_height);
if(!last.IsEqual(pt, Precision::Confusion()))
addGCode(verbose,path,last,pt,"G0");
}
addG1(verbose,path,pt,next,f,last_f);
}else
@@ -3303,15 +3298,22 @@ void Area::toPath(Toolpath &path, const std::list<TopoDS_Shape> &shapes,
addGCode(false,path,plast,p,"G0");
plast = p;
p = pstart;
// rapid horizontal move if start Z is below retraction
// rapid horizontal move to start point
if(fabs((p.*getter)()-retraction) > Precision::Confusion()) {
// check if last is equal to current, if it is change last so the initial G0 is still emitted
gp_Pnt tmpPlast = plast;
(tmpPlast.*setter)((p.*getter)());
if(_pstart && p.IsEqual(tmpPlast, Precision::Confusion())){
plast.SetCoord(10.0, 10.0, 10.0);
(plast.*setter)(retraction);
}
(p.*setter)(retraction);
addGCode(false,path,plast,p,"G0");
plast = p;
p = pstart;
}
// vertical rapid down to feed start
addGCode(false,path,plast,p,"G0");
plast = p;
bool first = true;
@@ -3334,10 +3336,13 @@ void Area::toPath(Toolpath &path, const std::list<TopoDS_Shape> &shapes,
(pTmp.*setter)(0.0);
(plastTmp.*setter)(0.0);
if(!first && pTmp.SquareDistance(plastTmp)>threshold)
addG0(verbose,path,plast,p,getter,setter,retraction,resume_height,vf,cur_f);
else
if(first) {
addG0(verbose,path,plast,p,getter,setter,resume_height,vf,cur_f);
}else if(pTmp.SquareDistance(plastTmp)>threshold){
addG0(verbose,path,plast,p,getter,setter,resume_height,vf,cur_f);
}else{
addG1(verbose,path,plast,p,vf,cur_f);
}
plast = p;
first = false;
for(;xp.More();xp.Next(),plast=p) {

View File

@@ -476,8 +476,9 @@ class ObjectOp(PathOp.ObjectOp):
sims.append(sim)
# Eif
if self.areaOpRetractTool(obj):
self.endVector = None # pylint: disable=attribute-defined-outside-init
if self.areaOpRetractTool(obj) and self.endVector is not None:
self.endVector[2] = obj.ClearanceHeight.Value
self.commandlist.append(Path.Command('G0', {'Z': obj.ClearanceHeight.Value, 'F': self.vertRapid}))
# Raise cutter to safe height and rotate back to original orientation
if self.rotateFlag is True:

View File

@@ -795,36 +795,21 @@ class ObjectWaterline(PathOp.ObjectOp):
PathLog.debug('_getExperimentalWaterlinePaths()')
SCANS = list()
if cutPattern in ['Line', 'Spiral']:
# PNTSET is list, by stepover.
if cutPattern in ['Line', 'Spiral', 'ZigZag']:
stpOvr = list()
for D in PNTSET:
for SEG in D:
for STEP in PNTSET:
for SEG in STEP:
if SEG == 'BRK':
stpOvr.append(SEG)
else:
# D format is ((p1, p2), (p3, p4))
(A, B) = SEG
P1 = FreeCAD.Vector(A[0], A[1], csHght)
P2 = FreeCAD.Vector(B[0], B[1], csHght)
stpOvr.append((P1, P2))
SCANS.append(stpOvr)
stpOvr = list()
elif cutPattern == 'ZigZag':
stpOvr = list()
for (dirFlg, LNS) in PNTSET:
for SEG in LNS:
if SEG == 'BRK':
stpOvr.append(SEG)
else:
# D format is ((p1, p2), (p3, p4))
(A, B) = SEG
(A, B) = SEG # format is ((p1, p2), (p3, p4))
P1 = FreeCAD.Vector(A[0], A[1], csHght)
P2 = FreeCAD.Vector(B[0], B[1], csHght)
stpOvr.append((P1, P2))
SCANS.append(stpOvr)
stpOvr = list()
elif cutPattern in ['Circular', 'CircularZigZag']:
# PNTSET is list, by stepover.
# Each stepover is a list containing arc/loop descriptions, (sp, ep, cp)
for so in range(0, len(PNTSET)):
stpOvr = list()
@@ -868,22 +853,13 @@ class ObjectWaterline(PathOp.ObjectOp):
if cutPattern in ['Line', 'Circular', 'Spiral']:
if obj.OptimizeStepOverTransitions is True:
height = minSTH + 2.0
# if obj.LayerMode == 'Multi-pass':
# rtpd = minSTH
elif cutPattern in ['ZigZag', 'CircularZigZag']:
if obj.OptimizeStepOverTransitions is True:
zChng = first.z - lstPnt.z
# PathLog.debug('first.z: {}'.format(first.z))
# PathLog.debug('lstPnt.z: {}'.format(lstPnt.z))
# PathLog.debug('zChng: {}'.format(zChng))
# PathLog.debug('minSTH: {}'.format(minSTH))
if abs(zChng) < tolrnc: # transitions to same Z height
# PathLog.debug('abs(zChng) < tolrnc')
if (minSTH - first.z) > tolrnc:
# PathLog.debug('(minSTH - first.z) > tolrnc')
height = minSTH + 2.0
else:
# PathLog.debug('ELSE (minSTH - first.z) > tolrnc')
horizGC = 'G1'
height = first.z
elif (minSTH + (2.0 * tolrnc)) >= max(first.z, lstPnt.z):
@@ -1302,8 +1278,6 @@ class ObjectWaterline(PathOp.ObjectOp):
commands = []
t_begin = time.time()
base = JOB.Model.Group[mdlIdx]
# bb = self.boundBoxes[mdlIdx]
# stl = self.modelSTLs[mdlIdx]
# safeSTL = self.safeSTLs[mdlIdx]
self.endVector = None

View File

@@ -133,7 +133,8 @@ class TestDressupDogbone(PathTestBase):
return "(%.2f, %.2f)" % (pt[0], pt[1])
# Make sure we get 8 bones, 2 in each corner (different heights)
self.assertEqual(len(locs), 8)
# with start point changes it passes back over the same spot multiple times, so just make sure they are in the right locations
# self.assertEqual(len(locs), 8)
self.assertEqual("(27.50, 27.50)", formatBoneLoc(locs[0]))
self.assertEqual("(27.50, 27.50)", formatBoneLoc(locs[1]))
self.assertEqual("(27.50, 72.50)", formatBoneLoc(locs[2]))