brepjs-sheetmetal 0.2.0 → 0.3.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.
@@ -6136,6 +6136,30 @@ function wireToPolygon(outline) {
6136
6136
  return (0, brepjs.ok)(poly);
6137
6137
  }
6138
6138
  /**
6139
+ * Read a wire as an OPEN polyline: every edge start plus the final edge's end,
6140
+ * so the last vertex of a non-closing path (a form cut) isn't dropped the way
6141
+ * {@link wireToPolygon} drops it for closed loops.
6142
+ *
6143
+ * Arc edges are linearised to their endpoints — the same assumption
6144
+ * {@link wireToPolygon} and the DXF writer make. Form cuts are straight-sided
6145
+ * today (louver/lance slits), so this is exact; a future curved form-feature cut
6146
+ * would render as straight chords in the overlay until arc tessellation is added.
6147
+ */
6148
+ function wireToOpenPolyline(wire) {
6149
+ const edges = (0, brepjs.getEdges)(wire);
6150
+ if (edges.length === 0) return [];
6151
+ const pts = edges.map((edge) => {
6152
+ const p = (0, brepjs.curveStartPoint)(edge);
6153
+ return [p[0], p[1]];
6154
+ });
6155
+ const lastEdge = edges[edges.length - 1];
6156
+ if (lastEdge) {
6157
+ const e = (0, brepjs.curveEndPoint)(lastEdge);
6158
+ pts.push([e[0], e[1]]);
6159
+ }
6160
+ return pts;
6161
+ }
6162
+ /**
6139
6163
  * Reduce a {@link FlatPattern} to serializable 2D polylines (outline, holes, bend
6140
6164
  * lines) for a developed-pattern overlay. Best-effort: a wire that fails to read
6141
6165
  * is dropped rather than throwing, so a partial pattern still yields what it can.
@@ -6161,6 +6185,15 @@ function flatPatternToPolylines(pattern) {
6161
6185
  to: [end[0], end[1]],
6162
6186
  direction: bend.direction
6163
6187
  };
6188
+ }),
6189
+ formCuts: pattern.formCuts.map(wireToOpenPolyline).filter((p) => p.length >= 2),
6190
+ formHinges: pattern.formHinges.map((hinge) => {
6191
+ const start = (0, brepjs.curveStartPoint)(hinge);
6192
+ const end = (0, brepjs.curveEndPoint)(hinge);
6193
+ return {
6194
+ from: [start[0], start[1]],
6195
+ to: [end[0], end[1]]
6196
+ };
6164
6197
  })
6165
6198
  };
6166
6199
  }
@@ -6135,6 +6135,30 @@ function wireToPolygon(outline) {
6135
6135
  return ok(poly);
6136
6136
  }
6137
6137
  /**
6138
+ * Read a wire as an OPEN polyline: every edge start plus the final edge's end,
6139
+ * so the last vertex of a non-closing path (a form cut) isn't dropped the way
6140
+ * {@link wireToPolygon} drops it for closed loops.
6141
+ *
6142
+ * Arc edges are linearised to their endpoints — the same assumption
6143
+ * {@link wireToPolygon} and the DXF writer make. Form cuts are straight-sided
6144
+ * today (louver/lance slits), so this is exact; a future curved form-feature cut
6145
+ * would render as straight chords in the overlay until arc tessellation is added.
6146
+ */
6147
+ function wireToOpenPolyline(wire) {
6148
+ const edges = getEdges(wire);
6149
+ if (edges.length === 0) return [];
6150
+ const pts = edges.map((edge) => {
6151
+ const p = curveStartPoint(edge);
6152
+ return [p[0], p[1]];
6153
+ });
6154
+ const lastEdge = edges[edges.length - 1];
6155
+ if (lastEdge) {
6156
+ const e = curveEndPoint(lastEdge);
6157
+ pts.push([e[0], e[1]]);
6158
+ }
6159
+ return pts;
6160
+ }
6161
+ /**
6138
6162
  * Reduce a {@link FlatPattern} to serializable 2D polylines (outline, holes, bend
6139
6163
  * lines) for a developed-pattern overlay. Best-effort: a wire that fails to read
6140
6164
  * is dropped rather than throwing, so a partial pattern still yields what it can.
@@ -6160,6 +6184,15 @@ function flatPatternToPolylines(pattern) {
6160
6184
  to: [end[0], end[1]],
6161
6185
  direction: bend.direction
6162
6186
  };
6187
+ }),
6188
+ formCuts: pattern.formCuts.map(wireToOpenPolyline).filter((p) => p.length >= 2),
6189
+ formHinges: pattern.formHinges.map((hinge) => {
6190
+ const start = curveStartPoint(hinge);
6191
+ const end = curveEndPoint(hinge);
6192
+ return {
6193
+ from: [start[0], start[1]],
6194
+ to: [end[0], end[1]]
6195
+ };
6163
6196
  })
6164
6197
  };
6165
6198
  }
@@ -24,6 +24,13 @@ export interface FlatPatternPolylines {
24
24
  holes: Polygon[];
25
25
  /** Bend lines, each with its fold direction. */
26
26
  bendLines: FlatPatternBendLine[];
27
+ /** Open form-feature cut paths in the blank (e.g. louver/lance three-sided cuts). */
28
+ formCuts: Polygon[];
29
+ /** Form-feature hinge lines (the uncut fold edge a louver/lance forms up along). */
30
+ formHinges: {
31
+ from: Pt2;
32
+ to: Pt2;
33
+ }[];
27
34
  }
28
35
  /**
29
36
  * Reduce a {@link FlatPattern} to serializable 2D polylines (outline, holes, bend
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brepjs-sheetmetal",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Sheet-metal CAD domain for brepjs — flange authoring, auto-miter, fold/unfold flat patterns",
5
5
  "keywords": [
6
6
  "sheet-metal",