Skip to content

Commit

Permalink
Merge 86965f7 into acaddbd
Browse files Browse the repository at this point in the history
  • Loading branch information
BarbourSmith committed Jul 12, 2021
2 parents acaddbd + 86965f7 commit cf59855
Show file tree
Hide file tree
Showing 17 changed files with 818 additions and 737 deletions.
Binary file modified dist/cgal_browser.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
<script src="three.js"></script>
<script src="TrackballControls.js"></script>
<script type="module"; src="/jsxcad.js"></script>
<!-- <script type="module"; src="http://localhost:3000/maslowWorker.js"></script> -->
<script type="module"; src="http://localhost:3000/maslowWorker.js"></script>
<script src="/js/flowDraw.bundle.js"></script>

</body>
Expand Down
8 changes: 4 additions & 4 deletions dist/jsxcad-algorithm-cgal.js

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions dist/jsxcad-api-shape.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { add as add$1, dot, subtract, scale as scale$1, abs, negate, normalize, cross, distance } from './jsxcad-math-vec3.js';
import { fromPoints as fromPoints$2, toXYPlaneTransforms } from './jsxcad-math-plane.js';
import { closePath, concatenatePath, assemble as assemble$1, eachPoint, flip, toConcreteGeometry, toDisplayGeometry, toTransformedGeometry, toPoints, transform, rewriteTags, taggedPaths, taggedGraph, openPath, taggedPoints, fromPolygonsToGraph, registerReifier, getPeg, union, taggedGroup, bend as bend$1, intersection, allTags, fromPointsToGraph, difference, rewrite, taggedPlan, translatePaths, getLeafs, taggedLayout, measureBoundingBox, getLayouts, visit, isNotVoid, extrude as extrude$1, extrudeToPlane as extrudeToPlane$1, fill as fill$1, empty, grow as grow$1, outline as outline$1, inset as inset$1, read, loft as loft$1, realize, minkowskiDifference as minkowskiDifference$1, minkowskiShell as minkowskiShell$1, minkowskiSum as minkowskiSum$1, isVoid, offset as offset$1, taggedItem, toDisjointGeometry, projectToPlane as projectToPlane$1, push as push$1, remesh as remesh$1, write, section as section$1, smooth as smooth$1, taggedSketch, split as split$1, test as test$1, twist as twist$1, toPolygonsWithHoles, arrangePolygonsWithHoles, fromPolygonsWithHolesToTriangles, fromTrianglesToGraph, alphaShape, rotateZPath, convexHullToGraph, fromFunctionToGraph, fromPathsToGraph, translatePath } from './jsxcad-geometry.js';
import { closePath, concatenatePath, assemble as assemble$1, eachPoint, flip, toConcreteGeometry, toDisplayGeometry, toTransformedGeometry, toPoints, transform, rewriteTags, taggedPaths, taggedGraph, openPath, taggedPoints, fromPolygonsToGraph, registerReifier, getPeg, union, taggedGroup, bend as bend$1, intersection, allTags, fromPointsToGraph, difference, rewrite, taggedPlan, translatePaths, getLeafs, taggedLayout, measureBoundingBox, getLayouts, visit, isNotVoid, extrude as extrude$1, extrudeToPlane as extrudeToPlane$1, fill as fill$1, empty, grow as grow$1, outline as outline$1, inset as inset$1, read, loft as loft$1, realize, minkowskiDifference as minkowskiDifference$1, minkowskiShell as minkowskiShell$1, minkowskiSum as minkowskiSum$1, isVoid, offset as offset$1, taggedItem, toDisjointGeometry, projectToPlane as projectToPlane$1, push as push$1, remesh as remesh$1, write, section as section$1, separate as separate$1, smooth as smooth$1, taggedSketch, test as test$1, twist as twist$1, toPolygonsWithHoles, arrangePolygonsWithHoles, fromPolygonsWithHolesToTriangles, fromTrianglesToGraph, alphaShape, rotateZPath, convexHullToGraph, fromFunctionToGraph, fromPathsToGraph, translatePath } from './jsxcad-geometry.js';
import { identityMatrix, fromTranslation, fromRotation, fromScaling } from './jsxcad-math-mat4.js';
import { emit, log as log$1, getModule, generateUniqueId, addPending, write as write$1 } from './jsxcad-sys.js';
export { elapsed, emit, info, read, write } from './jsxcad-sys.js';
Expand Down Expand Up @@ -3025,6 +3025,24 @@ const sectionProfile =

