| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 | 
							- include <../config/shelf.scad>
 
- include <../config/wall.scad>
 
- include <thread.scad>
 
- 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();
 
-         }
 
-     }
 
- }
 
 
  |