Skip to content

Commit

Permalink
Filler: skip NaN points from end of segment (#9287)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Jun 18, 2021
1 parent 8f98515 commit fb863f3
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/plugins/plugin.filler.js
Expand Up @@ -172,13 +172,24 @@ function computeBoundary(source) {
return computeLinearBoundary(source);
}

function findSegmentEnd(start, end, points) {
for (;end > start; end--) {
const point = points[end];
if (!isNaN(point.x) && !isNaN(point.y)) {
break;
}
}
return end;
}

function pointsFromSegments(boundary, line) {
const {x = null, y = null} = boundary || {};
const linePoints = line.points;
const points = [];
line.segments.forEach((segment) => {
const first = linePoints[segment.start];
const last = linePoints[segment.end];
line.segments.forEach(({start, end}) => {
end = findSegmentEnd(start, end, linePoints);
const first = linePoints[start];
const last = linePoints[end];
if (y !== null) {
points.push({x: first.x, y});
points.push({x: last.x, y});
Expand Down Expand Up @@ -406,16 +417,19 @@ function _segments(line, target, property) {
const parts = [];

for (const segment of segments) {
const bounds = getBounds(property, points[segment.start], points[segment.end], segment.loop);
let {start, end} = segment;
end = findSegmentEnd(start, end, points);

const bounds = getBounds(property, points[start], points[end], segment.loop);

if (!target.segments) {
// Special case for boundary not supporting `segments` (simpleArc)
// Bounds are provided as `target` for partial circle, or undefined for full circle
parts.push({
source: segment,
target: bounds,
start: points[segment.start],
end: points[segment.end]
start: points[start],
end: points[end]
});
continue;
}
Expand Down

0 comments on commit fb863f3

Please sign in to comment.