@rulecad/printcheck 0.2.2 → 0.3.1
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 +4 -0
- package/package.json +5 -1
- package/printcheck.d.mts +6 -5
- package/printcheck.mjs +8 -5
package/README.md
CHANGED
|
@@ -51,6 +51,10 @@ What it checks:
|
|
|
51
51
|
misses a tip like this, because each of its faces may slope at 45° or less. A shallow dip in a smoothed underside
|
|
52
52
|
spreads wide, so it doesn't count.
|
|
53
53
|
|
|
54
|
+
The layer checks (islands, the first layer, overhang as sliced) are the slow part, seconds on a curved part:
|
|
55
|
+
`check(triangles, printer, { slice: false })` leaves them out and says so (`print.unsliced`), for a page that shows
|
|
56
|
+
a part at once and slices it off its own thread (the viewer does).
|
|
57
|
+
|
|
54
58
|
Several parts printed together (a keycap with an inlaid legend in another colour): pass
|
|
55
59
|
`{ parts: [{ triangles, role }] }`. Then one part resting on another isn't an overhang, and each part must be closed on
|
|
56
60
|
its own. A part with `role: 'support'` is printed and then removed.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/printcheck",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Is this mesh printable? Bed fit, flat base, overhangs, bridges, breakaway supports and watertightness, for any FDM printer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"url": "git+https://github.com/JoniBach/rulecad.git",
|
|
31
31
|
"directory": "packages/printcheck"
|
|
32
32
|
},
|
|
33
|
+
"homepage": "https://github.com/JoniBach/rulecad/tree/main/packages/printcheck#readme",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/JoniBach/rulecad/issues"
|
|
36
|
+
},
|
|
33
37
|
"scripts": {
|
|
34
38
|
"test": "node --test"
|
|
35
39
|
},
|
package/printcheck.d.mts
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
/** @typedef {{ bed: number, overhang: number, layer?: number, support_gap?: number, bridge?: number, line?: number, print_gap?: number, foot?: number }} Printer mm and degrees; layer and line drive the sliced-layer island check; print_gap and foot (how far the first layer spreads each side) the first-layer check */
|
|
9
9
|
/**
|
|
10
10
|
* A finding: its level and words, and for programs a code (print.bridge, fit.gap, …), the numbers behind it, and where
|
|
11
|
-
* it is when that's known (the box round the faces it's about, in mm
|
|
12
|
-
* @typedef {{ level: 'pass' | 'warn' | 'fail' | 'info', text: string, code?: string, values?: Record<string, any>, at?: { lo: number[], hi: number[] }, refs?: Record<string, any> }} Finding
|
|
11
|
+
* it is when that's known: at, a point (the middle of it), and box, the box round the faces it's about, in mm.
|
|
12
|
+
* @typedef {{ level: 'pass' | 'warn' | 'fail' | 'info', text: string, code?: string, values?: Record<string, any>, at?: number[], box?: { lo: number[], hi: number[] }, refs?: Record<string, any> }} Finding
|
|
13
13
|
*/
|
|
14
14
|
export function bounds(polys: any): {
|
|
15
15
|
lo: number[];
|
|
@@ -23,7 +23,7 @@ export function bounds(polys: any): {
|
|
|
23
23
|
* @param {{ eps?: number, parts?: { triangles: Face[], role?: 'part' | 'support' }[] }} [options]
|
|
24
24
|
* @returns {Finding[]}
|
|
25
25
|
*/
|
|
26
|
-
export function check(polys: Face[], printer: Printer, { eps, parts }?: {
|
|
26
|
+
export function check(polys: Face[], printer: Printer, { eps, parts, slice }?: {
|
|
27
27
|
eps?: number;
|
|
28
28
|
parts?: {
|
|
29
29
|
triangles: Face[];
|
|
@@ -105,14 +105,15 @@ export type Printer = {
|
|
|
105
105
|
};
|
|
106
106
|
/**
|
|
107
107
|
* A finding: its level and words, and for programs a code (print.bridge, fit.gap, …), the numbers behind it, and where
|
|
108
|
-
* it is when that's known (the box round the faces it's about, in mm
|
|
108
|
+
* it is when that's known: at, a point (the middle of it), and box, the box round the faces it's about, in mm.
|
|
109
109
|
*/
|
|
110
110
|
export type Finding = {
|
|
111
111
|
level: "pass" | "warn" | "fail" | "info";
|
|
112
112
|
text: string;
|
|
113
113
|
code?: string;
|
|
114
114
|
values?: Record<string, any>;
|
|
115
|
-
at?:
|
|
115
|
+
at?: number[];
|
|
116
|
+
box?: {
|
|
116
117
|
lo: number[];
|
|
117
118
|
hi: number[];
|
|
118
119
|
};
|
package/printcheck.mjs
CHANGED
|
@@ -33,8 +33,8 @@ const LEDGE_SLACK = (15 * Math.PI) / 180; // a point's supports all within a hal
|
|
|
33
33
|
/** @typedef {{ bed: number, overhang: number, layer?: number, support_gap?: number, bridge?: number, line?: number, print_gap?: number, foot?: number }} Printer mm and degrees; layer and line drive the sliced-layer island check; print_gap and foot (how far the first layer spreads each side) the first-layer check */
|
|
34
34
|
/**
|
|
35
35
|
* A finding: its level and words, and for programs a code (print.bridge, fit.gap, …), the numbers behind it, and where
|
|
36
|
-
* it is when that's known (the box round the faces it's about, in mm
|
|
37
|
-
* @typedef {{ level: 'pass' | 'warn' | 'fail' | 'info', text: string, code?: string, values?: Record<string, any>, at?: { lo: number[], hi: number[] }, refs?: Record<string, any> }} Finding
|
|
36
|
+
* it is when that's known: at, a point (the middle of it), and box, the box round the faces it's about, in mm.
|
|
37
|
+
* @typedef {{ level: 'pass' | 'warn' | 'fail' | 'info', text: string, code?: string, values?: Record<string, any>, at?: number[], box?: { lo: number[], hi: number[] }, refs?: Record<string, any> }} Finding
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
40
|
export function bounds(polys) {
|
|
@@ -53,8 +53,9 @@ export function bounds(polys) {
|
|
|
53
53
|
* @param {{ eps?: number, parts?: { triangles: Face[], role?: 'part' | 'support' }[] }} [options]
|
|
54
54
|
* @returns {Finding[]}
|
|
55
55
|
*/
|
|
56
|
-
export function check(polys, printer, { eps = 1e-3, parts = null } = {}) {
|
|
57
|
-
|
|
56
|
+
export function check(polys, printer, { eps = 1e-3, parts = null, slice = true } = {}) {
|
|
57
|
+
// (a finding's at is a point, the middle of where it is; box is the box round it: one shape across the kit)
|
|
58
|
+
const out = [], f = (level, text, code, values, box) => out.push({ level, text, code, ...(values && { values }), ...(box && Number.isFinite(box.lo?.[0]) ? { at: box.lo.map((x, k) => (x + box.hi[k]) / 2), box } : {}) });
|
|
58
59
|
// What can't be checked is said at the door, not found out deep inside
|
|
59
60
|
for (const k of ['bed', 'overhang']) if (!(Number(printer?.[k]) > 0)) throw new Error(`check(model, printer): the printer's "${k}" is needed, a number above 0 (got ${JSON.stringify(printer?.[k])}): { bed: 256, overhang: 45, layer: 0.2 }`);
|
|
60
61
|
for (const k of ['layer', 'line', 'bridge', 'support_gap']) if (printer[k] != null && !(Number(printer[k]) > 0)) throw new Error(`check(model, printer): the printer's "${k}" must be a number above 0 (got ${JSON.stringify(printer[k])})`);
|
|
@@ -203,7 +204,9 @@ export function check(polys, printer, { eps = 1e-3, parts = null } = {}) {
|
|
|
203
204
|
const hanging = tips.filter((t) => t[2] - lo[2] > eps && !rests([t, t, t]));
|
|
204
205
|
if (hanging.length) f('warn', `${hanging.length === 1 ? 'a point starts' : `${hanging.length} points start`} in mid-air (z ${mm(Math.min(...hanging.map((t) => t[2])))}${hanging.length > 1 ? ` to ${mm(Math.max(...hanging.map((t) => t[2])))}` : ''} mm): the lowest points of tips hanging down, with nothing below to print on`, 'print.island', { points: hanging }, hanging.reduce((b, t) => grow(b, [t]), { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] }));
|
|
205
206
|
else f('pass', 'nothing starts in mid-air', 'print.island', { points: [] });
|
|
206
|
-
// And as the slicer sees it: every layer against the one below
|
|
207
|
+
// And as the slicer sees it: every layer against the one below (slice: false leaves this out, the slow part: a page
|
|
208
|
+
// can check a part at once, then slice it off its own thread)
|
|
209
|
+
if (!slice) { f('info', 'not sliced: the layers are checked on their own (islands, the first layer, layer overhang)', 'print.unsliced'); continue; }
|
|
207
210
|
// (the first layer spreads `foot` each side as it is squashed on to the bed: two parts printed in place must stand
|
|
208
211
|
// further apart there than the gap that prints apart higher up, or they print as one)
|
|
209
212
|
const firstGap = printer.foot > 0 && printer.print_gap > 0 ? printer.print_gap + 2 * printer.foot : 0;
|