@rulecad/shapes 0.4.7 → 0.4.8
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/CHANGELOG.md +6 -0
- package/optimised.d.mts +4 -2
- package/optimised.mjs +7 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ What changed in each release, for someone upgrading a workspace. A **printed siz
|
|
|
4
4
|
print (a hole's diameter, a seat's depth, a part's outline). Each release says whether any printed size moved, and
|
|
5
5
|
why.
|
|
6
6
|
|
|
7
|
+
## 0.4.8: a part as a region
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- `optimisedOutline` leaves a design's part named as a keep or avoid region to the design, as `optimisedSolid` does:
|
|
11
|
+
`regionShape` gives null for one. Before, it was drawn as a circle with no radius, and the build failed.
|
|
12
|
+
|
|
7
13
|
## 0.4.7: shaft bores in one place
|
|
8
14
|
### Added
|
|
9
15
|
|
package/optimised.d.mts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export function fromOutlines(loops: [number, number][][]): jscad.geometries.geom2.Geom2;
|
|
6
6
|
/**
|
|
7
|
-
* A region of a problem (a circle, a centred rectangle or a polygon) as a JSCAD 2D shape
|
|
8
|
-
*
|
|
7
|
+
* A region of a problem (a circle, a centred rectangle or a polygon) as a JSCAD 2D shape; a design's part is null (it
|
|
8
|
+
* is the design's own to add or cut, as it is in 3D).
|
|
9
|
+
* @param {{ at?: [number, number], r?: number, size?: [number, number], points?: [number, number][], part?: string }} r
|
|
9
10
|
* @param {number} [segments]
|
|
10
11
|
*/
|
|
11
12
|
export function regionShape(r: {
|
|
@@ -13,6 +14,7 @@ export function regionShape(r: {
|
|
|
13
14
|
r?: number;
|
|
14
15
|
size?: [number, number];
|
|
15
16
|
points?: [number, number][];
|
|
17
|
+
part?: string;
|
|
16
18
|
}, segments?: number): jscad.geometries.geom2.Geom2;
|
|
17
19
|
/**
|
|
18
20
|
* An optimised result's outline, its keep regions added and avoid regions cut exactly.
|
package/optimised.mjs
CHANGED
|
@@ -23,11 +23,13 @@ export function fromOutlines(loops) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* A region of a problem (a circle, a centred rectangle or a polygon) as a JSCAD 2D shape
|
|
27
|
-
*
|
|
26
|
+
* A region of a problem (a circle, a centred rectangle or a polygon) as a JSCAD 2D shape; a design's part is null (it
|
|
27
|
+
* is the design's own to add or cut, as it is in 3D).
|
|
28
|
+
* @param {{ at?: [number, number], r?: number, size?: [number, number], points?: [number, number][], part?: string }} r
|
|
28
29
|
* @param {number} [segments]
|
|
29
30
|
*/
|
|
30
31
|
export function regionShape(r, segments = 48) {
|
|
32
|
+
if (r.part || r.triangles) return null;
|
|
31
33
|
if (r.points) return polygon({ points: r.points });
|
|
32
34
|
if (r.size) return rectangle({ center: r.at, size: r.size });
|
|
33
35
|
return circle({ center: r.at, radius: r.r, segments });
|
|
@@ -40,8 +42,9 @@ export function regionShape(r, segments = 48) {
|
|
|
40
42
|
*/
|
|
41
43
|
export function optimisedOutline(result, { segments = 48 } = {}) {
|
|
42
44
|
let shape = fromOutlines(result.outlines);
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
+
const keep = result.regions.keep.map((r) => regionShape(r, segments)).filter(Boolean), avoid = result.regions.avoid.map((r) => regionShape(r, segments)).filter(Boolean);
|
|
46
|
+
if (keep.length) shape = union(shape, ...keep);
|
|
47
|
+
if (avoid.length) shape = subtract(shape, ...avoid);
|
|
45
48
|
return shape;
|
|
46
49
|
}
|
|
47
50
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/shapes",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "Shape helpers for printed JSCAD designs: text that prints cleanly, anchors on a face, clean local cuts, and enclosure pieces (shells, lids, rails, print-safe holes).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|