diff --git a/src/outlines.js b/src/outlines.js index 6ec7164..66f4308 100644 --- a/src/outlines.js +++ b/src/outlines.js @@ -265,14 +265,13 @@ exports.parse = (config = {}, points = {}, units = {}) => { const corner = a.sane(part.corner || 0, `${name}.corner`, 'number')(rec_units) const bevel = a.sane(part.bevel || 0, `${name}.bevel`, 'number')(rec_units) const rect_mirror = a.sane(part.mirror || false, `${name}.mirror`, 'boolean')() - const rect = rectangle(size[0], size[1], corner, bevel, name) + const rect = m.model.moveRelative(rectangle(size[0], size[1], corner, bevel, name), [-size[0]/2, -size[1]/2]) arg = anchor.position(u.deepcopy(rect)) if (rect_mirror) { const mirror_anchor = u.deepcopy(anchor_def) a.assert(mirror_anchor.ref, `Field "${name}.anchor.ref" must be speficied if mirroring is required!`) anchor = anchor_lib.parse(mirror_anchor, `${name}.anchor --> mirror`, points, undefined, undefined, true)(rec_units) - const mirror_rect = m.model.moveRelative(u.deepcopy(rect), [-size[0], 0]) - arg = u.union(arg, anchor.position(mirror_rect)) + arg = u.union(arg, anchor.position(u.deepcopy(rect))) } break case 'circle': diff --git a/src/point.js b/src/point.js index 41d2c85..f42ab68 100644 --- a/src/point.js +++ b/src/point.js @@ -59,7 +59,7 @@ module.exports = class Point { } rect(size=14) { - let rect = u.rect(size, size, [-size/2, -size/2], this.meta.mirrored) + let rect = u.rect(size, size, [-size/2, -size/2]) return this.position(rect) } } diff --git a/test/cases/001_cube___cases_cube_stl.stl b/test/cases/001_cube___cases_cube_stl.stl index 038a3bc..08f24dd 100644 --- a/test/cases/001_cube___cases_cube_stl.stl +++ b/test/cases/001_cube___cases_cube_stl.stl @@ -1,86 +1,86 @@ solid csg.js facet normal 0 0 -1 outer loop -vertex 0 5 0 -vertex 5 5 0 -vertex 5 0 0 +vertex -2.5 2.5 0 +vertex 2.5 2.5 0 +vertex 2.5 -2.5 0 endloop endfacet facet normal 0 0 -1 outer loop -vertex 0 5 0 -vertex 5 0 0 -vertex 0 0 0 +vertex -2.5 2.5 0 +vertex 2.5 -2.5 0 +vertex -2.5 -2.5 0 endloop endfacet facet normal 0 0 1 outer loop -vertex 0 5 5 -vertex 0 0 5 -vertex 5 0 5 +vertex -2.5 2.5 5 +vertex -2.5 -2.5 5 +vertex 2.5 -2.5 5 endloop endfacet facet normal 0 0 1 outer loop -vertex 0 5 5 -vertex 5 0 5 -vertex 5 5 5 +vertex -2.5 2.5 5 +vertex 2.5 -2.5 5 +vertex 2.5 2.5 5 endloop endfacet facet normal 0 -1 0 outer loop -vertex 5 0 0 -vertex 5 0 5 -vertex 0 0 5 +vertex 2.5 -2.5 0 +vertex 2.5 -2.5 5 +vertex -2.5 -2.5 5 endloop endfacet facet normal 0 -1 0 outer loop -vertex 5 0 0 -vertex 0 0 5 -vertex 0 0 0 +vertex 2.5 -2.5 0 +vertex -2.5 -2.5 5 +vertex -2.5 -2.5 0 endloop endfacet facet normal 1 0 0 outer loop -vertex 5 5 0 -vertex 5 5 5 -vertex 5 0 5 +vertex 2.5 2.5 0 +vertex 2.5 2.5 5 +vertex 2.5 -2.5 5 endloop endfacet facet normal 1 0 0 outer loop -vertex 5 5 0 -vertex 5 0 5 -vertex 5 0 0 +vertex 2.5 2.5 0 +vertex 2.5 -2.5 5 +vertex 2.5 -2.5 0 endloop endfacet facet normal 0 1 0 outer loop -vertex 5 5 5 -vertex 5 5 0 -vertex 0 5 0 +vertex 2.5 2.5 5 +vertex 2.5 2.5 0 +vertex -2.5 2.5 0 endloop endfacet facet normal 0 1 0 outer loop -vertex 5 5 5 -vertex 0 5 0 -vertex 0 5 5 +vertex 2.5 2.5 5 +vertex -2.5 2.5 0 +vertex -2.5 2.5 5 endloop endfacet facet normal -1 0 0 outer loop -vertex 0 5 5 -vertex 0 5 0 -vertex 0 0 0 +vertex -2.5 2.5 5 +vertex -2.5 2.5 0 +vertex -2.5 -2.5 0 endloop endfacet facet normal -1 0 0 outer loop -vertex 0 5 5 -vertex 0 0 0 -vertex 0 0 5 +vertex -2.5 2.5 5 +vertex -2.5 -2.5 0 +vertex -2.5 -2.5 5 endloop endfacet endsolid csg.js diff --git a/test/outlines/affect_mirror___outlines_test_dxf.dxf b/test/outlines/affect_mirror___outlines_test_dxf.dxf index b251d92..2d21a6e 100644 --- a/test/outlines/affect_mirror___outlines_test_dxf.dxf +++ b/test/outlines/affect_mirror___outlines_test_dxf.dxf @@ -241,193 +241,193 @@ LINE 8 0 10 -31.0980762 +27 20 --4.0980762 +-5.1961524 11 -36.2942286 +32.1961524 21 --7.0980762 +-8.1961524 0 LINE 8 0 10 -36.2942286 +32.1961524 20 --7.0980762 +-8.1961524 11 -39.2942286 +35.1961524 21 --1.9019238 +-3 0 LINE 8 0 10 -39.2942286 +35.1961524 20 --1.9019238 +-3 11 -34.0980762 +30 21 -1.0980762 +0 0 LINE 8 0 10 -34.0980762 +30 20 -1.0980762 +0 11 -31.0980762 +27 21 --4.0980762 +-5.1961524 0 LINE 8 0 10 -31.0980762 +27 20 -14.9019238 +13.8038476 11 -36.2942286 +32.1961524 21 -11.9019238 +10.8038476 0 LINE 8 0 10 -36.2942286 +32.1961524 20 -11.9019238 +10.8038476 11 -39.2942286 +35.1961524 21 -17.0980762 +16 0 LINE 8 0 10 -39.2942286 +35.1961524 20 -17.0980762 +16 11 -34.0980762 +30 21 -20.0980762 +19 0 LINE 8 0 10 -34.0980762 +30 20 -20.0980762 +19 11 -31.0980762 +27 21 -14.9019238 +13.8038476 0 LINE 8 0 10 --1.0980762 +-2.1961524 20 --4.0980762 +-8.1961524 11 -4.0980762 +3 21 --1.0980762 +-5.1961524 0 LINE 8 0 10 -4.0980762 +3 20 --1.0980762 +-5.1961524 11 -1.0980762 +0 21 -4.0980762 +0 0 LINE 8 0 10 -1.0980762 +0 20 -4.0980762 +0 11 --4.0980762 +-5.1961524 21 -1.0980762 +-3 0 LINE 8 0 10 --4.0980762 +-5.1961524 20 -1.0980762 +-3 11 --1.0980762 +-2.1961524 21 --4.0980762 +-8.1961524 0 LINE 8 0 10 --1.0980762 +-2.1961524 20 -14.9019238 +10.8038476 11 -4.0980762 +3 21 -17.9019238 +13.8038476 0 LINE 8 0 10 -4.0980762 +3 20 -17.9019238 +13.8038476 11 -1.0980762 +0 21 -23.0980762 +19 0 LINE 8 0 10 -1.0980762 +0 20 -23.0980762 +19 11 --4.0980762 +-5.1961524 21 -20.0980762 +16 0 LINE 8 0 10 --4.0980762 +-5.1961524 20 -20.0980762 +16 11 --1.0980762 +-2.1961524 21 -14.9019238 +10.8038476 0 ENDSEC 0 diff --git a/test/outlines/rectangles.yaml b/test/outlines/rectangles.yaml index 01410ec..43bf02a 100644 --- a/test/outlines/rectangles.yaml +++ b/test/outlines/rectangles.yaml @@ -16,12 +16,12 @@ outlines: ref: - matrix_default_default - mirror_matrix_default_default - shift: [-sx/2, 0] + shift: [0, sy/2] size: [20, 40] outside_rects: type: rectangle anchor: ref: matrix_default_default - shift: [-15, 5] + shift: [-10, 10] size: 10 mirror: true \ No newline at end of file