clipper2-ts 2.0.1-13 → 2.0.1-15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clipper2-ts",
3
- "version": "2.0.1-13",
3
+ "version": "2.0.1-15",
4
4
  "description": "TypeScript port of Clipper2 polygon clipping, boolean operations, offsetting, and triangulation library",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/Engine.ts CHANGED
@@ -2938,7 +2938,6 @@ protected buildTree(polytree: PolyPathBase, solutionOpen: Paths64): void {
2938
2938
 
2939
2939
  let startOp = outrec.pts!;
2940
2940
  let op2: OutPt | null = startOp;
2941
- let removedAny = false;
2942
2941
 
2943
2942
  while (true) {
2944
2943
  // NB if preserveCollinear == true, then only remove 180 deg. spikes
@@ -2952,7 +2951,6 @@ protected buildTree(polytree: PolyPathBase, solutionOpen: Paths64): void {
2952
2951
  outrec.pts = op2.prev;
2953
2952
  }
2954
2953
  op2 = this.disposeOutPt(op2!);
2955
- removedAny = true;
2956
2954
  if (!this.isValidClosedPath(op2)) {
2957
2955
  outrec.pts = null;
2958
2956
  return;
@@ -2965,7 +2963,7 @@ protected buildTree(polytree: PolyPathBase, solutionOpen: Paths64): void {
2965
2963
  if (op2 === startOp) break;
2966
2964
  }
2967
2965
 
2968
- if (removedAny) this.fixSelfIntersects(outrec);
2966
+ this.fixSelfIntersects(outrec);
2969
2967
  }
2970
2968
 
2971
2969
  private isValidClosedPath(op: OutPt | null): boolean {
@@ -2988,28 +2986,16 @@ protected buildTree(polytree: PolyPathBase, solutionOpen: Paths64): void {
2988
2986
 
2989
2987
  while (true) {
2990
2988
  if (op2.next && op2.next.next &&
2991
- // optimization (not in C# reference): bbox check before segsIntersect
2992
- this.boundingBoxesOverlap(op2.prev.pt, op2.pt, op2.next.pt, op2.next.next.pt) && // TEST: Bbox only
2989
+ this.boundingBoxesOverlap(op2.prev.pt, op2.pt, op2.next.pt, op2.next.next.pt) &&
2993
2990
  InternalClipper.segsIntersect(op2.prev.pt, op2.pt, op2.next.pt, op2.next.next.pt)) {
2994
- if (op2.next.next.next &&
2995
- // optimization (not in C# reference): bbox check before segsIntersect
2996
- this.boundingBoxesOverlap(op2.prev.pt, op2.pt, op2.next.next.pt, op2.next.next.next.pt) && // TEST: Bbox only
2997
- InternalClipper.segsIntersect(op2.prev.pt, op2.pt, op2.next.next.pt, op2.next.next.next.pt)) {
2998
- // adjacent intersections (ie a micro self-intersection)
2999
- op2 = this.duplicateOp(op2, false);
3000
- op2.pt = op2.next!.next!.next!.pt;
3001
- op2 = op2.next!;
3002
- } else {
3003
2991
  if (op2 === outrec.pts || op2.next === outrec.pts) {
3004
2992
  outrec.pts = outrec.pts!.prev;
3005
2993
  }
3006
2994
  this.doSplitOp(outrec, op2);
3007
2995
  if (outrec.pts === null) return;
3008
2996
  op2 = outrec.pts;
3009
- // triangles can't self-intersect
3010
2997
  if (op2.prev === op2.next!.next) break;
3011
2998
  continue;
3012
- }
3013
2999
  }
3014
3000
 
3015
3001
  op2 = op2.next!;
@@ -3340,7 +3326,8 @@ export class ClipperD extends ClipperBase {
3340
3326
  }
3341
3327
 
3342
3328
  public addPath(path: PathD, polytype: PathType, isOpen: boolean = false): void {
3343
- super.addPath(Clipper.scalePath64(path, this.scale), polytype, isOpen);
3329
+ const tmp: PathsD = [path];
3330
+ this.addPaths(tmp, polytype, isOpen);
3344
3331
  }
3345
3332
 
3346
3333
  public addPaths(paths: PathsD, polytype: PathType, isOpen: boolean = false): void {