|
245 | 245 | /** |
246 | 246 | * @private |
247 | 247 | */ |
248 | | - function getActualBezierRange(curve: BezierCurve, arc: IPathArcInBezierCurve, endpoints: IPoint[], offset: IPoint): IBezierRange { |
| 248 | + function getActualBezierRange(curve: BezierCurve, arc: IPathArcInBezierCurve, endpoints: IPoint[], offset: IPoint, pointMatchingDistance: number): IBezierRange { |
249 | 249 | var b = getScratch(curve.seed); |
250 | 250 | var tPoints = [arc.bezierData.startT, arc.bezierData.endT].map(t => new TPoint(b, t, offset)); |
251 | 251 | var ends = endpoints.slice(); |
|
255 | 255 | if (endpointDistancetoStart[0] > endpointDistancetoStart[1]) ends.reverse(); |
256 | 256 |
|
257 | 257 | for (var i = 2; i--;) { |
258 | | - if (!measure.isPointEqual(ends[i], tPoints[i].point)) { |
| 258 | + if (!measure.isPointEqual(ends[i], tPoints[i].point, pointMatchingDistance)) { |
259 | 259 | return null; |
260 | 260 | } |
261 | 261 | } |
|
273 | 273 | /** |
274 | 274 | * @private |
275 | 275 | */ |
276 | | - function getChainBezierRange(curve: BezierCurve, c: IChain, layer: string, addToLayer: IAddToLayer): IBezierRange { |
| 276 | + function getChainBezierRange(curve: BezierCurve, c: IChain, layer: string, addToLayer: IAddToLayer, pointMatchingDistance: number): IBezierRange { |
277 | 277 |
|
278 | 278 | var endLinks = [c.links[0], c.links[c.links.length - 1]]; |
279 | 279 | if ((endLinks[0].walkedPath.pathContext as IPathArcInBezierCurve).bezierData.startT > (endLinks[1].walkedPath.pathContext as IPathArcInBezierCurve).bezierData.startT) { |
280 | 280 | chain.reverse(c); |
281 | 281 | endLinks.reverse(); |
282 | 282 | } |
283 | 283 |
|
284 | | - var actualBezierRanges = endLinks.map(endLink => getActualBezierRange(curve, endLink.walkedPath.pathContext as IPathArcInBezierCurve, endLink.endPoints, endLink.walkedPath.offset)); |
| 284 | + var actualBezierRanges = endLinks.map(endLink => getActualBezierRange(curve, endLink.walkedPath.pathContext as IPathArcInBezierCurve, endLink.endPoints, endLink.walkedPath.offset, pointMatchingDistance)); |
285 | 285 |
|
286 | 286 | var result: IBezierRange = { |
287 | 287 | startT: actualBezierRanges[0] ? actualBezierRanges[0].startT : null, |
|
523 | 523 | model.findChains(curve, function (chains: IChain[], loose: IWalkPath[], layer: string) { |
524 | 524 |
|
525 | 525 | chains.forEach(c => { |
526 | | - var range = getChainBezierRange(curve, c, layer, addToLayer); |
| 526 | + var range = getChainBezierRange(curve, c, layer, addToLayer, options.pointMatchingDistance); |
527 | 527 | if (range) { |
528 | 528 | var b = getScratch(curve.seed); |
529 | 529 | var piece = b.split(range.startT, range.endT); |
|
538 | 538 | //bezier is linear |
539 | 539 | return addToLayer(wp.pathContext, layer, true); |
540 | 540 | } |
541 | | - var range = getActualBezierRange(curve, wp.pathContext as IPathArcInBezierCurve, point.fromPathEnds(wp.pathContext), wp.offset); |
| 541 | + var range = getActualBezierRange(curve, wp.pathContext as IPathArcInBezierCurve, point.fromPathEnds(wp.pathContext), wp.offset, options.pointMatchingDistance); |
542 | 542 | if (range) { |
543 | 543 | var b = getScratch(curve.seed); |
544 | 544 | var piece = b.split(range.startT, range.endT); |
|
0 commit comments