include <cartridge.scad>;

cartridge_clearance = 0.3;

module receptacle() {
  difference() {
    box();
    hole();
    track_grooves();
  }
  tape_guides();
}

module box() {
  translate([
    -5,
    -cartridge_clearance - 5,
    -cartridge_clearance - 10,
  ])
    cube([
      cartridge_length + 5 - grip_count * grip_wedge_width - back_vertical_fillet_radius,
      cartridge_width  + 10,
      cartridge_height + 20,
    ]);
}

module hole() {
  translate([
    -cartridge_clearance,
    -cartridge_clearance,
    -cartridge_clearance,
  ])
    cube([
      cartridge_length + cartridge_clearance,
      cartridge_width  + 2 * cartridge_clearance,
      cartridge_height + 2 * cartridge_clearance,
    ]);
}

module track_grooves() {
  translate([
    track_back_inset + cartridge_clearance,
    0,
    cartridge_height + cartridge_clearance
  ])
    rotate([0, 90, 0]) {
      translate([0, track_side_inset]) track_groove();
      translate([0, cartridge_width - track_side_inset]) track_groove();
    }
}

module track_groove() {
  cylinder(
    h=cartridge_length + cartridge_clearance,
    r=track_radius + cartridge_clearance,
  );
}

module tape_guides() {
  translate([0, cartridge_width])
    mirror([0, 1])
    tape_guide();
  tape_guide();
}

module tape_guide() {
  linear_extrude(cartridge_height + 2 * cartridge_clearance)
    polygon([
      [0, 0],
      [0, tape_guide_width - cartridge_clearance],
      [tape_guide_depth - cartridge_clearance, 0],
    ]);
}
