include <../config/laptop_pocket.scad> include <../config/thread.scad> include <../config/wall.scad> include <../config/cord.scad> include <../config/hole.scad> include include module laptop_pocket_object() { module back_shape() { handle_height = laptop_pocket_handle_back_height; handle_width = laptop_pocket_handle_width; width = laptop_pocket_width; height = laptop_pocket_height; rounding = laptop_pocket_rounding; module corner(x, y) { translate([x, y]) { circle(r = rounding); } } module handle(reverse = false) { move_left_x = width / 2 - rounding; move_right_x = move_left_x - handle_width + rounding * 2; move_y = handle_height / 2 - rounding; hull() { corner(reverse ? move_left_x : -move_left_x, move_y); corner(reverse ? move_right_x : -move_right_x, move_y); corner(reverse ? move_left_x : -move_left_x, -move_y); corner(reverse ? move_right_x : -move_right_x, -move_y); } } module center(scale_x = 0, scale_y = 0) { move_x = width / 2 - rounding - scale_x; move_bottom_y = rounding - handle_height / 2 + scale_y; move_top_y = move_bottom_y + height - rounding * 2 - scale_y * 2; hull() { corner(move_x, move_top_y); corner(move_x, move_bottom_y); corner(-move_x, move_top_y); corner(-move_x, move_bottom_y); } } module connectors() { rounding = laptop_pocket_rounding; module connector(left) { move_x = left ? (-rounding / 2) : (rounding / 2); translate([move_x, rounding / 2]) { difference() { square(rounding * 2, center = true); circle(r = rounding); translate([0, rounding / 2]) { square([rounding * 2, rounding], center = true); } move_x = left ? (-rounding / 2) : (rounding / 2); translate([move_x, -rounding / 2]) { square(rounding, center = true); } } } } width = laptop_pocket_width - laptop_pocket_handle_width * 2; height = laptop_pocket_height; handle_height = laptop_pocket_handle_back_height; move_x = width / 2 - rounding / 2; move_y = height - handle_height / 2 + rounding / 2; translate([move_x, move_y]) { connector(true); } translate([-move_x, move_y]) { connector(false); } } module base_shape() { handle(false); handle(true); center(); connectors(); } module hole_shape() { min_thickness = laptop_pocket_base_thickness * 2 + thread_top_diameter; default_thickness = laptop_pocket_handle_width; thickness = max(min_thickness, default_thickness); center(thickness, thickness); } render() { difference() { base_shape(); hole_shape(); } } } module front_shape() { rounding = laptop_pocket_rounding; width = laptop_pocket_width; height = laptop_pocket_handle_back_height; front_height = thread_top_diameter + laptop_pocket_base_thickness * 2; move_x = width / 2 - rounding; move_bottom_y = rounding - height / 2; move_top_y = move_bottom_y + front_height - rounding * 2; module corner(x, y) { translate([x, y]) { circle(r = rounding); } } hull() { corner(move_x, move_top_y); corner(move_x, move_bottom_y); corner(-move_x, move_top_y); corner(-move_x, move_bottom_y); } } module base_object() { back_thickness = thread_height + laptop_pocket_base_thickness; front_thickness = laptop_pocket_laptop_thickness; thickness = front_thickness + back_thickness; back_center = back_thickness / 2 - thickness / 2; front_center = thickness / 2 - front_thickness / 2; translate([0, back_center, 0]) { rotate([90, 0, 0]) { linear_extrude(height = back_thickness, center = true) { back_shape(); } } } translate([0, front_center, 0]) { rotate([90, 0, 0]) { linear_extrude(height = front_thickness, center = true) { front_shape(); } } } } module final_object() { module thread(move_x, move_z, front = false) { move_y = thread_height / 2 - laptop_pocket_laptop_thickness / 2 - thread_height / 2 - laptop_pocket_base_thickness / 2; translate([move_x, front ? -move_y : move_y, move_z]) { rotate([front ? 90 : 270, 0, 0]) { thread_object(); } } } module back_threads() { base_width = laptop_pocket_width - thread_top_diameter; base_height = laptop_pocket_height - thread_top_diameter; width = base_width - base_width % wall_holes_space; height = base_height - base_height % wall_holes_space; move_x = width / 2; move_y = height / 2; center_y = laptop_pocket_handle_back_height / 2 - laptop_pocket_height / 2; for (count_x = [-move_x : wall_holes_space : move_x]) { for (count_y = [-move_y : wall_holes_space : move_y]) { thread(count_x, count_y - center_y); } } } module front_threads() { move_y = thread_top_diameter / 2 - laptop_pocket_handle_back_height / 2 + laptop_pocket_base_thickness; base_width = laptop_pocket_width - thread_top_diameter; width = base_width - base_width % wall_holes_space; move_x = width / 2; for (count_x = [-move_x : wall_holes_space : move_x]) { thread(count_x, move_y, true); } } module single_cord(move_x) { radius = cord_hole_diameter / 2; height = thread_height + laptop_pocket_base_thickness; move_y = height / 2 - laptop_pocket_laptop_thickness / 2 - height / 2; move_z = laptop_pocket_handle_back_height / 2 - radius / 2 - laptop_pocket_base_thickness * 2; translate([move_x, move_y, move_z]) { rotate([90, 0, 0]) { cylinder(r = radius, h = height, center = true); } } } module cords() { move_x = laptop_pocket_width / 2 - laptop_pocket_handle_width / 2; single_cord(move_x); single_cord(-move_x); } color("#37c887") { render() { difference() { base_object(); back_threads(); front_threads(); cords(); } } } } final_object(); } module laptop_pocket_front_shape() { module base_shape() { width = laptop_pocket_width; height = laptop_pocket_handle_front_height; rounding = laptop_pocket_rounding; move_x = width / 2 - rounding; move_y = height / 2 - rounding; module corner(move_x, move_y) { translate([move_x, move_y]) { circle(r = rounding); } } hull() { corner(move_x, move_y); corner(move_x, -move_y); corner(-move_x, move_y); corner(-move_x, -move_y); } } module center_holes() { move_y = 0; base_width = laptop_pocket_width; width = base_width - base_width % wall_holes_space; move_x = width / 2; module hole(move_x) { translate([move_x, move_y]) { circle(r = thread_screw / 2); } } for (count = [-move_x : wall_holes_space : move_x]) { hole(count); } } module feature_holes(move_y, split) { module hole(move_x) { translate([move_x, move_y]) { rotate(split ? 180 : 0) { hole_shape(); } } } base_width = laptop_pocket_width; width = base_width - base_width % wall_holes_space; move_x = width / 2; for (count = [-move_x : wall_holes_space : move_x]) { hole(count); } } feature_holes_y = laptop_pocket_handle_front_height / 2 - hole_full_height() / 2 - laptop_pocket_rounding; module top_holes() { feature_holes(feature_holes_y, false); } module bottom_holes() { feature_holes(-feature_holes_y, true); } difference() { base_shape(); center_holes(); top_holes(); bottom_holes(); } } module laptop_pocket_front_object() { color("#3b71c4") { render() { thickness = laptop_pocket_front_thickness; linear_extrude(height = thickness, center = true) { laptop_pocket_front_shape(); } } } }