Shape.registerMethod('sectionProfile', sectionProfile);

const separate =
({
keepVolumes = true,
keepCavitiesInVolumes = true,
keepCavitiesAsVolumes = false,
} = {}) =>
(shape) =>
Shape.fromGeometry(
separate$1(
shape.toGeometry(),
keepVolumes,
keepCavitiesInVolumes,
keepCavitiesAsVolumes
)
);

Shape.registerMethod('separate', separate);

const scale =
(x = 1, y = x, z = y) =>
(shape) =>
Expand Down Expand Up @@ -3074,24 +3092,6 @@ const sketch = () => (shape) =>

Shape.registerMethod('sketch', sketch);

const split =
({
keepVolumes = true,
keepCavitiesInVolumes = true,
keepCavitiesAsVolumes = false,
} = {}) =>
(shape) =>
Shape.fromGeometry(
split$1(
shape.toGeometry(),
keepVolumes,
keepCavitiesInVolumes,
keepCavitiesAsVolumes
)
);

Shape.registerMethod('split', split);

const tags =
(op = (tags, shape) => tags) =>
(shape) =>
Expand Down Expand Up @@ -3776,4 +3776,4 @@ const yz = Peg('x', [0, 0, 0], [0, 0, 1], [0, -1, 0]);
const xz = Peg('y', [0, 0, 0], [0, 0, 1], [1, 0, 0]);
const xy = Peg('z', [0, 0, 0], [0, 1, 0], [-1, 0, 0]);

export { Alpha, Arc, Assembly, Box, ChainedHull, Cone, Empty, Group, Hershey, Hexagon, Hull, Icosahedron, Implicit, Item, Line, Octagon, Orb, Page, Path, Peg, Pentagon, Plan, Point, Points, Polygon, Polyhedron, Septagon, Shape, Spiral, Tetragon, Triangle, Wave, Weld, add, addTo, align, and, as, bend, clip, clipFrom, cloudSolid, color, colors, cut, cutFrom, defGrblConstantLaser, defGrblDynamicLaser, defGrblPlotter, defGrblSpindle, defRgbColor, defThreejsMaterial, defTool, define, drop, each, ensurePages, ex, extrude, extrudeToPlane, fill, fuse, grow, inline, inset, keep, loadGeometry, loft, log, loop, material, md, minkowskiDifference, minkowskiShell, minkowskiSum, move, noVoid, notAs, ofPlan, offset, op, orient, outline, pack, projectToPlane, push, remesh, rotate, rotateX, rotateY, rotateZ, rx, ry, rz, saveGeometry, scale, section, sectionProfile, size, sketch, smooth, split, tags, test, tint, tool, twist, view, voidFn, weld, withFill, withFn, withInset, withOp, x, xy, xz, y, yz, z };
export { Alpha, Arc, Assembly, Box, ChainedHull, Cone, Empty, Group, Hershey, Hexagon, Hull, Icosahedron, Implicit, Item, Line, Octagon, Orb, Page, Path, Peg, Pentagon, Plan, Point, Points, Polygon, Polyhedron, Septagon, Shape, Spiral, Tetragon, Triangle, Wave, Weld, add, addTo, align, and, as, bend, clip, clipFrom, cloudSolid, color, colors, cut, cutFrom, defGrblConstantLaser, defGrblDynamicLaser, defGrblPlotter, defGrblSpindle, defRgbColor, defThreejsMaterial, defTool, define, drop, each, ensurePages, ex, extrude, extrudeToPlane, fill, fuse, grow, inline, inset, keep, loadGeometry, loft, log, loop, material, md, minkowskiDifference, minkowskiShell, minkowskiSum, move, noVoid, notAs, ofPlan, offset, op, orient, outline, pack, projectToPlane, push, remesh, rotate, rotateX, rotateY, rotateZ, rx, ry, rz, saveGeometry, scale, section, sectionProfile, separate, size, sketch, smooth, tags, test, tint, tool, twist, view, voidFn, weld, withFill, withFn, withInset, withOp, x, xy, xz, y, yz, z };
87 changes: 86 additions & 1 deletion dist/jsxcad-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,114 @@ var notesApi = /*#__PURE__*/Object.freeze({
emitSourceLocation: emitSourceLocation
});

