top.scad 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. include <../config/pot.scad>
  2. include <../config/top.scad>
  3. include <bottom.scad>
  4. function top_size() = [
  5. bottom_size().x + top_wall_thickness * 2,
  6. bottom_size().y + top_wall_thickness * 4 + curtain_space * 2,
  7. bottom_size().z
  8. ];
  9. module top_object() {
  10. function base_size() = [
  11. top_size().x,
  12. top_size().y
  13. ];
  14. function base_size_no_rounding() = [
  15. base_size().x - wall_rounding * 2,
  16. base_size().y - wall_rounding * 2
  17. ];
  18. module cable_hole_shape() {
  19. circle(r = cable_hole / 2);
  20. }
  21. module cable_holes() {
  22. edge
  23. = bottom_size().x / 2
  24. - single_pot_size.x / 2
  25. - pot_wall_thickness;
  26. move = single_pot_size.x + pot_wall_thickness;
  27. for (count = [-edge : move : edge]) {
  28. translate([count, 0]) {
  29. cable_hole_shape();
  30. }
  31. }
  32. }
  33. module base_shape() {
  34. difference() {
  35. minkowski() {
  36. square(base_size_no_rounding(), center = true);
  37. circle(r = wall_rounding);
  38. }
  39. cable_holes();
  40. }
  41. }
  42. module base_object() {
  43. linear_extrude(height = top_wall_thickness) {
  44. base_shape();
  45. }
  46. }
  47. module diode_hole_shape() {
  48. square(diode_size, center = true);
  49. }
  50. module place_shape(cable = true) {
  51. function place_size_no_rounding() = [
  52. single_pot_size.x - (wall_rounding + top_placer_margin) * 2,
  53. single_pot_size.y - (wall_rounding + top_placer_margin) * 2
  54. ];
  55. render() {
  56. difference() {
  57. minkowski() {
  58. square(place_size_no_rounding(), center = true);
  59. circle(r = wall_rounding);
  60. }
  61. if (cable) {
  62. cable_hole_shape();
  63. } else {
  64. diode_hole_shape();
  65. }
  66. }
  67. }
  68. }
  69. module placer_shape(cable = true) {
  70. edge
  71. = bottom_size().x / 2
  72. - single_pot_size.x / 2
  73. - pot_wall_thickness;
  74. move = single_pot_size.x + pot_wall_thickness;
  75. for (count = [-edge : move : edge]) {
  76. translate([count, 0]) {
  77. place_shape(cable);
  78. }
  79. }
  80. }
  81. module placer_object(cable = true) {
  82. linear_extrude(height = top_placer_thickness / 2) {
  83. placer_shape(cable);
  84. }
  85. }
  86. module curtain_shape() {
  87. module curtain() {
  88. move = top_size().x / 2 - wall_rounding;
  89. render() {
  90. hull() {
  91. translate([move, 0]) {
  92. circle(r = wall_rounding);
  93. }
  94. translate([-move, 0]) {
  95. circle(r = wall_rounding);
  96. }
  97. }
  98. }
  99. }
  100. position = top_size().y / 2 - wall_rounding;
  101. translate([0, position]) {
  102. curtain();
  103. }
  104. translate([0, -position]) {
  105. curtain();
  106. }
  107. }
  108. module curtain_object() {
  109. linear_extrude(height = curtain_height) {
  110. curtain_shape();
  111. }
  112. }
  113. color(top_color) {
  114. render() {
  115. base_object();
  116. translate([0, 0, top_wall_thickness]) {
  117. placer_object(cable = true);
  118. curtain_object();
  119. }
  120. translate([0, 0, top_wall_thickness + top_placer_thickness / 2]) {
  121. placer_object(cable = false);
  122. }
  123. }
  124. }
  125. }