Page 1 of 1

No poly offset ortho at endings

Posted: Thu Sep 26, 2019 6:27 am
by CVH
Continuing from:
https://www.ribbonsoft.com/rsforum/viewtopic.php?t=6590
And all that were posted before.

I have issues with poly offsets since.... since ever.
I wondered that I might be the sole user that has these problems.
Probably, 123 views and non even tried.

With the little knowledge of scripting I first tried to follow the coding.
You may find my endeavour in: Bad poly offset.txt
The investigated path should return a correct distance!!

Then I tried to catch it in the act.
That was a little harder because core functions are involved.
But then a breakthrough.

As pro user the getDistance function is not handled by:
OffsetThrough.prototype.getDistance(...)
Instead it is handled by:
OffsetThroughPro.prototype.getDistance(...)

And for what my opinion is worth:
line 85-92 exclude any endings of line segments. :shock:
Furthermore, beside limiting inner segments,
line 83 will limit the outer ones too.

Code: Select all

77    OffsetThroughPro.prototype.getDistance = function(pos, shape) {
78        if (isPolylineShape(shape)) {
79            //return shape.getDistanceTo(pos, true);
80            var minDist = undefined;
81            for (var i=0; i<shape.countSegments(); i++) {
82                var seg = shape.getSegmentAt(i);
83                var d = seg.getDistanceTo(pos, true);
84                var p = seg.getClosestPointOnShape(pos, true);
85                if (isLineShape(seg)) {
86                    if (p.equalsFuzzy(seg.getEndPoint())) {
87                        continue;
88                    }
89                    if (p.equalsFuzzy(seg.getStartPoint())) {
90                        continue;
91                    }
92                }
93                if (isNumber(d) && (isNull(minDist) || d<minDist)) {
94                    minDist = d;
95                }
96            }
97            return minDist;
98        }
99        else {
100            return shape.getDistanceTo(pos, false);
101        }
102    };

Non-paying, non-pro user will get a proper offset.
:cry:

Regards,
CVH

Re: No poly offset ortho at endings

Posted: Mon Sep 30, 2019 9:42 am
by andrew
Thanks for your report.

Bug report at:
https://www.qcad.org/bugtracker/index.p ... sk_id=1948