Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filler: skip NaN points from end of segment #9287

Merged
merged 1 commit into from Jun 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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