include <../config/shelf.scad> include <../config/wall.scad> include function shelf_mounting_width() = shelf_angle_depth - shelf_rounding * 2; function shelf_mounting_holes() = [ shelf_mounting_width() / 4, shelf_mounting_width() / 4 * 3 ]; module shelf_angle_object() { module base_shape() { move_x = shelf_angle_depth / 2 - shelf_rounding; move_y = shelf_angle_height / 2 - shelf_rounding; module base() { hull() { translate([-move_x, move_y]) { circle(r = shelf_rounding); } translate([-move_x, -move_y]) { circle(r = shelf_rounding); } } hull() { translate([-move_x, shelf_rounding]) { square(shelf_rounding * 2, center = true); } translate([move_x, shelf_rounding]) { circle(r = shelf_rounding); } translate([-move_x, -shelf_rounding]) { square(shelf_rounding * 2, center = true); } translate([move_x, -shelf_rounding]) { circle(r = shelf_rounding); } } } module reverse_corner(size = 10, rotation = 0) { module base() { difference() { square(size * 2, center = true); circle(r = size); } } module mask() { translate([0, size / 2]) { square([size * 2, size], center = true); } translate([size / 2, -size / 2]) { square(size, center = true); } } render() { rotate(90 * rotation) { translate([size / 2, size / 2]) { difference() { base(); mask(); } } } } } module indentation() { width = shelf_angle_depth - shelf_rounding * 2; height = shelf_thickness; translate([shelf_rounding, 0]) { square([width, height], center = true); } } render() { difference() { base(); indentation(); } } test_height = shelf_angle_height / 2 - shelf_rounding * 3; test_depth = shelf_angle_depth - shelf_rounding * 3; size = min(test_height, test_depth); corner_move_x = size / 2 - shelf_angle_depth / 2 + shelf_rounding * 2; corner_move_y = size / 2 + shelf_rounding * 2; translate([corner_move_x, corner_move_y]) { reverse_corner(size, 0); } translate([corner_move_x, -corner_move_y]) { reverse_corner(size, 3); } } module base_object() { linear_extrude(height = shelf_angle_thickness, center = true) { base_shape(); } } module wall_thread(move_y = 0, split) { move_x = (split ? 0 : shelf_rounding * 2) - shelf_angle_depth / 2 - thread_height / 2 * (split ? -1 : 1); render() { translate([move_x, move_y, 0]) { rotate([0, split ? 90 : 270, 0]) { thread_object(); translate([0, 0, -thread_height / 2]) { rotate([0, 180, 0]) { radius = thread_top_diameter / 2; height = shelf_angle_depth; cylinder(r = radius, h = height); } } } } translate([0, move_y, 0]) { rotate([0, 90, 0]) { thread_screw_object(shelf_angle_depth * 2); } } } } module mount_thread(move_x) { move_y = shelf_thickness / 2 + thread_height / 2 + 1; translate([move_x, move_y, 0]) { rotate([90, 0, 0]) { render() { thread_object(); thread_screw_object(shelf_angle_height * 2); rotate([0, 180, 0]) { radius = thread_top_diameter / 2; height = shelf_angle_height; translate([0, 0, thread_height / 2]) { cylinder(r = radius, h = height); } } screw_height = thread_height / 2 + shelf_thickness + shelf_rounding; translate([0, 0, screw_height]) { cylinder(r = thread_screw, h = shelf_angle_height); } } } } } module final_object() { render() { difference() { base_object(); correction = shelf_angle_height % wall_holes_space; move = (shelf_angle_height - correction) / 2; for (count = [-move : wall_holes_space : move]) { wall_thread(count, count == 0); } for (count = shelf_mounting_holes()) { correction = shelf_rounding * 2 - shelf_angle_depth / 2; mount_thread(count + correction); } } } } color("#005555") { render() { final_object(); } } } module shelf_shape() { module base_shape() { move_x = shelf_width / 2 - shelf_rounding; move_y = shelf_depth / 2 - shelf_rounding; module corner(move) { translate(move) { circle(r = shelf_rounding); } } render() { hull() { corner([move_x, move_y]); corner([-move_x, move_y]); corner([move_x, -move_y]); corner([-move_x, -move_y]); } } } module mounting_holes() { base_move = shelf_width - shelf_width % wall_holes_space; move = base_move / 2; indentation_y = shelf_depth / 2; for (count_x = [-move : wall_holes_space : move]) { translate([count_x, -indentation_y]) { size = [shelf_angle_thickness, shelf_rounding * 4]; square(size, center = true); } for (count_y = shelf_mounting_holes()) { holes_y = count_y - shelf_depth / 2 + shelf_rounding * 2; translate([count_x, holes_y]) { circle(r = thread_screw / 2); } } } } module inside_holes() { move_x = (shelf_width - shelf_width % shelf_inside_holes_space) / 2; move_y = (shelf_depth - shelf_depth % shelf_inside_holes_space) / 2; for (count_x = [-move_x : shelf_inside_holes_space : move_x]) { for (count_y = [-move_y : shelf_inside_holes_space : move_y]) { translate([count_x, count_y]) { circle(r = shelf_inside_hole / 2); } } } } module vesa_holes() { translate(shelf_vesa_holes_move) { move_x = shelf_vesa_holes_width / 2; move_y = shelf_vesa_holes_depth / 2; translate([move_x, move_y]) { circle(r = shelf_vesa_hole / 2); } translate([-move_x, move_y]) { circle(r = shelf_vesa_hole / 2); } translate([move_x, -move_y]) { circle(r = shelf_vesa_hole / 2); } translate([-move_x, -move_y]) { circle(r = shelf_vesa_hole / 2); } } } module final_shape() { difference() { base_shape(); mounting_holes(); if (shelf_vesa_holes_enable) { vesa_holes(); } if (shelf_inside_holes_enable) { inside_holes(); } } } render() { final_shape(); } } module shelf_object() { module base() { linear_extrude(height = shelf_thickness, center = true) { shelf_shape(); } } color("#AAAAAA") { render() { base(); } } }