brepjs 18.35.5 → 18.36.0
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/dist/brepjs.cjs +92 -0
- package/dist/brepjs.js +87 -1
- package/dist/index.d.ts +2 -0
- package/dist/voxel/engine.d.ts +16 -0
- package/dist/voxel/index.d.ts +11 -0
- package/dist/voxel/registry.d.ts +18 -0
- package/dist/voxel/signFns.d.ts +23 -0
- package/package.json +3 -1
package/dist/brepjs.cjs
CHANGED
|
@@ -119,6 +119,92 @@ function vertexFinder() {
|
|
|
119
119
|
return buildVertexFinder([]);
|
|
120
120
|
}
|
|
121
121
|
//#endregion
|
|
122
|
+
//#region src/voxel/registry.ts
|
|
123
|
+
var _engines = /* @__PURE__ */ new Map();
|
|
124
|
+
var _defaultId = null;
|
|
125
|
+
var _cached = null;
|
|
126
|
+
function registerVoxel(id, engine) {
|
|
127
|
+
_engines.set(id, engine);
|
|
128
|
+
if (!_defaultId) _defaultId = id;
|
|
129
|
+
if (id === _defaultId) _cached = engine;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Return a voxel engine by id, or the default engine if no id is given.
|
|
133
|
+
*
|
|
134
|
+
* @throws If no engine has been registered via {@link initVoxel} or
|
|
135
|
+
* {@link registerVoxel}.
|
|
136
|
+
*/
|
|
137
|
+
function getVoxel(id) {
|
|
138
|
+
if (!id && _cached) return _cached;
|
|
139
|
+
const targetId = id ?? _defaultId;
|
|
140
|
+
if (!targetId) throw new Error("brepjs voxel engine not initialized. Call initVoxel() (or registerVoxel()) before using voxel operations.");
|
|
141
|
+
const engine = _engines.get(targetId);
|
|
142
|
+
if (!engine) throw new Error(`brepjs: voxel engine '${targetId}' is not registered.`);
|
|
143
|
+
return engine;
|
|
144
|
+
}
|
|
145
|
+
/** Return the id of the active default engine, or `null` if none is registered. */
|
|
146
|
+
function getActiveVoxelId() {
|
|
147
|
+
return _defaultId;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Register a loaded voxel engine and make it the default.
|
|
151
|
+
*
|
|
152
|
+
* Mirrors {@link initFromOC} for the kernel: the loader package
|
|
153
|
+
* (`brepjs-voxel`) instantiates the wasm, then hands the engine here.
|
|
154
|
+
*/
|
|
155
|
+
function initVoxel(engine, id = "voxel") {
|
|
156
|
+
registerVoxel(id, engine);
|
|
157
|
+
_defaultId = id;
|
|
158
|
+
_cached = engine;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/voxel/signFns.ts
|
|
162
|
+
function validateInputs(mesh, queries) {
|
|
163
|
+
if (mesh.vertices.length % 3 !== 0) return require_errors.validationError("VOXEL_INVALID_MESH", "mesh.vertices length must be a multiple of 3 (flat xyz).");
|
|
164
|
+
if (mesh.triangles.length % 3 !== 0) return require_errors.validationError("VOXEL_INVALID_MESH", "mesh.triangles length must be a multiple of 3.");
|
|
165
|
+
const vertexCount = mesh.vertices.length / 3;
|
|
166
|
+
for (let i = 0; i < mesh.triangles.length; i++) {
|
|
167
|
+
const idx = mesh.triangles[i];
|
|
168
|
+
if (idx === void 0 || idx >= vertexCount) return require_errors.validationError("VOXEL_INVALID_TRIANGLE_INDEX", `triangle index ${idx} at position ${i} is out of range for ${vertexCount} vertices.`);
|
|
169
|
+
}
|
|
170
|
+
if (queries.length % 3 !== 0) return require_errors.validationError("VOXEL_INVALID_QUERIES", "queries length must be a multiple of 3 (flat xyz).");
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
function resolveEngine(id) {
|
|
174
|
+
try {
|
|
175
|
+
return require_errors.ok(getVoxel(id));
|
|
176
|
+
} catch (cause) {
|
|
177
|
+
return require_errors.err(require_errors.moduleInitError("VOXEL_NOT_INITIALIZED", cause instanceof Error ? cause.message : "voxel engine not initialized", cause));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Generalized winding number at each query point against a triangle-soup mesh.
|
|
182
|
+
*
|
|
183
|
+
* `queries` is flat xyz (length 3·Q); the result has length Q. ~1 inside, ~0
|
|
184
|
+
* outside for a closed mesh; degrades gracefully on holes (the keystone that
|
|
185
|
+
* makes non-watertight repair possible — ADR-0013 §11).
|
|
186
|
+
*/
|
|
187
|
+
function windingNumbers(mesh, queries, id) {
|
|
188
|
+
const invalid = validateInputs(mesh, queries);
|
|
189
|
+
if (invalid) return require_errors.err(invalid);
|
|
190
|
+
const engine = resolveEngine(id);
|
|
191
|
+
if (require_errors.isErr(engine)) return engine;
|
|
192
|
+
return require_errors.ok(engine.value.winding_numbers(mesh.vertices, mesh.triangles, queries));
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Inside/outside classification (winding number > 0.5) at each query point.
|
|
196
|
+
*
|
|
197
|
+
* `queries` is flat xyz (length 3·Q); the result has length Q.
|
|
198
|
+
*/
|
|
199
|
+
function pointsInside(mesh, queries, id) {
|
|
200
|
+
const invalid = validateInputs(mesh, queries);
|
|
201
|
+
if (invalid) return require_errors.err(invalid);
|
|
202
|
+
const engine = resolveEngine(id);
|
|
203
|
+
if (require_errors.isErr(engine)) return engine;
|
|
204
|
+
const flags = engine.value.points_inside(mesh.vertices, mesh.triangles, queries);
|
|
205
|
+
return require_errors.ok(Array.from(flags, (flag) => flag === 1));
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
122
208
|
//#region src/core/kernelBoundary.ts
|
|
123
209
|
/** Convert Vec3 to a kernel 3D vector. Caller must call .delete() when done. */
|
|
124
210
|
function toKernelVec(v) {
|
|
@@ -5364,6 +5450,7 @@ exports.fuseAllBisect = require_primitiveFns.fuseAllBisect;
|
|
|
5364
5450
|
exports.fuseBlueprints = require_boolean2D.fuseBlueprints;
|
|
5365
5451
|
exports.fuseWithEvolution = require_primitiveFns.fuseWithEvolution;
|
|
5366
5452
|
exports.gearGeometry = gearGeometry;
|
|
5453
|
+
exports.getActiveVoxelId = getActiveVoxelId;
|
|
5367
5454
|
exports.getBounds = require_topologyQueryFns.getBounds;
|
|
5368
5455
|
exports.getBounds2D = require_blueprintFns.getBounds2D;
|
|
5369
5456
|
exports.getCompSolids = require_topologyQueryFns.getCompSolids;
|
|
@@ -5391,6 +5478,7 @@ exports.getSolids = require_topologyQueryFns.getSolids;
|
|
|
5391
5478
|
exports.getSurfaceType = require_faceFns.getSurfaceType;
|
|
5392
5479
|
exports.getTagMetadata = require_shapeFns.getTagMetadata;
|
|
5393
5480
|
exports.getVertices = require_topologyQueryFns.getVertices;
|
|
5481
|
+
exports.getVoxel = getVoxel;
|
|
5394
5482
|
exports.getWires = require_topologyQueryFns.getWires;
|
|
5395
5483
|
exports.guidedSweep = require_extrudeFns.guidedSweep;
|
|
5396
5484
|
exports.heal = heal;
|
|
@@ -5411,6 +5499,7 @@ exports.importThreeMF = importThreeMF;
|
|
|
5411
5499
|
exports.init = require_shapeTypes.init;
|
|
5412
5500
|
exports.initFromManifold = require_shapeTypes.initFromManifold;
|
|
5413
5501
|
exports.initFromOC = require_shapeTypes.initFromOC;
|
|
5502
|
+
exports.initVoxel = initVoxel;
|
|
5414
5503
|
exports.innerWires = require_faceFns.innerWires;
|
|
5415
5504
|
exports.interpolateCurve = require_curveFns.interpolateCurve;
|
|
5416
5505
|
exports.intersect = intersect;
|
|
@@ -5546,6 +5635,7 @@ exports.planarWire = require_shapeTypes.planarWire;
|
|
|
5546
5635
|
exports.planetPlacements = planetPlacements;
|
|
5547
5636
|
exports.pocket = pocket;
|
|
5548
5637
|
exports.pointOnSurface = require_faceFns.pointOnSurface;
|
|
5638
|
+
exports.pointsInside = pointsInside;
|
|
5549
5639
|
exports.polygon = require_primitiveFns.polygon;
|
|
5550
5640
|
exports.polyhedron = polyhedron;
|
|
5551
5641
|
exports.polysideInnerRadius = require_drawFns.polysideInnerRadius;
|
|
@@ -5572,6 +5662,7 @@ exports.registerHandler = require_workerHandler.registerHandler;
|
|
|
5572
5662
|
exports.registerKernel = require_shapeTypes.registerKernel;
|
|
5573
5663
|
exports.registerOperation = require_historyFns.registerOperation;
|
|
5574
5664
|
exports.registerShape = require_historyFns.registerShape;
|
|
5665
|
+
exports.registerVoxel = registerVoxel;
|
|
5575
5666
|
exports.rejectAll = require_workerHandler.rejectAll;
|
|
5576
5667
|
exports.removeChild = require_historyFns.removeChild;
|
|
5577
5668
|
exports.removeHolesFromFace = require_faceFns.removeHolesFromFace;
|
|
@@ -5709,6 +5800,7 @@ exports.vertexFinder = vertexFinder;
|
|
|
5709
5800
|
exports.vertexPosition = require_topologyQueryFns.vertexPosition;
|
|
5710
5801
|
exports.verticesOfEdge = require_primitiveFns.verticesOfEdge;
|
|
5711
5802
|
exports.walkAssembly = require_historyFns.walkAssembly;
|
|
5803
|
+
exports.windingNumbers = windingNumbers;
|
|
5712
5804
|
exports.wire = require_primitiveFns.wire;
|
|
5713
5805
|
exports.wireFinder = require_helpers.wireFinder;
|
|
5714
5806
|
exports.wireLoop = require_primitiveFns.wireLoop;
|
package/dist/brepjs.js
CHANGED
|
@@ -130,6 +130,92 @@ function vertexFinder() {
|
|
|
130
130
|
return buildVertexFinder([]);
|
|
131
131
|
}
|
|
132
132
|
//#endregion
|
|
133
|
+
//#region src/voxel/registry.ts
|
|
134
|
+
var _engines = /* @__PURE__ */ new Map();
|
|
135
|
+
var _defaultId = null;
|
|
136
|
+
var _cached = null;
|
|
137
|
+
function registerVoxel(id, engine) {
|
|
138
|
+
_engines.set(id, engine);
|
|
139
|
+
if (!_defaultId) _defaultId = id;
|
|
140
|
+
if (id === _defaultId) _cached = engine;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Return a voxel engine by id, or the default engine if no id is given.
|
|
144
|
+
*
|
|
145
|
+
* @throws If no engine has been registered via {@link initVoxel} or
|
|
146
|
+
* {@link registerVoxel}.
|
|
147
|
+
*/
|
|
148
|
+
function getVoxel(id) {
|
|
149
|
+
if (!id && _cached) return _cached;
|
|
150
|
+
const targetId = id ?? _defaultId;
|
|
151
|
+
if (!targetId) throw new Error("brepjs voxel engine not initialized. Call initVoxel() (or registerVoxel()) before using voxel operations.");
|
|
152
|
+
const engine = _engines.get(targetId);
|
|
153
|
+
if (!engine) throw new Error(`brepjs: voxel engine '${targetId}' is not registered.`);
|
|
154
|
+
return engine;
|
|
155
|
+
}
|
|
156
|
+
/** Return the id of the active default engine, or `null` if none is registered. */
|
|
157
|
+
function getActiveVoxelId() {
|
|
158
|
+
return _defaultId;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Register a loaded voxel engine and make it the default.
|
|
162
|
+
*
|
|
163
|
+
* Mirrors {@link initFromOC} for the kernel: the loader package
|
|
164
|
+
* (`brepjs-voxel`) instantiates the wasm, then hands the engine here.
|
|
165
|
+
*/
|
|
166
|
+
function initVoxel(engine, id = "voxel") {
|
|
167
|
+
registerVoxel(id, engine);
|
|
168
|
+
_defaultId = id;
|
|
169
|
+
_cached = engine;
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/voxel/signFns.ts
|
|
173
|
+
function validateInputs(mesh, queries) {
|
|
174
|
+
if (mesh.vertices.length % 3 !== 0) return validationError("VOXEL_INVALID_MESH", "mesh.vertices length must be a multiple of 3 (flat xyz).");
|
|
175
|
+
if (mesh.triangles.length % 3 !== 0) return validationError("VOXEL_INVALID_MESH", "mesh.triangles length must be a multiple of 3.");
|
|
176
|
+
const vertexCount = mesh.vertices.length / 3;
|
|
177
|
+
for (let i = 0; i < mesh.triangles.length; i++) {
|
|
178
|
+
const idx = mesh.triangles[i];
|
|
179
|
+
if (idx === void 0 || idx >= vertexCount) return validationError("VOXEL_INVALID_TRIANGLE_INDEX", `triangle index ${idx} at position ${i} is out of range for ${vertexCount} vertices.`);
|
|
180
|
+
}
|
|
181
|
+
if (queries.length % 3 !== 0) return validationError("VOXEL_INVALID_QUERIES", "queries length must be a multiple of 3 (flat xyz).");
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
function resolveEngine(id) {
|
|
185
|
+
try {
|
|
186
|
+
return ok(getVoxel(id));
|
|
187
|
+
} catch (cause) {
|
|
188
|
+
return err(moduleInitError("VOXEL_NOT_INITIALIZED", cause instanceof Error ? cause.message : "voxel engine not initialized", cause));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Generalized winding number at each query point against a triangle-soup mesh.
|
|
193
|
+
*
|
|
194
|
+
* `queries` is flat xyz (length 3·Q); the result has length Q. ~1 inside, ~0
|
|
195
|
+
* outside for a closed mesh; degrades gracefully on holes (the keystone that
|
|
196
|
+
* makes non-watertight repair possible — ADR-0013 §11).
|
|
197
|
+
*/
|
|
198
|
+
function windingNumbers(mesh, queries, id) {
|
|
199
|
+
const invalid = validateInputs(mesh, queries);
|
|
200
|
+
if (invalid) return err(invalid);
|
|
201
|
+
const engine = resolveEngine(id);
|
|
202
|
+
if (isErr(engine)) return engine;
|
|
203
|
+
return ok(engine.value.winding_numbers(mesh.vertices, mesh.triangles, queries));
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Inside/outside classification (winding number > 0.5) at each query point.
|
|
207
|
+
*
|
|
208
|
+
* `queries` is flat xyz (length 3·Q); the result has length Q.
|
|
209
|
+
*/
|
|
210
|
+
function pointsInside(mesh, queries, id) {
|
|
211
|
+
const invalid = validateInputs(mesh, queries);
|
|
212
|
+
if (invalid) return err(invalid);
|
|
213
|
+
const engine = resolveEngine(id);
|
|
214
|
+
if (isErr(engine)) return engine;
|
|
215
|
+
const flags = engine.value.points_inside(mesh.vertices, mesh.triangles, queries);
|
|
216
|
+
return ok(Array.from(flags, (flag) => flag === 1));
|
|
217
|
+
}
|
|
218
|
+
//#endregion
|
|
133
219
|
//#region src/core/kernelBoundary.ts
|
|
134
220
|
/** Convert Vec3 to a kernel 3D vector. Caller must call .delete() when done. */
|
|
135
221
|
function toKernelVec(v) {
|
|
@@ -5148,4 +5234,4 @@ var csg_exports = /* @__PURE__ */ __exportAll({
|
|
|
5148
5234
|
withEvaluator: () => withEvaluator
|
|
5149
5235
|
});
|
|
5150
5236
|
//#endregion
|
|
5151
|
-
export { BaseSketcher2d, BlueprintSketcher, BrepBugError, BrepErrorCode, BrepWrapperError, BrepkitAdapter, CompoundSketch, DEG2RAD, DisposalScope, FaceSketcher, HASH_CODE_MAX, OK, OcctWasmAdapter, RAD2DEG, Sketch, Sketcher, Sketches, addChild, addHoles, addMate, addStep, adjacentFaces, all, andThen, applyGlue, applyMatrix, approximateCurve, as2D, as3D, asTopo, assignRoles, autoHeal, bezier, blueprintToDXF, booleanPipeline, booleans_exports as booleans, boss, box, bsplineApprox, bug, cameraFromPlane, cameraLookAt, captureHint, cast, castShape, castShape3D, chamfer, chamferDistAngle as chamferDistAngleShape, chamferWithEvolution, checkAllInterferences, checkBoolean, checkInterference, circle, circularPattern, classifyPointOnFace, clearMeshCache, clone, closedWire, collect, collectShapes, colorFaces, colorShape, complexExtrude, composeTransforms, compound, compoundSketchExtrude, compoundSketchFace, compoundSketchLoft, compoundSketchRevolve, computationError, computeStraightSkeleton, cone, construction_exports as construction, convexHull, cornerFinder, countNodes, createAssembly, createAssemblyNode, createBlueprint, createCamera, createCompound, createCompoundBlueprint, createDistanceQuery, createEdge, createFace, createHandle, createHistory, createKernelHandle, createMeshCache, createNamedPlane, createOperationRegistry, createPlane, createRef, createRegistry, createShell, createSolid, createTaskQueue, createVertex, createWire, createWorkerClient, createWorkerHandler, csg_exports as csg, curve2dBoundingBox, curve2dDistanceFrom, curve2dFirstPoint, curve2dIsOnCurve, curve2dLastPoint, curve2dParameter, curve2dSplitAt, curve2dTangentAt, curveEndPoint, curveIsClosed, curveIsPeriodic, curveLength, curvePeriod, curvePointAt, curveStartPoint, curveTangentAt, cut, cut2D, cutAll, cutAllBisect, cutBlueprints, cutWithEvolution, cylinder, defaultScorer, dequeueTask, describe, deserializeDrawing, deserializeHistory, fromBREP as deserializeShape, downcast, draft, draw, drawCircle, drawEllipse, drawFaceOutline, drawParametricFunction, drawPointsInterpolation, drawPolysides, drawProjection, drawRectangle, drawRoundedRectangle, drawSingleCircle, drawSingleEllipse, drawText, drawingChamfer, drawingCut, drawingFillet, drawingFuse, drawingIntersect, drawingToSketchOnPlane, drill, edgeFinder, edgesOfFace, ellipse, ellipseArc, ellipsoid, enqueueTask, err, exportAssemblySTEP, exportDXF, exportGlb, exportGltf, exportIGES, exportOBJ, exportSTEP, exportSTEPConfigured, exportSTL, exportThreeMF, extrude, extrudeAll, face, faceCenter, faceFinder, faceGeomType, faceOrientation, facesOfEdge, fill, filledFace, fillet, filletWithEvolution, findFacesByTag, findNode, findStep, fixSelfIntersection, fixShape, flatMap, flatten, flipFaceOrientation, flipOrientation, fontMetrics, fromBREP$1 as fromBREP, fromKernelDir, fromKernelPnt, fromKernelVec, fromNullable, fuse, fuse2D, fuseAll, fuseAllBisect, fuseBlueprints, fuseWithEvolution, gearGeometry, getBounds, getBounds2D, getCompSolids, getCurveType, getDisposalStats, getEdges, getFaceColor, getFaceOrigins, getFaceTags, getFaces, getFont, getHashCode, getShape as getHistoryShape, getKernel, getNurbsCurveData, getNurbsSurfaceData, getOrientation, getOrientation2D, getPerformanceStats, getShapeColor, getShapeKind, getShells, getSingleFace, getSolids, getSurfaceType, getTagMetadata, getVertices, getWires, guidedSweep, heal, healFace, healSolid, healWire, helix, hull, importDXF, importGLB, importIGES, importOBJ, importSTEP, importSTL, importSVG, importSVGPathD, importThreeMF, init, initFromManifold, initFromOC, innerWires, interpolateCurve, intersect, intersect2D, intersectBlueprints, intersectWithEvolution, invalidateShapeCache, ioNs_exports as io, ioError, is2D, is3D, isChamferRadius, isClosedWire, isCompSolid, isCompound, isDisposeRequest, isEdge, isEmpty, isEqualShape, isErr, isErrorResponse, isFace, isFilletRadius, isInitRequest, isInside2D, isLive, isManifoldShell, isNumber, isOk, isOperationRequest, isOrientedFace, isPlanarFace, isPlanarWire, isProjectionPlane, isEmpty$1 as isQueueEmpty, isSameShape, isShape1D, isShape3D, isShell, isSolid, isSuccessResponse, isValid, isValidSolid, isVertex, isWire, iterCompSolids, iterEdges, iterFaces, iterShells, iterSolids, iterTopo, iterVertices, iterWires, kernelCall, kernelCallRaw, kernelCallScoped, kernelError, line, linearPattern, loadFont, loft, loftAll, makeBaseBox, makeExternalGear, makeInternalGear, makePlane, makePlanetaryGear, makeProjectedEdges, manifoldShell, map, mapBoth, mapErr, match, measureArea, measureCurvatureAt, measureCurvatureAtMid, measureDistance, measureDistanceProps, measureLength, measureLinearProps, measureSurfaceProps, measureVolume, measureVolumeProps, measurement_exports as measurement, mesh, meshEdges, meshMultiLOD, minkowski, mirror, mirror2D, mirrorDrawing, mirrorJoin, modifiers_exports as modifiers, modifyStep, moduleInitError, multiSectionSweep, normalAt, offset, offsetFace, offsetWire2D, ok, or, orElse, organiseBlueprints, orientedFace, outerWire, patterns_exports as patterns, pendingCount, pipeline, pivotPlane, planarFace, planarWire, planetPlacements, pocket, pointOnSurface, polygon, polyhedron, polysideInnerRadius, polysidesBlueprint, positionOnCurve, prewarm, primitives_exports as primitives, projectEdges, projectPointOnFace, query_exports as query, queryError, rectangularPattern, registerHandler, registerKernel, registerOperation, registerShape, rejectAll, removeChild, removeHolesFromFace, replayFrom, replayHistory, resetDisposalStats, resetPerformanceStats, resize, resolve, resolve3D, resolveDirection, resolvePlane, resolveRef, reverseCurve, revolve, roof, rotate, rotate2D, rotateDrawing, roundedRectangleBlueprint, scale, scale2D, scaleDrawing, section, sectionToFace, serializeHistory, setShapeOrigin, setTagMetadata, sewShells, shape, shapeType, sharedEdges, shell, shellWithEvolution, simplify, sketchCircle, sketchEllipse, sketchExtrude, sketchFace, sketchFaceOffset, sketchHelix, sketchLoft, sketchOnFace2D, sketchOnPlane2D, sketchParametricFunction, sketchPolysides, sketchRectangle, sketchRevolve, sketchRoundedRectangle, sketchSweep, sketchText, sketchWires, sketcherStateError, slice, solid, solidFromShell, solveAssembly, sphere, split, stepCount, stepsFrom, stretch2D, subFace, supportExtrude, supportsConstraintSketch, supportsProjection, surfaceFromGrid, surfaceFromImage, sweep, tagFaces, tangentArc, tap, tapErr, textBlueprints, textMetrics, thicken, threePointArc, toBREP, toBufferGeometryData, toGroupedBufferGeometryData, toKernelVec, toLODGeometryData, toLineGeometryData, toSVGPathD, toVec2, toVec3, torus, transformCopy, transforms_exports as transforms, translate, translate2D, translateDrawing, translatePlane, tryCatch, tryCatchAsync, twistExtrude, typeCastError, undoLast, unsupportedError, unwrap, unwrapErr, unwrapOr, unwrapOrElse, updateNode, updateRoles, uvBounds, uvCoordinates, validSolid, validatePlanetary, validationError, variableFillet, vecAdd, vecAngle, vecCross, vecDistance, vecDot, vecEquals, vecIsZero, vecLength, vecLengthSq, vecNegate, vecNormalize, vecProjectToPlane, vecRepr, vecRotate, vecScale, vecSub, vertex, vertexFinder, vertexPosition, verticesOfEdge, walkAssembly, wire, wireFinder, wireLoop, wiresOfFace, withKernel, withKernelDir, withKernelPnt, withKernelVec, withScope, withScopeResult, withScopeResultAsync, zip as zipResults };
|
|
5237
|
+
export { BaseSketcher2d, BlueprintSketcher, BrepBugError, BrepErrorCode, BrepWrapperError, BrepkitAdapter, CompoundSketch, DEG2RAD, DisposalScope, FaceSketcher, HASH_CODE_MAX, OK, OcctWasmAdapter, RAD2DEG, Sketch, Sketcher, Sketches, addChild, addHoles, addMate, addStep, adjacentFaces, all, andThen, applyGlue, applyMatrix, approximateCurve, as2D, as3D, asTopo, assignRoles, autoHeal, bezier, blueprintToDXF, booleanPipeline, booleans_exports as booleans, boss, box, bsplineApprox, bug, cameraFromPlane, cameraLookAt, captureHint, cast, castShape, castShape3D, chamfer, chamferDistAngle as chamferDistAngleShape, chamferWithEvolution, checkAllInterferences, checkBoolean, checkInterference, circle, circularPattern, classifyPointOnFace, clearMeshCache, clone, closedWire, collect, collectShapes, colorFaces, colorShape, complexExtrude, composeTransforms, compound, compoundSketchExtrude, compoundSketchFace, compoundSketchLoft, compoundSketchRevolve, computationError, computeStraightSkeleton, cone, construction_exports as construction, convexHull, cornerFinder, countNodes, createAssembly, createAssemblyNode, createBlueprint, createCamera, createCompound, createCompoundBlueprint, createDistanceQuery, createEdge, createFace, createHandle, createHistory, createKernelHandle, createMeshCache, createNamedPlane, createOperationRegistry, createPlane, createRef, createRegistry, createShell, createSolid, createTaskQueue, createVertex, createWire, createWorkerClient, createWorkerHandler, csg_exports as csg, curve2dBoundingBox, curve2dDistanceFrom, curve2dFirstPoint, curve2dIsOnCurve, curve2dLastPoint, curve2dParameter, curve2dSplitAt, curve2dTangentAt, curveEndPoint, curveIsClosed, curveIsPeriodic, curveLength, curvePeriod, curvePointAt, curveStartPoint, curveTangentAt, cut, cut2D, cutAll, cutAllBisect, cutBlueprints, cutWithEvolution, cylinder, defaultScorer, dequeueTask, describe, deserializeDrawing, deserializeHistory, fromBREP as deserializeShape, downcast, draft, draw, drawCircle, drawEllipse, drawFaceOutline, drawParametricFunction, drawPointsInterpolation, drawPolysides, drawProjection, drawRectangle, drawRoundedRectangle, drawSingleCircle, drawSingleEllipse, drawText, drawingChamfer, drawingCut, drawingFillet, drawingFuse, drawingIntersect, drawingToSketchOnPlane, drill, edgeFinder, edgesOfFace, ellipse, ellipseArc, ellipsoid, enqueueTask, err, exportAssemblySTEP, exportDXF, exportGlb, exportGltf, exportIGES, exportOBJ, exportSTEP, exportSTEPConfigured, exportSTL, exportThreeMF, extrude, extrudeAll, face, faceCenter, faceFinder, faceGeomType, faceOrientation, facesOfEdge, fill, filledFace, fillet, filletWithEvolution, findFacesByTag, findNode, findStep, fixSelfIntersection, fixShape, flatMap, flatten, flipFaceOrientation, flipOrientation, fontMetrics, fromBREP$1 as fromBREP, fromKernelDir, fromKernelPnt, fromKernelVec, fromNullable, fuse, fuse2D, fuseAll, fuseAllBisect, fuseBlueprints, fuseWithEvolution, gearGeometry, getActiveVoxelId, getBounds, getBounds2D, getCompSolids, getCurveType, getDisposalStats, getEdges, getFaceColor, getFaceOrigins, getFaceTags, getFaces, getFont, getHashCode, getShape as getHistoryShape, getKernel, getNurbsCurveData, getNurbsSurfaceData, getOrientation, getOrientation2D, getPerformanceStats, getShapeColor, getShapeKind, getShells, getSingleFace, getSolids, getSurfaceType, getTagMetadata, getVertices, getVoxel, getWires, guidedSweep, heal, healFace, healSolid, healWire, helix, hull, importDXF, importGLB, importIGES, importOBJ, importSTEP, importSTL, importSVG, importSVGPathD, importThreeMF, init, initFromManifold, initFromOC, initVoxel, innerWires, interpolateCurve, intersect, intersect2D, intersectBlueprints, intersectWithEvolution, invalidateShapeCache, ioNs_exports as io, ioError, is2D, is3D, isChamferRadius, isClosedWire, isCompSolid, isCompound, isDisposeRequest, isEdge, isEmpty, isEqualShape, isErr, isErrorResponse, isFace, isFilletRadius, isInitRequest, isInside2D, isLive, isManifoldShell, isNumber, isOk, isOperationRequest, isOrientedFace, isPlanarFace, isPlanarWire, isProjectionPlane, isEmpty$1 as isQueueEmpty, isSameShape, isShape1D, isShape3D, isShell, isSolid, isSuccessResponse, isValid, isValidSolid, isVertex, isWire, iterCompSolids, iterEdges, iterFaces, iterShells, iterSolids, iterTopo, iterVertices, iterWires, kernelCall, kernelCallRaw, kernelCallScoped, kernelError, line, linearPattern, loadFont, loft, loftAll, makeBaseBox, makeExternalGear, makeInternalGear, makePlane, makePlanetaryGear, makeProjectedEdges, manifoldShell, map, mapBoth, mapErr, match, measureArea, measureCurvatureAt, measureCurvatureAtMid, measureDistance, measureDistanceProps, measureLength, measureLinearProps, measureSurfaceProps, measureVolume, measureVolumeProps, measurement_exports as measurement, mesh, meshEdges, meshMultiLOD, minkowski, mirror, mirror2D, mirrorDrawing, mirrorJoin, modifiers_exports as modifiers, modifyStep, moduleInitError, multiSectionSweep, normalAt, offset, offsetFace, offsetWire2D, ok, or, orElse, organiseBlueprints, orientedFace, outerWire, patterns_exports as patterns, pendingCount, pipeline, pivotPlane, planarFace, planarWire, planetPlacements, pocket, pointOnSurface, pointsInside, polygon, polyhedron, polysideInnerRadius, polysidesBlueprint, positionOnCurve, prewarm, primitives_exports as primitives, projectEdges, projectPointOnFace, query_exports as query, queryError, rectangularPattern, registerHandler, registerKernel, registerOperation, registerShape, registerVoxel, rejectAll, removeChild, removeHolesFromFace, replayFrom, replayHistory, resetDisposalStats, resetPerformanceStats, resize, resolve, resolve3D, resolveDirection, resolvePlane, resolveRef, reverseCurve, revolve, roof, rotate, rotate2D, rotateDrawing, roundedRectangleBlueprint, scale, scale2D, scaleDrawing, section, sectionToFace, serializeHistory, setShapeOrigin, setTagMetadata, sewShells, shape, shapeType, sharedEdges, shell, shellWithEvolution, simplify, sketchCircle, sketchEllipse, sketchExtrude, sketchFace, sketchFaceOffset, sketchHelix, sketchLoft, sketchOnFace2D, sketchOnPlane2D, sketchParametricFunction, sketchPolysides, sketchRectangle, sketchRevolve, sketchRoundedRectangle, sketchSweep, sketchText, sketchWires, sketcherStateError, slice, solid, solidFromShell, solveAssembly, sphere, split, stepCount, stepsFrom, stretch2D, subFace, supportExtrude, supportsConstraintSketch, supportsProjection, surfaceFromGrid, surfaceFromImage, sweep, tagFaces, tangentArc, tap, tapErr, textBlueprints, textMetrics, thicken, threePointArc, toBREP, toBufferGeometryData, toGroupedBufferGeometryData, toKernelVec, toLODGeometryData, toLineGeometryData, toSVGPathD, toVec2, toVec3, torus, transformCopy, transforms_exports as transforms, translate, translate2D, translateDrawing, translatePlane, tryCatch, tryCatchAsync, twistExtrude, typeCastError, undoLast, unsupportedError, unwrap, unwrapErr, unwrapOr, unwrapOrElse, updateNode, updateRoles, uvBounds, uvCoordinates, validSolid, validatePlanetary, validationError, variableFillet, vecAdd, vecAngle, vecCross, vecDistance, vecDot, vecEquals, vecIsZero, vecLength, vecLengthSq, vecNegate, vecNormalize, vecProjectToPlane, vecRepr, vecRotate, vecScale, vecSub, vertex, vertexFinder, vertexPosition, verticesOfEdge, walkAssembly, windingNumbers, wire, wireFinder, wireLoop, wiresOfFace, withKernel, withKernelDir, withKernelPnt, withKernelVec, withScope, withScopeResult, withScopeResultAsync, zip as zipResults };
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ export { exportDXF, blueprintToDXF, type DXFEntity, type DXFExportOptions, } fro
|
|
|
34
34
|
export { exportThreeMF, type ThreeMFExportOptions, type ThreeMFMaterial, } from './io/threemfExportFns.js';
|
|
35
35
|
export { importSVGPathD, importSVG, type SVGImportOptions } from './io/svgImportFns.js';
|
|
36
36
|
export { exportSTEPConfigured, type StepExportOptions, type StepExportPart, } from './io/stepConfigFns.js';
|
|
37
|
+
export { initVoxel, registerVoxel, getVoxel, getActiveVoxelId, windingNumbers, pointsInside, } from './voxel/index.js';
|
|
38
|
+
export type { VoxelEngine, VoxelMeshInput } from './voxel/index.js';
|
|
37
39
|
export { default as Sketcher } from './sketching/sketcher.js';
|
|
38
40
|
export { default as FaceSketcher } from './sketching/faceSketcher.js';
|
|
39
41
|
export { BaseSketcher2d } from './2d/blueprints/baseSketcher2d.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wasm surface the voxel domain depends on — structurally satisfied by the
|
|
3
|
+
* loaded `brepjs-voxel-wasm` module. Kept snake_case to match the wasm-bindgen
|
|
4
|
+
* exports exactly, so the raw module is a zero-adapter `VoxelEngine`.
|
|
5
|
+
*
|
|
6
|
+
* All buffers are flat (no zero-copy across the wasm boundary, per ADR-0013):
|
|
7
|
+
* `verts` is xyz·V, `tris` is index·T, `queries` is xyz·Q.
|
|
8
|
+
*/
|
|
9
|
+
export interface VoxelEngine {
|
|
10
|
+
/** Generalized winding number per query point (~1 inside, ~0 outside). */
|
|
11
|
+
winding_numbers(verts: Float32Array, tris: Uint32Array, queries: Float32Array): Float32Array;
|
|
12
|
+
/** Inside/outside classification per query point (1 = inside, 0 = outside). */
|
|
13
|
+
points_inside(verts: Float32Array, tris: Uint32Array, queries: Float32Array): Uint8Array;
|
|
14
|
+
/** Engine artifact version, for loader/artifact compatibility checks. */
|
|
15
|
+
version(): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Voxel / SDF geometry domain (ADR-0013).
|
|
3
|
+
*
|
|
4
|
+
* A parallel domain to the B-rep kernel: its own engine registry and functional
|
|
5
|
+
* API. v1 surfaces the repair-slice keystone (Generalized Winding Number sign);
|
|
6
|
+
* grid / contour / bridge seams land behind the same registry.
|
|
7
|
+
*/
|
|
8
|
+
export type { VoxelEngine } from './engine.js';
|
|
9
|
+
export type { VoxelMeshInput } from './signFns.js';
|
|
10
|
+
export { registerVoxel, getVoxel, getActiveVoxelId, initVoxel } from './registry.js';
|
|
11
|
+
export { windingNumbers, pointsInside } from './signFns.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { VoxelEngine } from './engine.js';
|
|
2
|
+
export declare function registerVoxel(id: string, engine: VoxelEngine): void;
|
|
3
|
+
/**
|
|
4
|
+
* Return a voxel engine by id, or the default engine if no id is given.
|
|
5
|
+
*
|
|
6
|
+
* @throws If no engine has been registered via {@link initVoxel} or
|
|
7
|
+
* {@link registerVoxel}.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getVoxel(id?: string): VoxelEngine;
|
|
10
|
+
/** Return the id of the active default engine, or `null` if none is registered. */
|
|
11
|
+
export declare function getActiveVoxelId(): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Register a loaded voxel engine and make it the default.
|
|
14
|
+
*
|
|
15
|
+
* Mirrors {@link initFromOC} for the kernel: the loader package
|
|
16
|
+
* (`brepjs-voxel`) instantiates the wasm, then hands the engine here.
|
|
17
|
+
*/
|
|
18
|
+
export declare function initVoxel(engine: VoxelEngine, id?: string): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Result } from '../core/result.js';
|
|
2
|
+
/**
|
|
3
|
+
* Minimal triangle-soup input for sign queries. Structurally satisfied by a
|
|
4
|
+
* {@link KernelMeshResult} (which also carries normals/uvs/faceGroups).
|
|
5
|
+
*/
|
|
6
|
+
export interface VoxelMeshInput {
|
|
7
|
+
vertices: Float32Array;
|
|
8
|
+
triangles: Uint32Array;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Generalized winding number at each query point against a triangle-soup mesh.
|
|
12
|
+
*
|
|
13
|
+
* `queries` is flat xyz (length 3·Q); the result has length Q. ~1 inside, ~0
|
|
14
|
+
* outside for a closed mesh; degrades gracefully on holes (the keystone that
|
|
15
|
+
* makes non-watertight repair possible — ADR-0013 §11).
|
|
16
|
+
*/
|
|
17
|
+
export declare function windingNumbers(mesh: VoxelMeshInput, queries: Float32Array, id?: string): Result<Float32Array>;
|
|
18
|
+
/**
|
|
19
|
+
* Inside/outside classification (winding number > 0.5) at each query point.
|
|
20
|
+
*
|
|
21
|
+
* `queries` is flat xyz (length 3·Q); the result has length Q.
|
|
22
|
+
*/
|
|
23
|
+
export declare function pointsInside(mesh: VoxelMeshInput, queries: Float32Array, id?: string): Result<boolean[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brepjs",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.36.0",
|
|
4
4
|
"description": "Web CAD library with pluggable geometry kernel",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cad",
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"packages/brepjs-opencascade",
|
|
26
26
|
"packages/brepjs-bim",
|
|
27
27
|
"packages/brepjs-manifold",
|
|
28
|
+
"packages/brepjs-voxel-wasm",
|
|
29
|
+
"packages/brepjs-voxel",
|
|
28
30
|
"packages/brepjs-agent",
|
|
29
31
|
"packages/brepjs-viewer",
|
|
30
32
|
"apps/playground",
|