chiark / gitweb /
b2fbbfb72dc37f658e8dd0802eff6e86ba7cbe56
[reprap-play.git] / sewing-table.scad.m4
1 // -*- C -*-
2
3 include <funcs.scad>
4 include <commitid.scad>
5
6 ply_th = 18;
7 ply_hole_dia = 15;
8 ply_edge_min = 10;
9
10 tile_th = 3;
11 post_dia = 8;
12
13 post_shorter = 1;
14
15 screw_dia = 2.2;
16 screw_big_dia = 3.6;
17 screw_big_len = 4.0;
18
19 round_edge_rad = 2.0;
20
21 round_cnr_rad = 10;
22
23 interlock_dia = 10;
24 interlock_fine = 0.66;
25
26 interlock_fine_slope = 1.0;
27 interlock_fine_lenslop = 1.0;
28
29 demo_slop = 0.1;
30
31 // cutout
32
33 machine_rear_to_front = 85;
34
35 machine_rear_profile = [
36                         [ -  0,  -0.00 ],
37                         [ -  2,  -0.10 ],
38                         [ -  4,  -0.20 ],
39                         [ -  5,  -0.30 ],
40                         [ -  6,  -0.40 ],
41                         [ -  7,  -0.50 ],
42                         [ -  8,  -0.75 ],
43                         [ - 10,  -1.50 ],
44                         [ - 12,  -2.25 ],
45                         [ - 14,  -3.25 ],
46                         [ - 16,  -4.25 ],
47                         [ - 18,  -5.75 ],
48                         [ - 20,  -8.00 ]
49                         ];
50
51 machine_front_profile =  [
52                           [  128,  -3.70,  ],
53                           [  124,  -2.90,  ],
54                           [  120,  -2.45,  ],
55                           [  116,  -2.10,  ],
56                           [  112,  -1.80,  ],
57                           [  108,  -1.55,  ],
58                           [  104,  -1.25,  ],
59                           [  100,  -1.00,  ],
60                           [   96,  -0.80,  ],
61                           [   92,  -0.65,  ],
62                           [   88,  -0.55,  ],
63                           [   84,  -0.50,  ]
64                           ];
65
66 cutout_l_end_y_front_slop = 0.5;
67 cutout_l_end_y_rear_slop = 0.5;
68 cutout_l_end_x_slop = 0.25;
69
70 cutout_l_end_x = 22;
71 cutout_l_end_y = machine_rear_to_front;
72 cutout_l_end_curve = 1;
73 cutout_l_end_y_total = cutout_l_end_y
74   + cutout_l_end_y_front_slop + cutout_l_end_y_rear_slop;
75
76 tile02_tr = [-250, 0];
77 tile01_tr = [  0, 0];
78
79 cutout_tile01_y = 170 - 147 + cutout_l_end_y_front_slop;
80 cutout_tile11_x = cutout_l_end_x + cutout_l_end_curve;
81 cutout_tile11_y = cutout_l_end_y_total - cutout_tile01_y;
82
83 // front and rear curves
84
85 rearedge_len = 170;
86
87 rearcurve_strt_len = 52;
88
89 rearcurve_z_slop = 0.75;
90
91 rearcurve_avoid_y = 35;
92
93 rearcurve_double_inrad = 26.10 + 8.04;
94
95 reartablet_z = 2.54;
96 reartablet_x = 5 + 1;
97 reartablet_y = 5;
98
99 frontcurve_side_skew = 3.5 / 72;
100 frontcurve_avoid_y = 70;
101 frontcurve_z_slop = 0.75;
102
103 // calculated
104
105 TEST = false;
106
107 ply_edge_hole_dist = ply_edge_min + ply_hole_dia/2;
108
109 echo(str("HOLES IN PLY ctr dist from PLY edge = ", ply_edge_hole_dist));
110
111 hole_slop = (ply_hole_dia - post_dia)/2;
112 tile_hard_edge_hole_dist = ply_edge_hole_dist + hole_slop;
113
114 echo(str("HOLES IN PLY ctr dist from TILE HARD edge = ",
115          tile_hard_edge_hole_dist));
116
117 echo(str("HOLES IN PLY ctr dist from TILE ROUND edge = ",
118          tile_hard_edge_hole_dist + round_edge_rad));
119
120 thehd = [ tile_hard_edge_hole_dist, tile_hard_edge_hole_dist ];
121 thehd_tr = thehd;
122 thehd_tl = [ -thehd_tr[0], thehd_tr[1] ];
123 thehd_bl = -thehd_tr;
124 thehd_br = -thehd_tl;
125
126 interlock_rad = interlock_dia/2;
127 interlock_negative_rad = interlock_rad + 0.125;
128
129 interlock_sq_adj = 0.2; // arbitrary
130
131 first_front = machine_front_profile[len(machine_front_profile)-1];
132
133 m4_define(`POST_TCROSSSZ',
134           `2*( tile_hard_edge_hole_dist - test_edge + 1 )')
135
136 module Post(){
137   mirror([0,0,1]) {
138     difference(){
139       cylinder(r= post_dia/2, h= tile_th + ply_th - post_shorter);
140       translate([0,0, tile_th]) {
141         cylinder(r= screw_big_dia/2, h= screw_big_len);
142         cylinder(r= screw_dia/2, h= ply_th, $fn=20);
143       }
144     }
145     if (TEST) {
146       translate([0,0, tile_th/2]) {
147         cube([post_dia,      POST_TCROSSSZ, tile_th], center=true);
148         cube([POST_TCROSSSZ, post_dia,      tile_th], center=true);
149       }
150     }
151   }
152 }
153
154 module Posts(posts) {
155   for (p= posts) {
156     translate(concat(p, [0]))
157       Post();
158   }
159 }
160
161 module TileBase(botleft, topright){
162   size = topright - botleft;
163   botleft_post = botleft + thehd_tr;
164   topright_post = topright + thehd_bl;
165   difference(){
166     mirror([0,0,1])
167       translate(concat(botleft, [0]))
168       cube(concat(size, [tile_th]));
169     if (!TEST) {
170       cidsz = topright_post-botleft_post
171         + [-post_dia,-post_dia]
172         + [0, thehd[1]];
173       cidszr = [ min(cidsz[0],50), min(cidsz[1],50) ];
174       echo("CID",cidsz,cidszr);
175       translate( concat(botleft_post, [ -tile_th ])
176                  + 0.5 * [ post_dia, post_dia, 0 ]
177                  + 0.5 * concat( cidsz - cidszr, [ 0 ]) )
178         Commitid_BestCount_M(cidszr);
179     }
180     if (TEST) {
181       crossoff = tile_hard_edge_hole_dist + POST_TCROSSSZ/2;
182       cidsz = [ thehd[0], size[1] - 2*crossoff ];
183       cidszr = [ cidsz[0], min(cidsz[1], 50) ];
184       translate( concat(botleft + [0, crossoff] + (cidsz-cidszr)/2, [0]) )
185         Commitid_BestCount(cidszr);
186       difference(){
187         mirror([0,0,1]) {
188           translate(concat(botleft + [test_edge,test_edge], [test_tile_th]))
189             cube(concat(size - [test_edge,test_edge]*2, [tile_th]));
190           translate(concat(botleft_post, [-1]))
191             cube(concat(topright_post-botleft_post, [tile_th+2]));
192         }
193         minkowski(){
194           Machine();
195           cube(max(test_edge, tile_hard_edge_hole_dist)*2, center=true);
196         }
197       }
198     }
199   }
200 }
201
202 m4_dnl  INREFFRAME(left_cnr, right_cnr, morevars) { body; }
203 m4_define(`INREFFRAME',`
204   length_vec = ($2) - ($1);
205   length = dist2d([0,0], length_vec);
206   length_uvec = length_vec / length;
207   ortho_uvec = [ -length_uvec[1], length_uvec[0] ];
208   m = [ [ length_uvec[0],  ortho_uvec[0], 0, ($1)[0], ],
209         [ length_uvec[1],  ortho_uvec[1], 0, ($1)[1], ],
210         [ 0,              0,              1,            0, ],
211         [ 0,              0,              0,            1, ] ];
212   $3
213   multmatrix(m)
214 ')
215
216 m4_dnl  INREFFRAME(left_cnr, right_cnr, morevars)
217 m4_dnl    INREFFRAME_EDGE { body; }
218 m4_define(`INREFFRAME_EDGE',`
219   translate([0,0, -round_edge_rad])
220 ')
221
222 module RoundEdge(left_cnr, right_cnr) {
223   INREFFRAME(left_cnr, right_cnr)
224     INREFFRAME_EDGE {
225     difference(){
226       rotate([0,90,0])
227         cylinder(r= round_edge_rad, h= length, $fn=50);
228       translate([-1, 0, -20])
229         cube([length+2, 20, 20]);
230     }
231   }
232 }
233
234 module RoundCornerCut(ci) {
235   // ci should be [this_cnr, right_cnr]
236   // where right_cnr is to the right (ie, anticlockwise)
237   this_cnr = ci[0];
238   right_cnr = ci[1];
239   offr= round_cnr_rad - round_edge_rad;
240   INREFFRAME(this_cnr, right_cnr) INREFFRAME_EDGE {
241     difference(){
242       cube(offr*2 - 0.1, center=true);
243       translate([offr, offr, 0])
244         cylinder(center=true, h=20, r= offr);
245     }
246   }
247 }
248
249 module RoundCornerAdd(ci) {
250   this_cnr = ci[0];
251   right_cnr = ci[1];
252   bigr = round_cnr_rad - round_edge_rad;
253   INREFFRAME(this_cnr, right_cnr) INREFFRAME_EDGE {
254     intersection(){
255       cube(bigr*2 + 0.1, center=true);
256       translate([bigr, bigr, 0])
257         rotate_extrude(convexity=10, $fn=50)
258         translate([bigr, 0])
259         difference(){
260           circle(r= round_edge_rad, $fn=50);
261           mirror([1,1])
262             square([20,20]);
263         }
264     }
265   }
266 }
267
268 module InterlockLobePlan(negative) {
269   r = negative ? interlock_negative_rad : interlock_rad;
270   ymir = negative ? 0 : 1;
271
272   dx = sqrt(3) * r;
273   $fn= 80;
274   translate([thehd[0], 0]){
275     mirror([0,ymir]){
276       circle(r=r);
277       difference(){
278         translate([-dx, -0.1])
279           square([ dx*2, r/2 + 0.1 ]);
280         for (xi = [-1, 1]) {
281           translate([ xi*dx, r ])
282             circle(r=r);
283         }
284       }
285     }
286   }
287 }
288
289 module InterlockEdgePlan(negative, nlobes, length, dosquare=true) {
290   for (lobei = [ 0 : nlobes-1 ]) {
291     lobex = (length - thehd[0]*2) * (lobei ? lobei / (nlobes-1) : 0);
292     translate([lobex, 0, 0]) {
293       InterlockLobePlan(negative);
294     }
295   }
296
297   if (dosquare) {
298     iadj = 0;
299     slotshorter = negative ? -0.1 : interlock_fine_lenslop;
300     mirror([0, negative])
301       translate([slotshorter, iadj])
302       square([length - slotshorter*2, interlock_fine + iadj*2]);
303   }
304 }
305
306 module InterlockEdge(left_cnr, right_cnr, negative=0, nlobes=2) {
307   plusth = negative * 1.0;
308   protr = interlock_fine + interlock_sq_adj;
309
310   z2 = -tile_th/2;
311   z1 = -tile_th/2 - protr / interlock_fine_slope;
312   z3 = -tile_th/2 + protr / interlock_fine_slope;
313
314   negsign = negative ? -1 : +1;
315   yprotr = negsign * protr;
316
317   INREFFRAME(left_cnr, right_cnr) {
318     for (vsect = [ // zs0            zs1      ys0,            ys1
319                   [ -tile_th-plusth, plusth,  0,              0],
320                   [ z1,              z2,      0, yprotr],
321                   [ z2,              z3,      yprotr, 0],
322                   ]) {
323       zs0 = vsect[0];
324       zs1 = vsect[1];
325       zsd = zs1-zs0;
326       ys0 = vsect[2];
327       ys1 = vsect[3];
328       ysd = ys1-ys0;
329       sl = ysd/zsd;
330       m = [ [ 1,0,   0,    0 ],
331             [ 0,1, -sl, -ys0 + negsign*interlock_sq_adj ],
332             [ 0,0,   1,  zs0 ],
333             [ 0,0,   0,    1 ] ];
334       multmatrix(m)
335         linear_extrude(height=zsd, convexity=10)
336         InterlockEdgePlan(negative, nlobes, length, !!ysd);
337     }
338   }
339 }
340
341 function TestPiece_holes2corners(holes) =
342   [ holes[0] + thehd_bl,
343     holes[1] + thehd_br,
344     holes[1] + thehd_tr,
345     holes[0] + thehd_tl ];
346
347 module TestPiece1(){ ////toplevel
348   holes = [ [-100, 0],
349             [   0, 0]
350             ];
351   corners = TestPiece_holes2corners(holes);
352   rcs = [corners[0], corners[1]];
353   difference(){
354     union(){
355       TileBase(corners[0], corners[2]);
356       Posts(holes);
357       RoundEdge(corners[0], corners[1]);
358       RoundEdge(corners[3], corners[0]);
359     }
360     InterlockEdge(corners[1], corners[2], 1, nlobes=1);
361     RoundCornerCut(rcs);
362   }
363   RoundCornerAdd(rcs);
364 }
365
366 module TestPiece2(){ ////toplevel
367   holes = [ [   0, 0],
368             [  50, 0]
369             ];
370   corners = TestPiece_holes2corners(holes);
371   TileBase(corners[0], corners[2]);
372   Posts(holes);
373   RoundEdge(corners[0], corners[1]);
374   InterlockEdge(corners[3], corners[0], 0, nlobes=1);
375 }
376
377 module TestDemo(){ ////toplevel
378   translate([ -thehd[0], 0 ])
379     color("blue")
380     TestPiece1();
381   translate([ +thehd[0] + demo_slop, 0 ])
382     TestPiece2();
383 }
384
385 module Machine_Arm(){
386   ysz = cutout_l_end_y_total;
387   // assume the round end is arc of a circle
388   chordlen = dist2d([0,0], [ cutout_l_end_y, cutout_l_end_curve ]);
389   endrad = cutout_l_end_y / cutout_l_end_curve * chordlen;
390   
391   translate([0,0,-30]) linear_extrude(height=60) {
392     translate(tile01_tr + [0, (-cutout_tile01_y + cutout_tile11_y)/2]) {
393       intersection(){
394         translate([-100, -ysz/2])
395           square([400, ysz]);
396         translate([ endrad - cutout_tile11_x - cutout_l_end_x_slop, 0 ])
397           circle(r=endrad, $fa=0.01,$fd=5);
398       }
399     }
400   }
401 }
402
403 module Machine_Profile(){
404   first_rear = machine_rear_profile[0];
405   below_point = 0.5 * ( first_rear + first_front ) + [ 0, -10 ];
406   pol = concat( machine_rear_profile,
407                 [ below_point ],
408                 machine_front_profile);
409   skew_angle = atan2( first_front[1] - first_rear[1],
410                       first_front[0] - first_rear[0] );
411   echo(below_point, pol, skew_angle);
412   hull(){
413     for (z=[0,-40]) {
414       translate([0,z]) {
415         //scale([1,5])
416         rotate([0,0, -skew_angle ]){
417           //translate( - first_front )
418           polygon(pol);
419         }
420       }
421     }
422   }
423 }
424
425 module Machine_NewRearProfile(){
426   // figures copied out of xfig edit boxes
427   // best not to edit the posbox size if poss - just move it
428   posbox = 10 * ([7.2333,-14.1267] - [-16.2289,40.0289]); // box, Green
429   sideline = -10 * ([-6.2400,13.5600] - [-2.4467,28.2556]); // line, Blue
430   scaleline = 10 * dist2d([-1.1911,-20.4800], [-11.2600,4.0578]); // Green2
431   scaleline_mm = 12+5+10+5+3;
432   sh = -[abs(posbox[0]), abs(posbox[1])];
433   rot = atan2(-sideline[0], sideline[1]);
434   sc = scaleline_mm / scaleline;
435   echo("SH",sh,rot,sc);
436   scale(sc) rotate(rot) translate(sh){
437     import("sewing-table-rear-profile.dxf", convexity=10); // spline, Pink3
438   }
439 }
440
441 module Machine_NewRearCurve(){
442   intersection(){
443     rotate_extrude(convexity=10, $fn=32)
444       rotate(90)
445       translate([ 0, -rearcurve_double_inrad ])
446       Machine_NewRearProfile();
447     translate([0,0,-500])
448       cube([500,500,1000]);
449   }
450 }
451
452 module Machine_RearProfile(){ ////toplevel
453   intersection(){
454     Machine_Profile();
455     translate([ -200 + machine_rear_to_front/2, -100 ]) {
456       square([200,200]);
457     }
458   }
459 }
460
461 module Machine_FrontProfile(){
462   intersection(){
463     Machine_Profile();
464     translate([ machine_rear_to_front/2, -100 ]) {
465       square([200,200]);
466     }
467   }
468 }
469
470 module Machine_Curves(){ ////toplevel
471   translate([ tile01_tr[0] - cutout_l_end_x + rearedge_len,
472               cutout_tile11_y,
473               0 ]){
474     //%cube([20,20,20]);
475     translate([ -reartablet_x,
476                 -1,
477                 -reartablet_z])
478       mirror([0,0,1])
479       cube([ reartablet_x+1,
480              reartablet_y+1,
481              20 ]);
482   }
483   translate([ tile01_tr[0] - cutout_l_end_x + rearedge_len,
484               cutout_tile11_y,
485               frontcurve_z_slop ]){
486     translate([ 0, -first_front[0] , 0 ])
487       multmatrix([[1, -frontcurve_side_skew, 0, 0],
488                   [0,  1,   0, 0],
489                   [0,  0,   1, 0],
490                   [0,  0,   0, 1]])
491       translate([ 0, first_front[0] , 0 ])
492       mirror([1,0,0]){
493       rotate([0,-90,0])rotate([0,0,-90]){
494         linear_extrude(height= 200)
495           Machine_FrontProfile();
496       }
497     }
498     translate([ rearcurve_strt_len,
499                 0,
500                 rearcurve_z_slop ]){
501       translate([ 1,
502                   0,
503                   0
504                   ]){
505         rotate([0,-90,0])rotate([0,0,-90]){
506           linear_extrude(height= rearcurve_strt_len + 1)
507           Machine_RearProfile();
508         }
509       }
510       translate([ 0,
511                   0,
512                   rearcurve_double_inrad ]) {
513         intersection(){
514           rotate([90,0,0]){
515             rotate_extrude(convexity=10, $fn=32) {
516               rotate([0,0,90]) translate([ 0,
517                           -rearcurve_double_inrad ]) {
518                 Machine_RearProfile();
519               }
520             }
521           }
522           mirror([0,0,1])
523             translate([0,-75,0]) cube([150,150,150]);
524         }
525       }
526     }
527   }
528 }
529
530 module Machine(){ ////toplevel
531   Machine_Arm();
532   Machine_Curves();
533 }
534
535 function Rectangle_corners(c0, sz) =
536   // returns the corners of a rectangle from c0 to c0+sz
537   // if sz is positive, the corners are anticlockwise starting with c0
538   [ c0 + [ 0,     0     ],
539     c0 + [ sz[0], 0     ],
540     c0 + [ sz[0], sz[1] ],
541     c0 + [ 0,     sz[1] ] ];
542
543 function Rectangle_corners2posts(c) =
544   [ c[0] + thehd_tr,
545     c[1] + thehd_tl,
546     c[2] + thehd_bl,
547     c[3] + thehd_br ];
548
549 module Rectangle_TileBase(c) { TileBase(c[0], c[2]); }
550
551 function Posts_interpolate_one(c0,c1) = [c0, (c0+c1)/2, c1];
552
553 m4_dnl   R_EDGE(c,ix)
554 m4_dnl        c is from Rectangle_corners and
555 m4_dnl        ix is a corner number
556 m4_dnl    expands to two comma-separated corners:
557 m4_dnl    that denoted by ix, and the next one anticlockwise
558 m4_define(`R_EDGE',`$1[$2],$1[(($2)+1)%4]')
559
560 module FitTest(){ ////toplevel
561   sz = [280,180];
562   c0 = [-50,-80];
563   c = Rectangle_corners(c0, sz);
564   brace = [7,7,9];
565   difference(){
566     union(){
567       Rectangle_TileBase(c);
568       translate(concat(c0, [-brace[2] + 0.1])){
569         difference(){
570           cube(concat(sz,[brace[2]]) - [5,0,0]);
571           translate(brace + [0,0, -25])
572             cube(concat(sz, [50]) - brace*2 + [10,0,0]);
573         }
574       }
575       RoundEdge(R_EDGE(c,1));
576     }
577     Machine();
578   }
579 }
580
581 module Tile02(){ ////toplevel
582   sz = [100,170];
583   c0 = tile02_tr + -sz;
584   c = Rectangle_corners(c0, sz);
585   posts = Rectangle_corners2posts(c);
586   rcs = [R_EDGE(c,0)];
587   difference(){
588     union(){
589       Rectangle_TileBase(c);
590       Posts(posts);
591       RoundEdge(R_EDGE(c,0));
592       RoundEdge(R_EDGE(c,3));
593       InterlockEdge(R_EDGE(c,2), 0);
594     }
595     InterlockEdge(R_EDGE(c,1), 1);
596     RoundCornerCut(rcs);
597   }
598   RoundCornerAdd(rcs);
599 }
600
601 module Tile12(){ ////toplevel
602   sz = [100,250];
603   c0 = tile02_tr + [-sz[0], 0];
604   c = Rectangle_corners(c0, sz);
605   posts = Rectangle_corners2posts(c);
606   rcs = [R_EDGE(c,3)];
607   difference(){
608     union(){
609       Rectangle_TileBase(c);
610       Posts(posts);
611       RoundEdge(R_EDGE(c,2));
612       RoundEdge(R_EDGE(c,3));
613     }
614     InterlockEdge(R_EDGE(c,0), 1);
615     InterlockEdge(R_EDGE(c,1), 1);
616     RoundCornerCut(rcs);
617   }
618   RoundCornerAdd(rcs);
619 }
620
621 tile_01_11_cnr = tile01_tr + [-cutout_tile11_x, 0];
622 tile_11_10_cnr = tile01_tr + [0, cutout_tile11_y];
623 tile_01_00_cnr = tile01_tr - [0, cutout_tile01_y];
624
625 module Tile11(){ ////toplevel
626   sz = [250,250];
627   c0 = tile01_tr + [-sz[0],0];
628   c = Rectangle_corners(c0, sz);
629   cnr_posts = Rectangle_corners2posts(c);
630   posts = concat(
631                  Posts_interpolate_one(cnr_posts[0],
632                                        cnr_posts[1] - [cutout_tile11_x, 0]),
633                  [ cnr_posts[1] + [0, cutout_tile11_y],
634                    cnr_posts[2],
635                    cnr_posts[3]
636                    ]);
637   difference(){
638     union(){
639       Rectangle_TileBase(c);
640       Posts(posts);
641       RoundEdge(R_EDGE(c,2));
642       InterlockEdge(R_EDGE(c,3));
643     }
644     InterlockEdge(c[0], tile_01_11_cnr, 1);
645     InterlockEdge(tile_11_10_cnr, c[2], 1);
646     Machine();
647   }
648 }    
649
650 module Tile01(){ ////toplevel
651   sz = [250,170];
652   c0 = tile01_tr + -sz;
653   c = Rectangle_corners(c0, sz);
654   cnr_posts = Rectangle_corners2posts(c);
655   posts = concat(
656                  Posts_interpolate_one(R_EDGE(cnr_posts,0)),
657                  [ cnr_posts[2] + [0, -cutout_tile01_y] ],
658                  Posts_interpolate_one(cnr_posts[2] - [cutout_tile11_x, 0],
659                                        cnr_posts[3])
660                  );
661   difference(){
662     union(){
663       Rectangle_TileBase(c);
664       Posts(posts);
665       RoundEdge(R_EDGE(c,0));
666       InterlockEdge(tile_01_11_cnr, c[3]);
667       InterlockEdge(R_EDGE(c,3));
668     }
669     InterlockEdge(c[1], tile_01_00_cnr, 1);
670     Machine();
671   }
672 }    
673
674 module Tile10(){ ////toplevel
675   sz = [250,250];
676   c0 = tile01_tr + [0,0];
677   c = Rectangle_corners(c0, sz);
678   cnr_posts = Rectangle_corners2posts(c);
679   cty = cutout_tile11_y;
680   rcy = cty + rearcurve_avoid_y;
681   posts = [ cnr_posts[0] + [ 0,                             cty ],
682             cnr_posts[1] + [ -sz[0] + rearedge_len - cutout_l_end_x, cty ],
683             cnr_posts[1] + [ 0,                             rcy ],
684             cnr_posts[2],
685             cnr_posts[3] ];
686   rcs = [R_EDGE(c,2)];
687   difference(){
688     union(){
689       Rectangle_TileBase(c);
690       Posts(posts);
691       RoundEdge(R_EDGE(c,1));
692       RoundEdge(R_EDGE(c,2));
693       InterlockEdge(c[3], tile_11_10_cnr);
694     }
695     RoundCornerCut(rcs);
696     Machine();
697   }
698   RoundCornerAdd(rcs);
699 }
700
701 module Tile00(){ ////toplevel
702   sz = [250,170];
703   c0 = tile01_tr + [0,-sz[1]];
704   c = Rectangle_corners(c0, sz);
705   cnr_posts = Rectangle_corners2posts(c);
706   cty = cutout_tile01_y;
707   rcy = cty + frontcurve_avoid_y;
708   posts = [ cnr_posts[0],
709             cnr_posts[1],
710             cnr_posts[2] + [ 0,                             -rcy ],
711             cnr_posts[2] + [ -sz[0] + rearedge_len - cutout_l_end_x, -cty ],
712             cnr_posts[3] + [ 0,                             -cty ]
713             ];
714   rcs = [R_EDGE(c,1)];
715   difference(){
716     union(){
717       Rectangle_TileBase(c);
718       Posts(posts);
719       RoundEdge(R_EDGE(c,0));
720       RoundEdge(R_EDGE(c,1));
721       InterlockEdge(tile_01_00_cnr, c[0]);
722     }
723     RoundCornerCut(rcs);
724     Machine();
725   }
726   RoundCornerAdd(rcs);
727 }
728
729 module Demo(){ ////toplevel
730   translate(demo_slop*[-2,1]) color("blue") Tile12();
731   translate(demo_slop*[-2,0]) color("red")  Tile02();
732   translate(demo_slop*[-2,1]) color("orange") Tile11();
733   translate(demo_slop*[-2,0]) color("purple") Tile01();
734   translate(demo_slop*[-3,1]) color("blue")   Tile10();
735   translate(demo_slop*[-3,0]) color("red")    Tile00();
736   %Machine();
737 }
738   
739 //TestPiece1();
740 //TestPiece2();
741 //Demo();
742
743 //Machine_Profile();
744 //Machine_NewRearProfile();
745 //Machine_NewRearCurve();