fluidcad 0.0.3 → 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.
Files changed (123) hide show
  1. package/README.md +2 -2
  2. package/lib/dist/common/shape-factory.d.ts +1 -1
  3. package/lib/dist/oc/boolean-ops.d.ts +2 -2
  4. package/lib/dist/tsconfig.tsbuildinfo +1 -1
  5. package/package.json +3 -2
  6. package/lib/dist/constraints/constraint.d.ts +0 -11
  7. package/lib/dist/constraints/constraint.js +0 -51
  8. package/lib/dist/constraints/outside.d.ts +0 -3
  9. package/lib/dist/constraints/outside.js +0 -4
  10. package/lib/dist/core/2d/aslot.d.ts +0 -12
  11. package/lib/dist/core/2d/aslot.js +0 -40
  12. package/lib/dist/core/2d/crect.d.ts +0 -12
  13. package/lib/dist/core/2d/crect.js +0 -74
  14. package/lib/dist/core/2d/face-maker.d.ts +0 -13
  15. package/lib/dist/core/2d/face-maker.js +0 -119
  16. package/lib/dist/core/2d/face-maker2.d.ts +0 -6
  17. package/lib/dist/core/2d/face-maker2.js +0 -54
  18. package/lib/dist/core/region.d.ts +0 -13
  19. package/lib/dist/core/region.js +0 -18
  20. package/lib/dist/features/2d/amove.d.ts +0 -14
  21. package/lib/dist/features/2d/amove.js +0 -33
  22. package/lib/dist/features/2d/constraints/constraint.d.ts +0 -11
  23. package/lib/dist/features/2d/constraints/constraint.js +0 -49
  24. package/lib/dist/features/2d/constraints/outside.d.ts +0 -3
  25. package/lib/dist/features/2d/constraints/outside.js +0 -4
  26. package/lib/dist/features/2d/tarc-two-circles.d.ts +0 -18
  27. package/lib/dist/features/2d/tarc-two-circles.js +0 -61
  28. package/lib/dist/features/2d/tcircle-three-tan.d.ts +0 -13
  29. package/lib/dist/features/2d/tcircle-three-tan.js +0 -33
  30. package/lib/dist/features/2d/tcircle-two-tan.d.ts +0 -13
  31. package/lib/dist/features/2d/tcircle-two-tan.js +0 -33
  32. package/lib/dist/features/Extrude.d.ts +0 -1
  33. package/lib/dist/features/Extrude.js +0 -1
  34. package/lib/dist/features/cut-base.d.ts +0 -49
  35. package/lib/dist/features/cut-base.js +0 -312
  36. package/lib/dist/features/cut-symmetric.d.ts +0 -23
  37. package/lib/dist/features/cut-symmetric.js +0 -119
  38. package/lib/dist/features/cut-two-distances.d.ts +0 -24
  39. package/lib/dist/features/cut-two-distances.js +0 -110
  40. package/lib/dist/features/cut.d.ts +0 -27
  41. package/lib/dist/features/cut.js +0 -101
  42. package/lib/dist/features/extrude-symmetric.d.ts +0 -28
  43. package/lib/dist/features/extrude-symmetric.js +0 -177
  44. package/lib/dist/features/region2d.d.ts +0 -25
  45. package/lib/dist/features/region2d.js +0 -185
  46. package/lib/dist/features/repeat-circular2d.d.ts +0 -17
  47. package/lib/dist/features/repeat-circular2d.js +0 -90
  48. package/lib/dist/features/repeat-linear2d.d.ts +0 -17
  49. package/lib/dist/features/repeat-linear2d.js +0 -114
  50. package/lib/dist/features/revolve-options.d.ts +0 -6
  51. package/lib/dist/features/revolve-options.js +0 -1
  52. package/lib/dist/features/split.d.ts +0 -14
  53. package/lib/dist/features/split.js +0 -74
  54. package/lib/dist/features/state-scene-object.d.ts +0 -15
  55. package/lib/dist/features/state-scene-object.js +0 -44
  56. package/lib/dist/features/state-select.d.ts +0 -21
  57. package/lib/dist/features/state-select.js +0 -73
  58. package/lib/dist/features/translate2d.d.ts +0 -16
  59. package/lib/dist/features/translate2d.js +0 -61
  60. package/lib/dist/filters/all-filter.d.ts +0 -8
  61. package/lib/dist/filters/all-filter.js +0 -12
  62. package/lib/dist/filters/near-point-filter.d.ts +0 -11
  63. package/lib/dist/filters/near-point-filter.js +0 -33
  64. package/lib/dist/helpers/resolve-filters.d.ts +0 -6
  65. package/lib/dist/helpers/resolve-filters.js +0 -25
  66. package/lib/dist/math/axis.test.d.ts +0 -1
  67. package/lib/dist/math/axis.test.js +0 -287
  68. package/lib/dist/math/coordinate-system.test.d.ts +0 -1
  69. package/lib/dist/math/coordinate-system.test.js +0 -308
  70. package/lib/dist/math/matrix4.test.d.ts +0 -1
  71. package/lib/dist/math/matrix4.test.js +0 -357
  72. package/lib/dist/math/plane.test.d.ts +0 -1
  73. package/lib/dist/math/plane.test.js +0 -398
  74. package/lib/dist/math/point.test.d.ts +0 -1
  75. package/lib/dist/math/point.test.js +0 -385
  76. package/lib/dist/math/quaternion.test.d.ts +0 -1
  77. package/lib/dist/math/quaternion.test.js +0 -278
  78. package/lib/dist/math/vector3d.test.d.ts +0 -1
  79. package/lib/dist/math/vector3d.test.js +0 -276
  80. package/lib/dist/oc/constraint-resolver.d.ts +0 -7
  81. package/lib/dist/oc/constraint-resolver.js +0 -31
  82. package/lib/dist/oc/constraints/curve-constraint-solver.d.ts +0 -1
  83. package/lib/dist/oc/constraints/curve-constraint-solver.js +0 -2
  84. package/lib/dist/oc/constraints/geometric-constraint-solver.d.ts +0 -1
  85. package/lib/dist/oc/constraints/geometric-constraint-solver.js +0 -5
  86. package/lib/dist/oc/face-maker.d.ts +0 -14
  87. package/lib/dist/oc/face-maker.js +0 -191
  88. package/lib/dist/oc/measure.d.ts +0 -21
  89. package/lib/dist/oc/measure.js +0 -256
  90. package/lib/dist/oc/tangent-circle-solver.d.ts +0 -17
  91. package/lib/dist/oc/tangent-circle-solver.js +0 -72
  92. package/lib/dist/oc/tangent-line-solver.d.ts +0 -17
  93. package/lib/dist/oc/tangent-line-solver.js +0 -83
  94. package/lib/dist/oc/tangent-solver.d.ts +0 -14
  95. package/lib/dist/oc/tangent-solver.js +0 -199
  96. package/lib/dist/rendering/builder-context.d.ts +0 -16
  97. package/lib/dist/rendering/builder-context.js +0 -63
  98. package/lib/dist/tests/extrude.test.d.ts +0 -1
  99. package/lib/dist/tests/extrude.test.js +0 -48
  100. package/lib/dist/tests/features/copy.test.d.ts +0 -1
  101. package/lib/dist/tests/features/copy.test.js +0 -158
  102. package/lib/dist/tests/features/dispose.test.d.ts +0 -1
  103. package/lib/dist/tests/features/dispose.test.js +0 -189
  104. package/lib/dist/tests/features/part-pick.test.d.ts +0 -1
  105. package/lib/dist/tests/features/part-pick.test.js +0 -73
  106. package/lib/dist/tests/features/part-repeat.test.d.ts +0 -1
  107. package/lib/dist/tests/features/part-repeat.test.js +0 -109
  108. package/server/dist/fluidcad-server.d.ts +0 -32
  109. package/server/dist/fluidcad-server.js +0 -150
  110. package/server/dist/index.d.ts +0 -1
  111. package/server/dist/index.js +0 -290
  112. package/server/dist/routes/actions.d.ts +0 -3
  113. package/server/dist/routes/actions.js +0 -100
  114. package/server/dist/routes/export.d.ts +0 -3
  115. package/server/dist/routes/export.js +0 -55
  116. package/server/dist/routes/properties.d.ts +0 -3
  117. package/server/dist/routes/properties.js +0 -46
  118. package/server/dist/routes/screenshot.d.ts +0 -2
  119. package/server/dist/routes/screenshot.js +0 -76
  120. package/server/dist/vite-manager.d.ts +0 -10
  121. package/server/dist/vite-manager.js +0 -64
  122. package/server/dist/ws-protocol.d.ts +0 -138
  123. package/server/dist/ws-protocol.js +0 -4
