module chain_link() {
    translate([44, -0.10499, 0])
        intersection() {
            import("original-chain-link.stl");
            translate([-31, -40.285, 0])
                cube([30, 30, 20]);
        }
        
    for(x = [20, 40])
        translate([x, -21.5, 0])
            cube([2.5, 21.5, 13.3]);
}

module mount_plate() {
    difference() {
        rotate([90, 0, 0])
            linear_extrude(3)
                polygon([
                    [0, 0],
                    [0, 49],
                    [22.5, 49],
                    [22.5, 43],
                    [32, 43],
                    //[32, 31.5],
                    //[22, 31.5],
                    [32, 31],
                    [22, 31],
                    [22, 0],
                ]);
        
        for(z = [17.5, 37]) {
            translate([9, 0, z])
                rotate([90, 0, 0])
                    cylinder(h = 3, d = 4, $fn = 24);
        }
    }
    
    translate([40, 0, 0])
        cube([2.5, 8, 3]);
    
    translate([32, 0, 31.5])
        cube([10.5, 8, 2.5]);
}

module roof(h) {
    rotate([180, -90, 0])
        linear_extrude(h)
            polygon([
                [13.3, 0 ],
                [34, 0],
                [13.3, 21.5],
            ]);
}

module frame_mount() {
    mount_plate();
}

chain_link();


difference() {
    union() {
        translate([20, 0, 0])
            roof(22.5);
    
        frame_mount();
    }
    translate([22.5, 0, -2.5])
        roof(17.5);
}