chiark / gitweb /
26697d182fcc64638de9bd1d6cbb2799699146d6
[reprap-play.git] / sealing-box.scad.m4
1 // -*- C -*-
2
3 m4_dnl Box_Part($1=transl_x,$2=transl_y, $3=rot_z,$4=mirror_xy)
4 m4_dnl          $5=kind, $6=kindargs, $7=profile(profileargsargs))
5 m4_define(`Box_Part',`
6   translate([($1),($2)])
7     rotate([0,0,($3)])
8     mirror([($4),0,0])
9     BoxPart_Extrude_$5($6, $7)') m4_dnl
10
11 boxpart_d = 0.01;
12
13 m4_dnl BoxPart_Extrude_Linear(dist, `profile(...);');
14 m4_define(`BoxPart_Extrude_Linear',`
15   rotate([90,0,0])
16     translate([0,0, -($1)])
17     linear_extrude(height= boxpart_d + ($1)) {
18       $2
19     }
20 ')
21
22 m4_dnl BoxPart_Extrude_Arc(x0_radius, swept_angle, `profile(...);')
23 m4_dnl  arc starting at transl_x, transl_y, moving towards positive
24 m4_dnl  y at first and then bending towards negative x, until
25 m4_dnl  use negative x0_radius to inciate bending towards positive x
26 m4_dnl  swept_angle is reached
27 m4_dnl  x0_radius is the radius of the extruded part at x=0, not of the box
28 m4_define(`BoxPart_Extrude_Arc',`
29   translate([-($1),0,0])
30     intersection(){
31       translate([0,0,-500])
32         linear_extrude(height=1000)
33         scale(500)
34         mirror([($1)<0, 0,0])
35         FArcSegment_mask($2);
36       rotate_extrude(convexity=10, $fs=1, $fn=36)
37         mirror([($1)<0, 0,0])
38         translate([+($1),0,0]){
39           $3
40         }
41     }
42 ')
43
44 ts_cidoff = (ts_cnrrad * (1-.7) + wallthick * .8) * [1,1];
45
46 ts_xbox_lin = ts_xbox - ts_cnrrad*2;
47 ts_ybox_lin = ts_ybox - ts_cnrrad*2;
48
49 m4_dnl TestSealDoBoxShape(`profile(profileargs)');
50 m4_define(`TestSealDoBoxShape',`
51   Box_Part(0,               ts_cnrrad,    0,0, Linear,`ts_ybox_lin', `$1' )
52   Box_Part(0, ts_ybox-ts_cnrrad,          0,0, Arc,`-ts_cnrrad,90' , `$1' )
53   Box_Part(ts_cnrrad,       ts_ybox,    -90,0, Linear,`ts_xbox_lin', `$1' )
54   Box_Part(ts_xbox-ts_cnrrad, ts_ybox,  -90,0, Arc,`-ts_cnrrad,90' , `$1' )
55   Box_Part(ts_xbox, ts_ybox-ts_cnrrad, -180,0, Linear,`ts_ybox_lin', `$1' )
56   Box_Part(ts_xbox,         ts_cnrrad, -180,0, Arc,`-ts_cnrrad,90' , `$1' )
57   Box_Part(ts_xbox-ts_cnrrad, 0,       -270,0, Linear,`ts_xbox_lin', `$1' )
58   Box_Part(ts_cnrrad,         0,       -270,0, Arc,`-ts_cnrrad,90' , `$1' )
59 ')
60
61 m4_dnl '
62
63 module WallProfile(){
64   z = ts_zbox - innertube - tubesealrad;
65   translate([0, -0.1]) square([wallthick, z]);
66   translate([tubesealrad, z]) circle(r=tubesealrad, $fn=20);
67 }
68
69 module FloorProfile(){
70   mirror([0,1]) square([wallthick, floorth]);
71 }
72
73 module LidProfile(){
74   rad = tubesealrad + innertube;
75   morex = wallthick;
76   difference(){
77     translate([-lidoverlap - innertube,
78                ts_zbox - lidoverhang - innertube])
79       square([lidoverlap + innertube + wallthick,
80               lidoverhang + innertube + ceilth]);
81     hull(){
82       translate([tubesealrad,
83                  ts_zbox - innertube - tubesealrad])
84         for (t=[ [0,0],
85                  [morex*2, 0],
86                  [0, -ts_zbox]
87                  ]) {
88           translate(t)
89             circle(r= tubesealrad + innertube, $fn=20);
90         }
91     }
92   }
93 }
94
95 module CeilProfile(){
96   translate([0, ts_zbox])
97     square([wallthick*2, ceilth]);
98 }
99
100 module TestSealBoxBox(){
101   TestSealDoBoxShape(WallProfile(););
102   hull(){ TestSealDoBoxShape(FloorProfile();); }
103 }
104
105 module TestSealBoxLid(){ ////toplevel
106   TestSealDoBoxShape(LidProfile(););
107   hull(){ TestSealDoBoxShape(CeilProfile();); }
108 }