@bitbybit-dev/manifold 1.3.2-rc.1 → 1.4.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/README.md +1 -1
- package/lib/api/dto-registry.d.ts +8 -0
- package/lib/api/dto-registry.js +202 -0
- package/lib/api/inputs/manifold-inputs.d.ts +93 -92
- package/lib/api/inputs/manifold-inputs.js +4 -3
- package/lib/api/resolved-inputs/index.d.ts +82 -0
- package/lib/api/resolved-inputs/index.js +1 -0
- package/lib/api/services/cross-section/cross-section-booleans.js +6 -12
- package/lib/api/services/cross-section/cross-section-operations.js +12 -7
- package/lib/api/services/cross-section/cross-section-shapes.js +10 -7
- package/lib/api/services/cross-section/cross-section-transforms.js +12 -5
- package/lib/api/services/cross-section/cross-section.js +12 -8
- package/lib/api/services/manifold/manifold-booleans.js +16 -17
- package/lib/api/services/manifold/manifold-evaluate.js +6 -2
- package/lib/api/services/manifold/manifold-operations.js +25 -16
- package/lib/api/services/manifold/manifold-shapes.js +8 -8
- package/lib/api/services/manifold/manifold-transforms.js +12 -5
- package/lib/api/services/mesh/mesh-evaluate.js +16 -7
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/package.json +2 -2
|
@@ -828,7 +828,7 @@ export var Manifold;
|
|
|
828
828
|
/**
|
|
829
829
|
* How many properties each vertex has afterwards.
|
|
830
830
|
* @default 3
|
|
831
|
-
* @minimum
|
|
831
|
+
* @minimum 0
|
|
832
832
|
* @maximum Infinity
|
|
833
833
|
* @step 1
|
|
834
834
|
*/
|
|
@@ -854,8 +854,8 @@ export var Manifold;
|
|
|
854
854
|
* Edges bent more than this, in degrees, stay sharp; the rest are smoothed. At 0 nothing is
|
|
855
855
|
* smoothed.
|
|
856
856
|
* @default 60
|
|
857
|
-
* @minimum
|
|
858
|
-
* @maximum
|
|
857
|
+
* @minimum 0
|
|
858
|
+
* @maximum 180
|
|
859
859
|
* @step 1
|
|
860
860
|
*/
|
|
861
861
|
this.minSharpAngle = 60;
|
|
@@ -1100,6 +1100,7 @@ export var Manifold;
|
|
|
1100
1100
|
* How far to spin, in degrees; 360 gives a full turn.
|
|
1101
1101
|
* @default 360
|
|
1102
1102
|
* @minimum 0
|
|
1103
|
+
* @exclusiveMinimum true
|
|
1103
1104
|
* @maximum Infinity
|
|
1104
1105
|
* @step 1
|
|
1105
1106
|
*/
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { WithDefaults } from "@bitbybit-dev/base";
|
|
2
|
+
import * as Inputs from "../inputs";
|
|
3
|
+
export * from "@bitbybit-dev/base/lib/api/resolved-inputs";
|
|
4
|
+
/**
|
|
5
|
+
* The Manifold inputs DTOs as their defaults leave them: every property with a default is present,
|
|
6
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
7
|
+
*/
|
|
8
|
+
export declare namespace Manifold {
|
|
9
|
+
type CalculateCurvatureDto<T> = WithDefaults<Inputs.Manifold.CalculateCurvatureDto<T>, "gaussianIdx" | "meanIdx">;
|
|
10
|
+
type CalculateNormalsDto<T> = WithDefaults<Inputs.Manifold.CalculateNormalsDto<T>, "normalIdx" | "minSharpAngle">;
|
|
11
|
+
type CircleDto = WithDefaults<Inputs.Manifold.CircleDto, "radius" | "circularSegments">;
|
|
12
|
+
type ComposeDto<T> = Inputs.Manifold.ComposeDto<T>;
|
|
13
|
+
type CountDto = Inputs.Manifold.CountDto;
|
|
14
|
+
type CreateContourSectionDto = WithDefaults<Inputs.Manifold.CreateContourSectionDto, "fillRule">;
|
|
15
|
+
type CreateFromMeshDto = Inputs.Manifold.CreateFromMeshDto;
|
|
16
|
+
type CrossSectionDto<T> = Inputs.Manifold.CrossSectionDto<T>;
|
|
17
|
+
type CrossSectionFromPolygonPointsDto = WithDefaults<Inputs.Manifold.CrossSectionFromPolygonPointsDto, "fillRule" | "removeDuplicates" | "tolerance">;
|
|
18
|
+
type CrossSectionFromPolygonsPointsDto = WithDefaults<Inputs.Manifold.CrossSectionFromPolygonsPointsDto, "fillRule" | "removeDuplicates" | "tolerance">;
|
|
19
|
+
type CrossSectionsDto<T> = Inputs.Manifold.CrossSectionsDto<T>;
|
|
20
|
+
type CrossSectionWarpDto<T> = Inputs.Manifold.CrossSectionWarpDto<T>;
|
|
21
|
+
type CubeDto = WithDefaults<Inputs.Manifold.CubeDto, "center" | "size">;
|
|
22
|
+
type CylinderDto = WithDefaults<Inputs.Manifold.CylinderDto, "height" | "radiusLow" | "radiusHigh" | "circularSegments" | "center">;
|
|
23
|
+
type DecomposedManifoldMeshDto = Inputs.Manifold.DecomposedManifoldMeshDto;
|
|
24
|
+
type DecomposeManifoldOrCrossSectionDto<T> = Inputs.Manifold.DecomposeManifoldOrCrossSectionDto<T>;
|
|
25
|
+
type DecomposeManifoldsOrCrossSectionsDto<T> = Inputs.Manifold.DecomposeManifoldsOrCrossSectionsDto<T>;
|
|
26
|
+
type DrawManifoldOrCrossSectionDto<T, M> = WithDefaults<Inputs.Manifold.DrawManifoldOrCrossSectionDto<T, M>, "faceOpacity" | "faceColour" | "crossSectionColour" | "crossSectionWidth" | "crossSectionOpacity" | "computeNormals" | "drawTwoSided" | "backFaceColour" | "backFaceOpacity">;
|
|
27
|
+
type DrawManifoldsOrCrossSectionsDto<T, M> = WithDefaults<Inputs.Manifold.DrawManifoldsOrCrossSectionsDto<T, M>, "faceColour" | "faceOpacity" | "crossSectionColour" | "crossSectionWidth" | "crossSectionOpacity" | "computeNormals" | "drawTwoSided" | "backFaceColour" | "backFaceOpacity">;
|
|
28
|
+
type ExtrudeDto<T> = WithDefaults<Inputs.Manifold.ExtrudeDto<T>, "height" | "nDivisions" | "twistDegrees" | "scaleTopX" | "scaleTopY" | "center">;
|
|
29
|
+
type FromPolygonPointsDto = Inputs.Manifold.FromPolygonPointsDto;
|
|
30
|
+
type HullPointsDto<T> = Inputs.Manifold.HullPointsDto<T>;
|
|
31
|
+
type ManifoldDto<T> = Inputs.Manifold.ManifoldDto<T>;
|
|
32
|
+
type ManifoldOrCrossSectionDto<T> = Inputs.Manifold.ManifoldOrCrossSectionDto<T>;
|
|
33
|
+
type ManifoldRefineDto<T> = WithDefaults<Inputs.Manifold.ManifoldRefineDto<T>, "number">;
|
|
34
|
+
type ManifoldRefineLengthDto<T> = WithDefaults<Inputs.Manifold.ManifoldRefineLengthDto<T>, "length">;
|
|
35
|
+
type ManifoldRefineToleranceDto<T> = WithDefaults<Inputs.Manifold.ManifoldRefineToleranceDto<T>, "tolerance">;
|
|
36
|
+
type ManifoldsDto<T> = Inputs.Manifold.ManifoldsDto<T>;
|
|
37
|
+
type ManifoldSetPropertiesDto<T> = WithDefaults<Inputs.Manifold.ManifoldSetPropertiesDto<T>, "numProp">;
|
|
38
|
+
type ManifoldSimplifyDto<T> = Inputs.Manifold.ManifoldSimplifyDto<T>;
|
|
39
|
+
type ManifoldsMinGapDto<T> = WithDefaults<Inputs.Manifold.ManifoldsMinGapDto<T>, "searchLength">;
|
|
40
|
+
type ManifoldSmoothByNormalsDto<T> = WithDefaults<Inputs.Manifold.ManifoldSmoothByNormalsDto<T>, "normalIdx">;
|
|
41
|
+
type ManifoldSmoothOutDto<T> = WithDefaults<Inputs.Manifold.ManifoldSmoothOutDto<T>, "minSharpAngle" | "minSmoothness">;
|
|
42
|
+
type ManifoldsOrCrossSectionsDto<T> = Inputs.Manifold.ManifoldsOrCrossSectionsDto<T>;
|
|
43
|
+
type ManifoldsToMeshesDto<T> = Inputs.Manifold.ManifoldsToMeshesDto<T>;
|
|
44
|
+
type ManifoldToMeshDto<T> = Inputs.Manifold.ManifoldToMeshDto<T>;
|
|
45
|
+
type ManifoldWarpDto<T> = Inputs.Manifold.ManifoldWarpDto<T>;
|
|
46
|
+
type MeshDto<T> = Inputs.Manifold.MeshDto<T>;
|
|
47
|
+
type MeshHalfEdgeIndexDto<T> = WithDefaults<Inputs.Manifold.MeshHalfEdgeIndexDto<T>, "halfEdgeIndex">;
|
|
48
|
+
type MeshTriangleIndexDto<T> = WithDefaults<Inputs.Manifold.MeshTriangleIndexDto<T>, "triangleIndex">;
|
|
49
|
+
type MeshTriangleRunIndexDto<T> = WithDefaults<Inputs.Manifold.MeshTriangleRunIndexDto<T>, "triangleRunIndex">;
|
|
50
|
+
type MeshVertexIndexDto<T> = WithDefaults<Inputs.Manifold.MeshVertexIndexDto<T>, "vertexIndex">;
|
|
51
|
+
type MirrorCrossSectionDto<T> = WithDefaults<Inputs.Manifold.MirrorCrossSectionDto<T>, "normal">;
|
|
52
|
+
type MirrorDto<T> = WithDefaults<Inputs.Manifold.MirrorDto<T>, "normal">;
|
|
53
|
+
type OffsetDto<T> = WithDefaults<Inputs.Manifold.OffsetDto<T>, "delta" | "joinType" | "miterLimit" | "circularSegments">;
|
|
54
|
+
type RayCastDto<T> = WithDefaults<Inputs.Manifold.RayCastDto<T>, "origin" | "endpoint">;
|
|
55
|
+
type RectangleDto = WithDefaults<Inputs.Manifold.RectangleDto, "length" | "height" | "center">;
|
|
56
|
+
type RevolveDto<T> = WithDefaults<Inputs.Manifold.RevolveDto<T>, "revolveDegrees" | "matchProfile" | "circularSegments">;
|
|
57
|
+
type RotateCrossSectionDto<T> = WithDefaults<Inputs.Manifold.RotateCrossSectionDto<T>, "degrees">;
|
|
58
|
+
type RotateDto<T> = Inputs.Manifold.RotateDto<T>;
|
|
59
|
+
type RotateXYZDto<T> = WithDefaults<Inputs.Manifold.RotateXYZDto<T>, "x" | "y" | "z">;
|
|
60
|
+
type Scale2DCrossSectionDto<T> = WithDefaults<Inputs.Manifold.Scale2DCrossSectionDto<T>, "vector">;
|
|
61
|
+
type Scale3DDto<T> = WithDefaults<Inputs.Manifold.Scale3DDto<T>, "vector">;
|
|
62
|
+
type ScaleCrossSectionDto<T> = WithDefaults<Inputs.Manifold.ScaleCrossSectionDto<T>, "factor">;
|
|
63
|
+
type ScaleDto<T> = WithDefaults<Inputs.Manifold.ScaleDto<T>, "factor">;
|
|
64
|
+
type SimplifyDto<T> = WithDefaults<Inputs.Manifold.SimplifyDto<T>, "epsilon">;
|
|
65
|
+
type SliceDto<T> = WithDefaults<Inputs.Manifold.SliceDto<T>, "height">;
|
|
66
|
+
type SphereDto = WithDefaults<Inputs.Manifold.SphereDto, "radius" | "circularSegments">;
|
|
67
|
+
type SplitByPlaneDto<T> = WithDefaults<Inputs.Manifold.SplitByPlaneDto<T>, "normal" | "originOffset">;
|
|
68
|
+
type SplitByPlaneOnOffsetsDto<T> = WithDefaults<Inputs.Manifold.SplitByPlaneOnOffsetsDto<T>, "normal" | "originOffsets">;
|
|
69
|
+
type SplitManifoldsDto<T> = Inputs.Manifold.SplitManifoldsDto<T>;
|
|
70
|
+
type SquareDto = WithDefaults<Inputs.Manifold.SquareDto, "center" | "size">;
|
|
71
|
+
type TransformCrossSectionDto<T> = Inputs.Manifold.TransformCrossSectionDto<T>;
|
|
72
|
+
type TransformDto<T> = Inputs.Manifold.TransformDto<T>;
|
|
73
|
+
type TransformsDto<T> = Inputs.Manifold.TransformsDto<T>;
|
|
74
|
+
type TranslateByVectorsDto<T> = Inputs.Manifold.TranslateByVectorsDto<T>;
|
|
75
|
+
type TranslateCrossSectionDto<T> = Inputs.Manifold.TranslateCrossSectionDto<T>;
|
|
76
|
+
type TranslateDto<T> = Inputs.Manifold.TranslateDto<T>;
|
|
77
|
+
type TranslateXYCrossSectionDto<T> = WithDefaults<Inputs.Manifold.TranslateXYCrossSectionDto<T>, "x" | "y">;
|
|
78
|
+
type TranslateXYZDto<T> = WithDefaults<Inputs.Manifold.TranslateXYZDto<T>, "x" | "y" | "z">;
|
|
79
|
+
type TrimByPlaneDto<T> = WithDefaults<Inputs.Manifold.TrimByPlaneDto<T>, "normal" | "originOffset">;
|
|
80
|
+
type TwoCrossSectionsDto<T> = Inputs.Manifold.TwoCrossSectionsDto<T>;
|
|
81
|
+
type TwoManifoldsDto<T> = Inputs.Manifold.TwoManifoldsDto<T>;
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@bitbybit-dev/base/lib/api/resolved-inputs";
|
|
@@ -66,8 +66,7 @@ export class CrossSectionBooleans {
|
|
|
66
66
|
*/
|
|
67
67
|
differenceTwo(inputs) {
|
|
68
68
|
const { CrossSection } = this.manifold;
|
|
69
|
-
|
|
70
|
-
return difference(inputs.crossSection1, inputs.crossSection2);
|
|
69
|
+
return CrossSection.difference(inputs.crossSection1, inputs.crossSection2);
|
|
71
70
|
}
|
|
72
71
|
/**
|
|
73
72
|
* Fuses two cross-sections into one, the same as `add`.
|
|
@@ -83,8 +82,7 @@ export class CrossSectionBooleans {
|
|
|
83
82
|
*/
|
|
84
83
|
unionTwo(inputs) {
|
|
85
84
|
const { CrossSection } = this.manifold;
|
|
86
|
-
|
|
87
|
-
return union(inputs.crossSection1, inputs.crossSection2);
|
|
85
|
+
return CrossSection.union(inputs.crossSection1, inputs.crossSection2);
|
|
88
86
|
}
|
|
89
87
|
/**
|
|
90
88
|
* Keeps only the area two cross-sections share, the same as `intersect`.
|
|
@@ -100,8 +98,7 @@ export class CrossSectionBooleans {
|
|
|
100
98
|
*/
|
|
101
99
|
intersectionTwo(inputs) {
|
|
102
100
|
const { CrossSection } = this.manifold;
|
|
103
|
-
|
|
104
|
-
return intersection(inputs.crossSection1, inputs.crossSection2);
|
|
101
|
+
return CrossSection.intersection(inputs.crossSection1, inputs.crossSection2);
|
|
105
102
|
}
|
|
106
103
|
/**
|
|
107
104
|
* Cuts every further cross-section in the list out of the first one.
|
|
@@ -117,8 +114,7 @@ export class CrossSectionBooleans {
|
|
|
117
114
|
*/
|
|
118
115
|
difference(inputs) {
|
|
119
116
|
const { CrossSection } = this.manifold;
|
|
120
|
-
|
|
121
|
-
return difference(inputs.crossSections);
|
|
117
|
+
return CrossSection.difference(inputs.crossSections);
|
|
122
118
|
}
|
|
123
119
|
/**
|
|
124
120
|
* Fuses all the cross-sections in a list into one.
|
|
@@ -134,8 +130,7 @@ export class CrossSectionBooleans {
|
|
|
134
130
|
*/
|
|
135
131
|
union(inputs) {
|
|
136
132
|
const { CrossSection } = this.manifold;
|
|
137
|
-
|
|
138
|
-
return union(inputs.crossSections);
|
|
133
|
+
return CrossSection.union(inputs.crossSections);
|
|
139
134
|
}
|
|
140
135
|
/**
|
|
141
136
|
* Keeps only the area all the cross-sections in a list share.
|
|
@@ -151,7 +146,6 @@ export class CrossSectionBooleans {
|
|
|
151
146
|
*/
|
|
152
147
|
intersection(inputs) {
|
|
153
148
|
const { CrossSection } = this.manifold;
|
|
154
|
-
|
|
155
|
-
return intersection(inputs.crossSections);
|
|
149
|
+
return CrossSection.intersection(inputs.crossSections);
|
|
156
150
|
}
|
|
157
151
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs/manifold-inputs";
|
|
2
|
+
import { resolveDto } from "@bitbybit-dev/base";
|
|
1
3
|
/**
|
|
2
4
|
* Working with Manifold cross-sections beyond booleans: turning them into solids by extruding along
|
|
3
5
|
* Z or revolving, offsetting their outlines, wrapping them in a convex hull, simplifying them, and
|
|
@@ -41,7 +43,8 @@ export class CrossSectionOperations {
|
|
|
41
43
|
* ```
|
|
42
44
|
*/
|
|
43
45
|
extrude(inputs) {
|
|
44
|
-
|
|
46
|
+
const resolved = resolveDto(Inputs.Manifold.ExtrudeDto, inputs);
|
|
47
|
+
return resolved.crossSection.extrude(resolved.height, resolved.nDivisions, resolved.twistDegrees, [resolved.scaleTopX, resolved.scaleTopY], resolved.center);
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
47
50
|
* Spins a cross-section around the Y axis into a solid, like a lathe; only the part of the
|
|
@@ -61,8 +64,9 @@ export class CrossSectionOperations {
|
|
|
61
64
|
* ```
|
|
62
65
|
*/
|
|
63
66
|
revolve(inputs) {
|
|
64
|
-
const
|
|
65
|
-
|
|
67
|
+
const resolved = resolveDto(Inputs.Manifold.RevolveDto, inputs);
|
|
68
|
+
const res = resolved.crossSection.revolve(resolved.circularSegments, resolved.revolveDegrees);
|
|
69
|
+
if (resolved.matchProfile) {
|
|
66
70
|
return res.rotate([-90, 0, 0]);
|
|
67
71
|
}
|
|
68
72
|
else {
|
|
@@ -87,7 +91,8 @@ export class CrossSectionOperations {
|
|
|
87
91
|
* ```
|
|
88
92
|
*/
|
|
89
93
|
offset(inputs) {
|
|
90
|
-
|
|
94
|
+
const resolved = resolveDto(Inputs.Manifold.OffsetDto, inputs);
|
|
95
|
+
return resolved.crossSection.offset(resolved.delta, resolved.joinType, resolved.miterLimit, resolved.circularSegments);
|
|
91
96
|
}
|
|
92
97
|
/**
|
|
93
98
|
* Removes points of a cross-section that lie within `epsilon` of the line between their
|
|
@@ -106,7 +111,8 @@ export class CrossSectionOperations {
|
|
|
106
111
|
* ```
|
|
107
112
|
*/
|
|
108
113
|
simplify(inputs) {
|
|
109
|
-
|
|
114
|
+
const resolved = resolveDto(Inputs.Manifold.SimplifyDto, inputs);
|
|
115
|
+
return resolved.crossSection.simplify(resolved.epsilon);
|
|
110
116
|
}
|
|
111
117
|
/**
|
|
112
118
|
* Packs several cross-sections or polygons into one cross-section without fusing them, the
|
|
@@ -123,8 +129,7 @@ export class CrossSectionOperations {
|
|
|
123
129
|
*/
|
|
124
130
|
compose(inputs) {
|
|
125
131
|
const { CrossSection } = this.manifold;
|
|
126
|
-
|
|
127
|
-
return compose(inputs.polygons);
|
|
132
|
+
return CrossSection.compose(inputs.polygons);
|
|
128
133
|
}
|
|
129
134
|
/**
|
|
130
135
|
* Splits a cross-section into its separate, unconnected outlines, each with its own holes, the
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs/manifold-inputs";
|
|
2
|
+
import { resolveDto } from "@bitbybit-dev/base";
|
|
1
3
|
/**
|
|
2
4
|
* Building Manifold cross-sections, the flat outlines that become solids: squares, rectangles,
|
|
3
5
|
* circles and outlines from raw polygons. They lie in the XY plane; `center` places a shape on the
|
|
@@ -24,8 +26,9 @@ export class CrossSectionShapes {
|
|
|
24
26
|
* ```
|
|
25
27
|
*/
|
|
26
28
|
create(inputs) {
|
|
29
|
+
const resolved = resolveDto(Inputs.Manifold.CreateContourSectionDto, inputs);
|
|
27
30
|
const { CrossSection } = this.manifold;
|
|
28
|
-
return new CrossSection(
|
|
31
|
+
return new CrossSection(resolved.polygons, resolved.fillRule);
|
|
29
32
|
}
|
|
30
33
|
/**
|
|
31
34
|
* Creates a square cross-section of the given side; with `center` true it is centered on the
|
|
@@ -41,9 +44,9 @@ export class CrossSectionShapes {
|
|
|
41
44
|
* ```
|
|
42
45
|
*/
|
|
43
46
|
square(inputs) {
|
|
47
|
+
const resolved = resolveDto(Inputs.Manifold.SquareDto, inputs);
|
|
44
48
|
const { CrossSection } = this.manifold;
|
|
45
|
-
|
|
46
|
-
return square(inputs.size, inputs.center);
|
|
49
|
+
return CrossSection.square(resolved.size, resolved.center);
|
|
47
50
|
}
|
|
48
51
|
/**
|
|
49
52
|
* Creates a circular cross-section of the given radius, centered on the origin and drawn with
|
|
@@ -59,9 +62,9 @@ export class CrossSectionShapes {
|
|
|
59
62
|
* ```
|
|
60
63
|
*/
|
|
61
64
|
circle(inputs) {
|
|
65
|
+
const resolved = resolveDto(Inputs.Manifold.CircleDto, inputs);
|
|
62
66
|
const { CrossSection } = this.manifold;
|
|
63
|
-
|
|
64
|
-
return circle(inputs.radius, inputs.circularSegments);
|
|
67
|
+
return CrossSection.circle(resolved.radius, resolved.circularSegments);
|
|
65
68
|
}
|
|
66
69
|
/**
|
|
67
70
|
* Creates a rectangular cross-section with `length` along X and `height` along Y; with `center`
|
|
@@ -77,8 +80,8 @@ export class CrossSectionShapes {
|
|
|
77
80
|
* ```
|
|
78
81
|
*/
|
|
79
82
|
rectangle(inputs) {
|
|
83
|
+
const resolved = resolveDto(Inputs.Manifold.RectangleDto, inputs);
|
|
80
84
|
const { CrossSection } = this.manifold;
|
|
81
|
-
|
|
82
|
-
return square([inputs.length, inputs.height], inputs.center);
|
|
85
|
+
return CrossSection.square([resolved.length, resolved.height], resolved.center);
|
|
83
86
|
}
|
|
84
87
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs/manifold-inputs";
|
|
2
|
+
import { resolveDto } from "@bitbybit-dev/base";
|
|
1
3
|
/**
|
|
2
4
|
* Moving, turning, scaling, mirroring and warping Manifold cross-sections in the XY plane. Angles
|
|
3
5
|
* are in degrees and rotations turn about the origin; every method returns a new cross-section.
|
|
@@ -18,7 +20,8 @@ export class CrossSectionTransforms {
|
|
|
18
20
|
* ```
|
|
19
21
|
*/
|
|
20
22
|
scale2D(inputs) {
|
|
21
|
-
|
|
23
|
+
const resolved = resolveDto(Inputs.Manifold.Scale2DCrossSectionDto, inputs);
|
|
24
|
+
return resolved.crossSection.scale(resolved.vector);
|
|
22
25
|
}
|
|
23
26
|
/**
|
|
24
27
|
* Scales a cross-section uniformly about the origin by a factor.
|
|
@@ -33,7 +36,8 @@ export class CrossSectionTransforms {
|
|
|
33
36
|
* ```
|
|
34
37
|
*/
|
|
35
38
|
scale(inputs) {
|
|
36
|
-
|
|
39
|
+
const resolved = resolveDto(Inputs.Manifold.ScaleCrossSectionDto, inputs);
|
|
40
|
+
return resolved.crossSection.scale(resolved.factor);
|
|
37
41
|
}
|
|
38
42
|
/**
|
|
39
43
|
* Mirrors a cross-section across the line through the origin that is perpendicular to the given
|
|
@@ -49,7 +53,8 @@ export class CrossSectionTransforms {
|
|
|
49
53
|
* ```
|
|
50
54
|
*/
|
|
51
55
|
mirror(inputs) {
|
|
52
|
-
|
|
56
|
+
const resolved = resolveDto(Inputs.Manifold.MirrorCrossSectionDto, inputs);
|
|
57
|
+
return resolved.crossSection.mirror(resolved.normal);
|
|
53
58
|
}
|
|
54
59
|
/**
|
|
55
60
|
* Moves a cross-section by a 2D vector, in model units.
|
|
@@ -79,7 +84,8 @@ export class CrossSectionTransforms {
|
|
|
79
84
|
* ```
|
|
80
85
|
*/
|
|
81
86
|
translateXY(inputs) {
|
|
82
|
-
|
|
87
|
+
const resolved = resolveDto(Inputs.Manifold.TranslateXYCrossSectionDto, inputs);
|
|
88
|
+
return resolved.crossSection.translate([resolved.x, resolved.y]);
|
|
83
89
|
}
|
|
84
90
|
/**
|
|
85
91
|
* Rotates a cross-section about the origin by an angle in degrees, counterclockwise.
|
|
@@ -94,7 +100,8 @@ export class CrossSectionTransforms {
|
|
|
94
100
|
* ```
|
|
95
101
|
*/
|
|
96
102
|
rotate(inputs) {
|
|
97
|
-
|
|
103
|
+
const resolved = resolveDto(Inputs.Manifold.RotateCrossSectionDto, inputs);
|
|
104
|
+
return resolved.crossSection.rotate(resolved.degrees);
|
|
98
105
|
}
|
|
99
106
|
/**
|
|
100
107
|
* Applies a 3x3 matrix to a cross-section, for any combination of move, turn, scale and shear
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs";
|
|
1
2
|
import { CrossSectionShapes } from "./cross-section-shapes";
|
|
2
3
|
import { CrossSectionOperations } from "./cross-section-operations";
|
|
3
4
|
import { CrossSectionTransforms } from "./cross-section-transforms";
|
|
4
5
|
import { CrossSectionBooleans } from "./cross-section-booleans";
|
|
5
6
|
import { CrossSectionEvaluate } from "./cross-section-evaluate";
|
|
7
|
+
import { resolveDto } from "@bitbybit-dev/base";
|
|
6
8
|
/**
|
|
7
9
|
* Flat outlines in the Manifold kernel, the 2D shapes that `operations.extrude` and
|
|
8
10
|
* `operations.revolve` turn into solids and that `slice` and `project` cut out of them. A
|
|
@@ -43,16 +45,17 @@ export class CrossSection {
|
|
|
43
45
|
* ```
|
|
44
46
|
*/
|
|
45
47
|
crossSectionFromPoints(inputs) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
const resolved = resolveDto(Inputs.Manifold.CrossSectionFromPolygonPointsDto, inputs);
|
|
49
|
+
let points = resolved.points;
|
|
50
|
+
if (resolved.removeDuplicates) {
|
|
48
51
|
points = this.base.point.removeConsecutiveDuplicates({
|
|
49
52
|
points,
|
|
50
53
|
checkFirstAndLast: true,
|
|
51
|
-
tolerance:
|
|
54
|
+
tolerance: resolved.tolerance
|
|
52
55
|
});
|
|
53
56
|
}
|
|
54
57
|
const polygon = points.map(p => [p[0], p[1]]);
|
|
55
|
-
return this.manifold.CrossSection.ofPolygons([polygon],
|
|
58
|
+
return this.manifold.CrossSection.ofPolygons([polygon], resolved.fillRule);
|
|
56
59
|
}
|
|
57
60
|
/**
|
|
58
61
|
* Builds a cross-section from several polygons given as points, for instance an outline and its
|
|
@@ -76,16 +79,17 @@ export class CrossSection {
|
|
|
76
79
|
* ```
|
|
77
80
|
*/
|
|
78
81
|
crossSectionFromPolygons(inputs) {
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
const resolved = resolveDto(Inputs.Manifold.CrossSectionFromPolygonsPointsDto, inputs);
|
|
83
|
+
let polygonPoints = resolved.polygonPoints;
|
|
84
|
+
if (resolved.removeDuplicates) {
|
|
81
85
|
polygonPoints = polygonPoints.map(polygon => this.base.point.removeConsecutiveDuplicates({
|
|
82
86
|
points: polygon,
|
|
83
87
|
checkFirstAndLast: true,
|
|
84
|
-
tolerance:
|
|
88
|
+
tolerance: resolved.tolerance
|
|
85
89
|
}));
|
|
86
90
|
}
|
|
87
91
|
const polygons = polygonPoints.map(polygon => polygon.map(p => [p[0], p[1]]));
|
|
88
|
-
return this.manifold.CrossSection.ofPolygons(polygons,
|
|
92
|
+
return this.manifold.CrossSection.ofPolygons(polygons, resolved.fillRule);
|
|
89
93
|
}
|
|
90
94
|
/**
|
|
91
95
|
* Reads a cross-section back as its polygons, each a list of 2D points.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs/manifold-inputs";
|
|
2
|
+
import { resolveDto } from "@bitbybit-dev/base";
|
|
1
3
|
/**
|
|
2
4
|
* Combining Manifold solids: fusing, cutting and intersecting two or many at once, and splitting a
|
|
3
5
|
* solid with another solid or a plane. Because the kernel works on closed triangle meshes, these
|
|
@@ -102,8 +104,7 @@ export class ManifoldBooleans {
|
|
|
102
104
|
*/
|
|
103
105
|
differenceTwo(inputs) {
|
|
104
106
|
const { Manifold } = this.manifold;
|
|
105
|
-
|
|
106
|
-
return difference(inputs.manifold1, inputs.manifold2);
|
|
107
|
+
return Manifold.difference(inputs.manifold1, inputs.manifold2);
|
|
107
108
|
}
|
|
108
109
|
/**
|
|
109
110
|
* Fuses two solids into one, the same as `add`.
|
|
@@ -119,8 +120,7 @@ export class ManifoldBooleans {
|
|
|
119
120
|
*/
|
|
120
121
|
unionTwo(inputs) {
|
|
121
122
|
const { Manifold } = this.manifold;
|
|
122
|
-
|
|
123
|
-
return union(inputs.manifold1, inputs.manifold2);
|
|
123
|
+
return Manifold.union(inputs.manifold1, inputs.manifold2);
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* Keeps only the volume two solids share, the same as `intersect`.
|
|
@@ -136,8 +136,7 @@ export class ManifoldBooleans {
|
|
|
136
136
|
*/
|
|
137
137
|
intersectionTwo(inputs) {
|
|
138
138
|
const { Manifold } = this.manifold;
|
|
139
|
-
|
|
140
|
-
return intersection(inputs.manifold1, inputs.manifold2);
|
|
139
|
+
return Manifold.intersection(inputs.manifold1, inputs.manifold2);
|
|
141
140
|
}
|
|
142
141
|
/**
|
|
143
142
|
* Cuts every further solid in the list out of the first one.
|
|
@@ -153,8 +152,7 @@ export class ManifoldBooleans {
|
|
|
153
152
|
*/
|
|
154
153
|
difference(inputs) {
|
|
155
154
|
const { Manifold } = this.manifold;
|
|
156
|
-
|
|
157
|
-
return difference(inputs.manifolds);
|
|
155
|
+
return Manifold.difference(inputs.manifolds);
|
|
158
156
|
}
|
|
159
157
|
/**
|
|
160
158
|
* Fuses all the solids in a list into one.
|
|
@@ -170,8 +168,7 @@ export class ManifoldBooleans {
|
|
|
170
168
|
*/
|
|
171
169
|
union(inputs) {
|
|
172
170
|
const { Manifold } = this.manifold;
|
|
173
|
-
|
|
174
|
-
return union(inputs.manifolds);
|
|
171
|
+
return Manifold.union(inputs.manifolds);
|
|
175
172
|
}
|
|
176
173
|
/**
|
|
177
174
|
* Keeps only the volume all the solids in a list share.
|
|
@@ -187,8 +184,7 @@ export class ManifoldBooleans {
|
|
|
187
184
|
*/
|
|
188
185
|
intersection(inputs) {
|
|
189
186
|
const { Manifold } = this.manifold;
|
|
190
|
-
|
|
191
|
-
return intersection(inputs.manifolds);
|
|
187
|
+
return Manifold.intersection(inputs.manifolds);
|
|
192
188
|
}
|
|
193
189
|
/**
|
|
194
190
|
* Cuts a solid with another solid and keeps both pieces: the part inside the cutter and the
|
|
@@ -224,7 +220,8 @@ export class ManifoldBooleans {
|
|
|
224
220
|
* ```
|
|
225
221
|
*/
|
|
226
222
|
splitByPlane(inputs) {
|
|
227
|
-
|
|
223
|
+
const resolved = resolveDto(Inputs.Manifold.SplitByPlaneDto, inputs);
|
|
224
|
+
return resolved.manifold.splitByPlane(resolved.normal, resolved.originOffset);
|
|
228
225
|
}
|
|
229
226
|
/**
|
|
230
227
|
* Cuts a solid into slabs with several parallel planes, all with the same normal, at the given
|
|
@@ -244,14 +241,15 @@ export class ManifoldBooleans {
|
|
|
244
241
|
* ```
|
|
245
242
|
*/
|
|
246
243
|
splitByPlaneOnOffsets(inputs) {
|
|
244
|
+
const resolved = resolveDto(Inputs.Manifold.SplitByPlaneOnOffsetsDto, inputs);
|
|
247
245
|
const pieces = [];
|
|
248
246
|
const junk = [];
|
|
249
|
-
let remainder =
|
|
250
|
-
|
|
247
|
+
let remainder = resolved.manifold.asOriginal();
|
|
248
|
+
resolved.originOffsets.forEach((offset) => {
|
|
251
249
|
if (!remainder) {
|
|
252
250
|
return;
|
|
253
251
|
}
|
|
254
|
-
const halfs = remainder.splitByPlane(
|
|
252
|
+
const halfs = remainder.splitByPlane(resolved.normal, offset);
|
|
255
253
|
junk.push(remainder);
|
|
256
254
|
remainder = undefined;
|
|
257
255
|
if (halfs[1].isEmpty()) {
|
|
@@ -288,6 +286,7 @@ export class ManifoldBooleans {
|
|
|
288
286
|
* ```
|
|
289
287
|
*/
|
|
290
288
|
trimByPlane(inputs) {
|
|
291
|
-
|
|
289
|
+
const resolved = resolveDto(Inputs.Manifold.TrimByPlaneDto, inputs);
|
|
290
|
+
return resolved.manifold.asOriginal().trimByPlane(resolved.normal, resolved.originOffset);
|
|
292
291
|
}
|
|
293
292
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs";
|
|
2
|
+
import { resolveDto } from "@bitbybit-dev/base";
|
|
1
3
|
/**
|
|
2
4
|
* Measuring Manifold solids and reading their bookkeeping: surface area and volume, vertex,
|
|
3
5
|
* triangle and edge counts, the bounding box, the tolerance, the genus, the gap to another solid,
|
|
@@ -196,7 +198,8 @@ export class ManifoldEvaluate {
|
|
|
196
198
|
* ```
|
|
197
199
|
*/
|
|
198
200
|
minGap(inputs) {
|
|
199
|
-
|
|
201
|
+
const resolved = resolveDto(Inputs.Manifold.ManifoldsMinGapDto, inputs);
|
|
202
|
+
return resolved.manifold1.minGap(resolved.manifold2, resolved.searchLength);
|
|
200
203
|
}
|
|
201
204
|
/**
|
|
202
205
|
* Shoots a ray segment from one point to another and lists every place it crosses the surface
|
|
@@ -215,7 +218,8 @@ export class ManifoldEvaluate {
|
|
|
215
218
|
* ```
|
|
216
219
|
*/
|
|
217
220
|
rayCast(inputs) {
|
|
218
|
-
|
|
221
|
+
const resolved = resolveDto(Inputs.Manifold.RayCastDto, inputs);
|
|
222
|
+
return resolved.manifold.rayCast(resolved.origin, resolved.endpoint).map((hit) => ({
|
|
219
223
|
faceID: hit.faceID,
|
|
220
224
|
distance: hit.distance,
|
|
221
225
|
position: [...hit.position],
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs";
|
|
2
|
+
import { resolveDto } from "@bitbybit-dev/base";
|
|
1
3
|
/**
|
|
2
4
|
* Changing Manifold solids beyond booleans: wrapping them in a convex hull, slicing and projecting
|
|
3
5
|
* them into cross-sections, refining and smoothing their meshes, simplifying them, composing and
|
|
@@ -40,8 +42,7 @@ export class ManifoldOperations {
|
|
|
40
42
|
*/
|
|
41
43
|
hullPoints(inputs) {
|
|
42
44
|
const { Manifold } = this.manifold;
|
|
43
|
-
|
|
44
|
-
return hull(inputs.points);
|
|
45
|
+
return Manifold.hull(inputs.points);
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
48
|
* Cuts a solid with a plane parallel to the XY plane at the given Z height and returns the flat
|
|
@@ -60,7 +61,8 @@ export class ManifoldOperations {
|
|
|
60
61
|
* ```
|
|
61
62
|
*/
|
|
62
63
|
slice(inputs) {
|
|
63
|
-
|
|
64
|
+
const resolved = resolveDto(Inputs.Manifold.SliceDto, inputs);
|
|
65
|
+
return resolved.manifold.slice(resolved.height);
|
|
64
66
|
}
|
|
65
67
|
/**
|
|
66
68
|
* Flattens a solid onto the XY plane and returns its outline as a cross-section, like its
|
|
@@ -94,7 +96,8 @@ export class ManifoldOperations {
|
|
|
94
96
|
* ```
|
|
95
97
|
*/
|
|
96
98
|
setTolerance(inputs) {
|
|
97
|
-
|
|
99
|
+
const resolved = resolveDto(Inputs.Manifold.ManifoldRefineToleranceDto, inputs);
|
|
100
|
+
return resolved.manifold.setTolerance(resolved.tolerance);
|
|
98
101
|
}
|
|
99
102
|
/**
|
|
100
103
|
* Reserves a run of `count` unique mesh ids and returns the first, for marking sets of
|
|
@@ -114,8 +117,7 @@ export class ManifoldOperations {
|
|
|
114
117
|
*/
|
|
115
118
|
reserveIds(inputs) {
|
|
116
119
|
const { Manifold } = this.manifold;
|
|
117
|
-
|
|
118
|
-
return reserveIDs(inputs.count);
|
|
120
|
+
return Manifold.reserveIDs(inputs.count);
|
|
119
121
|
}
|
|
120
122
|
/**
|
|
121
123
|
* Makes a copy of a solid that counts as a new original, so the copy can carry its own vertex
|
|
@@ -153,8 +155,7 @@ export class ManifoldOperations {
|
|
|
153
155
|
*/
|
|
154
156
|
compose(inputs) {
|
|
155
157
|
const { Manifold } = this.manifold;
|
|
156
|
-
|
|
157
|
-
return union(inputs.manifolds);
|
|
158
|
+
return Manifold.union(inputs.manifolds);
|
|
158
159
|
}
|
|
159
160
|
/**
|
|
160
161
|
* Splits a solid into its separate, unconnected pieces, the inverse of `compose`.
|
|
@@ -190,7 +191,8 @@ export class ManifoldOperations {
|
|
|
190
191
|
* ```
|
|
191
192
|
*/
|
|
192
193
|
calculateNormals(inputs) {
|
|
193
|
-
|
|
194
|
+
const resolved = resolveDto(Inputs.Manifold.CalculateNormalsDto, inputs);
|
|
195
|
+
return resolved.manifold.calculateNormals(resolved.normalIdx, resolved.minSharpAngle);
|
|
194
196
|
}
|
|
195
197
|
/**
|
|
196
198
|
* Computes how strongly the surface bends at every vertex and stores it in property channels:
|
|
@@ -209,7 +211,8 @@ export class ManifoldOperations {
|
|
|
209
211
|
* ```
|
|
210
212
|
*/
|
|
211
213
|
calculateCurvature(inputs) {
|
|
212
|
-
|
|
214
|
+
const resolved = resolveDto(Inputs.Manifold.CalculateCurvatureDto, inputs);
|
|
215
|
+
return resolved.manifold.calculateCurvature(resolved.gaussianIdx, resolved.meanIdx);
|
|
213
216
|
}
|
|
214
217
|
/**
|
|
215
218
|
* Adds triangles to a smoothed solid until every point of its mesh lies within `tolerance` of
|
|
@@ -228,7 +231,8 @@ export class ManifoldOperations {
|
|
|
228
231
|
* ```
|
|
229
232
|
*/
|
|
230
233
|
refineToTolerance(inputs) {
|
|
231
|
-
|
|
234
|
+
const resolved = resolveDto(Inputs.Manifold.ManifoldRefineToleranceDto, inputs);
|
|
235
|
+
return resolved.manifold.refineToTolerance(resolved.tolerance);
|
|
232
236
|
}
|
|
233
237
|
/**
|
|
234
238
|
* Adds triangles to a solid by splitting every edge into pieces of roughly the given length,
|
|
@@ -247,7 +251,8 @@ export class ManifoldOperations {
|
|
|
247
251
|
* ```
|
|
248
252
|
*/
|
|
249
253
|
refineToLength(inputs) {
|
|
250
|
-
|
|
254
|
+
const resolved = resolveDto(Inputs.Manifold.ManifoldRefineLengthDto, inputs);
|
|
255
|
+
return resolved.manifold.refineToLength(resolved.length);
|
|
251
256
|
}
|
|
252
257
|
/**
|
|
253
258
|
* Adds triangles to a solid by splitting every edge into `number` pieces; with 2, each triangle
|
|
@@ -266,7 +271,8 @@ export class ManifoldOperations {
|
|
|
266
271
|
* ```
|
|
267
272
|
*/
|
|
268
273
|
refine(inputs) {
|
|
269
|
-
|
|
274
|
+
const resolved = resolveDto(Inputs.Manifold.ManifoldRefineDto, inputs);
|
|
275
|
+
return resolved.manifold.refine(resolved.number);
|
|
270
276
|
}
|
|
271
277
|
/**
|
|
272
278
|
* Marks a solid for smoothing by working out tangents from its triangles, so a later `refine`
|
|
@@ -287,7 +293,8 @@ export class ManifoldOperations {
|
|
|
287
293
|
* ```
|
|
288
294
|
*/
|
|
289
295
|
smoothOut(inputs) {
|
|
290
|
-
|
|
296
|
+
const resolved = resolveDto(Inputs.Manifold.ManifoldSmoothOutDto, inputs);
|
|
297
|
+
return resolved.manifold.smoothOut(resolved.minSharpAngle, resolved.minSmoothness);
|
|
291
298
|
}
|
|
292
299
|
/**
|
|
293
300
|
* Marks a solid for smoothing using the normals stored in its vertex properties, so a later
|
|
@@ -306,7 +313,8 @@ export class ManifoldOperations {
|
|
|
306
313
|
* ```
|
|
307
314
|
*/
|
|
308
315
|
smoothByNormals(inputs) {
|
|
309
|
-
|
|
316
|
+
const resolved = resolveDto(Inputs.Manifold.ManifoldSmoothByNormalsDto, inputs);
|
|
317
|
+
return resolved.manifold.smoothByNormals(resolved.normalIdx);
|
|
310
318
|
}
|
|
311
319
|
/**
|
|
312
320
|
* Removes vertices from a solid's mesh while keeping every surface within `tolerance` of where
|
|
@@ -348,6 +356,7 @@ export class ManifoldOperations {
|
|
|
348
356
|
* ```
|
|
349
357
|
*/
|
|
350
358
|
setProperties(inputs) {
|
|
351
|
-
|
|
359
|
+
const resolved = resolveDto(Inputs.Manifold.ManifoldSetPropertiesDto, inputs);
|
|
360
|
+
return resolved.manifold.setProperties(resolved.numProp, resolved.propFunc);
|
|
352
361
|
}
|
|
353
362
|
}
|