@@ -1,17 +0,0 @@
1
- import { BuildSceneObjectContext, SceneObject } from "../common/scene-object.js";
2
- import { GeometrySceneObject } from "./2d/geometry.js";
3
- import { LazyVertex } from "./lazy-vertex.js";
4
- import { CircularRepeatOptions } from "./repeat-circular.js";
5
- export declare class RepeatCircular2D extends GeometrySceneObject {
6
- center: LazyVertex;
7
- options: CircularRepeatOptions;
8
- private _targetObjects;
9
- constructor(center: LazyVertex, options: CircularRepeatOptions);
10
- target(...objects: SceneObject[]): this;
11
- get targetObjects(): SceneObject[] | null;
12
- build(context: BuildSceneObjectContext): void;
13
- compareTo(other: RepeatCircular2D): boolean;
14
- getType(): string;
15
- getUniqueType(): string;
16
- serialize(): {};
17
- }
@@ -1,90 +0,0 @@
1
- import { Matrix4 } from "../math/matrix4.js";
2
- import { rad } from "../helpers/math-helpers.js";
3
- import { ShapeOps } from "../oc/shape-ops.js";
4
- import { GeometrySceneObject } from "./2d/geometry.js";
5
- export class RepeatCircular2D extends GeometrySceneObject {
6
- center;
7
- options;
8
- _targetObjects = null;
9
- constructor(center, options) {
10
- super();
11
- this.center = center;
12
- this.options = options;
13
- }
14
- target(...objects) {
15
- this._targetObjects = objects;
16
- return this;
17
- }
18
- get targetObjects() {
19
- return this._targetObjects;
20
- }
21
- build(context) {
22
- let objects;
23
- const allSiblings = this.sketch.getPreviousSiblings(this);
24
- if (this.targetObjects && this.targetObjects.length > 0) {
25
- objects = allSiblings.filter(obj => this.targetObjects.includes(obj));
26
- }
27
- else {
28
- objects = allSiblings;
29
- }
30
- const plane = this.sketch.getPlane();
31
- const origin = plane.localToWorld(this.center.asPoint2D());
32
- const direction = plane.normal;
33
- const { count, centered, skip } = this.options;
34
- let offset;
35
- if ('offset' in this.options && this.options.offset !== undefined) {
36
- offset = this.options.offset;
37
- }
38
- else {
39
- offset = this.options.angle / (count - 1);
40
- }
41
- const startOffset = centered ? -(count * offset) / 2 : 0;
42
- for (let i = 1; i < count; i++) {
43
- if (skip?.includes(i))
44
- continue;
45
- const angle = startOffset + offset * i;
46
- const matrix = Matrix4.fromRotationAroundAxis(origin, direction, rad(angle));
47
- for (const obj of objects) {
48
- for (const shape of obj.getShapes()) {
49
- const transformed = ShapeOps.transform(shape, matrix);
50
- this.addShape(transformed);
51
- }
52
- }
53
- }
54
- this.setCurrentPosition(this.center.asPoint2D());
55
- }
56
- compareTo(other) {
57
- if (!(other instanceof RepeatCircular2D)) {
58
- return false;
59
- }
60
- if (!super.compareTo(other)) {
61
- return false;
62
- }
63
- if (!this.center.compareTo(other.center)) {
64
- return false;
65
- }
66
- const thisTargetObjects = this.targetObjects || [];
67
- const otherTargetObjects = other.targetObjects || [];
68
- if (thisTargetObjects.length !== otherTargetObjects.length) {
69
- return false;
70
- }
71
- for (let i = 0; i < thisTargetObjects.length; i++) {
72
- if (!thisTargetObjects[i].compareTo(otherTargetObjects[i])) {
73
- return false;
74
- }
75
- }
76
- if (JSON.stringify(this.options) !== JSON.stringify(other.options)) {
77
- return false;
78
- }
79
- return true;
80
- }
81
- getType() {
82
- return "repeat-circular";
83
- }
84
- getUniqueType() {
85
- return "repeat-circular-2d";
86
- }
87
- serialize() {
88
- return {};
89
- }
90
- }
@@ -1,17 +0,0 @@
1
- import { BuildSceneObjectContext, SceneObject } from "../common/scene-object.js";
2
- import { Axis } from "../math/axis.js";
3
- import { GeometrySceneObject } from "./2d/geometry.js";
4
- import { LinearRepeatOptions } from "./repeat-linear.js";
5
- export declare class RepeatLinear2D extends GeometrySceneObject {
6
- axes: Axis[];
7
- options: LinearRepeatOptions;
8
- private _targetObjects;
9
- constructor(axes: Axis[], options: LinearRepeatOptions);
10
- target(...objects: SceneObject[]): this;
11
- get targetObjects(): SceneObject[] | null;
12
- build(context: BuildSceneObjectContext): void;
13
- compareTo(other: RepeatLinear2D): boolean;
14
- getType(): string;
15
- getUniqueType(): string;
16
- serialize(): {};
17
- }
@@ -1,114 +0,0 @@
1
- import { Matrix4 } from "../math/matrix4.js";
2
- import { ShapeOps } from "../oc/shape-ops.js";
3
- import { GeometrySceneObject } from "./2d/geometry.js";
4
- export class RepeatLinear2D extends GeometrySceneObject {
5
- axes;
6
- options;
7
- _targetObjects = null;
8
- constructor(axes, options) {
9
- super();
10
- this.axes = axes;
11
- this.options = options;
12
- }
13
- target(...objects) {
14
- this._targetObjects = objects;
15
- return this;
16
- }
17
- get targetObjects() {
18
- return this._targetObjects;
19
- }
20
- build(context) {
21
- let objects;
22
- const allSiblings = this.sketch.getPreviousSiblings(this);
23
- if (this.targetObjects && this.targetObjects.length > 0) {
24
- objects = allSiblings.filter(obj => this.targetObjects.includes(obj));
25
- }
26
- else {
27
- objects = allSiblings;
28
- }
29
- const counts = Array.isArray(this.options.count)
30
- ? this.options.count
31
- : [this.options.count];
32
- const axisOffsets = this.axes.map((axis, i) => {
33
- const count = counts[i] ?? counts[0];
34
- const offset = this.options.offset != null
35
- ? this.options.offset
36
- : this.options.length / (count - 1);
37
- return { axis, count, offset };
38
- });
39
- // Generate all index combinations across axes
40
- let positions = [[]];
41
- for (const { count } of axisOffsets) {
42
- const next = [];
43
- for (const pos of positions) {
44
- for (let i = 0; i < count; i++) {
45
- next.push([...pos, i]);
46
- }
47
- }
48
- positions = next;
49
- }
50
- for (const pos of positions) {
51
- if (pos.every(idx => idx === 0))
52
- continue;
53
- if (this.options.skip?.some(s => s.length === pos.length && s.every((v, i) => v === pos[i]))) {
54
- continue;
55
- }
56
- let dx = 0, dy = 0, dz = 0;
57
- for (let a = 0; a < axisOffsets.length; a++) {
58
- const { axis, offset } = axisOffsets[a];
59
- const idx = this.options.centered
60
- ? pos[a] - Math.floor(axisOffsets[a].count / 2)
61
- : pos[a];
62
- dx += axis.direction.x * offset * idx;
63
- dy += axis.direction.y * offset * idx;
64
- dz += axis.direction.z * offset * idx;
65
- }
66
- const matrix = Matrix4.fromTranslation(dx, dy, dz);
67
- for (const obj of objects) {
68
- for (const shape of obj.getShapes()) {
69
- const transformed = ShapeOps.transform(shape, matrix);
70
- this.addShape(transformed);
71
- }
72
- }
73
- }
74
- }
75
- compareTo(other) {
76
- if (!(other instanceof RepeatLinear2D)) {
77
- return false;
78
- }
79
- if (!super.compareTo(other)) {
80
- return false;
81
- }
82
- if (this.axes.length !== other.axes.length) {
83
- return false;
84
- }
85
- for (let i = 0; i < this.axes.length; i++) {
86
- if (!this.axes[i].equals(other.axes[i])) {
87
- return false;
88
- }
89
- }
90
- const thisTargetObjects = this.targetObjects || [];
91
- const otherTargetObjects = other.targetObjects || [];
92
- if (thisTargetObjects.length !== otherTargetObjects.length) {
93
- return false;
94
- }
95
- for (let i = 0; i < thisTargetObjects.length; i++) {
96
- if (!thisTargetObjects[i].compareTo(otherTargetObjects[i])) {
97
- return false;
98
- }
99
- }
100
- if (JSON.stringify(this.options) !== JSON.stringify(other.options)) {
101
- return false;
102
- }
103
- return true;
104
- }
105
- getType() {
106
- return "repeat-linear";
107
- }
108
- getUniqueType() {
109
- return "repeat-linear-2d";
110
- }
111
- serialize() {
112
- return {};
113
- }
114
- }
@@ -1,6 +0,0 @@
1
- import { SceneObject } from "../common/scene-object.js";
2
- export type MergeScope = 'all' | 'none' | SceneObject | SceneObject[];
3
- export type RevolveOptions = {
4
- mergeScope?: MergeScope;
5
- symmetric?: boolean;
6
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,14 +0,0 @@
1
- import { BuildSceneObjectContext, SceneObject } from "../common/scene-object.js";
2
- import { GeometrySceneObject } from "./2d/geometry.js";
3
- export declare class Split2D extends GeometrySceneObject {
4
- private _targetObjects;
5
- constructor();
6
- target(...objects: GeometrySceneObject[]): this;
7
- get targetObjects(): GeometrySceneObject[] | null;
8
- build(context: BuildSceneObjectContext): void;
9
- getDependencies(): SceneObject[];
10
- createCopy(remap: Map<SceneObject, SceneObject>): SceneObject;
11
- compareTo(other: Split2D): boolean;
12
- getType(): string;
13
- serialize(): {};
14
- }
@@ -1,74 +0,0 @@
1
- import { Wire } from "../common/wire.js";
2
- import { Edge } from "../common/edge.js";
3
- import { GeometrySceneObject } from "./2d/geometry.js";
4
- import { FaceMaker } from "../core/2d/face-maker.js";
5
- export class Split2D extends GeometrySceneObject {
6
- _targetObjects = null;
7
- constructor() {
8
- super();
9
- }
10
- target(...objects) {
11
- this._targetObjects = objects;
12
- return this;
13
- }
14
- get targetObjects() {
15
- return this._targetObjects;
16
- }
17
- build(context) {
18
- const plane = this.sketch.getPlane();
19
- let sourceWires;
20
- if (this._targetObjects === null) {
21
- sourceWires = this.sketch.getGeometriesWithOwner();
22
- }
23
- else {
24
- sourceWires = new Map();
25
- for (const obj of this._targetObjects) {
26
- for (const shape of obj.getShapes()) {
27
- if (shape instanceof Wire || shape instanceof Edge) {
28
- sourceWires.set(shape, obj);
29
- }
30
- }
31
- }
32
- }
33
- const fusedWires = FaceMaker.fuseWires(Array.from(sourceWires.keys()), plane);
34
- for (const [wire, owner] of sourceWires) {
35
- owner.removeShape(wire, this);
36
- }
37
- this.addShapes(fusedWires);
38
- }
39
- getDependencies() {
40
- return this._targetObjects ? [...this._targetObjects] : [];
41
- }
42
- createCopy(remap) {
43
- const copy = new Split2D();
44
- if (this._targetObjects) {
45
- copy.target(...this._targetObjects.map(t => remap.get(t) || t));
46
- }
47
- return copy;
48
- }
49
- compareTo(other) {
50
- if (!(other instanceof Split2D)) {
51
- return false;
52
- }
53
- if (!super.compareTo(other)) {
54
- return false;
55
- }
56
- const thisTargets = this._targetObjects || [];
57
- const otherTargets = other._targetObjects || [];
58
- if (thisTargets.length !== otherTargets.length) {
59
- return false;
60
- }
61
- for (let i = 0; i < thisTargets.length; i++) {
62
- if (!thisTargets[i].compareTo(otherTargets[i])) {
63
- return false;
64
- }
65
- }
66
- return true;
67
- }
68
- getType() {
69
- return "split2d";
70
- }
71
- serialize() {
72
- return {};
73
- }
74
- }
@@ -1,15 +0,0 @@
1
- import { SceneObject } from "../common/scene-object.js";
2
- import { ShapeType } from "../common/shape-type.js";
3
- import { ShapeFilter, Shape } from "../common/shape.js";
4
- export declare class StateSceneObject extends SceneObject {
5
- private source;
6
- private key;
7
- constructor(source: SceneObject, key: string);
8
- build(): void;
9
- getShapes(filter?: ShapeFilter, type?: ShapeType): Shape[];
10
- compareTo(other: StateSceneObject): boolean;
11
- getDependencies(): SceneObject[];
12
- createCopy(remap: Map<SceneObject, SceneObject>): SceneObject;
13
- getType(): string;
14
- serialize(): {};
15
- }
@@ -1,44 +0,0 @@
1
- import { SceneObject } from "../common/scene-object.js";
2
- export class StateSceneObject extends SceneObject {
3
- source;
4
- key;
5
- constructor(source, key) {
6
- super();
7
- this.source = source;
8
- this.key = key;
9
- }
10
- build() {
11
- }
12
- getShapes(filter, type) {
13
- const shapes = this.source.getState(this.key);
14
- console.log(`============ StateSceneObject::getShapes - key: ${this.key}, shapes: ${shapes ? shapes.length : 0}`);
15
- return shapes ? shapes : [];
16
- }
17
- compareTo(other) {
18
- if (!(other instanceof StateSceneObject)) {
19
- return false;
20
- }
21
- if (this.key !== other.key) {
22
- return false;
23
- }
24
- if (!this.source.compareTo(other.source)) {
25
- return false;
26
- }
27
- return super.compareTo(other);
28
- }
29
- getDependencies() {
30
- return this.source ? [this.source] : [];
31
- }
32
- createCopy(remap) {
33
- const remappedSource = this.source
34
- ? (remap.get(this.source) || this.source)
35
- : undefined;
36
- return new StateSceneObject(remappedSource, this.key);
37
- }
38
- getType() {
39
- return "state";
40
- }
41
- serialize() {
42
- return {};
43
- }
44
- }
@@ -1,21 +0,0 @@
1
- import { BuildSceneObjectContext, SceneObject } from "../common/scene-object.js";
2
- import { Shape, ShapeFilter as ShapeFilterType } from "../common/shape.js";
3
- import { ShapeType } from "../common/shape-type.js";
4
- import { FilterBuilderBase } from "../filters/filter-builder-base.js";
5
- export declare class StateSelectSceneObject extends SceneObject {
6
- private stateKey;
7
- private filters;
8
- private sourceParent;
9
- private _isBuilt;
10
- constructor(stateKey: string, filters: FilterBuilderBase<Shape>[], sourceParent: SceneObject);
11
- build(_context?: BuildSceneObjectContext): void;
12
- getShapes(filter?: ShapeFilterType, type?: ShapeType): Shape[];
13
- private applyFilters;
14
- getDependencies(): SceneObject[];
15
- createCopy(remap: Map<SceneObject, SceneObject>): SceneObject;
16
- compareTo(other: SceneObject): boolean;
17
- getType(): string;
18
- serialize(): {
19
- stateKey: string;
20
- };
21
- }
@@ -1,73 +0,0 @@
1
- import { SceneObject } from "../common/scene-object.js";
2
- import { ShapeFilter } from "../filters/filter.js";
3
- export class StateSelectSceneObject extends SceneObject {
4
- stateKey;
5
- filters;
6
- sourceParent;
7
- _isBuilt = false;
8
- constructor(stateKey, filters, sourceParent) {
9
- super();
10
- this.stateKey = stateKey;
11
- this.filters = filters;
12
- this.sourceParent = sourceParent;
13
- }
14
- build(_context) {
15
- if (this._isBuilt) {
16
- return;
17
- }
18
- const shapes = this.sourceParent.getState(this.stateKey) || [];
19
- const filtered = this.applyFilters(shapes, this.filters);
20
- this.addShapes(filtered);
21
- this._isBuilt = true;
22
- }
23
- getShapes(filter, type) {
24
- if (!this._isBuilt) {
25
- this.build();
26
- }
27
- return super.getShapes(filter, type);
28
- }
29
- applyFilters(shapes, filters) {
30
- if (filters.length === 0) {
31
- return shapes;
32
- }
33
- return new ShapeFilter(shapes, ...filters).apply();
34
- }
35
- getDependencies() {
36
- return [this.sourceParent];
37
- }
38
- createCopy(remap) {
39
- const remappedParent = remap.get(this.sourceParent) || this.sourceParent;
40
- return new StateSelectSceneObject(this.stateKey, this.filters, remappedParent);
41
- }
42
- compareTo(other) {
43
- if (!(other instanceof StateSelectSceneObject)) {
44
- return false;
45
- }
46
- if (!super.compareTo(other)) {
47
- return false;
48
- }
49
- if (this.stateKey !== other.stateKey) {
50
- return false;
51
- }
52
- if (!this.sourceParent.compareTo(other.sourceParent)) {
53
- return false;
54
- }
55
- if (this.filters.length !== other.filters.length) {
56
- return false;
57
- }
58
- for (let i = 0; i < this.filters.length; i++) {
59
- if (!this.filters[i].equals(other.filters[i])) {
60
- return false;
61
- }
62
- }
63
- return true;
64
- }
65
- getType() {
66
- return "state-select";
67
- }
68
- serialize() {
69
- return {
70
- stateKey: this.stateKey,
71
- };
72
- }
73
- }
@@ -1,16 +0,0 @@
1
- import { BuildSceneObjectContext, SceneObject } from "../common/scene-object.js";
2
- import { LazyVertex } from "./lazy-vertex.js";
3
- import { PlaneObjectBase } from "./plane-renderable-base.js";
4
- export declare class Translate2D extends SceneObject {
5
- private targetObjects;
6
- private amount;
7
- private plane;
8
- constructor(targetObjects: SceneObject[], amount: LazyVertex, plane: PlaneObjectBase);
9
- build(context: BuildSceneObjectContext): void;
10
- clone(): SceneObject[];
11
- compareTo(other: Translate2D): boolean;
12
- getType(): string;
13
- serialize(): {
14
- amount: LazyVertex;
15
- };
16
- }
@@ -1,61 +0,0 @@
1
- import { SceneObject } from "../common/scene-object.js";
2
- import { Matrix4 } from "../math/matrix4.js";
3
- import { ShapeOps } from "../oc/shape-ops.js";
4
- export class Translate2D extends SceneObject {
5
- targetObjects;
6
- amount;
7
- plane;
8
- constructor(targetObjects, amount, plane) {
9
- super();
10
- this.targetObjects = targetObjects;
11
- this.amount = amount;
12
- this.plane = plane;
13
- }
14
- build(context) {
15
- const objects = this.targetObjects || context.getSceneObjects();
16
- const p = this.plane.getPlane();
17
- const local = this.amount.asPoint2D();
18
- const worldOffset = p.xDirection.multiply(local.x).add(p.yDirection.multiply(local.y));
19
- for (const obj of objects) {
20
- const shapes = obj.getShapes(false);
21
- for (const shape of shapes) {
22
- const transformed = ShapeOps.transform(shape, Matrix4.fromTranslation(worldOffset.x, worldOffset.y, worldOffset.z));
23
- this.addShape(transformed);
24
- obj.removeShape(shape, this);
25
- }
26
- }
27
- this.plane.removeShapes(this);
28
- }
29
- clone() {
30
- const targetObjects = this.targetObjects.map(obj => obj.clone()).flat();
31
- const plane = this.plane.clone()[0];
32
- return [new Translate2D(targetObjects, this.amount, plane)];
33
- }
34
- compareTo(other) {
35
- if (!(other instanceof Translate2D)) {
36
- return false;
37
- }
38
- if (!this.amount.compareTo(other.amount)) {
39
- return false;
40
- }
41
- const thisTargetObjects = this.targetObjects || [];
42
- const otherTargetObjects = other.targetObjects || [];
43
- if (thisTargetObjects.length !== otherTargetObjects.length) {
44
- return false;
45
- }
46
- for (let i = 0; i < thisTargetObjects.length; i++) {
47
- if (!thisTargetObjects[i].compareTo(otherTargetObjects[i])) {
48
- return false;
49
- }
50
- }
51
- return true;
52
- }
53
- getType() {
54
- return "translate2d";
55
- }
56
- serialize() {
57
- return {
58
- amount: this.amount
59
- };
60
- }
61
- }
@@ -1,8 +0,0 @@
1
- import { Matrix4 } from "../math/matrix4.js";
2
- import { Shape } from "../common/shapes.js";
3
- import { FilterBase } from "./filter-base.js";
4
- export declare class AllFilter extends FilterBase<Shape> {
5
- match(_shape: Shape): boolean;
6
- compareTo(other: AllFilter): boolean;
7
- transform(_matrix: Matrix4): AllFilter;
8
- }
@@ -1,12 +0,0 @@
1
- import { FilterBase } from "./filter-base.js";
2
- export class AllFilter extends FilterBase {
3
- match(_shape) {
4
- return true;
5
- }
6
- compareTo(other) {
7
- return other instanceof AllFilter;
8
- }
9
- transform(_matrix) {
10
- return new AllFilter();
11
- }
12
- }
@@ -1,11 +0,0 @@
1
- import { Matrix4 } from "../math/matrix4.js";
2
- import { Point } from "../math/point.js";
3
- import { Shape } from "../common/shapes.js";
4
- import { FilterBase } from "./filter-base.js";
5
- export declare class NearPointFilter extends FilterBase<Shape> {
6
- private point;
7
- constructor(point: Point);
8
- match(shape: Shape): boolean;
9
- compareTo(other: NearPointFilter): boolean;
10
- transform(matrix: Matrix4): NearPointFilter;
11
- }
@@ -1,33 +0,0 @@
1
- import { FilterBase } from "./filter-base.js";
2
- import { getOC } from "../oc/init.js";
3
- const NEAR_POINT_TOLERANCE = 0.5;
4
- export class NearPointFilter extends FilterBase {
5
- point;
6
- constructor(point) {
7
- super();
8
- this.point = point;
9
- }
10
- match(shape) {
11
- const oc = getOC();
12
- const gpPnt = new oc.gp_Pnt(this.point.x, this.point.y, this.point.z);
13
- const vertexMaker = new oc.BRepBuilderAPI_MakeVertex(gpPnt);
14
- const vertexShape = vertexMaker.Shape();
15
- gpPnt.delete();
16
- const progress = new oc.Message_ProgressRange();
17
- const distCalc = new oc.BRepExtrema_DistShapeShape(vertexShape, shape.getShape(), oc.Extrema_ExtFlag.Extrema_ExtFlag_MIN, oc.Extrema_ExtAlgo.Extrema_ExtAlgo_Grad, progress);
18
- let result = false;
19
- if (distCalc.IsDone()) {
20
- result = distCalc.Value() < NEAR_POINT_TOLERANCE;
21
- }
22
- distCalc.delete();
23
- progress.delete();
24
- vertexMaker.delete();
25
- return result;
26
- }
27
- compareTo(other) {
28
- return this.point.equals(other.point, 1e-6);
29
- }
30
- transform(matrix) {
31
- return new NearPointFilter(this.point.transform(matrix));
32
- }
33
- }
@@ -1,6 +0,0 @@
1
- import { Shape } from "../common/shape.js";
2
- import { EdgeFilterBuilder } from "../filters/edge/edge-filter.js";
3
- import { FaceFilterBuilder } from "../filters/face/face-filter.js";
4
- import { FilterBuilderBase } from "../filters/filter-builder-base.js";
5
- export declare function resolveEdgeFilters(args: (number | EdgeFilterBuilder)[], defaultBuilder?: EdgeFilterBuilder): FilterBuilderBase<Shape>[];
6
- export declare function resolveFaceFilters(args: (number | FaceFilterBuilder)[], defaultBuilder?: FaceFilterBuilder): FilterBuilderBase<Shape>[];
@@ -1,25 +0,0 @@
1
- import { EdgeFilterBuilder } from "../filters/edge/edge-filter.js";
2
- import { FaceFilterBuilder } from "../filters/face/face-filter.js";
3
- import { FilterBuilderBase } from "../filters/filter-builder-base.js";
4
- export function resolveEdgeFilters(args, defaultBuilder) {
5
- if (args.length === 0) {
6
- return defaultBuilder ? [defaultBuilder] : [];
7
- }
8
- if (args.every(a => typeof a === 'number')) {
9
- const indices = args;
10
- const builder = defaultBuilder ?? new EdgeFilterBuilder();
11
- return [builder.at(...indices)];
12
- }
13
- return args;
14
- }
15
- export function resolveFaceFilters(args, defaultBuilder) {
16
- if (args.length === 0) {
17
- return defaultBuilder ? [defaultBuilder] : [];
18
- }
19
- if (args.every(a => typeof a === 'number')) {
20
- const indices = args;
21
- const builder = defaultBuilder ?? new FaceFilterBuilder();
22
- return [builder.at(...indices)];
23
- }
24
- return args.filter(a => a instanceof FilterBuilderBase);
25
- }