@bitbybit-dev/manifold 1.2.0 → 1.3.0-rc.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/lib/api/inputs/manifold-inputs.d.ts +521 -224
- package/lib/api/inputs/manifold-inputs.js +380 -135
- package/lib/api/manifold-service.d.ts +37 -11
- package/lib/api/manifold-service.js +37 -11
- package/lib/api/services/cross-section/cross-section-booleans.d.ts +66 -29
- package/lib/api/services/cross-section/cross-section-booleans.js +66 -29
- package/lib/api/services/cross-section/cross-section-evaluate.d.ts +38 -17
- package/lib/api/services/cross-section/cross-section-evaluate.js +38 -17
- package/lib/api/services/cross-section/cross-section-operations.d.ts +73 -33
- package/lib/api/services/cross-section/cross-section-operations.js +73 -33
- package/lib/api/services/cross-section/cross-section-shapes.d.ts +38 -17
- package/lib/api/services/cross-section/cross-section-shapes.js +38 -17
- package/lib/api/services/cross-section/cross-section-transforms.d.ts +64 -29
- package/lib/api/services/cross-section/cross-section-transforms.js +64 -29
- package/lib/api/services/cross-section/cross-section.d.ts +81 -20
- package/lib/api/services/cross-section/cross-section.js +81 -20
- package/lib/api/services/manifold/manifold-booleans.d.ts +139 -43
- package/lib/api/services/manifold/manifold-booleans.js +143 -43
- package/lib/api/services/manifold/manifold-evaluate.d.ts +134 -59
- package/lib/api/services/manifold/manifold-evaluate.js +141 -59
- package/lib/api/services/manifold/manifold-operations.d.ts +195 -108
- package/lib/api/services/manifold/manifold-operations.js +197 -110
- package/lib/api/services/manifold/manifold-shapes.d.ts +64 -26
- package/lib/api/services/manifold/manifold-shapes.js +66 -28
- package/lib/api/services/manifold/manifold-transforms.d.ts +100 -38
- package/lib/api/services/manifold/manifold-transforms.js +100 -38
- package/lib/api/services/manifold/manifold.d.ts +25 -8
- package/lib/api/services/manifold/manifold.js +25 -8
- package/lib/api/services/mesh/mesh-evaluate.d.ts +103 -32
- package/lib/api/services/mesh/mesh-evaluate.js +108 -33
- package/lib/api/services/mesh/mesh-operations.d.ts +12 -15
- package/lib/api/services/mesh/mesh-operations.js +12 -15
- package/lib/api/services/mesh/mesh.d.ts +4 -2
- package/lib/api/services/mesh/mesh.js +4 -2
- package/package.json +3 -3
|
@@ -1,61 +1,82 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Measuring Manifold cross-sections: area, emptiness, vertex and contour counts and the bounding
|
|
3
|
+
* rectangle. Nothing here changes the cross-section.
|
|
4
4
|
*/
|
|
5
5
|
export class CrossSectionEvaluate {
|
|
6
6
|
constructor(_wasm) {
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @param inputs cross
|
|
11
|
-
* @returns area
|
|
9
|
+
* Measures the area of a cross-section, in square model units, holes excluded.
|
|
10
|
+
* @param inputs - The cross-section
|
|
11
|
+
* @returns The area
|
|
12
12
|
* @group basic
|
|
13
13
|
* @shortname area
|
|
14
14
|
* @drawable false
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const area = await bitbybit.manifold.crossSection.evaluate.area({ crossSection: outline });
|
|
18
|
+
* ```
|
|
15
19
|
*/
|
|
16
20
|
area(inputs) {
|
|
17
21
|
return inputs.crossSection.area();
|
|
18
22
|
}
|
|
19
23
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @param inputs cross
|
|
22
|
-
* @returns
|
|
24
|
+
* Tells whether a cross-section has no contours at all.
|
|
25
|
+
* @param inputs - The cross-section
|
|
26
|
+
* @returns True when the cross-section is empty
|
|
23
27
|
* @group basic
|
|
24
28
|
* @shortname is empty
|
|
25
29
|
* @drawable false
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const empty = await bitbybit.manifold.crossSection.evaluate.isEmpty({ crossSection: outline });
|
|
33
|
+
* ```
|
|
26
34
|
*/
|
|
27
35
|
isEmpty(inputs) {
|
|
28
36
|
return inputs.crossSection.isEmpty();
|
|
29
37
|
}
|
|
30
38
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @param inputs cross
|
|
33
|
-
* @returns number of vertices
|
|
39
|
+
* Counts the vertices of a cross-section over all its contours.
|
|
40
|
+
* @param inputs - The cross-section
|
|
41
|
+
* @returns The number of vertices
|
|
34
42
|
* @group basic
|
|
35
43
|
* @shortname num vert
|
|
36
44
|
* @drawable false
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const vertices = await bitbybit.manifold.crossSection.evaluate.numVert({ crossSection: outline });
|
|
48
|
+
* ```
|
|
37
49
|
*/
|
|
38
50
|
numVert(inputs) {
|
|
39
51
|
return inputs.crossSection.numVert();
|
|
40
52
|
}
|
|
41
53
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param inputs cross
|
|
44
|
-
* @returns number of
|
|
54
|
+
* Counts the contours of a cross-section: its outer outlines and its holes.
|
|
55
|
+
* @param inputs - The cross-section
|
|
56
|
+
* @returns The number of contours
|
|
45
57
|
* @group basic
|
|
46
58
|
* @shortname num contour
|
|
47
59
|
* @drawable false
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const contours = await bitbybit.manifold.crossSection.evaluate.numContour({ crossSection: plate });
|
|
63
|
+
* ```
|
|
48
64
|
*/
|
|
49
65
|
numContour(inputs) {
|
|
50
66
|
return inputs.crossSection.numContour();
|
|
51
67
|
}
|
|
52
68
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @
|
|
69
|
+
* Finds the rectangle around a cross-section as two 2D points: the minimum corner, then the
|
|
70
|
+
* maximum corner.
|
|
71
|
+
* @param inputs - The cross-section
|
|
72
|
+
* @returns The minimum corner and the maximum corner
|
|
56
73
|
* @group basic
|
|
57
74
|
* @shortname bounds
|
|
58
75
|
* @drawable false
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const [min, max] = await bitbybit.manifold.crossSection.evaluate.bounds({ crossSection: outline });
|
|
79
|
+
* ```
|
|
59
80
|
*/
|
|
60
81
|
bounds(inputs) {
|
|
61
82
|
const bounds = inputs.crossSection.bounds();
|
|
@@ -1,84 +1,124 @@
|
|
|
1
1
|
import * as Inputs from "../../inputs/manifold-inputs";
|
|
2
2
|
import * as Manifold3D from "manifold-3d";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Working with Manifold cross-sections beyond booleans: turning them into solids by extruding along
|
|
5
|
+
* Z or revolving, offsetting their outlines, wrapping them in a convex hull, simplifying them, and
|
|
6
|
+
* composing and decomposing them. Every method returns a new shape.
|
|
6
7
|
*/
|
|
7
8
|
export declare class CrossSectionOperations {
|
|
8
9
|
private manifold;
|
|
9
10
|
constructor(wasm: Manifold3D.ManifoldToplevel);
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
12
|
+
* Wraps a cross-section in its convex hull, the smallest outline without dents that contains
|
|
13
|
+
* it, like a rubber band stretched around it.
|
|
14
|
+
* @param inputs - The cross-section
|
|
15
|
+
* @returns The convex hull
|
|
14
16
|
* @group basic
|
|
15
17
|
* @shortname hull
|
|
16
18
|
* @drawable true
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const wrapped = await bitbybit.manifold.crossSection.operations.hull({ crossSection: outline });
|
|
22
|
+
* ```
|
|
17
23
|
*/
|
|
18
24
|
hull(inputs: Inputs.Manifold.CrossSectionDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
|
|
19
25
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
26
|
+
* Sweeps a cross-section along Z into a solid of the given height.
|
|
27
|
+
*
|
|
28
|
+
* `twistDegrees` turns the top against the bottom, `scaleTopX` and `scaleTopY` shrink or grow
|
|
29
|
+
* it, and `nDivisions` adds sections in between so twists and tapers stay smooth; 0 for both
|
|
30
|
+
* top scales makes a cone. `center` centers the solid on the XY plane instead of standing it on
|
|
31
|
+
* it.
|
|
32
|
+
* @param inputs - The cross-section, the height, the divisions, the twist in degrees, the top scale and whether to center it
|
|
33
|
+
* @returns The extruded solid
|
|
23
34
|
* @group basic
|
|
24
35
|
* @shortname extrude
|
|
25
36
|
* @drawable true
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const twisted = await bitbybit.manifold.crossSection.operations.extrude({ crossSection: square, height: 20, nDivisions: 20, twistDegrees: 90, scaleTopX: 0.5, scaleTopY: 0.5, center: false });
|
|
40
|
+
* ```
|
|
26
41
|
*/
|
|
27
42
|
extrude(inputs: Inputs.Manifold.ExtrudeDto<Manifold3D.CrossSection>): Manifold3D.Manifold;
|
|
28
43
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
44
|
+
* Spins a cross-section around the Y axis into a solid, like a lathe; only the part of the
|
|
45
|
+
* outline on the positive X side is used.
|
|
46
|
+
*
|
|
47
|
+
* `revolveDegrees` below 360 gives a partial turn and `circularSegments` sets how round the
|
|
48
|
+
* result is. The kernel stands the result along Z; `matchProfile`, true by default, turns it
|
|
49
|
+
* back to match the profile.
|
|
50
|
+
* @param inputs - The cross-section, the angle in degrees, the number of segments and whether to match the profile
|
|
51
|
+
* @returns The revolved solid
|
|
32
52
|
* @group basic
|
|
33
53
|
* @shortname revolve
|
|
34
54
|
* @drawable true
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const vase = await bitbybit.manifold.crossSection.operations.revolve({ crossSection: profile, revolveDegrees: 360, circularSegments: 64, matchProfile: true });
|
|
58
|
+
* ```
|
|
35
59
|
*/
|
|
36
60
|
revolve(inputs: Inputs.Manifold.RevolveDto<Manifold3D.CrossSection>): Manifold3D.Manifold;
|
|
37
61
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
62
|
+
* Moves the outline of a cross-section outward by `delta`, or inward for a negative delta, so
|
|
63
|
+
* an outer contour grows and a hole shrinks.
|
|
64
|
+
*
|
|
65
|
+
* `joinType` says how corners are treated: rounded, squared off, mitered or beveled;
|
|
66
|
+
* `miterLimit` caps how far a miter may reach and `circularSegments` how round a rounded corner
|
|
67
|
+
* is. `simplify` afterwards cleans up tiny segments.
|
|
68
|
+
* @param inputs - The cross-section, the distance, the corner treatment and its settings
|
|
69
|
+
* @returns The offset cross-section
|
|
41
70
|
* @group basic
|
|
42
71
|
* @shortname offset
|
|
43
72
|
* @drawable true
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const bigger = await bitbybit.manifold.crossSection.operations.offset({ crossSection: outline, delta: 1, joinType: Bit.Inputs.Manifold.manifoldJoinTypeEnum.round, miterLimit: 2, circularSegments: 32 });
|
|
76
|
+
* ```
|
|
44
77
|
*/
|
|
45
78
|
offset(inputs: Inputs.Manifold.OffsetDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
|
|
46
79
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* its two adjacent vertices. Near duplicate vertices and collinear points
|
|
50
|
-
* will be removed at lower epsilons, with elimination of line segments
|
|
51
|
-
* becoming increasingly aggressive with larger epsilons.
|
|
80
|
+
* Removes points of a cross-section that lie within `epsilon` of the line between their
|
|
81
|
+
* neighbors, dropping near-duplicates and collinear points.
|
|
52
82
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* @param inputs cross section and epsilon parameters
|
|
58
|
-
* @returns simplified cross section
|
|
83
|
+
* A larger epsilon removes more; run it after `offset` to clean up the tiny segments offsetting
|
|
84
|
+
* leaves behind.
|
|
85
|
+
* @param inputs - The cross-section and the distance below which a point is dropped
|
|
86
|
+
* @returns The simplified cross-section
|
|
59
87
|
* @group basic
|
|
60
88
|
* @shortname simplify
|
|
61
89
|
* @drawable true
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const cleaner = await bitbybit.manifold.crossSection.operations.simplify({ crossSection: offsetOutline, epsilon: 1e-4 });
|
|
93
|
+
* ```
|
|
62
94
|
*/
|
|
63
95
|
simplify(inputs: Inputs.Manifold.SimplifyDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
|
|
64
96
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* @
|
|
97
|
+
* Packs several cross-sections or polygons into one cross-section without fusing them, the
|
|
98
|
+
* inverse of `decompose`.
|
|
99
|
+
* @param inputs - The cross-sections or polygons to pack together
|
|
100
|
+
* @returns One cross-section holding all of them
|
|
68
101
|
* @group composition
|
|
69
102
|
* @shortname compose
|
|
70
103
|
* @drawable true
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const packed = await bitbybit.manifold.crossSection.operations.compose({ polygons: [square, disc] });
|
|
107
|
+
* ```
|
|
71
108
|
*/
|
|
72
109
|
compose(inputs: Inputs.Manifold.ComposeDto<(Manifold3D.CrossSection | Manifold3D.Polygons)[]>): Manifold3D.CrossSection;
|
|
73
110
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @
|
|
78
|
-
* @returns decomposed cross sections
|
|
111
|
+
* Splits a cross-section into its separate, unconnected outlines, each with its own holes, the
|
|
112
|
+
* inverse of `compose`.
|
|
113
|
+
* @param inputs - The cross-section
|
|
114
|
+
* @returns The separate outlines
|
|
79
115
|
* @group composition
|
|
80
116
|
* @shortname decompose
|
|
81
117
|
* @drawable true
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const pieces = await bitbybit.manifold.crossSection.operations.decompose({ crossSection: packed });
|
|
121
|
+
* ```
|
|
82
122
|
*/
|
|
83
123
|
decompose(inputs: Inputs.Manifold.CrossSectionDto<Manifold3D.CrossSection>): Manifold3D.CrossSection[];
|
|
84
124
|
}
|
|
@@ -1,40 +1,64 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Working with Manifold cross-sections beyond booleans: turning them into solids by extruding along
|
|
3
|
+
* Z or revolving, offsetting their outlines, wrapping them in a convex hull, simplifying them, and
|
|
4
|
+
* composing and decomposing them. Every method returns a new shape.
|
|
4
5
|
*/
|
|
5
6
|
export class CrossSectionOperations {
|
|
6
7
|
constructor(wasm) {
|
|
7
8
|
this.manifold = wasm;
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
11
|
+
* Wraps a cross-section in its convex hull, the smallest outline without dents that contains
|
|
12
|
+
* it, like a rubber band stretched around it.
|
|
13
|
+
* @param inputs - The cross-section
|
|
14
|
+
* @returns The convex hull
|
|
13
15
|
* @group basic
|
|
14
16
|
* @shortname hull
|
|
15
17
|
* @drawable true
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const wrapped = await bitbybit.manifold.crossSection.operations.hull({ crossSection: outline });
|
|
21
|
+
* ```
|
|
16
22
|
*/
|
|
17
23
|
hull(inputs) {
|
|
18
24
|
return inputs.crossSection.hull();
|
|
19
25
|
}
|
|
20
26
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
27
|
+
* Sweeps a cross-section along Z into a solid of the given height.
|
|
28
|
+
*
|
|
29
|
+
* `twistDegrees` turns the top against the bottom, `scaleTopX` and `scaleTopY` shrink or grow
|
|
30
|
+
* it, and `nDivisions` adds sections in between so twists and tapers stay smooth; 0 for both
|
|
31
|
+
* top scales makes a cone. `center` centers the solid on the XY plane instead of standing it on
|
|
32
|
+
* it.
|
|
33
|
+
* @param inputs - The cross-section, the height, the divisions, the twist in degrees, the top scale and whether to center it
|
|
34
|
+
* @returns The extruded solid
|
|
24
35
|
* @group basic
|
|
25
36
|
* @shortname extrude
|
|
26
37
|
* @drawable true
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const twisted = await bitbybit.manifold.crossSection.operations.extrude({ crossSection: square, height: 20, nDivisions: 20, twistDegrees: 90, scaleTopX: 0.5, scaleTopY: 0.5, center: false });
|
|
41
|
+
* ```
|
|
27
42
|
*/
|
|
28
43
|
extrude(inputs) {
|
|
29
44
|
return inputs.crossSection.extrude(inputs.height, inputs.nDivisions, inputs.twistDegrees, [inputs.scaleTopX, inputs.scaleTopY], inputs.center);
|
|
30
45
|
}
|
|
31
46
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
47
|
+
* Spins a cross-section around the Y axis into a solid, like a lathe; only the part of the
|
|
48
|
+
* outline on the positive X side is used.
|
|
49
|
+
*
|
|
50
|
+
* `revolveDegrees` below 360 gives a partial turn and `circularSegments` sets how round the
|
|
51
|
+
* result is. The kernel stands the result along Z; `matchProfile`, true by default, turns it
|
|
52
|
+
* back to match the profile.
|
|
53
|
+
* @param inputs - The cross-section, the angle in degrees, the number of segments and whether to match the profile
|
|
54
|
+
* @returns The revolved solid
|
|
35
55
|
* @group basic
|
|
36
56
|
* @shortname revolve
|
|
37
57
|
* @drawable true
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const vase = await bitbybit.manifold.crossSection.operations.revolve({ crossSection: profile, revolveDegrees: 360, circularSegments: 64, matchProfile: true });
|
|
61
|
+
* ```
|
|
38
62
|
*/
|
|
39
63
|
revolve(inputs) {
|
|
40
64
|
const res = inputs.crossSection.revolve(inputs.circularSegments, inputs.revolveDegrees);
|
|
@@ -46,43 +70,56 @@ export class CrossSectionOperations {
|
|
|
46
70
|
}
|
|
47
71
|
}
|
|
48
72
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
73
|
+
* Moves the outline of a cross-section outward by `delta`, or inward for a negative delta, so
|
|
74
|
+
* an outer contour grows and a hole shrinks.
|
|
75
|
+
*
|
|
76
|
+
* `joinType` says how corners are treated: rounded, squared off, mitered or beveled;
|
|
77
|
+
* `miterLimit` caps how far a miter may reach and `circularSegments` how round a rounded corner
|
|
78
|
+
* is. `simplify` afterwards cleans up tiny segments.
|
|
79
|
+
* @param inputs - The cross-section, the distance, the corner treatment and its settings
|
|
80
|
+
* @returns The offset cross-section
|
|
52
81
|
* @group basic
|
|
53
82
|
* @shortname offset
|
|
54
83
|
* @drawable true
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const bigger = await bitbybit.manifold.crossSection.operations.offset({ crossSection: outline, delta: 1, joinType: Bit.Inputs.Manifold.manifoldJoinTypeEnum.round, miterLimit: 2, circularSegments: 32 });
|
|
87
|
+
* ```
|
|
55
88
|
*/
|
|
56
89
|
offset(inputs) {
|
|
57
90
|
return inputs.crossSection.offset(inputs.delta, inputs.joinType, inputs.miterLimit, inputs.circularSegments);
|
|
58
91
|
}
|
|
59
92
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* its two adjacent vertices. Near duplicate vertices and collinear points
|
|
63
|
-
* will be removed at lower epsilons, with elimination of line segments
|
|
64
|
-
* becoming increasingly aggressive with larger epsilons.
|
|
93
|
+
* Removes points of a cross-section that lie within `epsilon` of the line between their
|
|
94
|
+
* neighbors, dropping near-duplicates and collinear points.
|
|
65
95
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* @param inputs cross section and epsilon parameters
|
|
71
|
-
* @returns simplified cross section
|
|
96
|
+
* A larger epsilon removes more; run it after `offset` to clean up the tiny segments offsetting
|
|
97
|
+
* leaves behind.
|
|
98
|
+
* @param inputs - The cross-section and the distance below which a point is dropped
|
|
99
|
+
* @returns The simplified cross-section
|
|
72
100
|
* @group basic
|
|
73
101
|
* @shortname simplify
|
|
74
102
|
* @drawable true
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const cleaner = await bitbybit.manifold.crossSection.operations.simplify({ crossSection: offsetOutline, epsilon: 1e-4 });
|
|
106
|
+
* ```
|
|
75
107
|
*/
|
|
76
108
|
simplify(inputs) {
|
|
77
109
|
return inputs.crossSection.simplify(inputs.epsilon);
|
|
78
110
|
}
|
|
79
111
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* @
|
|
112
|
+
* Packs several cross-sections or polygons into one cross-section without fusing them, the
|
|
113
|
+
* inverse of `decompose`.
|
|
114
|
+
* @param inputs - The cross-sections or polygons to pack together
|
|
115
|
+
* @returns One cross-section holding all of them
|
|
83
116
|
* @group composition
|
|
84
117
|
* @shortname compose
|
|
85
118
|
* @drawable true
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* const packed = await bitbybit.manifold.crossSection.operations.compose({ polygons: [square, disc] });
|
|
122
|
+
* ```
|
|
86
123
|
*/
|
|
87
124
|
compose(inputs) {
|
|
88
125
|
const { CrossSection } = this.manifold;
|
|
@@ -90,14 +127,17 @@ export class CrossSectionOperations {
|
|
|
90
127
|
return compose(inputs.polygons);
|
|
91
128
|
}
|
|
92
129
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* @
|
|
97
|
-
* @returns decomposed cross sections
|
|
130
|
+
* Splits a cross-section into its separate, unconnected outlines, each with its own holes, the
|
|
131
|
+
* inverse of `compose`.
|
|
132
|
+
* @param inputs - The cross-section
|
|
133
|
+
* @returns The separate outlines
|
|
98
134
|
* @group composition
|
|
99
135
|
* @shortname decompose
|
|
100
136
|
* @drawable true
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const pieces = await bitbybit.manifold.crossSection.operations.decompose({ crossSection: packed });
|
|
140
|
+
* ```
|
|
101
141
|
*/
|
|
102
142
|
decompose(inputs) {
|
|
103
143
|
return inputs.crossSection.decompose();
|
|
@@ -1,49 +1,70 @@
|
|
|
1
1
|
import * as Inputs from "../../inputs/manifold-inputs";
|
|
2
2
|
import * as Manifold3D from "manifold-3d";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Building Manifold cross-sections, the flat outlines that become solids: squares, rectangles,
|
|
5
|
+
* circles and outlines from raw polygons. They lie in the XY plane; `center` places a shape on the
|
|
6
|
+
* origin, otherwise its corner sits there.
|
|
6
7
|
*/
|
|
7
8
|
export declare class CrossSectionShapes {
|
|
8
9
|
private manifold;
|
|
9
10
|
constructor(wasm: Manifold3D.ManifoldToplevel);
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @
|
|
12
|
+
* Builds a cross-section from polygons given as 2D points, fusing overlapping ones so the
|
|
13
|
+
* result has no crossings.
|
|
14
|
+
*
|
|
15
|
+
* `fillRule` decides which regions count as inside where polygons overlap or a polygon crosses
|
|
16
|
+
* itself.
|
|
17
|
+
* @param inputs - The polygons as 2D point lists and the fill rule
|
|
18
|
+
* @returns The cross-section
|
|
17
19
|
* @group base
|
|
18
20
|
* @shortname create
|
|
19
21
|
* @drawable true
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const outline = await bitbybit.manifold.crossSection.shapes.create({ polygons: [[[0, 0], [10, 0], [10, 10], [0, 10]]], fillRule: Bit.Inputs.Manifold.fillRuleEnum.evenOdd });
|
|
25
|
+
* ```
|
|
20
26
|
*/
|
|
21
27
|
create(inputs: Inputs.Manifold.CreateContourSectionDto): Manifold3D.CrossSection;
|
|
22
28
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @
|
|
29
|
+
* Creates a square cross-section of the given side; with `center` true it is centered on the
|
|
30
|
+
* origin, otherwise its corner sits there.
|
|
31
|
+
* @param inputs - The side length and whether to center it
|
|
32
|
+
* @returns The square cross-section
|
|
26
33
|
* @group primitives
|
|
27
34
|
* @shortname square
|
|
28
35
|
* @drawable true
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const square = await bitbybit.manifold.crossSection.shapes.square({ size: 10, center: true });
|
|
39
|
+
* ```
|
|
29
40
|
*/
|
|
30
41
|
square(inputs: Inputs.Manifold.SquareDto): Manifold3D.CrossSection;
|
|
31
42
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @
|
|
43
|
+
* Creates a circular cross-section of the given radius, centered on the origin and drawn with
|
|
44
|
+
* `circularSegments` straight sides.
|
|
45
|
+
* @param inputs - The radius and the number of sides
|
|
46
|
+
* @returns The circle cross-section
|
|
35
47
|
* @group primitives
|
|
36
48
|
* @shortname circle
|
|
37
49
|
* @drawable true
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const disc = await bitbybit.manifold.crossSection.shapes.circle({ radius: 5, circularSegments: 64 });
|
|
53
|
+
* ```
|
|
38
54
|
*/
|
|
39
55
|
circle(inputs: Inputs.Manifold.CircleDto): Manifold3D.CrossSection;
|
|
40
56
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @
|
|
57
|
+
* Creates a rectangular cross-section with `length` along X and `height` along Y; with `center`
|
|
58
|
+
* true it is centered on the origin, otherwise its corner sits there.
|
|
59
|
+
* @param inputs - The length, the height and whether to center it
|
|
60
|
+
* @returns The rectangle cross-section
|
|
44
61
|
* @group primitives
|
|
45
62
|
* @shortname rectangle
|
|
46
63
|
* @drawable true
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const rectangle = await bitbybit.manifold.crossSection.shapes.rectangle({ length: 20, height: 10, center: true });
|
|
67
|
+
* ```
|
|
47
68
|
*/
|
|
48
69
|
rectangle(inputs: Inputs.Manifold.RectangleDto): Manifold3D.CrossSection;
|
|
49
70
|
}
|
|
@@ -1,33 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Building Manifold cross-sections, the flat outlines that become solids: squares, rectangles,
|
|
3
|
+
* circles and outlines from raw polygons. They lie in the XY plane; `center` places a shape on the
|
|
4
|
+
* origin, otherwise its corner sits there.
|
|
4
5
|
*/
|
|
5
6
|
export class CrossSectionShapes {
|
|
6
7
|
constructor(wasm) {
|
|
7
8
|
this.manifold = wasm;
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
11
|
+
* Builds a cross-section from polygons given as 2D points, fusing overlapping ones so the
|
|
12
|
+
* result has no crossings.
|
|
13
|
+
*
|
|
14
|
+
* `fillRule` decides which regions count as inside where polygons overlap or a polygon crosses
|
|
15
|
+
* itself.
|
|
16
|
+
* @param inputs - The polygons as 2D point lists and the fill rule
|
|
17
|
+
* @returns The cross-section
|
|
16
18
|
* @group base
|
|
17
19
|
* @shortname create
|
|
18
20
|
* @drawable true
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const outline = await bitbybit.manifold.crossSection.shapes.create({ polygons: [[[0, 0], [10, 0], [10, 10], [0, 10]]], fillRule: Bit.Inputs.Manifold.fillRuleEnum.evenOdd });
|
|
24
|
+
* ```
|
|
19
25
|
*/
|
|
20
26
|
create(inputs) {
|
|
21
27
|
const { CrossSection } = this.manifold;
|
|
22
28
|
return new CrossSection(inputs.polygons, inputs.fillRule);
|
|
23
29
|
}
|
|
24
30
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* @
|
|
31
|
+
* Creates a square cross-section of the given side; with `center` true it is centered on the
|
|
32
|
+
* origin, otherwise its corner sits there.
|
|
33
|
+
* @param inputs - The side length and whether to center it
|
|
34
|
+
* @returns The square cross-section
|
|
28
35
|
* @group primitives
|
|
29
36
|
* @shortname square
|
|
30
37
|
* @drawable true
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const square = await bitbybit.manifold.crossSection.shapes.square({ size: 10, center: true });
|
|
41
|
+
* ```
|
|
31
42
|
*/
|
|
32
43
|
square(inputs) {
|
|
33
44
|
const { CrossSection } = this.manifold;
|
|
@@ -35,12 +46,17 @@ export class CrossSectionShapes {
|
|
|
35
46
|
return square(inputs.size, inputs.center);
|
|
36
47
|
}
|
|
37
48
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
49
|
+
* Creates a circular cross-section of the given radius, centered on the origin and drawn with
|
|
50
|
+
* `circularSegments` straight sides.
|
|
51
|
+
* @param inputs - The radius and the number of sides
|
|
52
|
+
* @returns The circle cross-section
|
|
41
53
|
* @group primitives
|
|
42
54
|
* @shortname circle
|
|
43
55
|
* @drawable true
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const disc = await bitbybit.manifold.crossSection.shapes.circle({ radius: 5, circularSegments: 64 });
|
|
59
|
+
* ```
|
|
44
60
|
*/
|
|
45
61
|
circle(inputs) {
|
|
46
62
|
const { CrossSection } = this.manifold;
|
|
@@ -48,12 +64,17 @@ export class CrossSectionShapes {
|
|
|
48
64
|
return circle(inputs.radius, inputs.circularSegments);
|
|
49
65
|
}
|
|
50
66
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @
|
|
67
|
+
* Creates a rectangular cross-section with `length` along X and `height` along Y; with `center`
|
|
68
|
+
* true it is centered on the origin, otherwise its corner sits there.
|
|
69
|
+
* @param inputs - The length, the height and whether to center it
|
|
70
|
+
* @returns The rectangle cross-section
|
|
54
71
|
* @group primitives
|
|
55
72
|
* @shortname rectangle
|
|
56
73
|
* @drawable true
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const rectangle = await bitbybit.manifold.crossSection.shapes.rectangle({ length: 20, height: 10, center: true });
|
|
77
|
+
* ```
|
|
57
78
|
*/
|
|
58
79
|
rectangle(inputs) {
|
|
59
80
|
const { CrossSection } = this.manifold;
|