chiark / gitweb /
poster-tube-lid: WallMount 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_csink = 2.5; // XXX
95
96 catch_stalk_h = 4.5;
97 catch_stalk_len = 50;
98 catch_tip_th = 4;
99 catch_head_th = 3;
100
101 catch_pin_slop = 0.25; // each side, and above
102 catch_pin_slop_x_extra = 0.0; // only on one side
103 catch_stalk_above_gap = 1.5;
104 catch_stalk_eff_bend_rad = catch_stalk_len * 0.75;
105
106 catch_strap_width = 12;
107 catch_stalk_base_width = 15;
108
109 catch_knob_dia = 6;
110 catch_knob_above_gap = 5;
111 catch_knob_height = 3.0;
112
113 catch_stalk_below_gap = 1.0;
114 catch_stalk_beside_gap = 2.0;
115
116 // calculated
117
118 TAU = PI*2;
119
120 bayo_entry_x = bayo_entry;
121 bayo_entry_z = bayo_entry;
122 bayo_inramp_x = bayo_inramp;
123 bayo_inramp_z = bayo_inramp;
124
125 oring_mid_dia = oring_bore + oring_thick;
126 oring_outer_dia = oring_mid_dia + oring_thick;
127
128 oring_oblate = (1 - oring_compress);
129
130 oring_y_rad = oring_thick/2 * oring_oblate;
131 oring_x_rad = oring_thick/2 / oring_oblate;
132
133 by_oring_z = oring_y_rad * (1 + cos(oring_upper_embed_angle));
134
135 side_height = rivet_posn + bayo_behind + rivet_thick/2;
136 side_thick = rivet_tall + over_rivet_wall;
137
138 top_z = top_thick_by_oring + oring_y_rad + by_oring_z;
139
140 middle_bot_z = top_z - top_thick_middle;
141
142 bayo_top_z = bayo_behind + bayo_gap;
143
144 bayo_nom_rad = main_dia/2 + side_thick;
145 bayo_real_rad = main_dia/2 + rivet_tall;
146
147 rivet_entry_width = rivet_width + side_rivet_gap;
148
149 jig_mark_rad = jig_mark + main_dia/2 + jig_thick;
150
151 handling_dia = oring_bore + oring_thick*2 + min_wall*2;
152 handling_angle = 45;
153
154 sm_inner_rad = (sm_inner_circum + sm_bolt_tighten_allow/2) / TAU;
155 sm_outer_rad = sm_inner_rad + sm_main_thick;
156
157 wm_main_width = sm_main_width;
158 wm_y_min = sqrt( pow(sm_inner_rad, 2) -
159                  pow(sm_inner_rad - (wm_thick - sm_main_thick), 2) );
160 wm_y_screw = wm_y_min + wm_screw_around + wm_screw_dia/2;
161 wm_y_max = wm_y_screw + wm_screw_dia/2 + wm_screw_around;
162 wm_y_slotc_screw = wm_y_screw + wm_screw_slot/2;
163 wm_y_slot1_screw = wm_y_screw + wm_screw_slot;
164 wm_y_slot1_max = wm_y_max + wm_screw_slot;
165 wm_z_slot0_screw = wm_main_width + wm_screwdriver_dia/2;
166 wm_z_slotc_screw = wm_z_slot0_screw + wm_screw_slot/2;
167 wm_z_slot1_screw = wm_z_slot0_screw + wm_screw_slot;
168 wm_z_max = wm_z_slot1_screw + wm_screw_around;
169
170 smc_pos = [ 0, sm_inner_rad, 0 ];
171
172 smc_bolt_nut_dia = sm_bolt_nut_width / cos(30);
173 smc_bolt_nut_eff_thick = sm_bolt_nut_thick + sm_bolt_tighten_allow;
174
175 smc_bolt_y = sm_bolt_dia/2 + sm_bolt_y_clear;
176 smc_max_y = smc_bolt_y + sm_bolt_y_over
177   + max(sm_bolt_head_dia/2, smc_bolt_nut_dia/2);
178 smc_cnr_c_x = sm_bolt_shaft/2 - sm_closure_cnr
179   + sm_bolt_head_thick/2 + smc_bolt_nut_eff_thick/2;
180
181 catch_cr = catch_knob_dia/2 + catch_stalk_beside_gap;
182 catch_strap_thick = sm_main_thick;
183
184 echo("R ", sm_inner_rad, bayo_real_rad, bayo_nom_rad);
185
186 $fs= coarse ? 2.5 : 0.5;
187 $fa= coarse ? 5 : 1;
188
189 include <poster-tube-lid-parametric.scad>
190
191 // bayonet definition
192
193 bayo_a = [ bayo_entry_x, 0 ];
194 bayo_p = [ 0, bayo_entry_z ];
195 bayo_n = [ 0, bayo_behind-bayo_inramp_z ];
196 bayo_m = [ bayo_inramp_x, bayo_behind ];
197 bayo_l = bayo_m + bayo_interf * [ 1/bayo_interf_slope,  1 ];
198 bayo_k = bayo_l + [ bayo_interf_width, 0 ];
199 bayo_j = bayo_k + bayo_interf * [ 1/bayo_interf_slope, -1 ];
200 bayo_i = bayo_j + [ rivet_width + inside_rivet_gap, 0 ];
201 bayo_h = [ bayo_i[0], bayo_behind + bayo_gap + bayo_interf ];
202 bayo_g = [ bayo_m[0] - rivet_width, bayo_h[1] ];
203
204 bayo_e = [-bayo_p[0], bayo_p[1]] - [rivet_entry_width,0];
205 bayo_d = [-bayo_a[0], bayo_a[1]] - [rivet_entry_width,0];
206 bayo_c = bayo_d + [0,-5];
207 bayo_b = bayo_a + [0,-5];
208
209 bayo_f = [ bayo_e[0], bayo_g[1] + (bayo_e[0] - bayo_g[0]) ];
210
211 bayo_polygon = [ bayo_a,
212                  bayo_b,
213                  bayo_c,
214                  bayo_d,
215                  bayo_e,
216                  bayo_f,
217                  bayo_g,
218                  bayo_h,
219                  bayo_i,
220                  bayo_j,
221                  bayo_k,
222                  bayo_l,
223                  bayo_m,
224                  bayo_n,
225                  bayo_p ];
226
227 echo(bayo_polygon);
228
229 // CATCH
230
231 cppxC = 0.41 * sm_inner_rad * TAU;
232
233 // catch pin
234
235 cpp_adj = (bayo_n[0] - bayo_f[0]) * (1 - sm_inner_rad / bayo_nom_rad);
236 // radius scaling due to nom and actual radius difference in
237 // bayo entry construction
238
239 cppa = bayo_f + [1,-1] * catch_pin_slop + [1,0] * cpp_adj;
240 cppb = bayo_g + [1,-1] * catch_pin_slop + [1,0] * cpp_adj;
241 cppd = [ bayo_n[0]
242          - catch_pin_slop - catch_pin_slop_x_extra,
243          -catch_stalk_above_gap ];
244 cppi = [ cppa[0], cppd[1] ];
245 cppc = [ cppd[0], cppb[1] ];
246 cpph = cppd + [0,-1] * catch_stalk_h;
247 cppe = cppd + [0,-1] * (catch_knob_above_gap + catch_knob_dia/2);
248 cppf = [ cppa[0], cppe[1] ];
249 cppg = [ cppa[0], cpph[1] ];
250 cppB = 0.5 * (cppf + cppe);
251
252 echo("RR", sm_inner_rad / bayo_nom_rad);
253
254 // catch assembly depression below pin
255
256 cppy6 = cppB[1] - (catch_knob_dia/2
257                    + (cppc[1] - cppd[1])
258                    + catch_stalk_below_gap);
259 cpp7 = [ cppB[0], cppy6 + catch_cr ];
260 cpp11 = cpp7 + [1,0] * catch_cr;
261 cppy9 = cppy6 + catch_strap_width * 1/3;
262 cpp9 = [ cpp7[0] + catch_cr * 2, cppy9 ];
263 cpp8 = cpp9 + [0,-1] * catch_cr;
264 cpp10 = cpp8 + [-1,0] * catch_cr;
265 cppC = [ cppxC, cpp9[1] ];
266 cppD = cppC + [0,-1] * catch_strap_width;
267
268 // catch assembly stalk and so on
269
270 catch_cr3 = catch_cr + catch_stalk_h;
271
272 cppF = [ cppg[0] - catch_stalk_eff_bend_rad, cppd[1] ];
273 cpp4 = [ cppg[0] - catch_stalk_len, cpph[1] ] + [1,-1] * catch_cr;
274 cpp5 = [ cpp4[0], cppC[1] + catch_cr ];
275 cpp2 = cpp5 + [-1,0] * (catch_cr * 2 + catch_stalk_base_width);
276 cpp2r = cpp2 + [1,0] * catch_cr;
277 cpp2d = cpp2 + [0,-1] * catch_cr;
278 cpp3 = [ cpp2[0] + catch_cr + catch_cr3, cppd[1] - catch_cr3 ];
279 cppA = [ -cppxC, cpp9[1] ];
280 cppE = [ cppA[0], cppD[1] ];
281
282 catch_assembly_dy = -cppy9 + catch_strap_width;
283
284
285 module MainProfile(){
286   main_cnr_pos = [ side_thick, top_z ] - [1,1]*main_cnr;
287   difference(){
288     union(){
289       translate(main_cnr_pos){
290         intersection(){
291           difference(){
292             circle(r = main_cnr);
293             circle(r = main_cnr * 0.5);
294           }
295           square([10,10]);
296         }
297       }
298       polygon([[ -top_middle_dr,        middle_bot_z      ],
299                [ -top_middle_dr,        top_z             ],
300                [ main_cnr_pos[0],       top_z             ],
301                [ side_thick,            main_cnr_pos[1]   ],
302                [ side_thick,            -side_height      ],
303                [ side_taper,            -side_height      ],
304                [ 0,                     -rivet_posn       ],
305                [ 0,                     by_oring_z        ],
306                [ -oring_x_rad,          by_oring_z        ],
307                ],
308               convexity=10);
309     }
310     translate([ oring_mid_dia/2 - main_dia/2, 0 ])
311       hull(){
312       translate([ 0, oring_y_rad ])
313         scale([ 1/oring_oblate * (oring_compress_more+1) , oring_oblate ])
314         circle(oring_thick/2);
315       translate([ 0, oring_y_rad*2 - oring_thick/2 ])
316         circle(oring_thick/2);
317     }
318   }
319 }
320
321 module StrapLoopProfile(){
322   circle(r = strap_loop_thick/2);
323 }
324
325 module StrapLoop(){ ////toplevel
326   bigrad = strap_loop_inside/2 + strap_loop_thick/2;
327   extralen = strap_loop_thick * 5;
328
329   intersection(){
330     rotate([strap_loop_elevation, 0,0]){
331       for (x= [ -1, +1 ] * bigrad) {
332         translate([x, -extralen, 0])
333           rotate([-90,0,0])
334           linear_extrude(height= extralen + strap_loop_strlen + 0.1,
335                          convexity=10)
336           StrapLoopProfile();
337       }
338       translate([0, strap_loop_strlen, 0]){
339         intersection(){
340           rotate_extrude(convexity=10)
341             translate([bigrad, 0,0])
342             StrapLoopProfile();
343           translate([0,50,0])
344             cube([100,100,100], center=true);
345         }
346       }
347     }
348     translate([0, 50, 0])
349       cube(100, center=true);
350   }
351 }
352
353 module RotateProjectSlice(offset, slice_size, nom_rad, real_rad){
354   // nom_rad > real_rad
355   rotate([0,0, atan2(offset, nom_rad) ]){
356     intersection(){
357       translate([-offset, -10, 0])
358         rotate([90,0,0])
359         linear_extrude(height= nom_rad*2, convexity=50)
360         children(0);
361       translate([0,0, -25])
362         cylinder(h=50, r= real_rad);
363       translate([0,0, -25])
364         linear_extrude(height= 50, convexity=50)
365         polygon([ [ 0,0 ],
366                   [ -slice_size, -real_rad*2 ],
367                   [ +slice_size, -real_rad*2 ] ]);
368     }
369   }
370 }
371
372 module RotateProject(x_min, x_max, slice_size, nom_rad, real_rad){
373   offs = [ for (i=[ x_min :
374                     slice_size :
375                     x_max + slice_size ]) i ];
376   echo (offs);
377   for (off=offs)
378     RotateProjectSlice(off, slice_size, nom_rad, real_rad)
379     children(0);
380 }
381
382 module BayonetCutout(){
383   RotateProject(bayo_c[0], bayo_i[0], bayo_slice_size,
384                 bayo_nom_rad, 
385                 bayo_real_rad)
386     translate([-0.5 * (bayo_a[0] + bayo_d[0]), 0])
387     polygon(bayo_polygon, convexity=10);
388 }
389
390 module ProfilesDemo(){ ////toplevel
391   translate([-10,0]) MainProfile();
392   translate([+10, -side_height]) polygon(bayo_polygon, convexity=10);
393 }
394
395 module LimitForHandling(){ ////toplevel
396   hull() for (r=[0,180])
397     rotate([0,0,r]) {
398       for (rs=[-1,+1]) {
399         for (xd=[0,1]) {
400           rotate([0,0, rs * handling_angle/2]) {
401             translate([rs * xd * main_dia/2 * tan(handling_angle/2),
402                        main_dia/2 + side_thick - main_cnr,
403                        top_z - main_cnr]) {
404               mirror([0,0,1])
405                 cylinder(r= main_cnr, h=50);
406               sphere(main_cnr);
407             }
408           }
409         }
410       } 
411     }
412   hull() rotate_extrude(convexity=10){
413     translate([ handling_dia/2 - main_cnr, top_z - main_cnr ]) {
414       circle(r = main_cnr);
415       mirror([0,1]) square([ main_cnr, 50 ]);
416     }
417   }
418   //cylinder(r= handling_dia/2, h=20);
419 }
420
421 module Cover(){ ////toplevel
422   render() difference(){
423     intersection(){
424       union(){
425         rotate_extrude(convexity=10)
426           translate([main_dia/2, 0])
427           MainProfile();
428         translate([0,0, middle_bot_z])
429           cylinder(h= top_thick_middle, r = main_dia/2 - top_middle_dr + 1);
430       }
431       LimitForHandling();
432     }
433     for (r=[0,180]){
434       rotate([0,0, r])
435         translate([0,0, -side_height])
436         BayonetCutout();
437       rotate([0,0, r + asin((-oring_rm_beside) / (main_dia/2))])
438         translate([0,
439                    oring_mid_dia/2 + oring_thick/4 * oring_rm_scale,
440                    oring_y_rad * 1.5])
441         rotate([-oring_rm_angle, 0, 0])
442         mirror([0,0,1])
443         cylinder(r = oring_thick/4 * oring_rm_scale, h=20);
444     }
445     for (r=[0 : 60 : 179]) {
446       rotate([0,0, r]) {
447         height = top_thick_middle - brace_above_below*2;
448         translate([0,0, middle_bot_z + brace_above_below + height/2 ])
449         cube(center=true, [ oring_bore - brace_end_shorter,
450                             brace_hole_width, height ]);
451       }
452     }
453   }
454   if (enable_head_cups)
455     for (r=[0,180])
456       rotate([0,0,r])
457         translate([-implheadcup_large_dia * .5 - implheadcup_thick/2,
458                    -implheadcup_large_dia * .0,
459                    middle_bot_z + 0.1])
460         ImplHeadCup();
461
462 //  translate(strap_loop_thick * [-0.5, 0, +1])
463 //    translate([handling_dia/2, 0, -side_height])
464 //    rotate([0,180,0]) rotate([0,0,90])
465 //    StrapLoop();
466 }
467
468 module SavingHole(){
469   translate([0,0, -10])
470     cylinder(r= main_dia/2 - jig_rim, h=20);
471 }
472
473 module Jig(){ ////toplevel
474   difference(){
475     union(){
476       translate([0,0, -side_height]){
477         cylinder(r= main_dia/2 + jig_thick, h= side_height + jig_thick);
478       }
479       translate([-jig_mark_rad, 0, jig_thick - jig_mark])
480         cube([jig_mark_rad*2, jig_mark, jig_mark]);
481     }
482     translate([0,0, -side_height-1])
483       cylinder(r= main_dia/2, h= side_height + 1);
484     SavingHole();
485     translate([0,0, -rivet_posn])
486       rotate([90, 0,0])
487       translate([0,0, -100])
488       cylinder(r= jig_hole_dia/2, h = 200);
489   }
490 }
491
492 module CoverPrint(){ ////toplevel
493   rotate([0,180,0]) Cover();
494 }
495
496 module CoverTest2(){ ////toplevel
497   difference(){
498     Cover();
499     SavingHole();
500   }
501 }
502
503 module CoverTest1(){ ////toplevel
504   difference(){
505     CoverTest2();
506     difference(){
507       for (r= [ 40, 147 ]){
508         rotate([0,0, r]){
509           translate([0,0, -10]) {
510             cube([ main_dia*3, main_dia * .53, 18], center=true);
511           }
512         }
513       }
514 //      translate([ 50, 0, 0 ])
515 //      cube([ 100,
516 //             strap_loop_inside + strap_loop_thick*2 + 1,
517 //             100 ],
518 //           center=true);
519     }
520   }
521 }
522
523 module ImplHeadCupTest(){ ////toplevel
524   for (r=[0,180])
525     rotate([0,0,r])
526       translate([-17,0,0])
527       ImplHeadCup();
528 }
529
530 module SomeStrap(width, cut_width=0){
531   // children(0) is to add, (1) subtract
532   difference(){
533     union(){
534       cylinder(r=sm_outer_rad, h=width);
535       StrapMountProtrusion(smc_cnr_c_x + sm_closure_cnr,
536                            smc_max_y,
537                            sm_closure_cnr,
538                            width);
539       children(0);
540     }
541     translate([0,0,-1])
542       cylinder(r=sm_inner_rad, h=max(width+2, cut_width));
543     translate(smc_pos)
544       StrapMountBolt(10, width);
545     translate(smc_pos)
546       cube([ sm_bolt_tighten_allow, 40,100 ], center=true);
547     children(1);
548   }
549 }
550
551 module StrapMountBolt(l_delta, strap_width){ ///toplevel
552   // positioned relative to smc_pos
553   translate([(smc_bolt_nut_eff_thick - sm_bolt_head_thick)/2,
554              smc_bolt_y,
555              strap_width/2]){
556     translate([ -sm_bolt_shaft/2-1, 0,0 ]){
557       rotate([0,90,0]) cylinder(r= sm_bolt_dia/2, h= sm_bolt_shaft+2);
558     }
559     translate([ -sm_bolt_shaft/2, 0,0 ])
560       rotate([0,-90,0])
561       cylinder($fn=6, r=smc_bolt_nut_dia/2,
562                h=smc_bolt_nut_eff_thick + l_delta);
563     translate([ sm_bolt_shaft/2, 0,0 ])
564       rotate([0,90,0])
565       cylinder(r=sm_bolt_head_dia/2, h=sm_bolt_head_thick + l_delta);
566   }
567 }
568
569 module StrapMountProtrusion(half_x, max_y, cnr, width){
570   translate(smc_pos){
571     linear_extrude(height=width, convexity=10){
572       hull(){
573         for (m = [0,1]) mirror([m,0,0]) {
574           translate([-(half_x - cnr), max_y - cnr])
575             circle(r=cnr);
576           translate([-half_x, -sm_inner_rad])
577             square([1,1]);
578         }
579       }
580     }
581   }
582 }
583
584 module StrapMount(){ ////toplevel
585   SomeStrap(sm_main_width){
586     rotate([0,0,180]){
587       StrapMountProtrusion(strap_loop_inside/2 + strap_loop_thick,
588                            strap_loop_thick,
589                            sm_closure_cnr,
590                            sm_main_width);
591       translate(smc_pos +
592                 [0,0, sm_main_width] +
593                 strap_loop_thick * [ 0, 0.5, -1.0 ])
594         StrapLoop();
595     }
596     union(){ };
597   }
598 }
599
600 module WallScrewHoleSlot(){ ////toplevel
601   linextr_x_yz(-(wm_thick + 1), 1) {
602     hull(){
603       for (dx = [-1,+1] * wm_screw_slot/2)
604         translate([dx, 0])
605           circle(r = wm_screw_dia/2);
606     }
607   }
608 }
609
610 module WallMount(){ ////toplevel
611   SomeStrap(sm_main_width, wm_z_max + 2){
612     union(){
613       linextr(0, wm_z_max){
614         translate([ -sm_outer_rad, 0 ])
615           rectfromto([ 0, -wm_y_max ],
616                      [ wm_thick, wm_y_slot1_max ]);
617       }
618     }
619     union(){
620       translate([ -sm_outer_rad + wm_thick, 0, wm_z_slotc_screw]) {
621         translate([ 0, wm_y_slotc_screw, 0 ])
622           WallScrewHoleSlot();
623         translate([ 0, -wm_y_slotc_screw, 0 ])
624           rotate([90,0,0])
625           WallScrewHoleSlot();
626       }
627     }
628   }
629 }
630
631 module CatchAssemblyCoreProfile(){
632   difference(){
633     union(){
634       hull(){
635         translate(cpp3) circle(r= catch_cr3);
636         polygon([ cpp3,
637                   cpp2r,
638                   cpp5,
639                   cpph,
640                   cppd
641                   ]);
642       }
643       polygon([cppD,
644                cppC,
645                cpp9,
646                cpp10,
647                cpp11,
648                cpp4,
649                cpp2r,
650                cpp2d,
651                cppA,
652                cppE
653                ]);
654       translate(cpp8) circle(r= catch_cr);
655     }
656     hull(){
657       translate(cpp4) circle(r= catch_cr);
658       translate(cpp5) circle(r= catch_cr);
659       translate(cpp7) circle(r= catch_cr);
660       polygon([cpp4,
661                cppg,
662                cpph,
663                cpp10,
664                cpp11,
665                ]);
666     }
667     translate(cpp2) circle(r= catch_cr);
668   }
669   // if cpp11 is above cpp10, the subtracted hull above
670   // can go down too far.  Ensure we do not cut off below cppy6.
671   polygon([ cppE,
672             cppD,
673             cpp9,
674             [ cpp9[0],            cppy6 ],
675             [ cpp7[0] - catch_cr, cppy6 ],
676             cpp2d
677             ]);
678 }
679
680 module CatchTipProfile(dy){
681   ddy = [0,dy];
682   intersection(){
683     translate(cppF){
684       difference(){
685 //      circle(r = dist2d(cppF, cppd));
686         //circle(r = dist2d(cppF, cppa));
687       }
688     }
689     polygon([ cppa,
690               cppi + ddy,
691               cppd + ddy,
692               cppc,
693               cppb ]);
694   }
695 }
696
697 module CatchHeadProfile(){
698   polygon([ cppd,
699             cppd,
700             cppi,
701             cppf,
702             cppe,
703             cpph ]);
704 }
705
706
707 module CatchCore(){ /////toplevel
708   linear_extrude(height=catch_strap_thick, convexity=10)
709     CatchAssemblyCoreProfile();
710
711   hull(){
712     linear_extrude(height=catch_head_th, convexity=10)
713       CatchTipProfile(0);
714     linear_extrude(height=catch_tip_th, convexity=10)
715       CatchTipProfile(catch_tip_th - catch_head_th);
716   }
717
718   linear_extrude(height=catch_head_th, convexity=10)
719     CatchHeadProfile();
720
721   translate(concat(cppB,[0])) hull(){
722     translate([0,0, catch_knob_height + catch_head_th - catch_knob_dia/2])
723       sphere(r = catch_knob_dia/2);
724     cylinder(r = catch_knob_dia/2, h = 0.1);
725   }
726 }
727
728 module CatchPreDistort(){ /////toplevel
729   scale(100 / sm_inner_rad)
730     rotate([90,0,0])
731     CatchCore();
732 }
733
734 module CatchAssembly(){ /////toplevel
735   rotate([0,0, -(cppe[0] + cppB[0] + catch_pin_slop) / sm_inner_rad * 360/TAU])
736     translate([0,0, catch_assembly_dy])
737     scale(sm_inner_rad / 100)
738     import(str("poster-tube-lid,CatchPostDistort-fa",
739                (coarse ? 20 : 3),
740                ".stl"),
741            convexity=20);
742
743   SomeStrap(catch_strap_width){
744     union(){ }
745     union(){
746       translate([-200, -200, -200])
747         cube([400, 200, 400]);
748     }
749   }
750 }
751
752 module CatchDemo(){ /////toplevel
753   color("blue") translate([0,0,
754                            -catch_assembly_dy
755              ])
756     CatchAssembly();
757   translate([0,0,+side_height
758              ])
759     Cover();
760 }
761
762 module CatchDemoS(){ /////toplevel
763   color("blue") translate([0,0,
764              -catch_assembly_dy
765              ])
766     CatchAssembly();
767   intersection(){
768     translate([0,0,+side_height
769                ])
770       Cover();
771     mirror([0,1,0]) translate([-250,33,0]) cube([500,500,500]);
772   }
773   color("black")
774     translate([0,-33,0])
775     cube([6.15, 2,2], center=true);
776 }
777
778 module CatchPinProfileDemo(){ /////toplevel
779   translate([0, 0 * -bayo_behind,0]) {
780     echo("G ",
781          bayo_n[0] - bayo_e[0]);
782     color("blue") translate([0,0,
783                              +1,
784                ]) {
785       CatchAssemblyCoreProfile();
786       CatchHeadProfile();
787     }
788     translate([0,0,10])
789       color("red")
790       CatchTipProfile(0);
791
792     polygon(bayo_polygon, convexity=10);
793
794     // adhoc show a position
795     color("purple")
796     translate(concat(
797                      cppa,
798                      10
799                      )) difference(){ circle(2.5); circle(2.0); }
800
801  }
802 }
803
804 //ProfilesDemo();
805 //BayonetCutout();
806 //MainProfile();
807 //Cover();
808 //Jig();
809 //CoverTest();