fluidcad 0.0.2 → 0.0.4
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/README.md +7 -7
- package/lib/dist/common/shape-factory.d.ts +1 -1
- package/lib/dist/oc/boolean-ops.d.ts +2 -2
- package/lib/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/lib/dist/constraints/constraint.d.ts +0 -11
- package/lib/dist/constraints/constraint.js +0 -51
- package/lib/dist/constraints/outside.d.ts +0 -3
- package/lib/dist/constraints/outside.js +0 -4
- package/lib/dist/core/2d/aslot.d.ts +0 -12
- package/lib/dist/core/2d/aslot.js +0 -40
- package/lib/dist/core/2d/crect.d.ts +0 -12
- package/lib/dist/core/2d/crect.js +0 -74
- package/lib/dist/core/2d/face-maker.d.ts +0 -13
- package/lib/dist/core/2d/face-maker.js +0 -119
- package/lib/dist/core/2d/face-maker2.d.ts +0 -6
- package/lib/dist/core/2d/face-maker2.js +0 -54
- package/lib/dist/core/region.d.ts +0 -13
- package/lib/dist/core/region.js +0 -18
- package/lib/dist/features/2d/amove.d.ts +0 -14
- package/lib/dist/features/2d/amove.js +0 -33
- package/lib/dist/features/2d/constraints/constraint.d.ts +0 -11
- package/lib/dist/features/2d/constraints/constraint.js +0 -49
- package/lib/dist/features/2d/constraints/outside.d.ts +0 -3
- package/lib/dist/features/2d/constraints/outside.js +0 -4
- package/lib/dist/features/2d/tarc-two-circles.d.ts +0 -18
- package/lib/dist/features/2d/tarc-two-circles.js +0 -61
- package/lib/dist/features/2d/tcircle-three-tan.d.ts +0 -13
- package/lib/dist/features/2d/tcircle-three-tan.js +0 -33
- package/lib/dist/features/2d/tcircle-two-tan.d.ts +0 -13
- package/lib/dist/features/2d/tcircle-two-tan.js +0 -33
- package/lib/dist/features/Extrude.d.ts +0 -1
- package/lib/dist/features/Extrude.js +0 -1
- package/lib/dist/features/cut-base.d.ts +0 -49
- package/lib/dist/features/cut-base.js +0 -312
- package/lib/dist/features/cut-symmetric.d.ts +0 -23
- package/lib/dist/features/cut-symmetric.js +0 -119
- package/lib/dist/features/cut-two-distances.d.ts +0 -24
- package/lib/dist/features/cut-two-distances.js +0 -110
- package/lib/dist/features/cut.d.ts +0 -27
- package/lib/dist/features/cut.js +0 -101
- package/lib/dist/features/extrude-symmetric.d.ts +0 -28
- package/lib/dist/features/extrude-symmetric.js +0 -177
- package/lib/dist/features/region2d.d.ts +0 -25
- package/lib/dist/features/region2d.js +0 -185
- package/lib/dist/features/repeat-circular2d.d.ts +0 -17
- package/lib/dist/features/repeat-circular2d.js +0 -90
- package/lib/dist/features/repeat-linear2d.d.ts +0 -17
- package/lib/dist/features/repeat-linear2d.js +0 -114
- package/lib/dist/features/revolve-options.d.ts +0 -6
- package/lib/dist/features/revolve-options.js +0 -1
- package/lib/dist/features/split.d.ts +0 -14
- package/lib/dist/features/split.js +0 -74
- package/lib/dist/features/state-scene-object.d.ts +0 -15
- package/lib/dist/features/state-scene-object.js +0 -44
- package/lib/dist/features/state-select.d.ts +0 -21
- package/lib/dist/features/state-select.js +0 -73
- package/lib/dist/features/translate2d.d.ts +0 -16
- package/lib/dist/features/translate2d.js +0 -61
- package/lib/dist/filters/all-filter.d.ts +0 -8
- package/lib/dist/filters/all-filter.js +0 -12
- package/lib/dist/filters/near-point-filter.d.ts +0 -11
- package/lib/dist/filters/near-point-filter.js +0 -33
- package/lib/dist/helpers/resolve-filters.d.ts +0 -6
- package/lib/dist/helpers/resolve-filters.js +0 -25
- package/lib/dist/math/axis.test.d.ts +0 -1
- package/lib/dist/math/axis.test.js +0 -287
- package/lib/dist/math/coordinate-system.test.d.ts +0 -1
- package/lib/dist/math/coordinate-system.test.js +0 -308
- package/lib/dist/math/matrix4.test.d.ts +0 -1
- package/lib/dist/math/matrix4.test.js +0 -357
- package/lib/dist/math/plane.test.d.ts +0 -1
- package/lib/dist/math/plane.test.js +0 -398
- package/lib/dist/math/point.test.d.ts +0 -1
- package/lib/dist/math/point.test.js +0 -385
- package/lib/dist/math/quaternion.test.d.ts +0 -1
- package/lib/dist/math/quaternion.test.js +0 -278
- package/lib/dist/math/vector3d.test.d.ts +0 -1
- package/lib/dist/math/vector3d.test.js +0 -276
- package/lib/dist/oc/constraint-resolver.d.ts +0 -7
- package/lib/dist/oc/constraint-resolver.js +0 -31
- package/lib/dist/oc/constraints/curve-constraint-solver.d.ts +0 -1
- package/lib/dist/oc/constraints/curve-constraint-solver.js +0 -2
- package/lib/dist/oc/constraints/geometric-constraint-solver.d.ts +0 -1
- package/lib/dist/oc/constraints/geometric-constraint-solver.js +0 -5
- package/lib/dist/oc/face-maker.d.ts +0 -14
- package/lib/dist/oc/face-maker.js +0 -191
- package/lib/dist/oc/measure.d.ts +0 -21
- package/lib/dist/oc/measure.js +0 -256
- package/lib/dist/oc/tangent-circle-solver.d.ts +0 -17
- package/lib/dist/oc/tangent-circle-solver.js +0 -72
- package/lib/dist/oc/tangent-line-solver.d.ts +0 -17
- package/lib/dist/oc/tangent-line-solver.js +0 -83
- package/lib/dist/oc/tangent-solver.d.ts +0 -14
- package/lib/dist/oc/tangent-solver.js +0 -199
- package/lib/dist/rendering/builder-context.d.ts +0 -16
- package/lib/dist/rendering/builder-context.js +0 -63
- package/lib/dist/tests/extrude.test.d.ts +0 -1
- package/lib/dist/tests/extrude.test.js +0 -48
- package/lib/dist/tests/features/copy.test.d.ts +0 -1
- package/lib/dist/tests/features/copy.test.js +0 -158
- package/lib/dist/tests/features/dispose.test.d.ts +0 -1
- package/lib/dist/tests/features/dispose.test.js +0 -189
- package/lib/dist/tests/features/part-pick.test.d.ts +0 -1
- package/lib/dist/tests/features/part-pick.test.js +0 -73
- package/lib/dist/tests/features/part-repeat.test.d.ts +0 -1
- package/lib/dist/tests/features/part-repeat.test.js +0 -109
- package/server/dist/fluidcad-server.d.ts +0 -32
- package/server/dist/fluidcad-server.js +0 -150
- package/server/dist/index.d.ts +0 -1
- package/server/dist/index.js +0 -290
- package/server/dist/routes/actions.d.ts +0 -3
- package/server/dist/routes/actions.js +0 -100
- package/server/dist/routes/export.d.ts +0 -3
- package/server/dist/routes/export.js +0 -55
- package/server/dist/routes/properties.d.ts +0 -3
- package/server/dist/routes/properties.js +0 -46
- package/server/dist/routes/screenshot.d.ts +0 -2
- package/server/dist/routes/screenshot.js +0 -76
- package/server/dist/vite-manager.d.ts +0 -10
- package/server/dist/vite-manager.js +0 -64
- package/server/dist/ws-protocol.d.ts +0 -138
- package/server/dist/ws-protocol.js +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fluidcad",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Parametric CAD modeling library using javascript",
|
|
5
5
|
"author": "Marwan Aouida <contact@marwan.dev>",
|
|
6
6
|
"homepage": "https://fluidcad.io",
|
|
@@ -39,10 +39,11 @@
|
|
|
39
39
|
"./server": "./server/dist/index.js"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
|
+
"clean": "rm -rf lib/dist server/dist ui/dist",
|
|
42
43
|
"build:lib": "tsc -p lib/tsconfig.json",
|
|
43
44
|
"build:server": "tsc -p server/tsconfig.json",
|
|
44
45
|
"build:ui": "vite build --config ui/vite.config.ts",
|
|
45
|
-
"build": "npm run build:lib && npm run build:server && npm run build:ui",
|
|
46
|
+
"build": "npm run clean && npm run build:lib && npm run build:server && npm run build:ui",
|
|
46
47
|
"prepublishOnly": "npm run build",
|
|
47
48
|
"dev:lib": "tsc -p lib/tsconfig.json --watch",
|
|
48
49
|
"dev:server": "node --experimental-transform-types --no-warnings server/src/index.ts",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { GccEnt_Position, gp_Pln } from "occjs-wrapper";
|
|
2
|
-
import { Comparable, SceneObject } from "../common/scene-object.js";
|
|
3
|
-
export type ConstraintQualifier = 'any' | 'outside' | 'enclosed' | 'enclosing';
|
|
4
|
-
export declare class GeometricConstraint implements Comparable<GeometricConstraint> {
|
|
5
|
-
private object;
|
|
6
|
-
private qualifier;
|
|
7
|
-
constructor(object: SceneObject, qualifier: ConstraintQualifier);
|
|
8
|
-
getQualified(plane: gp_Pln): import("occjs-wrapper").GccEnt_QualifiedCirc | import("occjs-wrapper").GccEnt_QualifiedLin;
|
|
9
|
-
getQualifier(qualifier: ConstraintQualifier): GccEnt_Position;
|
|
10
|
-
compareTo(other: GeometricConstraint): boolean;
|
|
11
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { getOC } from "../load.js";
|
|
2
|
-
import { Geometry } from "../oc/geometry.js";
|
|
3
|
-
export class GeometricConstraint {
|
|
4
|
-
object;
|
|
5
|
-
qualifier;
|
|
6
|
-
constructor(object, qualifier) {
|
|
7
|
-
this.object = object;
|
|
8
|
-
this.qualifier = qualifier;
|
|
9
|
-
}
|
|
10
|
-
getQualified(plane) {
|
|
11
|
-
const oc = getOC();
|
|
12
|
-
const shape = this.object.getShapes()[0];
|
|
13
|
-
const adaptor = new oc.BRepAdaptor_Curve(shape.getShape());
|
|
14
|
-
const type = adaptor.GetType();
|
|
15
|
-
if (type === oc.GeomAbs_CurveType.GeomAbs_Circle) {
|
|
16
|
-
const circle = adaptor.Circle();
|
|
17
|
-
adaptor.delete();
|
|
18
|
-
const c1 = Geometry.get2dCircleRaw(plane, circle);
|
|
19
|
-
circle.delete();
|
|
20
|
-
const qualifier = this.getQualifier(this.qualifier);
|
|
21
|
-
const qualified = new oc.GccEnt_QualifiedCirc(c1, qualifier);
|
|
22
|
-
return qualified;
|
|
23
|
-
}
|
|
24
|
-
else if (type === oc.GeomAbs_CurveType.GeomAbs_Line) {
|
|
25
|
-
const line = adaptor.Line();
|
|
26
|
-
adaptor.delete();
|
|
27
|
-
const l1 = Geometry.get2dLineRaw(plane, line);
|
|
28
|
-
line.delete();
|
|
29
|
-
const qualifier = this.getQualifier(this.qualifier);
|
|
30
|
-
const qualified = new oc.GccEnt_QualifiedLin(l1, qualifier);
|
|
31
|
-
return qualified;
|
|
32
|
-
}
|
|
33
|
-
throw new Error('Unsupported shape type for constraint: ' + type);
|
|
34
|
-
}
|
|
35
|
-
getQualifier(qualifier) {
|
|
36
|
-
const oc = getOC();
|
|
37
|
-
switch (qualifier) {
|
|
38
|
-
case 'any':
|
|
39
|
-
return oc.GccEnt_Position.GccEnt_unqualified;
|
|
40
|
-
case 'enclosed':
|
|
41
|
-
return oc.GccEnt_Position.GccEnt_enclosed;
|
|
42
|
-
case 'enclosing':
|
|
43
|
-
return oc.GccEnt_Position.GccEnt_enclosing;
|
|
44
|
-
case 'outside':
|
|
45
|
-
return oc.GccEnt_Position.GccEnt_outside;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
compareTo(other) {
|
|
49
|
-
return this.qualifier === other.qualifier && this.object.compareTo(other.object);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Point2DLike } from "../../math/point.js";
|
|
2
|
-
import { Slot } from "../../features/2d/slot.js";
|
|
3
|
-
import { PlaneLike } from "../../math/plane.js";
|
|
4
|
-
import { SceneObject } from "../../common/scene-object.js";
|
|
5
|
-
interface ASlotFunction {
|
|
6
|
-
(distance: number, radius: number, angle: number, centered?: boolean): Slot;
|
|
7
|
-
(start: Point2DLike, distance: number, radius: number, angle: number): Slot;
|
|
8
|
-
(distance: number, radius: number, angle: number, targetPlane: PlaneLike | SceneObject): Slot;
|
|
9
|
-
(distance: number, radius: number, angle: number, centered: boolean, targetPlane: PlaneLike | SceneObject): Slot;
|
|
10
|
-
}
|
|
11
|
-
declare const _default: ASlotFunction;
|
|
12
|
-
export default _default;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { isPoint2DLike } from "../../math/point.js";
|
|
2
|
-
import { Move } from "../../features/2d/move.js";
|
|
3
|
-
import { Slot } from "../../features/2d/slot.js";
|
|
4
|
-
import { normalizePoint2D } from "../../helpers/normalize.js";
|
|
5
|
-
import { registerBuilder } from "../../index.js";
|
|
6
|
-
import { isPlaneLike } from "../../math/plane.js";
|
|
7
|
-
import { SceneObject } from "../../common/scene-object.js";
|
|
8
|
-
import { resolvePlane } from "../../helpers/resolve.js";
|
|
9
|
-
function build(context) {
|
|
10
|
-
return function aSlot() {
|
|
11
|
-
let planeObj = null;
|
|
12
|
-
let argCount = arguments.length;
|
|
13
|
-
// Detect plane as last argument
|
|
14
|
-
if (argCount > 0) {
|
|
15
|
-
const lastArg = arguments[argCount - 1];
|
|
16
|
-
if (isPlaneLike(lastArg) || (lastArg instanceof SceneObject && !isPoint2DLike(lastArg))) {
|
|
17
|
-
planeObj = resolvePlane(lastArg, context);
|
|
18
|
-
argCount--;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
if (typeof arguments[0] !== 'number') {
|
|
22
|
-
// aslot(start, distance, radius, angle)
|
|
23
|
-
const start = normalizePoint2D(arguments[0]);
|
|
24
|
-
const distance = arguments[1];
|
|
25
|
-
const radius = arguments[2];
|
|
26
|
-
const angle = arguments[3];
|
|
27
|
-
const s = new Slot(distance, radius, false, angle, planeObj);
|
|
28
|
-
context.addSceneObjects([new Move(start), s]);
|
|
29
|
-
return s;
|
|
30
|
-
}
|
|
31
|
-
const distance = arguments[0];
|
|
32
|
-
const radius = arguments[1];
|
|
33
|
-
const angle = arguments[2];
|
|
34
|
-
const centered = argCount === 4 ? arguments[3] : false;
|
|
35
|
-
const s = new Slot(distance, radius, centered, angle, planeObj);
|
|
36
|
-
context.addSceneObject(s);
|
|
37
|
-
return s;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
export default registerBuilder(build);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Point2DLike } from "../../math/point.js";
|
|
2
|
-
import { Rect, RectOptions } from "../../features/2d/rect.js";
|
|
3
|
-
import { PlaneLike } from "../../math/plane.js";
|
|
4
|
-
import { SceneObject } from "../../common/scene-object.js";
|
|
5
|
-
interface CRectFunction {
|
|
6
|
-
(width: number, height?: number, options?: RectOptions): Rect;
|
|
7
|
-
(start: Point2DLike, width: number, height?: number, options?: RectOptions): Rect;
|
|
8
|
-
(width: number, height: number, targetPlane: PlaneLike | SceneObject): Rect;
|
|
9
|
-
(width: number, height: number, options: RectOptions, targetPlane: PlaneLike | SceneObject): Rect;
|
|
10
|
-
}
|
|
11
|
-
declare const _default: CRectFunction;
|
|
12
|
-
export default _default;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { isPoint2DLike } from "../../math/point.js";
|
|
2
|
-
import { Move } from "../../features/2d/move.js";
|
|
3
|
-
import { Rect } from "../../features/2d/rect.js";
|
|
4
|
-
import { normalizePoint2D } from "../../helpers/normalize.js";
|
|
5
|
-
import { registerBuilder } from "../../index.js";
|
|
6
|
-
import { isPlaneLike } from "../../math/plane.js";
|
|
7
|
-
import { SceneObject } from "../../common/scene-object.js";
|
|
8
|
-
import { resolvePlane } from "../../helpers/resolve.js";
|
|
9
|
-
function build(context) {
|
|
10
|
-
return function cRect() {
|
|
11
|
-
let width;
|
|
12
|
-
let height;
|
|
13
|
-
let options;
|
|
14
|
-
let start;
|
|
15
|
-
let rect;
|
|
16
|
-
let planeObj = null;
|
|
17
|
-
let argCount = arguments.length;
|
|
18
|
-
// Detect plane as last argument
|
|
19
|
-
if (argCount > 0) {
|
|
20
|
-
const lastArg = arguments[argCount - 1];
|
|
21
|
-
if (isPlaneLike(lastArg) || (lastArg instanceof SceneObject && !isPoint2DLike(lastArg))) {
|
|
22
|
-
planeObj = resolvePlane(lastArg, context);
|
|
23
|
-
argCount--;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (argCount === 1) {
|
|
27
|
-
width = arguments[0];
|
|
28
|
-
height = width;
|
|
29
|
-
rect = new Rect(width, height, true, options, planeObj);
|
|
30
|
-
context.addSceneObject(rect);
|
|
31
|
-
}
|
|
32
|
-
else if (argCount === 2) {
|
|
33
|
-
if (typeof arguments[0] === 'number') {
|
|
34
|
-
width = arguments[0];
|
|
35
|
-
height = arguments[1];
|
|
36
|
-
rect = new Rect(width, height, true, options, planeObj);
|
|
37
|
-
context.addSceneObject(rect);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
start = normalizePoint2D(arguments[0]);
|
|
41
|
-
width = arguments[1];
|
|
42
|
-
height = width;
|
|
43
|
-
rect = new Rect(width, height, true, options, planeObj);
|
|
44
|
-
context.addSceneObjects([new Move(start), rect]);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else if (argCount === 3) {
|
|
48
|
-
if (typeof arguments[0] === 'number') {
|
|
49
|
-
width = arguments[0];
|
|
50
|
-
height = arguments[1];
|
|
51
|
-
options = arguments[2];
|
|
52
|
-
rect = new Rect(width, height, true, options, planeObj);
|
|
53
|
-
context.addSceneObject(rect);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
start = normalizePoint2D(arguments[0]);
|
|
57
|
-
width = arguments[1];
|
|
58
|
-
height = arguments[2];
|
|
59
|
-
rect = new Rect(width, height, true, options, planeObj);
|
|
60
|
-
context.addSceneObjects([new Move(start), rect]);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else if (argCount === 4) {
|
|
64
|
-
start = normalizePoint2D(arguments[0]);
|
|
65
|
-
width = arguments[1];
|
|
66
|
-
height = arguments[2];
|
|
67
|
-
options = arguments[3];
|
|
68
|
-
rect = new Rect(width, height, true, options, planeObj);
|
|
69
|
-
context.addSceneObjects([new Move(start), rect]);
|
|
70
|
-
}
|
|
71
|
-
return rect;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
export default registerBuilder(build);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Wire } from "../../common/wire.js";
|
|
2
|
-
import { Plane } from "../../math/plane.js";
|
|
3
|
-
import { Face } from "../../common/face.js";
|
|
4
|
-
import { Edge } from "../../common/edge.js";
|
|
5
|
-
export declare class FaceMaker {
|
|
6
|
-
static getFaces(shapes: Array<Wire | Edge>, plane: Plane): Face[];
|
|
7
|
-
static unifyWires(shapes: (Wire | Edge)[]): Wire[];
|
|
8
|
-
private static createFacesFromWires;
|
|
9
|
-
private static fuseIntersectingFaces;
|
|
10
|
-
private static boundingBoxesIntersect;
|
|
11
|
-
private static getFaceInfos;
|
|
12
|
-
private static getWiresFromFaces;
|
|
13
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { FaceDriller } from "./face-driller.js";
|
|
2
|
-
import { Wire } from "../../common/wire.js";
|
|
3
|
-
import { FaceOps } from "../../oc/face-ops.js";
|
|
4
|
-
import { Explorer } from "../../oc/explorer.js";
|
|
5
|
-
import { ShapeOps } from "../../oc/shape-ops.js";
|
|
6
|
-
import { Edge } from "../../common/edge.js";
|
|
7
|
-
import { WireOps } from "../../oc/wire-ops.js";
|
|
8
|
-
export class FaceMaker {
|
|
9
|
-
static getFaces(shapes, plane) {
|
|
10
|
-
const wires = this.unifyWires(shapes);
|
|
11
|
-
let faces = this.createFacesFromWires(wires, plane);
|
|
12
|
-
console.log("====== Faces before fuse:", faces.length);
|
|
13
|
-
faces = this.fuseIntersectingFaces(faces);
|
|
14
|
-
console.log("====== Faces after fuse:", faces.length);
|
|
15
|
-
const newWires = this.getWiresFromFaces(faces);
|
|
16
|
-
let faceInfo = this.getFaceInfos(faces, newWires);
|
|
17
|
-
const faceDriller = new FaceDriller(faceInfo);
|
|
18
|
-
faceInfo = faceDriller.drillHoles();
|
|
19
|
-
console.log("====== Faces after drilling holes:", faceInfo.length);
|
|
20
|
-
return faceInfo.map(info => info.face);
|
|
21
|
-
}
|
|
22
|
-
static unifyWires(shapes) {
|
|
23
|
-
const wires = [];
|
|
24
|
-
for (let shape of shapes) {
|
|
25
|
-
if (shape instanceof Wire) {
|
|
26
|
-
wires.push(shape);
|
|
27
|
-
}
|
|
28
|
-
else if (shape instanceof Edge) {
|
|
29
|
-
const wire = WireOps.makeWireFromEdges([shape]);
|
|
30
|
-
wires.push(wire);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return wires;
|
|
34
|
-
}
|
|
35
|
-
static createFacesFromWires(wires, plane) {
|
|
36
|
-
if (wires.length === 0)
|
|
37
|
-
return [];
|
|
38
|
-
console.log("Creating faces from wires:", wires.length);
|
|
39
|
-
const faces = [];
|
|
40
|
-
for (let wire of wires) {
|
|
41
|
-
const face = FaceOps.makeFaceOnPlaneWrapped(wire, plane);
|
|
42
|
-
const fixedFace = FaceOps.fixFaceOrientation(face);
|
|
43
|
-
faces.push(fixedFace);
|
|
44
|
-
}
|
|
45
|
-
return faces;
|
|
46
|
-
}
|
|
47
|
-
static fuseIntersectingFaces(faces) {
|
|
48
|
-
if (faces.length === 0)
|
|
49
|
-
return [];
|
|
50
|
-
if (faces.length === 1)
|
|
51
|
-
return faces;
|
|
52
|
-
// Pre-compute bounding boxes for all faces
|
|
53
|
-
const faceBoxes = faces.map((face, index) => ({
|
|
54
|
-
face,
|
|
55
|
-
index,
|
|
56
|
-
bbox: ShapeOps.getBoundingBox(face)
|
|
57
|
-
}));
|
|
58
|
-
const result = [];
|
|
59
|
-
const processedFaces = new Set();
|
|
60
|
-
for (let i = 0; i < faces.length; i++) {
|
|
61
|
-
const face1 = faces[i];
|
|
62
|
-
if (processedFaces.has(face1)) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
let fusedFace = face1;
|
|
66
|
-
const facesToFuse = [face1];
|
|
67
|
-
let bbox1 = faceBoxes[i].bbox;
|
|
68
|
-
// Find all faces that intersect with face1 using bounding box pre-filtering
|
|
69
|
-
for (let j = i + 1; j < faces.length; j++) {
|
|
70
|
-
const face2 = faces[j];
|
|
71
|
-
if (processedFaces.has(face2)) {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
const bbox2 = faceBoxes[j].bbox;
|
|
75
|
-
// Quick bounding box intersection test before expensive geometric operations
|
|
76
|
-
if (!this.boundingBoxesIntersect(bbox1, bbox2)) {
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
const newFusedFace = FaceOps.fuseFacesAndUnify(fusedFace, face2);
|
|
80
|
-
if (newFusedFace) {
|
|
81
|
-
fusedFace = newFusedFace;
|
|
82
|
-
bbox1 = ShapeOps.getBoundingBox(fusedFace);
|
|
83
|
-
facesToFuse.push(face2);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// Add the final fused face to results
|
|
87
|
-
result.push(fusedFace);
|
|
88
|
-
// Mark all processed faces
|
|
89
|
-
facesToFuse.forEach(face => processedFaces.add(face));
|
|
90
|
-
}
|
|
91
|
-
console.log("Fused faces count:", result.length);
|
|
92
|
-
return result;
|
|
93
|
-
}
|
|
94
|
-
static boundingBoxesIntersect(bbox1, bbox2) {
|
|
95
|
-
return !(bbox1.maxX < bbox2.minX || bbox2.maxX < bbox1.minX ||
|
|
96
|
-
bbox1.maxY < bbox2.minY || bbox2.maxY < bbox1.minY);
|
|
97
|
-
}
|
|
98
|
-
static getFaceInfos(faces, facesWires) {
|
|
99
|
-
const faceInfos = faces.map((face, index) => {
|
|
100
|
-
const bbox = ShapeOps.getBoundingBox(face);
|
|
101
|
-
const diagonal = Math.sqrt(Math.pow(bbox.maxX - bbox.minX, 2) + Math.pow(bbox.maxY - bbox.minY, 2));
|
|
102
|
-
return { face, wire: facesWires[index], bbox, diagonal };
|
|
103
|
-
});
|
|
104
|
-
// Sort by diagonal size (largest first for better hole containment logic)
|
|
105
|
-
faceInfos.sort((a, b) => b.diagonal - a.diagonal);
|
|
106
|
-
return faceInfos;
|
|
107
|
-
}
|
|
108
|
-
static getWiresFromFaces(faces) {
|
|
109
|
-
const wires = [];
|
|
110
|
-
for (let face of faces) {
|
|
111
|
-
const faceWires = Explorer.findWiresWrapped(face);
|
|
112
|
-
console.log("Found wires in face:", faceWires.length);
|
|
113
|
-
for (const wire of faceWires) {
|
|
114
|
-
wires.push(wire);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return wires;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Face } from "../../common/face.js";
|
|
2
|
-
import { Explorer } from "../../oc/explorer.js";
|
|
3
|
-
export class FaceMaker2 {
|
|
4
|
-
static getFaces(shapes, plane, drill = true) {
|
|
5
|
-
const cellsBuilder = new oc.BOPAlgo_CellsBuilder();
|
|
6
|
-
const argsList = new oc.TopTools_ListOfShape();
|
|
7
|
-
for (const face of sketchShapes) {
|
|
8
|
-
argsList.Append(face.getShape());
|
|
9
|
-
}
|
|
10
|
-
cellsBuilder.SetArguments(argsList);
|
|
11
|
-
cellsBuilder.SetNonDestructive(true);
|
|
12
|
-
const progress = new oc.Message_ProgressRange();
|
|
13
|
-
cellsBuilder.Perform(progress);
|
|
14
|
-
if (cellsBuilder.HasErrors()) {
|
|
15
|
-
console.error('CellsBuilder: Perform() reported errors');
|
|
16
|
-
cellsBuilder.delete();
|
|
17
|
-
argsList.delete();
|
|
18
|
-
progress.delete();
|
|
19
|
-
throw new Error('Failed to partition sketch faces for pick mode');
|
|
20
|
-
// cells = sketchFaces;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
cellsBuilder.AddAllToResult(0, false);
|
|
24
|
-
// cellsBuilder.MakeContainers();
|
|
25
|
-
// cellsBuilder.Perform(new oc.Message_ProgressRange());
|
|
26
|
-
const allParts = cellsBuilder.GetAllParts();
|
|
27
|
-
console.log('CellsBuilder: GetAllParts count:', allParts.NbChildren());
|
|
28
|
-
const [gpPln, dispose] = Convert.toGpPln(plane);
|
|
29
|
-
const planeFace = new oc.BRepBuilderAPI_MakeFace(gpPln, -10000, 10000, -10000, 10000).Face();
|
|
30
|
-
// 3. Split the face using the edges as tools
|
|
31
|
-
const splitter = new oc.BRepAlgoAPI_Splitter();
|
|
32
|
-
const objects = new oc.TopTools_ListOfShape();
|
|
33
|
-
objects.Append(planeFace);
|
|
34
|
-
splitter.SetArguments(objects);
|
|
35
|
-
// Add each split edge as a tool
|
|
36
|
-
const tools = Explorer.findShapes(allParts, oc.TopAbs_ShapeEnum.TopAbs_EDGE).map(e => oc.TopoDS.Edge(e));
|
|
37
|
-
const toolsList = new oc.TopTools_ListOfShape();
|
|
38
|
-
for (const t of tools) {
|
|
39
|
-
toolsList.Append(t);
|
|
40
|
-
}
|
|
41
|
-
splitter.SetTools(toolsList);
|
|
42
|
-
splitter.SetNonDestructive(true);
|
|
43
|
-
splitter.SetCheckInverted(true);
|
|
44
|
-
splitter.Build(new oc.Message_ProgressRange());
|
|
45
|
-
splitter.SimplifyResult(false, false, oc.Precision.Angular());
|
|
46
|
-
const result = splitter.Shape();
|
|
47
|
-
const areas = Explorer.findShapes(result, oc.TopAbs_ShapeEnum.TopAbs_FACE);
|
|
48
|
-
cells = areas.map(f => {
|
|
49
|
-
console.log('Converting cell face from OC shape', Explorer.getShapeType(f));
|
|
50
|
-
return Face.fromTopoDSFace(oc.TopoDS.Face(f));
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Point2DLike } from "../math/point.js";
|
|
2
|
-
import { ISceneObject } from "./interfaces.js";
|
|
3
|
-
interface RegionFunction {
|
|
4
|
-
/** Activates interactive region selection on the last sketch. */
|
|
5
|
-
(): ISceneObject;
|
|
6
|
-
/**
|
|
7
|
-
* Selects specific regions from the last sketch.
|
|
8
|
-
* @param points - 2D points inside the regions to select
|
|
9
|
-
*/
|
|
10
|
-
(...points: Point2DLike[]): ISceneObject;
|
|
11
|
-
}
|
|
12
|
-
declare const _default: RegionFunction;
|
|
13
|
-
export default _default;
|
package/lib/dist/core/region.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { normalizePoint2D } from "../helpers/normalize.js";
|
|
2
|
-
import { registerBuilder } from "../index.js";
|
|
3
|
-
import { Region2D } from "../features/region2d.js";
|
|
4
|
-
function build(context) {
|
|
5
|
-
return function region(...args) {
|
|
6
|
-
const extrudable = context.getLastExtrudable();
|
|
7
|
-
if (!extrudable) {
|
|
8
|
-
throw new Error("Region requires a preceding sketch or extrudable");
|
|
9
|
-
}
|
|
10
|
-
const region2d = new Region2D(extrudable);
|
|
11
|
-
if (args.length > 0) {
|
|
12
|
-
region2d.points(...args.map(p => normalizePoint2D(p)));
|
|
13
|
-
}
|
|
14
|
-
context.addSceneObject(region2d);
|
|
15
|
-
return region2d;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export default registerBuilder(build);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SceneObject } from "../../common/scene-object.js";
|
|
2
|
-
import { GeometrySceneObject } from "./geometry.js";
|
|
3
|
-
import { LazyVertex } from "../lazy-vertex.js";
|
|
4
|
-
export declare class Move extends GeometrySceneObject {
|
|
5
|
-
targetPosition: LazyVertex;
|
|
6
|
-
constructor(targetPosition: LazyVertex);
|
|
7
|
-
getType(): string;
|
|
8
|
-
build(): void;
|
|
9
|
-
clone(): SceneObject[];
|
|
10
|
-
compareTo(other: this): boolean;
|
|
11
|
-
serialize(): {
|
|
12
|
-
position: LazyVertex;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { GeometrySceneObject } from "./geometry.js";
|
|
2
|
-
export class Move extends GeometrySceneObject {
|
|
3
|
-
targetPosition;
|
|
4
|
-
constructor(targetPosition) {
|
|
5
|
-
super();
|
|
6
|
-
this.targetPosition = targetPosition;
|
|
7
|
-
}
|
|
8
|
-
getType() {
|
|
9
|
-
return 'move';
|
|
10
|
-
}
|
|
11
|
-
build() {
|
|
12
|
-
const point = this.targetPosition.asPoint2D();
|
|
13
|
-
this.setCurrentPosition(point);
|
|
14
|
-
}
|
|
15
|
-
clone() {
|
|
16
|
-
const move = new Move(this.targetPosition);
|
|
17
|
-
return [move];
|
|
18
|
-
}
|
|
19
|
-
compareTo(other) {
|
|
20
|
-
if (!(other instanceof Move)) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
if (!super.compareTo(other)) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
return this.targetPosition.compareTo(other.targetPosition);
|
|
27
|
-
}
|
|
28
|
-
serialize() {
|
|
29
|
-
return {
|
|
30
|
-
position: this.targetPosition
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { GccEnt_Position, gp_Pln } from "occjs-wrapper";
|
|
2
|
-
import { Comparable, SceneObject } from "../common/scene-object.js";
|
|
3
|
-
export type ConstraintQualifier = 'any' | 'outside' | 'enclosed' | 'enclosing';
|
|
4
|
-
export declare class GeometricConstraint implements Comparable<GeometricConstraint> {
|
|
5
|
-
private object;
|
|
6
|
-
private qualifier;
|
|
7
|
-
constructor(object: SceneObject, qualifier: ConstraintQualifier);
|
|
8
|
-
getQualified(plane: gp_Pln): any;
|
|
9
|
-
getQualifier(qualifier: ConstraintQualifier): GccEnt_Position;
|
|
10
|
-
compareTo(other: GeometricConstraint): any;
|
|
11
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
export class GeometricConstraint {
|
|
2
|
-
object;
|
|
3
|
-
qualifier;
|
|
4
|
-
constructor(object, qualifier) {
|
|
5
|
-
this.object = object;
|
|
6
|
-
this.qualifier = qualifier;
|
|
7
|
-
}
|
|
8
|
-
getQualified(plane) {
|
|
9
|
-
const oc = getOC();
|
|
10
|
-
const shape = this.object.getShapes()[0];
|
|
11
|
-
const adaptor = new oc.BRepAdaptor_Curve(shape.getShape());
|
|
12
|
-
const type = adaptor.GetType();
|
|
13
|
-
if (type === oc.GeomAbs_CurveType.GeomAbs_Circle) {
|
|
14
|
-
const circle = adaptor.Circle();
|
|
15
|
-
adaptor.delete();
|
|
16
|
-
const c1 = Geometry.get2dCircleRaw(plane, circle);
|
|
17
|
-
circle.delete();
|
|
18
|
-
const qualifier = this.getQualifier(this.qualifier);
|
|
19
|
-
const qualified = new oc.GccEnt_QualifiedCirc(c1, qualifier);
|
|
20
|
-
return qualified;
|
|
21
|
-
}
|
|
22
|
-
else if (type === oc.GeomAbs_CurveType.GeomAbs_Line) {
|
|
23
|
-
const line = adaptor.Line();
|
|
24
|
-
adaptor.delete();
|
|
25
|
-
const l1 = Geometry.get2dLineRaw(plane, line);
|
|
26
|
-
line.delete();
|
|
27
|
-
const qualifier = this.getQualifier(this.qualifier);
|
|
28
|
-
const qualified = new oc.GccEnt_QualifiedLin(l1, qualifier);
|
|
29
|
-
return qualified;
|
|
30
|
-
}
|
|
31
|
-
throw new Error('Unsupported shape type for constraint: ' + type);
|
|
32
|
-
}
|
|
33
|
-
getQualifier(qualifier) {
|
|
34
|
-
const oc = getOC();
|
|
35
|
-
switch (qualifier) {
|
|
36
|
-
case 'any':
|
|
37
|
-
return oc.GccEnt_Position.GccEnt_unqualified;
|
|
38
|
-
case 'enclosed':
|
|
39
|
-
return oc.GccEnt_Position.GccEnt_enclosed;
|
|
40
|
-
case 'enclosing':
|
|
41
|
-
return oc.GccEnt_Position.GccEnt_enclosing;
|
|
42
|
-
case 'outside':
|
|
43
|
-
return oc.GccEnt_Position.GccEnt_outside;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
compareTo(other) {
|
|
47
|
-
return this.qualifier === other.qualifier && this.object.compareTo(other.object);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { GeometrySceneObject } from "./geometry.js";
|
|
2
|
-
import { LazyVertex } from "../lazy-vertex.js";
|
|
3
|
-
import { QualifiedSceneObject } from "./constraints/qualified-geometry.js";
|
|
4
|
-
export declare class TangentArcTwoObjects extends GeometrySceneObject {
|
|
5
|
-
c1: QualifiedSceneObject;
|
|
6
|
-
c2: QualifiedSceneObject;
|
|
7
|
-
radius: number;
|
|
8
|
-
constructor(c1: QualifiedSceneObject, c2: QualifiedSceneObject, radius: number);
|
|
9
|
-
build(): void;
|
|
10
|
-
start(index?: number): LazyVertex;
|
|
11
|
-
end(index?: number): LazyVertex;
|
|
12
|
-
compareTo(other: TangentArcTwoObjects): boolean;
|
|
13
|
-
getType(): string;
|
|
14
|
-
getUniqueType(): string;
|
|
15
|
-
serialize(): {
|
|
16
|
-
radius: number;
|
|
17
|
-
};
|
|
18
|
-
}
|