// License: CC0
//
// To the extent possible under law, Clementine Computing LLC has waived
// all copyright and related or neighboring rights to this file.
//
// This work is published from: United States.
//

include <PopufareHousingCommon.scad>

module PopufareHousingFrontBottomPlate() {
  
  w = POPUFARE_HOUSING_WIDTH;
  h = POPUFARE_FRONT_HEIGHT;

  bx = POPUFARE_BRACKET_CX;
  br = POPUFARE_BRACKET_D/2.0;
  de = POPUFARE_BRACKET_DE;

  lip = _MATERIAL_THICKNESS;
  lip_top = _MATERIAL_THICKNESS * sqrt(2.0);
  
  h_tot = h - lip_top + lip;
  
  difference() {
    union() {
      square([w,h], center=true);
      
      // lip to cover bottom plate
      //
      translate([0,-(h/2 + lip/2)]) square([w,lip], center=true);
      
      // left/right overhang
      //
      translate([-w/2-lip, -h/2 - lip]) square([lip,h_tot]);
      translate([ w/2, -h/2 - lip]) square([lip,h_tot]);
    };
    
    // shave off top front panel to accomodate angle plate.
    // fudge to guard against stray geometry
    //
    translate([0, (h/2 - 0.4999*lip_top)]) square([2*w, lip_top + 0.15], center=true);
    
    // attach to bottom plate bracket
    //
    translate([ -(w/2 - de), -(h/2-bx) ]) circle(br);
    translate([  (w/2 - de), -(h/2-bx) ]) circle(br);
    
    // side plate bracket attachment
    //
    translate([ -(w/2 - bx), 0]) circle(br);
    translate([  (w/2 - bx), 0]) circle(br);
  }

}

//PopufareHousingFrontBottomPlate();
