chiark / gitweb /
nook-case: wip, different L and R sides in mains
[reprap-play.git] / nook-case.scad
1 // -*- C -*-
2
3 include <utils.scad>
4
5 nook_th = 12.41 + 0.50;
6 nook_w = 127.12 + 0.75;
7 nook_h = 123.44 + 21.88 + 21.05 + 0.75;
8
9 nook_cnr_rad = 10;
10
11 case_th = 2.5;
12 ledge_w = 4;
13 tape_th = 1.75;
14 tape_inside = 2.0;
15
16 gap = 0.5 * [1,1];
17
18 tape_w = 15;
19
20 test_pillar = 4;
21
22 $test = false;
23
24 // calculated
25
26 ledge_h = case_th;
27 lid_th = case_th;
28
29 spp0 = [0,0];
30 spp1 = spp0 + case_th * [-1,0];
31 spp9 = spp0 + ledge_h * [0,-1];
32 spp8 = spp9 + nook_th * [0,-1];
33 spp7 = spp8 + case_th * [-1,-1];
34
35 spp11y = spp1[1] - tape_th;
36 spp4y  = 0.5 * (spp0[1] + spp7[1]);
37 spp3y = spp4y + tape_inside/2;  spp5y = spp4y - tape_inside/2;
38 spp2y = spp3y + tape_th;        spp6y = spp5y - tape_th;
39
40 spp20 = spp8 + nook_cnr_rad * [1,0];
41 spp20x = spp20[0];
42
43 tppA = spp0 + gap;
44 tppB = spp1 + [0, gap[1]];
45 tppC = tppB + lid_th * [0,1];
46 tppD = [ spp20x, tppC[1] ];
47 tppE = [ spp20x, tppB[1] ];
48 tppF = tppA + ledge_w * [1,0];
49 tppG = tppF + ledge_h * [0,-1];
50 tppH = [ tppA[0], tppG[1] ];
51
52 tppJx = tppA[0] + tape_th;
53
54 tppK = [ tppC[0], tppG[1] ];
55 spp31 = tppK - [0, gap[1]];
56 spp30 = [ spp8[0], spp31[1] ];
57
58 nom_cnr = 0.5 * [nook_w, nook_h, 0] - nook_cnr_rad * [1,1,0];
59
60 module RightSideMainProfile() {
61   rectfromto(spp7, spp0);
62   rectfromto(spp7, spp20);
63 }
64
65 module LeftSideMainProfile() {
66   rectfromto(spp7, spp30);
67   rectfromto(spp7, spp20);
68 }
69
70 module TopTapeCutout() {
71   polygon([ tppA,
72             tppA + [-40, 0],
73             tppG + [-40,-1],
74             [ tppJx, tppH[1]-1 ],
75             [ tppJx, tppC[1]+1 ],
76             [ tppA[0], tppC[1]+1 ]]);
77 }
78
79 module RightTopMainProfile() {
80   l = [ tppA, tppB, tppC, tppD, tppE, tppF, tppG, tppH ];
81   echo(l);
82   polygon(l);
83 }
84
85 module LeftTopMainProfile() {
86   l = [ tppC, tppD, tppE, tppF, tppG, tppK ];
87   echo(l);
88   polygon(l);
89 }
90
91 module SideTapeCutout1(y0,y1) {
92   rectfromto([ spp7[0]-1, y0 ],
93              [ spp8[0]+1, y1 ]);
94 }
95
96 module SideTapeCutout() {
97   SideTapeCutout1(spp6y, spp5y);
98   SideTapeCutout1(spp3y, spp2y);
99   SideTapeCutout1(spp3y, spp2y);
100   SideTapeCutout1(spp11y, spp1[1] + 1);
101 }
102
103 module Demo(){ ////toplevel
104   translate([0,0,-2]) LeftSideMainProfile(); 
105   translate([0,0,-2]) color("yellow") LeftTopMainProfile();
106   color("red") difference(){
107     LeftSideMainProfile();
108     SideTapeCutout();
109   }
110   translate([0,0,0]) color("purple") difference(){
111     LeftTopMainProfile();
112     TopTapeCutout();
113   }
114   translate([nook_cnr_rad*2 + 5, 0,0]) mirror([1,0,0]) {
115     color("red") RightSideMainProfile();
116     color("purple") RightTopMainProfile();
117   }
118   //%SideTapeCutout();
119 }
120
121 module FaceCore(z0,z1){
122   for (mx=[0,1]) mirror([mx,0,0]) {
123       for (my=[0,1]) mirror([0,my,0]) {
124           translate(-nom_cnr) {
125             rotate_extrude(angle=90, convexity=10)
126               translate(-[1,0,0] * nook_cnr_rad)
127               children(mx);
128           }
129         }
130       translate([nook_w/2, 0,0])
131         linextr_y_xz(-nom_cnr[1]-0.1, nom_cnr[1]+0.1)
132         children(1-mx);
133     }
134   for (my=[0,1]) mirror([0,my,0]) {
135       translate([0, -nook_h/2, 0])
136         linextr_x_yz(-nom_cnr[0]-0.1, nom_cnr[0]+0.1)
137         children(0);
138     }
139   if (!$test) {
140     linextr(z0,z1)
141       rectfromto(-nom_cnr, nom_cnr);
142   }
143 }
144
145 module Base(){ ////toplevel
146   FaceCore(0,0) {
147     LeftSideMainProfile();
148     RightSideMainProfile();
149   }
150 }
151
152 module Top(){ ////toplevel
153   FaceCore(0,0) {
154     LeftTopMainProfile();
155     RightTopMainProfile();
156   }
157 }
158
159 module TestExtrude(){
160   difference(){
161     linextr_y_xz(-test_pillar, tape_w+test_pillar) children(0);
162     linextr_y_xz(           0, tape_w            ) children(1);
163   }
164 }
165
166 module TestSide(){ ////toplevel
167   TestExtrude() { LeftSideMainProfile(); SideTapeCutout(); }
168 }
169
170 module TestTop(){ ////toplevel
171   TestExtrude() { LeftTopMainProfile(); TopTapeCutout(); }
172 }
173 module TestTopPrint(){ ////toplevel
174   rotate([180,0,0]) TestTop();
175 }