chiark / gitweb /
poster-tube-lid: WallMountBase wip (nfc)
[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
219 smc_pos = [ 0, sm_inner_rad, 0 ];
220
221 smc_bolt_nut_dia = sm_bolt_nut_width / cos(30);
222 smc_bolt_nut_eff_thick = sm_bolt_nut_thick + sm_bolt_tighten_allow;
223
224 smc_bolt_y = sm_bolt_dia/2 + sm_bolt_y_clear;
225 smc_max_y = smc_bolt_y + sm_bolt_y_over
226   + max(sm_bolt_head_dia/2, smc_bolt_nut_dia/2);
227 smc_cnr_c_x = sm_bolt_shaft/2 - sm_closure_cnr
228   + sm_bolt_head_thick/2 + smc_bolt_nut_eff_thick/2;
229
230 catch_cr = catch_knob_dia/2 + catch_stalk_beside_gap;
231 catch_strap_thick = sm_main_thick;
232
233 echo("R ", sm_inner_rad, bayo_real_rad, bayo_nom_rad);
234
235 $fs= coarse ? 2.5 : 0.5;
236 $fa= coarse ? 5 : 1;
237
238 include <poster-tube-lid-parametric.scad>
239
240 // bayonet definition
241
242 bayo_a = [ bayo_entry_x, 0 ];
243 bayo_p = [ 0, bayo_entry_z ];
244 bayo_n = [ 0, bayo_behind-bayo_inramp_z ];
245 bayo_m = [ bayo_inramp_x, bayo_behind ];
246 bayo_l = bayo_m + bayo_interf * [ 1/bayo_interf_slope,  1 ];
247 bayo_k = bayo_l + [ bayo_interf_width, 0 ];
248 bayo_j = bayo_k + bayo_interf * [ 1/bayo_interf_slope, -1 ];
249 bayo_i = bayo_j + [ rivet_width + inside_rivet_gap, 0 ];
250 bayo_h = [ bayo_i[0], bayo_behind + bayo_gap + bayo_interf ];
251 bayo_g = [ bayo_m[0] - rivet_width, bayo_h[1] ];
252
253 bayo_e = [-bayo_p[0], bayo_p[1]] - [rivet_entry_width,0];
254 bayo_d = [-bayo_a[0], bayo_a[1]] - [rivet_entry_width,0];
255 bayo_c = bayo_d + [0,-5];
256 bayo_b = bayo_a + [0,-5];
257
258 bayo_f = [ bayo_e[0], bayo_g[1] + (bayo_e[0] - bayo_g[0]) ];
259
260 bayo_polygon = [ bayo_a,
261                  bayo_b,
262                  bayo_c,
263                  bayo_d,
264                  bayo_e,
265                  bayo_f,
266                  bayo_g,
267                  bayo_h,
268                  bayo_i,
269                  bayo_j,
270                  bayo_k,
271                  bayo_l,
272                  bayo_m,
273                  bayo_n,
274                  bayo_p ];
275
276 echo(bayo_polygon);
277
278 // CATCH
279
280 cppxC = 0.41 * sm_inner_rad * TAU;
281
282 // catch pin
283
284 cpp_adj = (bayo_n[0] - bayo_f[0]) * (1 - sm_inner_rad / bayo_nom_rad);
285 // radius scaling due to nom and actual radius difference in
286 // bayo entry construction
287
288 cppa = bayo_f + [1,-1] * catch_pin_slop + [1,0] * cpp_adj;
289 cppb = bayo_g + [1,-1] * catch_pin_slop + [1,0] * cpp_adj;
290 cppd = [ bayo_n[0]
291          - catch_pin_slop - catch_pin_slop_x_extra,
292          -catch_stalk_above_gap ];
293 cppi = [ cppa[0], cppd[1] ];
294 cppc = [ cppd[0], cppb[1] ];
295 cpph = cppd + [0,-1] * catch_stalk_h;
296 cppe = cppd + [0,-1] * (catch_knob_above_gap + catch_knob_dia/2);
297 cppf = [ cppa[0], cppe[1] ];
298 cppg = [ cppa[0], cpph[1] ];
299 cppB = 0.5 * (cppf + cppe);
300
301 echo("RR", sm_inner_rad / bayo_nom_rad);
302
303 // catch assembly depression below pin
304
305 cppy6 = cppB[1] - (catch_knob_dia/2
306                    + (cppc[1] - cppd[1])
307                    + catch_stalk_below_gap);
308 cpp7 = [ cppB[0], cppy6 + catch_cr ];
309 cpp11 = cpp7 + [1,0] * catch_cr;
310 cppy9 = cppy6 + catch_strap_width * 1/3;
311 cpp9 = [ cpp7[0] + catch_cr * 2, cppy9 ];
312 cpp8 = cpp9 + [0,-1] * catch_cr;
313 cpp10 = cpp8 + [-1,0] * catch_cr;
314 cppC = [ cppxC, cpp9[1] ];
315 cppD = cppC + [0,-1] * catch_strap_width;
316
317 // catch assembly stalk and so on
318
319 catch_cr3 = catch_cr + catch_stalk_h;
320
321 cppF = [ cppg[0] - catch_stalk_eff_bend_rad, cppd[1] ];
322 cpp4 = [ cppg[0] - catch_stalk_len, cpph[1] ] + [1,-1] * catch_cr;
323 cpp5 = [ cpp4[0], cppC[1] + catch_cr ];
324 cpp2 = cpp5 + [-1,0] * (catch_cr * 2 + catch_stalk_base_width);
325 cpp2r = cpp2 + [1,0] * catch_cr;
326 cpp2d = cpp2 + [0,-1] * catch_cr;
327 cpp3 = [ cpp2[0] + catch_cr + catch_cr3, cppd[1] - catch_cr3 ];
328 cppA = [ -cppxC, cpp9[1] ];
329 cppE = [ cppA[0], cppD[1] ];
330
331 catch_assembly_dy = -cppy9 + catch_strap_width;
332
333
334 module MainProfile(){
335   main_cnr_pos = [ side_thick, top_z ] - [1,1]*main_cnr;
336   difference(){
337     union(){
338       translate(main_cnr_pos){
339         intersection(){
340           difference(){
341             circle(r = main_cnr);
342             circle(r = main_cnr * 0.5);
343           }
344           square([10,10]);
345         }
346       }
347       polygon([[ -top_middle_dr,        middle_bot_z      ],
348                [ -top_middle_dr,        top_z             ],
349                [ main_cnr_pos[0],       top_z             ],
350                [ side_thick,            main_cnr_pos[1]   ],
351                [ side_thick,            -side_height      ],
352                [ side_taper,            -side_height      ],
353                [ 0,                     -rivet_posn       ],
354                [ 0,                     by_oring_z        ],
355                [ -oring_x_rad,          by_oring_z        ],
356                ],
357               convexity=10);
358     }
359     translate([ oring_mid_dia/2 - main_dia/2, 0 ])
360       hull(){
361       translate([ 0, oring_y_rad ])
362         scale([ 1/oring_oblate * (oring_compress_more+1) , oring_oblate ])
363         circle(oring_thick/2);
364       translate([ 0, oring_y_rad*2 - oring_thick/2 ])
365         circle(oring_thick/2);
366     }
367   }
368 }
369
370 module StrapLoopProfile(){
371   circle(r = strap_loop_thick/2);
372 }
373
374 module StrapLoop(){ ////toplevel
375   bigrad = strap_loop_inside/2 + strap_loop_thick/2;
376   extralen = strap_loop_thick * 5;
377
378   intersection(){
379     rotate([strap_loop_elevation, 0,0]){
380       for (x= [ -1, +1 ] * bigrad) {
381         translate([x, -extralen, 0])
382           rotate([-90,0,0])
383           linear_extrude(height= extralen + strap_loop_strlen + 0.1,
384                          convexity=10)
385           StrapLoopProfile();
386       }
387       translate([0, strap_loop_strlen, 0]){
388         intersection(){
389           rotate_extrude(convexity=10)
390             translate([bigrad, 0,0])
391             StrapLoopProfile();
392           translate([0,50,0])
393             cube([100,100,100], center=true);
394         }
395       }
396     }
397     translate([0, 50, 0])
398       cube(100, center=true);
399   }
400 }
401
402 module RotateProjectSlice(offset, slice_size, nom_rad, real_rad){
403   // nom_rad > real_rad
404   rotate([0,0, atan2(offset, nom_rad) ]){
405     intersection(){
406       translate([-offset, -10, 0])
407         rotate([90,0,0])
408         linear_extrude(height= nom_rad*2, convexity=50)
409         children(0);
410       translate([0,0, -25])
411         cylinder(h=50, r= real_rad);
412       translate([0,0, -25])
413         linear_extrude(height= 50, convexity=50)
414         polygon([ [ 0,0 ],
415                   [ -slice_size, -real_rad*2 ],
416                   [ +slice_size, -real_rad*2 ] ]);
417     }
418   }
419 }
420
421 module RotateProject(x_min, x_max, slice_size, nom_rad, real_rad){
422   offs = [ for (i=[ x_min :
423                     slice_size :
424                     x_max + slice_size ]) i ];
425   echo (offs);
426   for (off=offs)
427     RotateProjectSlice(off, slice_size, nom_rad, real_rad)
428     children(0);
429 }
430
431 module BayonetCutout(){
432   RotateProject(bayo_c[0], bayo_i[0], bayo_slice_size,
433                 bayo_nom_rad, 
434                 bayo_real_rad)
435     translate([-0.5 * (bayo_a[0] + bayo_d[0]), 0])
436     polygon(bayo_polygon, convexity=10);
437 }
438
439 module ProfilesDemo(){ ////toplevel
440   translate([-10,0]) MainProfile();
441   translate([+10, -side_height]) polygon(bayo_polygon, convexity=10);
442 }
443
444 module LimitForHandling(){ ////toplevel
445   hull() for (r=[0,180])
446     rotate([0,0,r]) {
447       for (rs=[-1,+1]) {
448         for (xd=[0,1]) {
449           rotate([0,0, rs * handling_angle/2]) {
450             translate([rs * xd * main_dia/2 * tan(handling_angle/2),
451                        main_dia/2 + side_thick - main_cnr,
452                        top_z - main_cnr]) {
453               mirror([0,0,1])
454                 cylinder(r= main_cnr, h=50);
455               sphere(main_cnr);
456             }
457           }
458         }
459       } 
460     }
461   hull() rotate_extrude(convexity=10){
462     translate([ handling_dia/2 - main_cnr, top_z - main_cnr ]) {
463       circle(r = main_cnr);
464       mirror([0,1]) square([ main_cnr, 50 ]);
465     }
466   }
467   //cylinder(r= handling_dia/2, h=20);
468 }
469
470 module Cover(){ ////toplevel
471   render() difference(){
472     intersection(){
473       union(){
474         rotate_extrude(convexity=10)
475           translate([main_dia/2, 0])
476           MainProfile();
477         translate([0,0, middle_bot_z])
478           cylinder(h= top_thick_middle, r = main_dia/2 - top_middle_dr + 1);
479       }
480       LimitForHandling();
481     }
482     for (r=[0,180]){
483       rotate([0,0, r])
484         translate([0,0, -side_height])
485         BayonetCutout();
486       rotate([0,0, r + asin((-oring_rm_beside) / (main_dia/2))])
487         translate([0,
488                    oring_mid_dia/2 + oring_thick/4 * oring_rm_scale,
489                    oring_y_rad * 1.5])
490         rotate([-oring_rm_angle, 0, 0])
491         mirror([0,0,1])
492         cylinder(r = oring_thick/4 * oring_rm_scale, h=20);
493     }
494     for (r=[0 : 60 : 179]) {
495       rotate([0,0, r]) {
496         height = top_thick_middle - brace_above_below*2;
497         translate([0,0, middle_bot_z + brace_above_below + height/2 ])
498         cube(center=true, [ oring_bore - brace_end_shorter,
499                             brace_hole_width, height ]);
500       }
501     }
502   }
503   if (enable_head_cups)
504     for (r=[0,180])
505       rotate([0,0,r])
506         translate([-implheadcup_large_dia * .5 - implheadcup_thick/2,
507                    -implheadcup_large_dia * .0,
508                    middle_bot_z + 0.1])
509         ImplHeadCup();
510
511 //  translate(strap_loop_thick * [-0.5, 0, +1])
512 //    translate([handling_dia/2, 0, -side_height])
513 //    rotate([0,180,0]) rotate([0,0,90])
514 //    StrapLoop();
515 }
516
517 module SavingHole(){
518   translate([0,0, -10])
519     cylinder(r= main_dia/2 - jig_rim, h=20);
520 }
521
522 module Jig(){ ////toplevel
523   difference(){
524     union(){
525       translate([0,0, -side_height]){
526         cylinder(r= main_dia/2 + jig_thick, h= side_height + jig_thick);
527       }
528       translate([-jig_mark_rad, 0, jig_thick - jig_mark])
529         cube([jig_mark_rad*2, jig_mark, jig_mark]);
530     }
531     translate([0,0, -side_height-1])
532       cylinder(r= main_dia/2, h= side_height + 1);
533     SavingHole();
534     translate([0,0, -rivet_posn])
535       rotate([90, 0,0])
536       translate([0,0, -100])
537       cylinder(r= jig_hole_dia/2, h = 200);
538   }
539 }
540
541 module CoverPrint(){ ////toplevel
542   rotate([0,180,0]) Cover();
543 }
544
545 module CoverTest2(){ ////toplevel
546   difference(){
547     Cover();
548     SavingHole();
549   }
550 }
551
552 module CoverTest1(){ ////toplevel
553   difference(){
554     CoverTest2();
555     difference(){
556       for (r= [ 40, 147 ]){
557         rotate([0,0, r]){
558           translate([0,0, -10]) {
559             cube([ main_dia*3, main_dia * .53, 18], center=true);
560           }
561         }
562       }
563 //      translate([ 50, 0, 0 ])
564 //      cube([ 100,
565 //             strap_loop_inside + strap_loop_thick*2 + 1,
566 //             100 ],
567 //           center=true);
568     }
569   }
570 }
571
572 module ImplHeadCupTest(){ ////toplevel
573   for (r=[0,180])
574     rotate([0,0,r])
575       translate([-17,0,0])
576       ImplHeadCup();
577 }
578
579 module SomeStrap(width, cut_width=0){
580   // children(0) is to add, (1) subtract
581   difference(){
582     union(){
583       cylinder(r=sm_outer_rad, h=width);
584       StrapMountProtrusion(smc_cnr_c_x + sm_closure_cnr,
585                            smc_max_y,
586                            sm_closure_cnr,
587                            width);
588       children(0);
589     }
590     translate([0,0,-1])
591       cylinder(r=sm_inner_rad, h=max(width+2, cut_width));
592     translate(smc_pos)
593       StrapMountBolt(10, width);
594     translate(smc_pos)
595       cube([ sm_bolt_tighten_allow, 40,100 ], center=true);
596     children(1);
597   }
598 }
599
600 module StrapMountBolt(l_delta, strap_width){ ///toplevel
601   // positioned relative to smc_pos
602   translate([(smc_bolt_nut_eff_thick - sm_bolt_head_thick)/2,
603              smc_bolt_y,
604              strap_width/2]){
605     translate([ -sm_bolt_shaft/2-1, 0,0 ]){
606       rotate([0,90,0]) cylinder(r= sm_bolt_dia/2, h= sm_bolt_shaft+2);
607     }
608     translate([ -sm_bolt_shaft/2, 0,0 ])
609       rotate([0,-90,0])
610       cylinder($fn=6, r=smc_bolt_nut_dia/2,
611                h=smc_bolt_nut_eff_thick + l_delta);
612     translate([ sm_bolt_shaft/2, 0,0 ])
613       rotate([0,90,0])
614       cylinder(r=sm_bolt_head_dia/2, h=sm_bolt_head_thick + l_delta);
615   }
616 }
617
618 module StrapMountProtrusion(half_x, max_y, cnr, width){
619   translate(smc_pos){
620     linear_extrude(height=width, convexity=10){
621       hull(){
622         for (m = [0,1]) mirror([m,0,0]) {
623           translate([-(half_x - cnr), max_y - cnr])
624             circle(r=cnr);
625           translate([-half_x, -sm_inner_rad])
626             square([1,1]);
627         }
628       }
629     }
630   }
631 }
632
633 module StrapMount(){ ////toplevel
634   SomeStrap(sm_main_width){
635     rotate([0,0,180]){
636       StrapMountProtrusion(strap_loop_inside/2 + strap_loop_thick,
637                            strap_loop_thick,
638                            sm_closure_cnr,
639                            sm_main_width);
640       translate(smc_pos +
641                 [0,0, sm_main_width] +
642                 strap_loop_thick * [ 0, 0.5, -1.0 ])
643         StrapLoop();
644     }
645     union(){ };
646   }
647 }
648
649 module WallScrewHoleSlot(){ ////toplevel
650   ds = [-1,+1] * wm_screw_slot/2;
651   linextr_x_yz(-(wm_thick + 1), 1) {
652     hull(){
653       for (d = ds)
654         translate([d, 0])
655           circle(r = wm_screw_dia/2);
656     }
657   }
658   hull(){
659     for (d = ds){
660       translate([0, d, 0]){
661         linextr_x_yz(0, 1)
662           circle(r = wm_screw_head/2);
663         linextr_x_yz(-(wm_screw_head - wm_screw_dia)/2, 0)
664           circle(r = wm_screw_dia/2);
665       }
666     }
667   }
668 }
669
670 module WallMountMounts(){
671   linextr(0, wm_z_max){
672     translate([ -sm_outer_rad, 0 ])
673       rectfromto([ 0, -wm_y_max ],
674                  [ wm_thick, wm_y_slot1_max ]);
675   }
676 }
677 module WallMountScrewHoles(){
678   translate([ -sm_outer_rad + wm_thick, 0, wm_z_slotc_screw]) {
679     translate([ 0, wm_y_slotc_screw, 0 ])
680       WallScrewHoleSlot();
681     translate([ 0, -wm_y_slotc_screw, 0 ])
682       rotate([90,0,0])
683       WallScrewHoleSlot();
684   }
685 }
686
687 module WallMount(){ ////toplevel
688   SomeStrap(sm_main_width, wm_z_max + 2){
689     WallMountMounts();
690     WallMountScrewHoles();
691   }
692 }
693
694 module WallMountBaseRingCut(){
695   circle(r = wmb_mount_cut_rad);
696 }
697
698 module WallMountBaseMounts(){
699   linextr(0, wmb_z_max) {
700     difference(){
701       rectfromto([ -sm_outer_rad, -wmb_y_mount_max ],
702                  [ wmb_x_outer,   +wmb_y_mount_max ]);
703       WallMountBaseRingCut();
704     }
705   }
706 }
707
708 // screws, nuts, slots for nuts to go down into
709 module WallMountBaseScrewsEtc(){ ////toplevel
710   for (my=[0,1]) {
711     mirror([0, my, 0]) {
712       translate([wmb_x_screw, 0, wmb_z_screw]) {
713         linextr_y_xz(wmb_y_screw_end,
714                      wmb_y_screw_end + 100) // XXX change 100
715           circle(r = wmb_screw_dia/2);
716         linextr_y_xz(wmb_y_screw_end + web_screw_len,
717                      wmb_y_screw_end + 100) // XXX change 100
718           circle(r = wmb_screw_head_dia/2);
719         linextr_y_xz(wmb_y_nut_min,
720                      wmb_y_nut_min + wmb_nut_th) {
721           hull(){
722             rotate(30)
723               circle(r = wmb_nut_rad, $fn = 6);
724             translate([0, 100]) // XXX change 100
725               square(wmb_nut_across, center=true);
726           }
727         }
728       }
729     }
730   }
731 }
732
733 module WallMountForBase(){ ////toplevel
734   SomeStrap(sm_main_width, wm_z_max + 2){
735     union(){
736       WallMountMounts();
737       WallMountBaseMounts();
738     }
739     union(){
740       WallMountScrewHoles();
741       WallMountBaseScrewsEtc();
742     }
743   }
744 }
745
746 module WallMountBasePillarsPlan(){
747   for (my = [0,1]) {
748     mirror([0, my]) {
749       rectfromto([ -sm_outer_rad, wmbb_y_max - wmb_mount_y_width ],
750                  [ wmbb_x_outer, wmbb_y_max ]);
751     }
752   }
753 }
754
755 module WallMountBase(){ ////toplevel
756   difference(){
757     union(){
758       // vertical blocks rising to join to wall mount
759       linextr(wmbb_z_min, wmb_z_max) {
760         difference(){
761           WallMountBasePillarsPlan();
762           WallMountBaseRingCut();
763         }
764       }
765
766       hull(){
767         linextr(wmbb_z_flat_whole_min, wmbb_z_flat_max)
768           circle(r = main_dia/2 + wmb_base_extra_rad);
769         linextr(wmbb_z_min, wmbb_z_flat_max)
770           circle(r = main_dia/2 + wmb_base_extra_rad -
771                  (wmb_bottom_th - wmb_bottom_th_min));
772       }
773     }
774
775     // cutaway for mount part
776     linextr(-wmb_mount_gap_z, wmb_z_max+1) {
777       for (my = [0,1]) {
778         mirror([0, my])
779           rectfromto([ -sm_outer_rad-1, wmb_y_mount_max + wmb_mount_gap_xy ],
780                      [ wmb_x_outer + wmb_mount_gap_xy, 1 ]);
781       }
782     }
783
784     WallMountBaseScrewsEtc();
785   }
786 }
787
788 module WallMountForBaseDemo(){ ////toplevel
789   render() WallMountForBase();
790   color("blue") render() WallMountBase();
791   %WallMountBaseScrewsEtc();
792 }
793
794 module CatchAssemblyCoreProfile(){
795   difference(){
796     union(){
797       hull(){
798         translate(cpp3) circle(r= catch_cr3);
799         polygon([ cpp3,
800                   cpp2r,
801                   cpp5,
802                   cpph,
803                   cppd
804                   ]);
805       }
806       polygon([cppD,
807                cppC,
808                cpp9,
809                cpp10,
810                cpp11,
811                cpp4,
812                cpp2r,
813                cpp2d,
814                cppA,
815                cppE
816                ]);
817       translate(cpp8) circle(r= catch_cr);
818     }
819     hull(){
820       translate(cpp4) circle(r= catch_cr);
821       translate(cpp5) circle(r= catch_cr);
822       translate(cpp7) circle(r= catch_cr);
823       polygon([cpp4,
824                cppg,
825                cpph,
826                cpp10,
827                cpp11,
828                ]);
829     }
830     translate(cpp2) circle(r= catch_cr);
831   }
832   // if cpp11 is above cpp10, the subtracted hull above
833   // can go down too far.  Ensure we do not cut off below cppy6.
834   polygon([ cppE,
835             cppD,
836             cpp9,
837             [ cpp9[0],            cppy6 ],
838             [ cpp7[0] - catch_cr, cppy6 ],
839             cpp2d
840             ]);
841 }
842
843 module CatchTipProfile(dy){
844   ddy = [0,dy];
845   intersection(){
846     translate(cppF){
847       difference(){
848 //      circle(r = dist2d(cppF, cppd));
849         //circle(r = dist2d(cppF, cppa));
850       }
851     }
852     polygon([ cppa,
853               cppi + ddy,
854               cppd + ddy,
855               cppc,
856               cppb ]);
857   }
858 }
859
860 module CatchHeadProfile(){
861   polygon([ cppd,
862             cppd,
863             cppi,
864             cppf,
865             cppe,
866             cpph ]);
867 }
868
869
870 module CatchCore(){ /////toplevel
871   linear_extrude(height=catch_strap_thick, convexity=10)
872     CatchAssemblyCoreProfile();
873
874   hull(){
875     linear_extrude(height=catch_head_th, convexity=10)
876       CatchTipProfile(0);
877     linear_extrude(height=catch_tip_th, convexity=10)
878       CatchTipProfile(catch_tip_th - catch_head_th);
879   }
880
881   linear_extrude(height=catch_head_th, convexity=10)
882     CatchHeadProfile();
883
884   translate(concat(cppB,[0])) hull(){
885     translate([0,0, catch_knob_height + catch_head_th - catch_knob_dia/2])
886       sphere(r = catch_knob_dia/2);
887     cylinder(r = catch_knob_dia/2, h = 0.1);
888   }
889 }
890
891 module CatchPreDistort(){ /////toplevel
892   scale(100 / sm_inner_rad)
893     rotate([90,0,0])
894     CatchCore();
895 }
896
897 module CatchAssembly(){ /////toplevel
898   rotate([0,0, -(cppe[0] + cppB[0] + catch_pin_slop) / sm_inner_rad * 360/TAU])
899     translate([0,0, catch_assembly_dy])
900     scale(sm_inner_rad / 100)
901     import(str("poster-tube-lid,CatchPostDistort-fa",
902                (coarse ? 20 : 3),
903                ".stl"),
904            convexity=20);
905
906   SomeStrap(catch_strap_width){
907     union(){ }
908     union(){
909       translate([-200, -200, -200])
910         cube([400, 200, 400]);
911     }
912   }
913 }
914
915 module CatchDemo(){ /////toplevel
916   color("blue") translate([0,0,
917                            -catch_assembly_dy
918              ])
919     CatchAssembly();
920   translate([0,0,+side_height
921              ])
922     Cover();
923 }
924
925 module CatchDemoS(){ /////toplevel
926   color("blue") translate([0,0,
927              -catch_assembly_dy
928              ])
929     CatchAssembly();
930   intersection(){
931     translate([0,0,+side_height
932                ])
933       Cover();
934     mirror([0,1,0]) translate([-250,33,0]) cube([500,500,500]);
935   }
936   color("black")
937     translate([0,-33,0])
938     cube([6.15, 2,2], center=true);
939 }
940
941 module CatchPinProfileDemo(){ /////toplevel
942   translate([0, 0 * -bayo_behind,0]) {
943     echo("G ",
944          bayo_n[0] - bayo_e[0]);
945     color("blue") translate([0,0,
946                              +1,
947                ]) {
948       CatchAssemblyCoreProfile();
949       CatchHeadProfile();
950     }
951     translate([0,0,10])
952       color("red")
953       CatchTipProfile(0);
954
955     polygon(bayo_polygon, convexity=10);
956
957     // adhoc show a position
958     color("purple")
959     translate(concat(
960                      cppa,
961                      10
962                      )) difference(){ circle(2.5); circle(2.0); }
963
964  }
965 }
966
967 //ProfilesDemo();
968 //BayonetCutout();
969 //MainProfile();
970 //Cover();
971 //Jig();
972 //CoverTest();