+module FaceCore(z0,z1, extra_left, extra_right){
+ difference(){
+ for (mx=[0,1]) mirror([mx,0,0]) {
+ for (my=[0,1]) mirror([0,my,0]) {
+ translate(-nom_cnr) {
+ rotate_extrude(angle=90, convexity=10) {
+ intersection(){
+ translate(-[1,0,0] * nook_cnr_rad)
+ children(mx);
+ rectfromto([-100,-100], [0,100]);
+ }
+ }
+ }
+ }
+ translate([nook_w/2, 0,0])
+ linextr_y_xz(-nom_cnr[1]-0.1, nom_cnr[1]+0.1)
+ children(1-mx);
+ }
+ for (my=[0,1]) mirror([0,my,0]) {
+ translate([-nook_w/2, 0,0])
+ mirror([1,0,0])
+ linextr_y_xz(tapb, tapa)
+ children(2);
+ }
+ }
+ for (my=[0,1]) mirror([0,my,0]) {
+ translate([0, -nook_h/2, 0]) {
+ linextr_x_yz(-nom_cnr[0]-0.1, etxc + extra_left) children(0);
+ linextr_x_yz(etxc - extra_right, etxb + extra_right) children(1);
+ linextr_x_yz(etxb - extra_left, etxa + extra_left) children(0);
+ linextr_x_yz(etxa - extra_right, nom_cnr[0]+0.1) children(1);
+ }
+ }
+ if (!$test) {
+ linextr(z0,z1)
+ rectfromto(-nom_cnr, nom_cnr);
+ }
+}
+
+module DiagonaliseNearHinge(wider){
+ sz = spp0[1] - spp30[1] + gap[1];
+
+ for (my=[0,1]) mirror([0,my,0]) {
+ translate([-etxa, -nook_h/2, 0])
+ mirror([1,0,0])
+ linextr_y_xz(spp31[0] - wider, spp30[0] + gap[0] + 0.1)
+ translate([ 0, spp30[1] ])
+ polygon([[ -1, 0 ],
+ [ 0, 0 ],
+ [ sz/diag_near_hinge_slope, sz ],
+ [ sz/diag_near_hinge_slope, sz + 0.1 ],
+ [ -1, sz + 0.1 ]]);
+ }
+}
+
+module Base(){ ////toplevel
+ difference(){
+ FaceCore(spp7[1],spp8[1], 0.3, 0) {
+ LeftSideMainProfile();
+ RightSideMainProfile();
+ SideTapeCutout();
+ }
+ translate([0, -nook_h/2, 0])
+ mirror([0,1,0])
+ linextr_x_yz(-usb_w/2, usb_w/2)
+ rectfromto(spp8 + [-40, usb_below], [40, 40]);
+ translate([ gap[0], 0,0 ])
+ DiagonaliseNearHinge(10);
+/*
+ translate([nook_w/2, 0, 0])
+ linextr_y_xz(oprb, opra)
+ translate(spp0)
+ rectfromto([-40, -open_recess_h], [40, 1]);
+*/
+ }
+ if ($test) {
+ linextr(spp7[1], spp8[1]) {
+ hull(){
+ for (r=[0,180])
+ rotate([0,0,r])
+ translate(nom_cnr + -1 * nook_cnr_rad*[1,1])
+ square(12);
+ }
+ }
+ }
+}
+
+module Top(){ ////toplevel
+ difference(){
+ FaceCore(tppE[1],tppD[1], -gap[0], gap[0] + 0.3) {
+ LeftTopMainProfile();
+ RightTopMainProfile();
+ TopTapeCutout();
+ }
+ translate([nook_w/2, 0,0])
+ linextr_y_xz(opqb, opqa)
+ rectfromto(spp8, tppC + [-1,1]);
+ }
+ translate([0,0, gap[1]])
+ DiagonaliseNearHinge(0);
+ translate([nook_w/2, tooth_y, 0])
+ linextr_y_xz(-tooth_w/2, +tooth_w/2)
+ ToothProfile();
+}
+module TopPrint(){ ////toplevel
+ rotate([0,0,90]) rotate([180,0,0]) Top();
+}
+module BasePrint(){ ////toplevel
+ rotate([0,0,90]) Base();
+}
+
+module TestExtrude(){
+ difference(){
+ linextr_y_xz(-test_pillar, tape_w+test_pillar) children(0);
+ linextr_y_xz( 0, tape_w ) children(1);
+ }
+}
+
+module BaseTestRest(){ ////toplevel
+ cube([30,15, spp8[1]-spp7[1]]);
+}
+
+module Demo3(){ ////toplevel
+ color("purple") Top();
+ color("red") Base();
+}
+
+module TestSide(){ ////toplevel
+ TestExtrude() { LeftSideMainProfile(); SideTapeCutout(); }
+}
+
+module TestTop(){ ////toplevel
+ TestExtrude() { LeftTopMainProfile(); TopTapeCutout(); }
+}
+module TestTopPrint(){ ////toplevel
+ rotate([180,0,0]) TestTop();
+}