const evaluate = async (ecmascript, { api, path }) => {
const builder = new Function(
`{ ${Object.keys(api).join(', ')} }`,
`return async () => { ${ecmascript} };`
);
const module = await builder(api);
try {
pushModule(path);
await module();
} finally {
popModule();
}
};

const execute = async (
script,
{ evaluate, replay, path, topLevel = {} }
) => {
try {
console.log(`QQ/execute/0`);
const updates = {};
const ecmascript = await toEcmascript(script, {
path,
topLevel,
updates,
});
const pending = new Set(Object.keys(updates));
const unprocessed = new Set(Object.keys(updates));
let somethingHappened;
let somethingFailed;
const schedule = () => {
console.log(`Updates remaining ${[...pending].join(', ')}`);
for (const id of [...pending]) {
const entry = updates[id];
const outstandingDependencies = entry.dependencies.filter(
(dependency) => updates[dependency]
);
if (outstandingDependencies.length === 0) {
console.log(`Scheduling: ${id}`);
pending.delete(id);
evaluate(updates[id].program)
.then(() => {
console.log(`Completed ${id}`);
delete updates[id];
unprocessed.delete(id);
})
.catch((error) => somethingFailed(error)) // FIX: Deadlock?
.finally(() => somethingHappened());
}
}
};
while (unprocessed.size > 0) {
const somethingHappens = new Promise((resolve, reject) => {
somethingHappened = resolve;
somethingFailed = reject;
});
schedule();
if (unprocessed.size > 0) {
// Wait for something to happen.
await somethingHappens;
}
}
return replay(ecmascript, { path });
} catch (error) {
throw error;
}
};

const DYNAMIC_MODULES = new Map();

const registerDynamicModule = (bare, path) =>
DYNAMIC_MODULES.set(bare, path);

