Basic outlining done

This commit is contained in:
Bán Dénes 2020-06-06 23:07:14 +02:00
parent 12f97a9171
commit a21f672839
5 changed files with 31 additions and 13 deletions

View file

@ -14,7 +14,7 @@ zones:
stagger: 12
rows:
- bind_x: left
- bind_x: left
- bind_x: right
- bind_x: right
- name: middle
stagger: 5

View file

@ -19,12 +19,17 @@ const outline = (points, config) => {
const glue_conf = config.outline.glue
const internal_part = (line) => {
// taking the middle part only, so that we don't interfere with corner rounding
return u.line(m.point.middle(line, 0.4), m.point.middle(line, 0.6))
}
const get_line = (def={}) => {
const point = points[def.key]
if (!point) throw new Error(`Point ${def.key} not found...`)
const rect = m.model.originate(point.rect(footprint))
line = rect.paths[def.line || 'top']
return line
return internal_part(line)
}
assert.ok(glue_conf.top)
@ -68,6 +73,7 @@ const outline = (points, config) => {
jsu = require('util')
let i = 0
const keys = {}
let left_keys = {}
let right_keys = {}
for (const zone of Object.values(config.zones)) {
@ -101,17 +107,28 @@ const outline = (points, config) => {
let key = new m.models.RoundRectangle(to_x - from_x, to_y - from_y, corner)
key = m.model.moveRelative(key, [from_x, from_y])
key = p.position(key)
console.log(i+1, pname, jsu.inspect(key, true, null, true))
if (i == 7) throw 7
// keys[pname] = u.deepcopy(key)
// console.log(i+1, pname, jsu.inspect(key, true, null, true))
// if (i == 7) throw 7
keys[pname] = u.deepcopy(p.position(u.rect(14, 14, [-7, -7])))
if (mirrored) {
// TODO running into the problem again where the right side doesn't combine properly
// have to debug this at a lower level, it might be a bug in the makerjs source :/
// first step is to export these inspections and create a minimal reproduction
// if that fails as well, I have to dive into the combineUnion code...
// if (pname === 'mirror_inner_top') {
// u.dump_model({a: right_keys, b: key}, `debug_bad`, true)
// }
right_keys = m.model.combineUnion(key, right_keys)
u.dump_model({a: glue, c: right_keys}, `right_${++i}`)
} else {
// if (pname === 'inner_top') {
// u.dump_model({a: left_keys, b: key}, `debug_good`, true)
// }
left_keys = m.model.combineUnion(key, left_keys)
u.dump_model({a: glue, b: left_keys}, `left_${++i}`)
}
@ -126,7 +143,7 @@ const outline = (points, config) => {
glue = m.model.combineUnion(glue, left_keys)
u.dump_model({a: glue, b: left_keys, c: {models: right_keys}}, `all_after_left`)
glue = m.model.combineUnion(glue, right_keys)
u.dump_model({a: glue, b: left_keys, c: {models: right_keys}}, `all_after_right`)
u.dump_model({a: glue, b: {models: keys}}, `fullll`)
// glue = m.model.outline(glue, expansion)

View file

@ -38,6 +38,10 @@ exports.rect = (w, h, o=[0, 0], mirrored=false) => {
return m.model.move({paths: res}, o)
}
const eq = exports.eq = (a=[], b=[]) => {
return a[0] === b[0] && a[1] === b[1]
}
exports.poly = (arr) => {
let counter = 0
let prev = arr[arr.length - 1]
@ -45,12 +49,10 @@ exports.poly = (arr) => {
paths: {}
}
for (const p of arr) {
if (eq(prev, p)) continue
res.paths['p' + (++counter)] = line(prev, p)
prev = p
}
return res
}
exports.eq = (a, b) => {
return a[0] === b[0] && a[1] === b[1]
}

5
package-lock.json generated
View file

@ -189,9 +189,8 @@
}
},
"makerjs": {
"version": "0.17.0",
"resolved": "https://registry.npmjs.org/makerjs/-/makerjs-0.17.0.tgz",
"integrity": "sha512-uUCQKnzqVwfIzwp4nJEcOBQoxoI5pOD4Y2+8lzRlcboWvO4+H2okzmZ6DiTAT+2w28qDN548Wl/EWXwj2FjACw==",
"version": "github:mrzealot/maker.js-dist#417521f11c9482fc9f518836348a4fb5a5b68b47",
"from": "github:mrzealot/maker.js-dist",
"requires": {
"@danmarshall/jscad-typings": "^1.0.0",
"@types/bezier-js": "^0.0.6",

View file

@ -7,7 +7,7 @@
"dependencies": {
"fs-extra": "^9.0.0",
"js-yaml": "^3.14.0",
"makerjs": "^0.17.0",
"makerjs": "github:mrzealot/maker.js-dist",
"yargs": "^15.3.1"
}
}