@rulecad/shapes 0.4.8 → 0.4.9

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 CHANGED
@@ -4,6 +4,17 @@ 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.9: swept parts as regions
8
+ ### Added
9
+
10
+ - `regionShape` (and so `optimisedOutline`) takes a region of `rings`: closed outlines solid on their left, holes
11
+ clockwise, as cad gives a part swept past a flat plate. It is cut with its holes open; drawn from its `points`
12
+ alone, the solver's single polygon of all its outlines, it would not be.
13
+
14
+ ### Printed sizes that moved
15
+
16
+ - None.
17
+
7
18
  ## 0.4.8: a part as a region
8
19
  ### Fixed
9
20
 
package/optimised.d.mts CHANGED
@@ -4,9 +4,10 @@
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; 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
7
+ * A region of a problem (a circle, a centred rectangle, a polygon, or rings: closed outlines solid on their left, holes
8
+ * clockwise, as a part swept past the plate is cut) as a JSCAD 2D shape; a design's part is null (it is the design's own
9
+ * to add or cut, as it is in 3D).
10
+ * @param {{ at?: [number, number], r?: number, size?: [number, number], points?: [number, number][], rings?: [number, number][][], part?: string }} r
10
11
  * @param {number} [segments]
11
12
  */
12
13
  export function regionShape(r: {
@@ -14,6 +15,7 @@ export function regionShape(r: {
14
15
  r?: number;
15
16
  size?: [number, number];
16
17
  points?: [number, number][];
18
+ rings?: [number, number][][];
17
19
  part?: string;
18
20
  }, segments?: number): jscad.geometries.geom2.Geom2;
19
21
  /**
package/optimised.mjs CHANGED
@@ -23,13 +23,15 @@ 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; 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
26
+ * A region of a problem (a circle, a centred rectangle, a polygon, or rings: closed outlines solid on their left, holes
27
+ * clockwise, as a part swept past the plate is cut) as a JSCAD 2D shape; a design's part is null (it is the design's own
28
+ * to add or cut, as it is in 3D).
29
+ * @param {{ at?: [number, number], r?: number, size?: [number, number], points?: [number, number][], rings?: [number, number][][], part?: string }} r
29
30
  * @param {number} [segments]
30
31
  */
31
32
  export function regionShape(r, segments = 48) {
32
33
  if (r.part || r.triangles) return null;
34
+ if (r.rings) return fromOutlines(r.rings); // a section of several outlines (a part swept past, its holes open), each solid on its left
33
35
  if (r.points) return polygon({ points: r.points });
34
36
  if (r.size) return rectangle({ center: r.at, size: r.size });
35
37
  return circle({ center: r.at, radius: r.r, segments });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulecad/shapes",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
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": {