Skip to content

Commit

Permalink
Bugfix: Replace @flatten-js/boolean-op dependency with newest version…
Browse files Browse the repository at this point in the history
… of @flatten-js/core.

Boolean-op is deprecated and doesn't work with the newest version of core anymore. Core now contains all necessary boolean operations.
  • Loading branch information
gigerdo committed Sep 19, 2020
1 parent d7bc1f6 commit a865235
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 45 deletions.
60 changes: 34 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@
"engines": {
"node": ">=4.2.4"
},
"dependencies": {
"@flatten-js/boolean-op": "^1.1.1"
},
"peerDependencies": {
"@flatten-js/core": "^1.0.15"
"@flatten-js/core": "^1.2.15"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
Expand Down
26 changes: 11 additions & 15 deletions src/polygonOffset.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
import {Segment, Arc, Polygon, Face} from "@flatten-js/core";
import {CW, CCW, INSIDE, OUTSIDE, ORIENTATION} from "@flatten-js/core";
import {vector} from "@flatten-js/core";
import {unify,subtract} from "@flatten-js/boolean-op";
import {BOOLEAN_UNION} from "@flatten-js/boolean-op";

import {addToIntPoints, getSortedArray, splitByIntersections} from "@flatten-js/boolean-op";
import {removeNotRelevantChains, removeOldFaces, restoreFaces} from "@flatten-js/boolean-op";
import {BooleanOperations} from "@flatten-js/core";

import {arcSE, arcStartSweep, arcEndSweep} from "./createArcs";

Expand Down Expand Up @@ -45,10 +41,10 @@ export function offset(polygon, value) {
}

if (w > 0) {
offsetPolygon = unify(offsetPolygon, offsetEdge);
offsetPolygon = BooleanOperations.unify(offsetPolygon, offsetEdge);
}
else {
offsetPolygon = subtract(offsetPolygon, offsetEdge);
offsetPolygon = BooleanOperations.subtract(offsetPolygon, offsetEdge);
}
}
}
Expand Down Expand Up @@ -98,13 +94,13 @@ export function offsetArc(arc, value) {
edge_cap2 = [...polygon.edges][3];

for (let pt of ips) {
addToIntPoints(edge_cap1, pt, int_points);
addToIntPoints(edge_cap2, pt, int_points);
BooleanOperations.addToIntPoints(edge_cap1, pt, int_points);
BooleanOperations.addToIntPoints(edge_cap2, pt, int_points);
}

// Sort intersection points and insert them as new vertices
let int_points_sorted = getSortedArray(int_points);
splitByIntersections(polygon, int_points_sorted);
let int_points_sorted = BooleanOperations.getSortedArray(int_points);
BooleanOperations.splitByIntersections(polygon, int_points_sorted);


// Set BV flags
Expand All @@ -116,8 +112,8 @@ export function offsetArc(arc, value) {
}

// Remove inner "chains"
let op = BOOLEAN_UNION;
removeNotRelevantChains(polygon, op, int_points_sorted, true);
let op = BooleanOperations.BOOLEAN_UNION;
BooleanOperations.removeNotRelevantChains(polygon, op, int_points_sorted, true);

// return int_points_sorted;
// Swap links
Expand Down Expand Up @@ -148,9 +144,9 @@ export function offsetArc(arc, value) {
}

// remove old faces
removeOldFaces(polygon, int_points);
BooleanOperations.removeOldFaces(polygon, int_points);
// restore faces
restoreFaces(polygon, int_points, int_points);
BooleanOperations.restoreFaces(polygon, int_points, int_points);
}

let face0 = [...polygon.faces][0];
Expand Down

0 comments on commit a865235

Please sign in to comment.