const buildImportModule = (api) => async (name) => {
const buildImportModule = (baseApi) => async (name) => {
console.log(`QQ/importModule/0`);
const internalModule = DYNAMIC_MODULES.get(name);
if (internalModule !== undefined) {
const module = await import(internalModule);
return module;
}
console.log(`QQ/importModule/1`);
let script;
if (script === undefined) {
const path = `source/${name}`;
const sources = [];
sources.push(name);
script = await read(path, { sources });
}
console.log(`QQ/importModule/2`);
if (script === undefined) {
throw Error(`Cannot import module ${name}`);
}
console.log(`QQ/importModule/3`);
const scriptText =
typeof script === 'string'
? script
: new TextDecoder('utf8').decode(script);
console.log(`QQ/importModule/4`);
const path = name;
const topLevel = new Map();
const onError = (error) => console.log(error.stack);
const api = { ...baseApi, sha: 'master' };
console.log(`QQ/importModule/5`);
const evaluate$1 = (script) => evaluate(script, { api, path });
console.log(`QQ/importModule/6`);

return execute(scriptText, { evaluate: evaluate$1, path, topLevel, onError });
/*
const ecmascript = await toEcmascript(scriptText, { path: name });
const builder = new Function(
`{ ${Object.keys(api).join(', ')} }`,
Expand All @@ -108,6 +191,7 @@ const buildImportModule = (api) => async (name) => {
} finally {
popModule();
}
*/
};

/*
Expand Down Expand Up @@ -167,3 +251,4 @@ registerDynamicModule(module('threejs'), './jsxcad-api-v1-threejs.js');
registerDynamicModule(module('units'), './jsxcad-api-v1-units.js');

export default api;
export { evaluate, execute };
29 changes: 3 additions & 26 deletions dist/jsxcad-convert-notebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,33 +180,10 @@ const toHtml = async (
const run = async () => {
const body = document.getElementsByTagName('body')[0];
const bookElement = document.createElement('div');
// Organize by card.
const cards = [];
const cardNotes = new Map();
for (const note of notebook) {
let card = '';
if (note.context && note.context.card) {
card = note.context.card;
}
if (!cardNotes.has(card)) {
cards.push(card);
cardNotes.set(card, []);
}
cardNotes.get(card).push(note);
}
for (const cardId of cards) {
const cardElement = document.createElement('div');
cardElement.className = 'note card';
const notebookElement = await toDomElement(cardNotes.get(cardId));
cardElement.appendChild(notebookElement);
bookElement.appendChild(cardElement);
}
bookElement.classList.add('book', 'notebook', 'loaded');
const notebookElement = await toDomElement(notebook);
bookElement.appendChild(notebookElement);
body.appendChild(bookElement);
bookElement.classList.add('book', 'notebook', 'loaded');
};
if (document.readyState === 'complete') {
Expand Down
14 changes: 7 additions & 7 deletions dist/jsxcad-geometry.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { identityMatrix, fromTranslation, fromZRotation, fromScaling, fromXRotation, fromYRotation } from './jsxcad-math-mat4.js';
import { composeTransforms, fromSurfaceMeshToGraph, fromPointsToAlphaShapeAsSurfaceMesh, fromSurfaceMeshToLazyGraph, arrangePathsIntoTriangles, fromPolygonsToSurfaceMesh, deserializeSurfaceMesh, fromGraphToSurfaceMesh, fromSurfaceMeshEmitBoundingBox, differenceOfSurfaceMeshes, bendSurfaceMesh, fromPointsToConvexHullAsSurfaceMesh, extrudeSurfaceMesh, extrudeToPlaneOfSurfaceMesh, fromFunctionToSurfaceMesh, fromPointsToSurfaceMesh, arrangePaths, growSurfaceMesh, intersectionOfSurfaceMeshes, fromSurfaceMeshToPolygonsWithHoles, insetOfPolygonWithHoles, loftBetweenCongruentSurfaceMeshes, minkowskiDifferenceOfSurfaceMeshes, minkowskiShellOfSurfaceMeshes, minkowskiSumOfSurfaceMeshes, offsetOfPolygonWithHoles, outlineSurfaceMesh, projectToPlaneOfSurfaceMesh, serializeSurfaceMesh, pushSurfaceMesh, remeshSurfaceMesh, reverseFaceOrientationsOfSurfaceMesh, sectionOfSurfaceMesh, subdivideSurfaceMesh, splitSurfaceMesh, fromSurfaceMeshToTriangles, doesSelfIntersectOfSurfaceMesh, twistSurfaceMesh, unionOfSurfaceMeshes } from './jsxcad-algorithm-cgal.js';
import { composeTransforms, fromSurfaceMeshToGraph, fromPointsToAlphaShapeAsSurfaceMesh, fromSurfaceMeshToLazyGraph, arrangePathsIntoTriangles, fromPolygonsToSurfaceMesh, deserializeSurfaceMesh, fromGraphToSurfaceMesh, fromSurfaceMeshEmitBoundingBox, differenceOfSurfaceMeshes, bendSurfaceMesh, fromPointsToConvexHullAsSurfaceMesh, extrudeSurfaceMesh, extrudeToPlaneOfSurfaceMesh, fromFunctionToSurfaceMesh, fromPointsToSurfaceMesh, arrangePaths, growSurfaceMesh, intersectionOfSurfaceMeshes, fromSurfaceMeshToPolygonsWithHoles, insetOfPolygonWithHoles, loftBetweenCongruentSurfaceMeshes, minkowskiDifferenceOfSurfaceMeshes, minkowskiShellOfSurfaceMeshes, minkowskiSumOfSurfaceMeshes, offsetOfPolygonWithHoles, outlineSurfaceMesh, projectToPlaneOfSurfaceMesh, serializeSurfaceMesh, pushSurfaceMesh, remeshSurfaceMesh, reverseFaceOrientationsOfSurfaceMesh, sectionOfSurfaceMesh, subdivideSurfaceMesh, separateSurfaceMesh, fromSurfaceMeshToTriangles, doesSelfIntersectOfSurfaceMesh, twistSurfaceMesh, unionOfSurfaceMeshes } from './jsxcad-algorithm-cgal.js';
export { arrangePolygonsWithHoles } from './jsxcad-algorithm-cgal.js';
import { equals, min, max, transform as transform$5, canonicalize as canonicalize$5, scale as scale$3, subtract } from './jsxcad-math-vec3.js';
import { cache, cacheRewriteTags, cacheSection } from './jsxcad-cache.js';
Expand Down Expand Up @@ -2475,15 +2475,15 @@ const smooth = (geometry, options) => {
return rewrite(toTransformedGeometry(geometry), op);
};

const split$1 = (
const separate$1 = (
geometry,
keepVolumes = true,
keepCavitiesInVolumes = true,
keepCavitiesAsVolumes = false
) =>
taggedGroup(
{},
...splitSurfaceMesh(
...separateSurfaceMesh(
toSurfaceMesh(geometry.graph),
keepVolumes,
keepCavitiesInVolumes,
Expand All @@ -2496,7 +2496,7 @@ const split$1 = (
)
);

const split = (
const separate = (
geometry,
keepVolumes = true,
keepCavitiesInVolumes = true,
Expand All @@ -2505,7 +2505,7 @@ const split = (
const op = (geometry, descend) => {
switch (geometry.type) {
case 'graph':
return split$1(
return separate$1(
geometry,
keepVolumes,
keepCavitiesInVolumes,
Expand All @@ -2517,7 +2517,7 @@ const split = (
// Not implemented yet.
return geometry;
case 'plan':
return split(
return separate(
reify(geometry).content[0],
keepVolumes,
keepCavitiesInVolumes,
Expand Down Expand Up @@ -2985,4 +2985,4 @@ const translate = (vector, geometry) =>
const scale = (vector, geometry) =>
transform$4(fromScaling(vector), geometry);

export { allTags, alphaShape, assemble, bend, canonicalize, canonicalize$4 as canonicalizePath, canonicalize$3 as canonicalizePaths, close as closePath, concatenate as concatenatePath, convexHull as convexHullToGraph, deduplicate as deduplicatePath, difference, disjoint, doesNotOverlap, drop, eachItem, eachPoint, empty, extrude, extrudeToPlane, fill, flip, flip$3 as flipPath, fresh, fromFunction as fromFunctionToGraph, fromPaths as fromPathsToGraph, fromPoints as fromPointsToGraph, fromPolygons as fromPolygonsToGraph, fromPolygonsWithHolesToTriangles, fromSurfaceToPaths, fromTriangles as fromTrianglesToGraph, getAnyNonVoidSurfaces, getAnySurfaces, getFaceablePaths, getGraphs, getItems, getLayouts, getLeafs, getNonVoidFaceablePaths, getNonVoidGraphs, getNonVoidItems, getNonVoidPaths, getNonVoidPlans, getNonVoidPoints, getEdges as getPathEdges, getPaths, getPeg, getPlans, getPoints, getTags, grow, hash, inset, intersection, isClockwise as isClockwisePath, isClosed as isClosedPath, isNotVoid, isVoid, keep, loft, measureBoundingBox, minkowskiDifference, minkowskiShell, minkowskiSum, offset, open as openPath, outline, prepareForSerialization, projectToPlane, push, read, realize, realizeGraph, registerReifier, reify, remesh, rerealizeGraph, reverseFaceOrientations as reverseFaceOrientationsOfGraph, rewrite, rewriteTags, rotateX, rotateY, rotateZ, rotateZ$1 as rotateZPath, scale, scale$2 as scalePath, scale$1 as scalePaths, section, smooth, soup, split, taggedDisplayGeometry, taggedGraph, taggedGroup, taggedItem, taggedLayout, taggedPaths, taggedPlan, taggedPoints, taggedSketch, taggedTriangles, test, toConcreteGeometry, toDisjointGeometry, toDisplayGeometry, toKeptGeometry, toPoints, toPolygonsWithHoles, toTransformedGeometry, toTriangles as toTrianglesFromGraph, toVisiblyDisjointGeometry, transform$4 as transform, transform$2 as transformPaths, translate, translate$2 as translatePath, translate$1 as translatePaths, twist, union, update, visit, write };
export { allTags, alphaShape, assemble, bend, canonicalize, canonicalize$4 as canonicalizePath, canonicalize$3 as canonicalizePaths, close as closePath, concatenate as concatenatePath, convexHull as convexHullToGraph, deduplicate as deduplicatePath, difference, disjoint, doesNotOverlap, drop, eachItem, eachPoint, empty, extrude, extrudeToPlane, fill, flip, flip$3 as flipPath, fresh, fromFunction as fromFunctionToGraph, fromPaths as fromPathsToGraph, fromPoints as fromPointsToGraph, fromPolygons as fromPolygonsToGraph, fromPolygonsWithHolesToTriangles, fromSurfaceToPaths, fromTriangles as fromTrianglesToGraph, getAnyNonVoidSurfaces, getAnySurfaces, getFaceablePaths, getGraphs, getItems, getLayouts, getLeafs, getNonVoidFaceablePaths, getNonVoidGraphs, getNonVoidItems, getNonVoidPaths, getNonVoidPlans, getNonVoidPoints, getEdges as getPathEdges, getPaths, getPeg, getPlans, getPoints, getTags, grow, hash, inset, intersection, isClockwise as isClockwisePath, isClosed as isClosedPath, isNotVoid, isVoid, keep, loft, measureBoundingBox, minkowskiDifference, minkowskiShell, minkowskiSum, offset, open as openPath, outline, prepareForSerialization, projectToPlane, push, read, realize, realizeGraph, registerReifier, reify, remesh, rerealizeGraph, reverseFaceOrientations as reverseFaceOrientationsOfGraph, rewrite, rewriteTags, rotateX, rotateY, rotateZ, rotateZ$1 as rotateZPath, scale, scale$2 as scalePath, scale$1 as scalePaths, section, separate, smooth, soup, taggedDisplayGeometry, taggedGraph, taggedGroup, taggedItem, taggedLayout, taggedPaths, taggedPlan, taggedPoints, taggedSketch, taggedTriangles, test, toConcreteGeometry, toDisjointGeometry, toDisplayGeometry, toKeptGeometry, toPoints, toPolygonsWithHoles, toTransformedGeometry, toTriangles as toTrianglesFromGraph, toVisiblyDisjointGeometry, transform$4 as transform, transform$2 as transformPaths, translate, translate$2 as translatePath, translate$1 as translatePaths, twist, union, update, visit, write };
Loading

0 comments on commit cf59855

Please sign in to comment.