chiark / gitweb /
poster-tube-lid: WallMountBase wip
[reprap-play.git] / poster-tube-lid.scad
1 // -*- C -*-
2
3 // Print, for each end:
4 //
5 //   CoverPrint
6 //   StrapMount
7 //   CatchAssembly
8
9 include <funcs.scad>
10 include <utils.scad>
11
12 coarse = false;
13 enable_head_cups = false;
14
15 main_dia = 71.2 + 0.50 - 2.26;
16 top_thick_middle = 4;
17 top_thick_by_oring = 3.0;
18 top_middle_dr = 11;
19
20 main_cnr = 6.0;
21
22 min_wall = 3;
23
24 rivet_posn = 6.0 + 0.30;
25 rivet_thick = 1.67;
26 rivet_width = 4.15 + 1.0;
27 rivet_tall = 5.51 + 1.49;
28
29 over_rivet_wall = 1.0;
30 side_rivet_gap = 1.5;
31 inside_rivet_gap = 1.5;
32
33 bayo_interf = 0.30;
34 bayo_behind = 8.5;
35 bayo_interf_width = 2.0;
36 bayo_interf_slope = 0.5;
37
38 oring_thick = 5.0;
39 oring_bore = 62.0;
40
41 oring_upper_embed_angle = 80;
42 oring_compress = 0.1; // proportion
43 oring_compress_more = 0.2;
44
45 oring_rm_beside = 8;
46 oring_rm_scale = 2.0;
47 oring_rm_angle = 20;
48
49 side_taper = 1.0;
50
51 bayo_gap = 6.0;
52
53 bayo_entry = 1.167;
54 bayo_inramp = 0.9;
55
56 bayo_slice_size = coarse ? 5 : 1;
57
58 brace_hole_width = 1.0;
59 brace_above_below = 1.2;
60 brace_end_shorter = 0.3;
61
62 jig_thick = 1.4;
63 jig_hole_dia = 3.0;
64 jig_rim = 5;
65 jig_mark = 5;
66
67 strap_loop_thick = 6;
68 strap_loop_inside = 10;
69 strap_loop_strlen = 10;
70 strap_loop_elevation = 45;
71
72 sm_inner_circum = 218 - 1.90 - 1.00 - 0.50;
73 sm_main_thick = 2.0;
74 sm_main_width = 20;
75
76 sm_bolt_dia = 3.5 + 0.1;
77 sm_bolt_shaft = 21.0;
78 sm_bolt_head_dia = 6.94 + 1.0;
79 sm_bolt_head_thick = 2.14;
80 sm_bolt_nut_width = 5.89 + 0.25;
81 sm_bolt_nut_thick = 3.68;
82 sm_bolt_tighten_allow = 2.0;
83
84 sm_bolt_y_clear = 0.75;
85 sm_bolt_y_over = 0.5;
86
87 sm_closure_cnr = 3.0;
88
89 wm_thick = 5;
90 wm_screw_dia = 4.5; // XXX
91 wm_screwdriver_dia = 6.0; // XXX
92 wm_screw_around = 4.0; // XXX
93 wm_screw_slot = 3.5;
94 wm_screw_head = 7.5; // XXX
95
96 wmb_screw_dia = 5;
97 wmb_screw_head_dia = 10; // XXX
98 wmb_screw_around_x = 4; // XXX
99 wmb_screw_around_z = 6; // XXX
100 wmb_screw_depth_min = 10;
101 web_screw_len = 15 + 1; // XXX
102 wmb_nut_across = 8; // XXX
103 wmb_nut_around_min = 2; // XXX
104 wmb_nut_behind_min = 5;
105 wmb_nut_th = 4; // XXX
106 wmb_mount_wall = 4.5;
107 wmb_mount_gap_xy = 0.5;
108 wmb_mount_gap_z = 0.5;
109 wmb_mount_y_width = 10;
110 wmb_bottom_gap = 35; // includes allowance for padding, etc.
111 wmb_bottom_th = 7;
112 wmb_bottom_th_min = 1;
113 wmb_ring_gap = 1.0;
114 wmb_base_extra_rad = 10;
115
116 catch_stalk_h = 4.5;
117 catch_stalk_len = 50;
118 catch_tip_th = 4;
119 catch_head_th = 3;
120
121 catch_pin_slop = 0.25; // each side, and above
122 catch_pin_slop_x_extra = 0.0; // only on one side
123 catch_stalk_above_gap = 1.5;
124 catch_stalk_eff_bend_rad = catch_stalk_len * 0.75;
125
126 catch_strap_width = 12;
127 catch_stalk_base_width = 15;
128
129 catch_knob_dia = 6;
130 catch_knob_above_gap = 5;
131 catch_knob_height = 3.0;
132
133 catch_stalk_below_gap = 1.0;
134 catch_stalk_beside_gap = 2.0;
135
136 // calculated
137
138 TAU = PI*2;
139
140 bayo_entry_x = bayo_entry;
141 bayo_entry_z = bayo_entry;
142 bayo_inramp_x = bayo_inramp;
143 bayo_inramp_z = bayo_inramp;
144
145 oring_mid_dia = oring_bore + oring_thick;
146 oring_outer_dia = oring_mid_dia + oring_thick;
147
148 oring_oblate = (1 - oring_compress);
149
150 oring_y_rad = oring_thick/2 * oring_oblate;
151 oring_x_rad = oring_thick/2 / oring_oblate;
152
153 by_oring_z = oring_y_rad * (1 + cos(oring_upper_embed_angle));
154
155 side_height = rivet_posn + bayo_behind + rivet_thick/2;
156 side_thick = rivet_tall + over_rivet_wall;
157
158 top_z = top_thick_by_oring + oring_y_rad + by_oring_z;
159
160 middle_bot_z = top_z - top_thick_middle;
161
162 bayo_top_z = bayo_behind + bayo_gap;
163
164 bayo_nom_rad = main_dia/2 + side_thick;
165 bayo_real_rad = main_dia/2 + rivet_tall;
166
167 rivet_entry_width = rivet_width + side_rivet_gap;
168
169 jig_mark_rad = jig_mark + main_dia/2 + jig_thick;
170
171 handling_dia = oring_bore + oring_thick*2 + min_wall*2;
172 handling_angle = 45;
173
174 sm_inner_rad = (sm_inner_circum + sm_bolt_tighten_allow/2) / TAU;
175 sm_outer_rad = sm_inner_rad + sm_main_thick;
176
177 wm_main_width = sm_main_width;
178 wm_y_min = sqrt( pow(sm_inner_rad, 2) -
179                  pow(sm_inner_rad - (wm_thick - sm_main_thick), 2) );
180 wm_y_screw = wm_y_min + wm_screw_around + wm_screw_dia/2;
181 wm_y_max = wm_y_screw + wm_screw_dia/2 + wm_screw_around;
182 wm_y_slotc_screw = wm_y_screw + wm_screw_slot/2;
183 wm_y_slot1_screw = wm_y_screw + wm_screw_slot;
184 wm_y_slot1_max = wm_y_max + wm_screw_slot;
185 wm_z_slot0_screw = wm_main_width + wm_screwdriver_dia/2;
186 wm_z_slotc_screw = wm_z_slot0_screw + wm_screw_slot/2;
187 wm_z_slot1_screw = wm_z_slot0_screw + wm_screw_slot;
188 wm_z_max = wm_z_slot1_screw + wm_screw_around;
189
190 wmb_mount_cut_rad = sm_outer_rad + wmb_ring_gap;
191 wmb_nut_rad = wmb_nut_across / cos(30) * 0.5;
192 wmb_x_screw_plus_around_r = max(
193                                 wmb_screw_around_x + wmb_screw_dia/2,
194                                 wmb_nut_around_min + wmb_nut_across/2
195                                 );
196 wmb_x_screw = -sm_outer_rad + wmb_x_screw_plus_around_r;
197 wmb_x_outer = -sm_outer_rad + wmb_x_screw_plus_around_r * 2;
198 function wmb_screw_thing_y_min(dia) = sqrt(
199                        pow(wmb_mount_cut_rad, 2) -
200                        pow(wmb_x_screw + dia/2, 2)
201                        );
202 wmb_y_screw_end = wmb_screw_thing_y_min(wmb_screw_dia);
203 wmb_y_nut_min = wmb_screw_thing_y_min(wmb_nut_across + wmb_nut_around_min*2);
204 wmb_y_mount_max = max(
205                       wmb_y_nut_min + wmb_nut_th + wmb_nut_behind_min,
206                       wmb_y_screw_end + wmb_screw_depth_min
207                       );
208 wmb_z_screw = max(
209                   wmb_screw_around_z + wmb_screw_dia/2,
210                   wmb_nut_around_min + wmb_nut_rad
211                   );
212 wmb_z_max = wmb_z_screw * 2;
213 wmbb_y_max = wmb_y_mount_max + wmb_mount_gap_xy + wmb_mount_wall;
214 wmbb_x_outer = wmb_x_outer + (wmb_mount_gap_xy + wmb_mount_wall);
215 wmbb_z_flat_max = -wmb_bottom_gap;
216 wmbb_z_flat_whole_min = wmbb_z_flat_max - wmb_bottom_th_min;
217 wmbb_z_min      = wmbb_z_flat_max - wmb_bottom_th;
218 wmbb_r_top = main_dia/2 + wmb_base_extra_rad;
219 wmbb_r_bottom = wmbb_r_top - (wmb_bottom_th - wmb_bottom_th_min);
220
221 smc_pos = [ 0, sm_inner_rad, 0 ];
222
223 smc_bolt_nut_dia = sm_bolt_nut_width / cos(30);
224 smc_bolt_nut_eff_thick = sm_bolt_nut_thick + sm_bolt_tighten_allow;
225
226 smc_bolt_y = sm_bolt_dia/2 + sm_bolt_y_clear;
227 smc_max_y = smc_bolt_y + sm_bolt_y_over
228   + max(sm_bolt_head_dia/2, smc_bolt_nut_dia/2);
229 smc_cnr_c_x = sm_bolt_shaft/2 - sm_closure_cnr
230   + sm_bolt_head_thick/2 + smc_bolt_nut_eff_thick/2;
231
232 catch_cr = catch_knob_dia/2 + catch_stalk_beside_gap;
233 catch_strap_thick = sm_main_thick;
234
235 echo("R ", sm_inner_rad, bayo_real_rad, bayo_nom_rad);
236
237 $fs= coarse ? 2.5 : 0.5;
238 $fa= coarse ? 5 : 1;
239
240 include <poster-tube-lid-parametric.scad>
241
242 // bayonet definition
243
244 bayo_a = [ bayo_entry_x, 0 ];
245 bayo_p = [ 0, bayo_entry_z ];
246 bayo_n = [ 0, bayo_behind-bayo_inramp_z ];
247 bayo_m = [ bayo_inramp_x, bayo_behind ];
248 bayo_l = bayo_m + bayo_interf * [ 1/bayo_interf_slope,  1 ];
249 bayo_k = bayo_l + [ bayo_interf_width, 0 ];
250 bayo_j = bayo_k + bayo_interf * [ 1/bayo_interf_slope, -1 ];
251 bayo_i = bayo_j + [ rivet_width + inside_rivet_gap, 0 ];
252 bayo_h = [ bayo_i[0], bayo_behind + bayo_gap + bayo_interf ];
253 bayo_g = [ bayo_m[0] - rivet_width, bayo_h[1] ];
254
255 bayo_e = [-bayo_p[0], bayo_p[1]] - [rivet_entry_width,0];
256 bayo_d = [-bayo_a[0], bayo_a[1]] - [rivet_entry_width,0];
257 bayo_c = bayo_d + [0,-5];
258 bayo_b = bayo_a + [0,-5];
259
260 bayo_f = [ bayo_e[0], bayo_g[1] + (bayo_e[0] - bayo_g[0]) ];
261
262 bayo_polygon = [ bayo_a,
263                  bayo_b,
264                  bayo_c,
265                  bayo_d,
266                  bayo_e,
267                  bayo_f,
268                  bayo_g,
269                  bayo_h,
270                  bayo_i,
271                  bayo_j,
272                  bayo_k,
273                  bayo_l,
274                  bayo_m,
275                  bayo_n,
276                  bayo_p ];
277
278 echo(bayo_polygon);
279
280 // CATCH
281
282 cppxC = 0.41 * sm_inner_rad * TAU;
283
284 // catch pin
285
286 cpp_adj = (bayo_n[0] - bayo_f[0]) * (1 - sm_inner_rad / bayo_nom_rad);
287 // radius scaling due to nom and actual radius difference in
288 // bayo entry construction
289
290 cppa = bayo_f + [1,-1] * catch_pin_slop + [1,0] * cpp_adj;
291 cppb = bayo_g + [1,-1] * catch_pin_slop + [1,0] * cpp_adj;
292 cppd = [ bayo_n[0]
293          - catch_pin_slop - catch_pin_slop_x_extra,
294          -catch_stalk_above_gap ];
295 cppi = [ cppa[0], cppd[1] ];
296 cppc = [ cppd[0], cppb[1] ];
297 cpph = cppd + [0,-1] * catch_stalk_h;
298 cppe = cppd + [0,-1] * (catch_knob_above_gap + catch_knob_dia/2);
299 cppf = [ cppa[0], cppe[1] ];
300 cppg = [ cppa[0], cpph[1] ];
301 cppB = 0.5 * (cppf + cppe);
302
303 echo("RR", sm_inner_rad / bayo_nom_rad);
304
305 // catch assembly depression below pin
306
307 cppy6 = cppB[1] - (catch_knob_dia/2
308                    + (cppc[1] - cppd[1])
309                    + catch_stalk_below_gap);
310 cpp7 = [ cppB[0], cppy6 + catch_cr ];
311 cpp11 = cpp7 + [1,0] * catch_cr;
312 cppy9 = cppy6 + catch_strap_width * 1/3;
313 cpp9 = [ cpp7[0] + catch_cr * 2, cppy9 ];
314 cpp8 = cpp9 + [0,-1] * catch_cr;
315 cpp10 = cpp8 + [-1,0] * catch_cr;
316 cppC = [ cppxC, cpp9[1] ];
317 cppD = cppC + [0,-1] * catch_strap_width;
318
319 // catch assembly stalk and so on
320
321 catch_cr3 = catch_cr + catch_stalk_h;
322
323 cppF = [ cppg[0] - catch_stalk_eff_bend_rad, cppd[1] ];
324 cpp4 = [ cppg[0] - catch_stalk_len, cpph[1] ] + [1,-1] * catch_cr;
325 cpp5 = [ cpp4[0], cppC[1] + catch_cr ];
326 cpp2 = cpp5 + [-1,0] * (catch_cr * 2 + catch_stalk_base_width);
327 cpp2r = cpp2 + [1,0] * catch_cr;
328 cpp2d = cpp2 + [0,-1] * catch_cr;
329 cpp3 = [ cpp2[0] + catch_cr + catch_cr3, cppd[1] - catch_cr3 ];
330 cppA = [ -cppxC, cpp9[1] ];
331 cppE = [ cppA[0], cppD[1] ];
332
333 catch_assembly_dy = -cppy9 + catch_strap_width;
334
335
336 module MainProfile(){
337   main_cnr_pos = [ side_thick, top_z ] - [1,1]*main_cnr;
338   difference(){
339     union(){
340       translate(main_cnr_pos){
341         intersection(){
342           difference(){
343             circle(r = main_cnr);
344             circle(r = main_cnr * 0.5);
345           }
346           square([10,10]);
347         }
348       }
349       polygon([[ -top_middle_dr,        middle_bot_z      ],
350                [ -top_middle_dr,        top_z             ],
351                [ main_cnr_pos[0],       top_z             ],
352                [ side_thick,            main_cnr_pos[1]   ],
353                [ side_thick,            -side_height      ],
354                [ side_taper,            -side_height      ],
355                [ 0,                     -rivet_posn       ],
356                [ 0,                     by_oring_z        ],
357                [ -oring_x_rad,          by_oring_z        ],
358                ],
359               convexity=10);
360     }
361     translate([ oring_mid_dia/2 - main_dia/2, 0 ])
362       hull(){
363       translate([ 0, oring_y_rad ])
364         scale([ 1/oring_oblate * (oring_compress_more+1) , oring_oblate ])
365         circle(oring_thick/2);
366       translate([ 0, oring_y_rad*2 - oring_thick/2 ])
367         circle(oring_thick/2);
368     }
369   }
370 }
371
372 module StrapLoopProfile(){
373   circle(r = strap_loop_thick/2);
374 }
375
376 module StrapLoop(){ ////toplevel
377   bigrad = strap_loop_inside/2 + strap_loop_thick/2;
378   extralen = strap_loop_thick * 5;
379
380   intersection(){
381     rotate([strap_loop_elevation, 0,0]){
382       for (x= [ -1, +1 ] * bigrad) {
383         translate([x, -extralen, 0])
384           rotate([-90,0,0])
385           linear_extrude(height= extralen + strap_loop_strlen + 0.1,
386                          convexity=10)
387           StrapLoopProfile();
388       }
389       translate([0, strap_loop_strlen, 0]){
390         intersection(){
391           rotate_extrude(convexity=10)
392             translate([bigrad, 0,0])
393             StrapLoopProfile();
394           translate([0,50,0])
395             cube([100,100,100], center=true);
396         }
397       }
398     }
399     translate([0, 50, 0])
400       cube(100, center=true);
401   }
402 }
403
404 module RotateProjectSlice(offset, slice_size, nom_rad, real_rad){
405   // nom_rad > real_rad
406   rotate([0,0, atan2(offset, nom_rad) ]){
407     intersection(){
408       translate([-offset, -10, 0])
409         rotate([90,0,0])
410         linear_extrude(height= nom_rad*2, convexity=50)
411         children(0);
412       translate([0,0, -25])
413         cylinder(h=50, r= real_rad);
414       translate([0,0, -25])
415         linear_extrude(height= 50, convexity=50)
416         polygon([ [ 0,0 ],
417                   [ -slice_size, -real_rad*2 ],
418                   [ +slice_size, -real_rad*2 ] ]);
419     }
420   }
421 }
422
423 module RotateProject(x_min, x_max, slice_size, nom_rad, real_rad){
424   offs = [ for (i=[ x_min :
425                     slice_size :
426                     x_max + slice_size ]) i ];
427   echo (offs);
428   for (off=offs)
429     RotateProjectSlice(off, slice_size, nom_rad, real_rad)
430     children(0);
431 }
432
433 module BayonetCutout(){
434   RotateProject(bayo_c[0], bayo_i[0], bayo_slice_size,
435                 bayo_nom_rad, 
436                 bayo_real_rad)
437     translate([-0.5 * (bayo_a[0] + bayo_d[0]), 0])
438     polygon(bayo_polygon, convexity=10);
439 }
440
441 module ProfilesDemo(){ ////toplevel
442   translate([-10,0]) MainProfile();
443   translate([+10, -side_height]) polygon(bayo_polygon, convexity=10);
444 }
445
446 module LimitForHandling(){ ////toplevel
447   hull() for (r=[0,180])
448     rotate([0,0,r]) {
449       for (rs=[-1,+1]) {
450         for (xd=[0,1]) {
451           rotate([0,0, rs * handling_angle/2]) {
452             translate([rs * xd * main_dia/2 * tan(handling_angle/2),
453                        main_dia/2 + side_thick - main_cnr,
454                        top_z - main_cnr]) {
455               mirror([0,0,1])
456                 cylinder(r= main_cnr, h=50);
457               sphere(main_cnr);
458             }
459           }
460         }
461       } 
462     }
463   hull() rotate_extrude(convexity=10){
464     translate([ handling_dia/2 - main_cnr, top_z - main_cnr ]) {
465       circle(r = main_cnr);
466       mirror([0,1]) square([ main_cnr, 50 ]);
467     }
468   }
469   //cylinder(r= handling_dia/2, h=20);
470 }
471
472 module Cover(){ ////toplevel
473   render() difference(){
474     intersection(){
475       union(){
476         rotate_extrude(convexity=10)
477           translate([main_dia/2, 0])
478           MainProfile();
479         translate([0,0, middle_bot_z])
480           cylinder(h= top_thick_middle, r = main_dia/2 - top_middle_dr + 1);
481       }
482       LimitForHandling();
483     }
484     for (r=[0,180]){
485       rotate([0,0, r])
486         translate([0,0, -side_height])
487         BayonetCutout();
488       rotate([0,0, r + asin((-oring_rm_beside) / (main_dia/2))])
489         translate([0,
490                    oring_mid_dia/2 + oring_thick/4 * oring_rm_scale,
491                    oring_y_rad * 1.5])
492         rotate([-oring_rm_angle, 0, 0])
493         mirror([0,0,1])
494         cylinder(r = oring_thick/4 * oring_rm_scale, h=20);
495     }
496     for (r=[0 : 60 : 179]) {
497       rotate([0,0, r]) {
498         height = top_thick_middle - brace_above_below*2;
499         translate([0,0, middle_bot_z + brace_above_below + height/2 ])
500         cube(center=true, [ oring_bore - brace_end_shorter,
501                             brace_hole_width, height ]);
502       }
503     }
504   }
505   if (enable_head_cups)
506     for (r=[0,180])
507       rotate([0,0,r])
508         translate([-implheadcup_large_dia * .5 - implheadcup_thick/2,
509                    -implheadcup_large_dia * .0,
510                    middle_bot_z + 0.1])
511         ImplHeadCup();
512
513 //  translate(strap_loop_thick * [-0.5, 0, +1])
514 //    translate([handling_dia/2, 0, -side_height])
515 //    rotate([0,180,0]) rotate([0,0,90])
516 //    StrapLoop();
517 }
518
519 module SavingHole(){
520   translate([0,0, -10])
521     cylinder(r= main_dia/2 - jig_rim, h=20);
522 }
523
524 module Jig(){ ////toplevel
525   difference(){
526     union(){
527       translate([0,0, -side_height]){
528         cylinder(r= main_dia/2 + jig_thick, h= side_height + jig_thick);
529       }
530       translate([-jig_mark_rad, 0, jig_thick - jig_mark])
531         cube([jig_mark_rad*2, jig_mark, jig_mark]);
532     }
533     translate([0,0, -side_height-1])
534       cylinder(r= main_dia/2, h= side_height + 1);
535     SavingHole();
536     translate([0,0, -rivet_posn])
537       rotate([90, 0,0])
538       translate([0,0, -100])
539       cylinder(r= jig_hole_dia/2, h = 200);
540   }
541 }
542
543 module CoverPrint(){ ////toplevel
544   rotate([0,180,0]) Cover();
545 }
546
547 module CoverTest2(){ ////toplevel
548   difference(){
549     Cover();
550     SavingHole();
551   }
552 }
553
554 module CoverTest1(){ ////toplevel
555   difference(){
556     CoverTest2();
557     difference(){
558       for (r= [ 40, 147 ]){
559         rotate([0,0, r]){
560           translate([0,0, -10]) {
561             cube([ main_dia*3, main_dia * .53, 18], center=true);
562           }
563         }
564       }
565 //      translate([ 50, 0, 0 ])
566 //      cube([ 100,
567 //             strap_loop_inside + strap_loop_thick*2 + 1,
568 //             100 ],
569 //           center=true);
570     }
571   }
572 }
573
574 module ImplHeadCupTest(){ ////toplevel
575   for (r=[0,180])
576     rotate([0,0,r])
577       translate([-17,0,0])
578       ImplHeadCup();
579 }
580
581 module SomeStrap(width, cut_width=0){
582   // children(0) is to add, (1) subtract
583   difference(){
584     union(){
585       cylinder(r=sm_outer_rad, h=width);
586       StrapMountProtrusion(smc_cnr_c_x + sm_closure_cnr,
587                            smc_max_y,
588                            sm_closure_cnr,
589                            width);
590       children(0);
591     }
592     translate([0,0,-1])
593       cylinder(r=sm_inner_rad, h=max(width+2, cut_width));
594     translate(smc_pos)
595       StrapMountBolt(10, width);
596     translate(smc_pos)
597       cube([ sm_bolt_tighten_allow, 40,100 ], center=true);
598     children(1);
599   }
600 }
601
602 module StrapMountBolt(l_delta, strap_width){ ///toplevel
603   // positioned relative to smc_pos
604   translate([(smc_bolt_nut_eff_thick - sm_bolt_head_thick)/2,
605              smc_bolt_y,
606              strap_width/2]){
607     translate([ -sm_bolt_shaft/2-1, 0,0 ]){
608       rotate([0,90,0]) cylinder(r= sm_bolt_dia/2, h= sm_bolt_shaft+2);
609     }
610     translate([ -sm_bolt_shaft/2, 0,0 ])
611       rotate([0,-90,0])
612       cylinder($fn=6, r=smc_bolt_nut_dia/2,
613                h=smc_bolt_nut_eff_thick + l_delta);
614     translate([ sm_bolt_shaft/2, 0,0 ])
615       rotate([0,90,0])
616       cylinder(r=sm_bolt_head_dia/2, h=sm_bolt_head_thick + l_delta);
617   }
618 }
619
620 module StrapMountProtrusion(half_x, max_y, cnr, width){
621   translate(smc_pos){
622     linear_extrude(height=width, convexity=10){
623       hull(){
624         for (m = [0,1]) mirror([m,0,0]) {
625           translate([-(half_x - cnr), max_y - cnr])
626             circle(r=cnr);
627           translate([-half_x, -sm_inner_rad])
628             square([1,1]);
629         }
630       }
631     }
632   }
633 }
634
635 module StrapMount(){ ////toplevel
636   SomeStrap(sm_main_width){
637     rotate([0,0,180]){
638       StrapMountProtrusion(strap_loop_inside/2 + strap_loop_thick,
639                            strap_loop_thick,
640                            sm_closure_cnr,
641                            sm_main_width);
642       translate(smc_pos +
643                 [0,0, sm_main_width] +
644                 strap_loop_thick * [ 0, 0.5, -1.0 ])
645         StrapLoop();
646     }
647     union(){ };
648   }
649 }
650
651 module WallScrewHoleSlot(){ ////toplevel
652   ds = [-1,+1] * wm_screw_slot/2;
653   linextr_x_yz(-(wm_thick + 1), 1) {
654     hull(){
655       for (d = ds)
656         translate([d, 0])
657           circle(r = wm_screw_dia/2);
658     }
659   }
660   hull(){
661     for (d = ds){
662       translate([0, d, 0]){
663         linextr_x_yz(0, 1)
664           circle(r = wm_screw_head/2);
665         linextr_x_yz(-(wm_screw_head - wm_screw_dia)/2, 0)
666           circle(r = wm_screw_dia/2);
667       }
668     }
669   }
670 }
671
672 module WallMountMounts(){
673   linextr(0, wm_z_max){
674     translate([ -sm_outer_rad, 0 ])
675       rectfromto([ 0, -wm_y_max ],
676                  [ wm_thick, wm_y_slot1_max ]);
677   }
678 }
679 module WallMountScrewHoles(){
680   translate([ -sm_outer_rad + wm_thick, 0, wm_z_slotc_screw]) {
681     translate([ 0, wm_y_slotc_screw, 0 ])
682       WallScrewHoleSlot();
683     translate([ 0, -wm_y_slotc_screw, 0 ])
684       rotate([90,0,0])
685       WallScrewHoleSlot();
686   }
687 }
688
689 module WallMount(){ ////toplevel
690   SomeStrap(sm_main_width, wm_z_max + 2){
691     WallMountMounts();
692     WallMountScrewHoles();
693   }
694 }
695
696 module WallMountBaseRingCut(){
697   circle(r = wmb_mount_cut_rad);
698 }
699
700 module WallMountBaseMounts(){
701   linextr(0, wmb_z_max) {
702     difference(){
703       rectfromto([ -sm_outer_rad, -wmb_y_mount_max ],
704                  [ wmb_x_outer,   +wmb_y_mount_max ]);
705       WallMountBaseRingCut();
706     }
707   }
708 }
709
710 // screws, nuts, slots for nuts to go down into
711 module WallMountBaseScrewsEtc(){ ////toplevel
712   for (my=[0,1]) {
713     mirror([0, my, 0]) {
714       translate([wmb_x_screw, 0, wmb_z_screw]) {
715         linextr_y_xz(wmb_y_screw_end,
716                      wmb_y_screw_end + 100) // XXX change 100
717           circle(r = wmb_screw_dia/2);
718         linextr_y_xz(wmb_y_screw_end + web_screw_len,
719                      wmb_y_screw_end + 100) // XXX change 100
720           circle(r = wmb_screw_head_dia/2);
721         linextr_y_xz(wmb_y_nut_min,
722                      wmb_y_nut_min + wmb_nut_th) {
723           hull(){
724             rotate(30)
725               circle(r = wmb_nut_rad, $fn = 6);
726             translate([0, 100]) // XXX change 100
727               square(wmb_nut_across, center=true);
728           }
729         }
730       }
731     }
732   }
733 }
734
735 module WallMountForBase(){ ////toplevel
736   SomeStrap(sm_main_width, wm_z_max + 2){
737     union(){
738       WallMountMounts();
739       WallMountBaseMounts();
740     }
741     union(){
742       WallMountScrewHoles();
743       WallMountBaseScrewsEtc();
744     }
745   }
746 }
747
748 module WallMountBasePillarsPlan(){
749   for (my = [0,1]) {
750     mirror([0, my]) {
751       rectfromto([ -sm_outer_rad, wmbb_y_max - wmb_mount_y_width ],
752                  [ wmbb_x_outer, wmbb_y_max ]);
753     }
754   }
755 }
756
757 module WallMountBase(){ ////toplevel
758   difference(){
759     union(){
760       // vertical blocks rising to join to wall mount
761       linextr(wmbb_z_min, wmb_z_max) {
762         difference(){
763           WallMountBasePillarsPlan();
764           WallMountBaseRingCut();
765         }
766       }
767
768       hull(){
769         linextr(wmbb_z_flat_whole_min, wmbb_z_flat_max)
770           circle(r = wmbb_r_top);
771         linextr(wmbb_z_min, wmbb_z_flat_max)
772           circle(r = wmbb_r_bottom);
773       }
774       linextr(wmbb_z_min, wmbb_z_flat_max) {
775         hull(){
776           WallMountBasePillarsPlan();
777           circle(r = wmbb_r_bottom);
778         }
779       }
780     }
781
782     // cutaway for mount part
783     linextr(-wmb_mount_gap_z, wmb_z_max+1) {
784       for (my = [0,1]) {
785         mirror([0, my])
786           rectfromto([ -sm_outer_rad-1, wmb_y_mount_max + wmb_mount_gap_xy ],
787                      [ wmb_x_outer + wmb_mount_gap_xy, 1 ]);
788       }
789     }
790
791     WallMountBaseScrewsEtc();
792   }
793 }
794
795 module WallMountForBaseDemo(){ ////toplevel
796   render() WallMountForBase();
797   color("blue") render() WallMountBase();
798   %WallMountBaseScrewsEtc();
799 }
800
801 module CatchAssemblyCoreProfile(){
802   difference(){
803     union(){
804       hull(){
805         translate(cpp3) circle(r= catch_cr3);
806         polygon([ cpp3,
807                   cpp2r,
808                   cpp5,
809                   cpph,
810                   cppd
811                   ]);
812       }
813       polygon([cppD,
814                cppC,
815                cpp9,
816                cpp10,
817                cpp11,
818                cpp4,
819                cpp2r,
820                cpp2d,
821                cppA,
822                cppE
823                ]);
824       translate(cpp8) circle(r= catch_cr);
825     }
826     hull(){
827       translate(cpp4) circle(r= catch_cr);
828       translate(cpp5) circle(r= catch_cr);
829       translate(cpp7) circle(r= catch_cr);
830       polygon([cpp4,
831                cppg,
832                cpph,
833                cpp10,
834                cpp11,
835                ]);
836     }
837     translate(cpp2) circle(r= catch_cr);
838   }
839   // if cpp11 is above cpp10, the subtracted hull above
840   // can go down too far.  Ensure we do not cut off below cppy6.
841   polygon([ cppE,
842             cppD,
843             cpp9,
844             [ cpp9[0],            cppy6 ],
845             [ cpp7[0] - catch_cr, cppy6 ],
846             cpp2d
847             ]);
848 }
849
850 module CatchTipProfile(dy){
851   ddy = [0,dy];
852   intersection(){
853     translate(cppF){
854       difference(){
855 //      circle(r = dist2d(cppF, cppd));
856         //circle(r = dist2d(cppF, cppa));
857       }
858     }
859     polygon([ cppa,
860               cppi + ddy,
861               cppd + ddy,
862               cppc,
863               cppb ]);
864   }
865 }
866
867 module CatchHeadProfile(){
868   polygon([ cppd,
869             cppd,
870             cppi,
871             cppf,
872             cppe,
873             cpph ]);
874 }
875
876
877 module CatchCore(){ /////toplevel
878   linear_extrude(height=catch_strap_thick, convexity=10)
879     CatchAssemblyCoreProfile();
880
881   hull(){
882     linear_extrude(height=catch_head_th, convexity=10)
883       CatchTipProfile(0);
884     linear_extrude(height=catch_tip_th, convexity=10)
885       CatchTipProfile(catch_tip_th - catch_head_th);
886   }
887
888   linear_extrude(height=catch_head_th, convexity=10)
889     CatchHeadProfile();
890
891   translate(concat(cppB,[0])) hull(){
892     translate([0,0, catch_knob_height + catch_head_th - catch_knob_dia/2])
893       sphere(r = catch_knob_dia/2);
894     cylinder(r = catch_knob_dia/2, h = 0.1);
895   }
896 }
897
898 module CatchPreDistort(){ /////toplevel
899   scale(100 / sm_inner_rad)
900     rotate([90,0,0])
901     CatchCore();
902 }
903
904 module CatchAssembly(){ /////toplevel
905   rotate([0,0, -(cppe[0] + cppB[0] + catch_pin_slop) / sm_inner_rad * 360/TAU])
906     translate([0,0, catch_assembly_dy])
907     scale(sm_inner_rad / 100)
908     import(str("poster-tube-lid,CatchPostDistort-fa",
909                (coarse ? 20 : 3),
910                ".stl"),
911            convexity=20);
912
913   SomeStrap(catch_strap_width){
914     union(){ }
915     union(){
916       translate([-200, -200, -200])
917         cube([400, 200, 400]);
918     }
919   }
920 }
921
922 module CatchDemo(){ /////toplevel
923   color("blue") translate([0,0,
924                            -catch_assembly_dy
925              ])
926     CatchAssembly();
927   translate([0,0,+side_height
928              ])
929     Cover();
930 }
931
932 module CatchDemoS(){ /////toplevel
933   color("blue") translate([0,0,
934              -catch_assembly_dy
935              ])
936     CatchAssembly();
937   intersection(){
938     translate([0,0,+side_height
939                ])
940       Cover();
941     mirror([0,1,0]) translate([-250,33,0]) cube([500,500,500]);
942   }
943   color("black")
944     translate([0,-33,0])
945     cube([6.15, 2,2], center=true);
946 }
947
948 module CatchPinProfileDemo(){ /////toplevel
949   translate([0, 0 * -bayo_behind,0]) {
950     echo("G ",
951          bayo_n[0] - bayo_e[0]);
952     color("blue") translate([0,0,
953                              +1,
954                ]) {
955       CatchAssemblyCoreProfile();
956       CatchHeadProfile();
957     }
958     translate([0,0,10])
959       color("red")
960       CatchTipProfile(0);
961
962     polygon(bayo_polygon, convexity=10);
963
964     // adhoc show a position
965     color("purple")
966     translate(concat(
967                      cppa,
968                      10
969                      )) difference(){ circle(2.5); circle(2.0); }
970
971  }
972 }
973
974 //ProfilesDemo();
975 //BayonetCutout();
976 //MainProfile();
977 //Cover();
978 //Jig();
979 //CoverTest();