+module WebProfile(){
+ upp_app_Vars(a_bevel){
+ if ($gppR[1] <= $gppP[1]) {
+ polygon([ $gppP,
+ $xppE,
+ $gppT,
+ $gppQ ]);
+ polygon([ $gppP,
+ $xppE,
+ $xppF,
+ $gppS,
+ $gppR ],
+ convexity=10);
+ } else {
+ polygon([ $gppP,
+ $xppE,
+ $xppF,
+ $gppS,
+ $gppP + web_height * [1,0] ],
+ convexity=10);
+ }
+ polygon([ $gppS,
+ $xppF,
+ $xppF + [1,0],
+ $gppS + [1,0] ],
+ convexity=10);
+ }
+}
+
+module SomeBaseProfile(I, F){
+ polygon([ I,
+ F,
+ [ hsz+1, F[1] ],
+ [ hsz+1, I[1] ] ]);
+}
+
+module BaseProfile(){
+ SomeBaseProfile($xppI, $xppF);
+}
+
+module DCoverProfileRaw(){
+ polygon([ cpp1,
+ cpp2,
+ cppA,
+ cppB,
+ cppC,
+ cppD,
+ cppE,
+ cppF,
+ cppG,
+ cppK,
+ cppH ],
+ convexity = 10);
+}
+
+module DCoverProfile(){
+ mirror([1,0])
+ translate(-cppZ)
+ DCoverProfileRaw();
+}
+
+module SWalls(ymin, ymax, t_bevel) {
+ upp_app_Vars(t_bevel) {
+ translate([0,ymin,0])
+ mirror([0,1,0])
+ rotate([90,0,0])
+ linear_extrude(height= ymax-ymin, convexity=10)
+ for (xm=[0,1])
+ mirror([xm,0])
+ translate([-hsz, 0])
+ children();
+ }
+}
+
+module AtTwoCorners(){
+ for (xm=[0,1]) {
+ mirror([xm,0,0])
+ translate((hsz - cnr_rad) * [1,1])
+ intersection(){
+ rotate_extrude(convexity=10)
+ translate([-cnr_rad,0])
+ children();
+ translate([0,0,-250])
+ cube([50,50,500]);
+ }
+ }
+}
+
+module Box(){
+ /// corners, and front and back of base
+ for (ym=[0,1]) mirror([0,ym,0]) {
+ AtTwoCorners(){
+ UsualProfile();
+ }
+ hull() AtTwoCorners(){
+ upp_app_Vars(bevel){
+ polygon([ $xppI,
+ $xppF,
+ $xppF + [0.1, 0],
+ $xppI + [0.1, 0]
+ ]);
+ }
+ }
+ }
+
+ // side walls and base
+ SWalls(yw6 , yw4 , bevel ) { UsualProfile(); BaseProfile(); }
+ SWalls(yw5 , yw4 , a_bevel) { AnchorWallProfile(); BaseProfile(); }
+ SWalls(yw5 , yw12, a_bevel) { NearAnchorProfile(); BaseProfile(); }
+ SWalls(yw3 , yw2 , a_bevel) { AnchorProfile(); BaseProfile(); }
+ SWalls(yw11, yw12, a_bevel) { AnchorWallProfile(); BaseProfile(); }
+ SWalls(yw11, yw13, bevel ) { UsualProfile(); BaseProfile(); }
+ SWalls(yw1, yw10, a_bevel) { WebProfile(); SomeBaseProfile($gppS, $xppF); }
+
+ // front and rear walls
+ rotate([0,0,90]) SWalls(yw6, yw13, bevel) UsualProfile();
+}
+
+module DCover(){ ////toplevel
+ translate([ -display_width/2, -hsz, 0 ])
+ rotate([0,90,0])
+ rotate([0,0,90])
+ linear_extrude( display_width - display_rhs_secs, convexity = 10)
+ DCoverProfile();
+}
+
+module DCoverSupportAllowance(){
+ translate([0, -hsz, 0])
+ cube(center=true,
+ [ display_width + 2 * dcover_edge_gap_more_width,
+ wall_thick * 2,
+ dcover_slop_inside * 2 + 0.01 ]);
+}
+
+module BoltHoles(){
+ translate([0,0, -(bolt_above + 0.5 * bolthole_height)])
+ cube(center=true, [ cut, bolthole_width, bolthole_height ]);
+}
+
+module KsafeBase(){ ////toplevel
+ DCover();
+
+ difference(){
+ Box();
+
+ BoltHoles();
+
+ // string slot
+ translate([ -cut,
+ -(bolthole_width/2 + bolthole_rhs),
+ 1 ])
+ mirror([0,1,0]) mirror([0,0,1])
+ cube([ cut*2,
+ string_slot,
+ lidinner_thick_allow + string_depth + 1 ]);
+
+ // thumb slots
+ for (mx=[0,1]) mirror([mx,0,0]) {
+ translate([ thumbslot_between/2,
+ 0,
+ -thumbslot_depth ])
+ cube([ thumbslot_width,
+ cut,
+ thumbslot_depth+1 ]);
+ }
+
+ DCoverSupportAllowance();
+ }
+}
+
+module DemoProfiles(){ ////toplevel