Basic outlining done
This commit is contained in:
parent
12f97a9171
commit
a21f672839
5 changed files with 31 additions and 13 deletions
|
@ -14,7 +14,7 @@ zones:
|
||||||
stagger: 12
|
stagger: 12
|
||||||
rows:
|
rows:
|
||||||
- bind_x: left
|
- bind_x: left
|
||||||
- bind_x: left
|
- bind_x: right
|
||||||
- bind_x: right
|
- bind_x: right
|
||||||
- name: middle
|
- name: middle
|
||||||
stagger: 5
|
stagger: 5
|
||||||
|
|
|
@ -19,12 +19,17 @@ const outline = (points, config) => {
|
||||||
|
|
||||||
const glue_conf = config.outline.glue
|
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 get_line = (def={}) => {
|
||||||
const point = points[def.key]
|
const point = points[def.key]
|
||||||
if (!point) throw new Error(`Point ${def.key} not found...`)
|
if (!point) throw new Error(`Point ${def.key} not found...`)
|
||||||
const rect = m.model.originate(point.rect(footprint))
|
const rect = m.model.originate(point.rect(footprint))
|
||||||
line = rect.paths[def.line || 'top']
|
line = rect.paths[def.line || 'top']
|
||||||
return line
|
return internal_part(line)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.ok(glue_conf.top)
|
assert.ok(glue_conf.top)
|
||||||
|
@ -68,6 +73,7 @@ const outline = (points, config) => {
|
||||||
jsu = require('util')
|
jsu = require('util')
|
||||||
|
|
||||||
let i = 0
|
let i = 0
|
||||||
|
const keys = {}
|
||||||
let left_keys = {}
|
let left_keys = {}
|
||||||
let right_keys = {}
|
let right_keys = {}
|
||||||
for (const zone of Object.values(config.zones)) {
|
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)
|
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 = m.model.moveRelative(key, [from_x, from_y])
|
||||||
key = p.position(key)
|
key = p.position(key)
|
||||||
console.log(i+1, pname, jsu.inspect(key, true, null, true))
|
// console.log(i+1, pname, jsu.inspect(key, true, null, true))
|
||||||
if (i == 7) throw 7
|
// if (i == 7) throw 7
|
||||||
// keys[pname] = u.deepcopy(key)
|
keys[pname] = u.deepcopy(p.position(u.rect(14, 14, [-7, -7])))
|
||||||
if (mirrored) {
|
if (mirrored) {
|
||||||
// TODO running into the problem again where the right side doesn't combine properly
|
// 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 :/
|
// 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
|
// 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 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)
|
right_keys = m.model.combineUnion(key, right_keys)
|
||||||
u.dump_model({a: glue, c: right_keys}, `right_${++i}`)
|
u.dump_model({a: glue, c: right_keys}, `right_${++i}`)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// if (pname === 'inner_top') {
|
||||||
|
// u.dump_model({a: left_keys, b: key}, `debug_good`, true)
|
||||||
|
// }
|
||||||
|
|
||||||
left_keys = m.model.combineUnion(key, left_keys)
|
left_keys = m.model.combineUnion(key, left_keys)
|
||||||
u.dump_model({a: glue, b: left_keys}, `left_${++i}`)
|
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)
|
glue = m.model.combineUnion(glue, left_keys)
|
||||||
u.dump_model({a: glue, b: left_keys, c: {models: right_keys}}, `all_after_left`)
|
u.dump_model({a: glue, b: left_keys, c: {models: right_keys}}, `all_after_left`)
|
||||||
glue = m.model.combineUnion(glue, right_keys)
|
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)
|
// glue = m.model.outline(glue, expansion)
|
||||||
|
|
|
@ -38,6 +38,10 @@ exports.rect = (w, h, o=[0, 0], mirrored=false) => {
|
||||||
return m.model.move({paths: res}, o)
|
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) => {
|
exports.poly = (arr) => {
|
||||||
let counter = 0
|
let counter = 0
|
||||||
let prev = arr[arr.length - 1]
|
let prev = arr[arr.length - 1]
|
||||||
|
@ -45,12 +49,10 @@ exports.poly = (arr) => {
|
||||||
paths: {}
|
paths: {}
|
||||||
}
|
}
|
||||||
for (const p of arr) {
|
for (const p of arr) {
|
||||||
|
if (eq(prev, p)) continue
|
||||||
res.paths['p' + (++counter)] = line(prev, p)
|
res.paths['p' + (++counter)] = line(prev, p)
|
||||||
prev = p
|
prev = p
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.eq = (a, b) => {
|
|
||||||
return a[0] === b[0] && a[1] === b[1]
|
|
||||||
}
|
|
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -189,9 +189,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"makerjs": {
|
"makerjs": {
|
||||||
"version": "0.17.0",
|
"version": "github:mrzealot/maker.js-dist#417521f11c9482fc9f518836348a4fb5a5b68b47",
|
||||||
"resolved": "https://registry.npmjs.org/makerjs/-/makerjs-0.17.0.tgz",
|
"from": "github:mrzealot/maker.js-dist",
|
||||||
"integrity": "sha512-uUCQKnzqVwfIzwp4nJEcOBQoxoI5pOD4Y2+8lzRlcboWvO4+H2okzmZ6DiTAT+2w28qDN548Wl/EWXwj2FjACw==",
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@danmarshall/jscad-typings": "^1.0.0",
|
"@danmarshall/jscad-typings": "^1.0.0",
|
||||||
"@types/bezier-js": "^0.0.6",
|
"@types/bezier-js": "^0.0.6",
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fs-extra": "^9.0.0",
|
"fs-extra": "^9.0.0",
|
||||||
"js-yaml": "^3.14.0",
|
"js-yaml": "^3.14.0",
|
||||||
"makerjs": "^0.17.0",
|
"makerjs": "github:mrzealot/maker.js-dist",
|
||||||
"yargs": "^15.3.1"
|
"yargs": "^15.3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue