chiark / gitweb /
poster-tube-lid: WallMount primary looks good
[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 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   ds = [-1,+1] * wm_screw_slot/2;
602   linextr_x_yz(-(wm_thick + 1), 1) {
603     hull(){
604       for (d = ds)
605         translate([d, 0])
606           circle(r = wm_screw_dia/2);
607     }
608   }
609   hull(){
610     for (d = ds){
611       translate([0, d, 0]){
612         linextr_x_yz(0, 1)
613           circle(r = wm_screw_head/2);
614         linextr_x_yz(-(wm_screw_head - wm_screw_dia)/2, 0)
615           circle(r = wm_screw_dia/2);
616       }
617     }
618   }
619 }
620
621 module WallMountMounts(){
622   linextr(0, wm_z_max){
623     translate([ -sm_outer_rad, 0 ])
624       rectfromto([ 0, -wm_y_max ],
625                  [ wm_thick, wm_y_slot1_max ]);
626   }
627 }
628 module WallMountScrewHoles(){
629   translate([ -sm_outer_rad + wm_thick, 0, wm_z_slotc_screw]) {
630     translate([ 0, wm_y_slotc_screw, 0 ])
631       WallScrewHoleSlot();
632     translate([ 0, -wm_y_slotc_screw, 0 ])
633       rotate([90,0,0])
634       WallScrewHoleSlot();
635   }
636 }
637
638 module WallMount(){ ////toplevel
639   SomeStrap(sm_main_width, wm_z_max + 2){
640     WallMountMounts();
641     WallMountScrewHoles();
642   }
643 }
644
645 module CatchAssemblyCoreProfile(){
646   difference(){
647     union(){
648       hull(){
649         translate(cpp3) circle(r= catch_cr3);
650         polygon([ cpp3,
651                   cpp2r,
652                   cpp5,
653                   cpph,
654                   cppd
655                   ]);
656       }
657       polygon([cppD,
658                cppC,
659                cpp9,
660                cpp10,
661                cpp11,
662                cpp4,
663                cpp2r,
664                cpp2d,
665                cppA,
666                cppE
667                ]);
668       translate(cpp8) circle(r= catch_cr);
669     }
670     hull(){
671       translate(cpp4) circle(r= catch_cr);
672       translate(cpp5) circle(r= catch_cr);
673       translate(cpp7) circle(r= catch_cr);
674       polygon([cpp4,
675                cppg,
676                cpph,
677                cpp10,
678                cpp11,
679                ]);
680     }
681     translate(cpp2) circle(r= catch_cr);
682   }
683   // if cpp11 is above cpp10, the subtracted hull above
684   // can go down too far.  Ensure we do not cut off below cppy6.
685   polygon([ cppE,
686             cppD,
687             cpp9,
688             [ cpp9[0],            cppy6 ],
689             [ cpp7[0] - catch_cr, cppy6 ],
690             cpp2d
691             ]);
692 }
693
694 module CatchTipProfile(dy){
695   ddy = [0,dy];
696   intersection(){
697     translate(cppF){
698       difference(){
699 //      circle(r = dist2d(cppF, cppd));
700         //circle(r = dist2d(cppF, cppa));
701       }
702     }
703     polygon([ cppa,
704               cppi + ddy,
705               cppd + ddy,
706               cppc,
707               cppb ]);
708   }
709 }
710
711 module CatchHeadProfile(){
712   polygon([ cppd,
713             cppd,
714             cppi,
715             cppf,
716             cppe,
717             cpph ]);
718 }
719
720
721 module CatchCore(){ /////toplevel
722   linear_extrude(height=catch_strap_thick, convexity=10)
723     CatchAssemblyCoreProfile();
724
725   hull(){
726     linear_extrude(height=catch_head_th, convexity=10)
727       CatchTipProfile(0);
728     linear_extrude(height=catch_tip_th, convexity=10)
729       CatchTipProfile(catch_tip_th - catch_head_th);
730   }
731
732   linear_extrude(height=catch_head_th, convexity=10)
733     CatchHeadProfile();
734
735   translate(concat(cppB,[0])) hull(){
736     translate([0,0, catch_knob_height + catch_head_th - catch_knob_dia/2])
737       sphere(r = catch_knob_dia/2);
738     cylinder(r = catch_knob_dia/2, h = 0.1);
739   }
740 }
741
742 module CatchPreDistort(){ /////toplevel
743   scale(100 / sm_inner_rad)
744     rotate([90,0,0])
745     CatchCore();
746 }
747
748 module CatchAssembly(){ /////toplevel
749   rotate([0,0, -(cppe[0] + cppB[0] + catch_pin_slop) / sm_inner_rad * 360/TAU])
750     translate([0,0, catch_assembly_dy])
751     scale(sm_inner_rad / 100)
752     import(str("poster-tube-lid,CatchPostDistort-fa",
753                (coarse ? 20 : 3),
754                ".stl"),
755            convexity=20);
756
757   SomeStrap(catch_strap_width){
758     union(){ }
759     union(){
760       translate([-200, -200, -200])
761         cube([400, 200, 400]);
762     }
763   }
764 }
765
766 module CatchDemo(){ /////toplevel
767   color("blue") translate([0,0,
768                            -catch_assembly_dy
769              ])
770     CatchAssembly();
771   translate([0,0,+side_height
772              ])
773     Cover();
774 }
775
776 module CatchDemoS(){ /////toplevel
777   color("blue") translate([0,0,
778              -catch_assembly_dy
779              ])
780     CatchAssembly();
781   intersection(){
782     translate([0,0,+side_height
783                ])
784       Cover();
785     mirror([0,1,0]) translate([-250,33,0]) cube([500,500,500]);
786   }
787   color("black")
788     translate([0,-33,0])
789     cube([6.15, 2,2], center=true);
790 }
791
792 module CatchPinProfileDemo(){ /////toplevel
793   translate([0, 0 * -bayo_behind,0]) {
794     echo("G ",
795          bayo_n[0] - bayo_e[0]);
796     color("blue") translate([0,0,
797                              +1,
798                ]) {
799       CatchAssemblyCoreProfile();
800       CatchHeadProfile();
801     }
802     translate([0,0,10])
803       color("red")
804       CatchTipProfile(0);
805
806     polygon(bayo_polygon, convexity=10);
807
808     // adhoc show a position
809     color("purple")
810     translate(concat(
811                      cppa,
812                      10
813                      )) difference(){ circle(2.5); circle(2.0); }
814
815  }
816 }
817
818 //ProfilesDemo();
819 //BayonetCutout();
820 //MainProfile();
821 //Cover();
822 //Jig();
823 //CoverTest();