r = 35;
h = 20.32;
thickness = 2;
a = 10.16;
d = 1.6;

shield_bottom();
rotate([0,0,135]){translate([140,0,0]){bottom2();}}
//color("blue"){rotate([0,0,45]){translate([0,-(sqrt(2*pow(r/1.6,2))+thickness)/4,thickness+30]){cube([10,2,60],center=true);}}} // SHT25V01A


for(i=[[1,-1],[2,1]/*,[3,-1]*/]){
rotate([0,0,90*i[1]]){translate([0,0,i[0]*h]){shield_part();}}
}

rotate([0,0,-90]){translate([0,0,3*h]){shield_top(r,h,thickness);}}

module shield_top(){
        difference(){
                top(r,h);
                translate([0,0,-thickness]){top(r-thickness,h-thickness);}
        }
        difference(){
                intersection(){
                        union(){
                                translate([-thickness/2,thickness-r,0]){cube([thickness,2*r-thickness*2,h]);}
                                translate([thickness-r,-thickness/2,0]){cube([2*r-thickness*2,thickness,h]);}
                        }
                                translate([0,0,-thickness]){top(r-thickness,h-thickness);}
                }
                rotate([0,0,45]){
                                cube([sqrt(2*pow(r/1.6,2))-thickness*2,sqrt(2*pow(r/1.6,2))-thickness*2,h*5],center=true);
                }
        }

        rotate([0,0,45]){
                translate([0,0,h/6]){
                        difference(){
                                difference(){
                                        cube([sqrt(2*pow(r/1.6,2)),sqrt(2*pow(r/1.6,2)),h/3],center=true);
                                        cube([sqrt(2*pow(r/1.6,2))-thickness*2,sqrt(2*pow(r/1.6,2))-thickness*2,h/2],center=true);
                                }
                                rotate([0,90,0]){
                                        translate([0,(sqrt(2*pow(r/1.6,2))+thickness)/4,0]){
                                                cube([1.5*thickness,4*thickness,sqrt(2*pow(r/1.6,2)+thickness)+thickness],center=true);
                                        }
                                }
                        }
                }
        }
}

module top(r,h){
        difference(){
                intersection(){
                        translate([-r,-r,0]){cube([2*r,2*r,h]);}
                        cylinder(h=h, r=r,$fn=100);
                }
                translate([0,0,h/5]){
                        difference(){
                                translate([-r,-r,0]){cube([r*2,r*2,h+1]);}
                                resize([0,0,h*5/3]){sphere(r=r,$fn=100);}
                        }
                }
        }

}

module shield_part(){
        difference(){
                difference(){
                        translate([0,0,0.01]){scale(0.999){part(r,h);}}
                        resize([2*r-thickness*2,2*r-thickness*2,0]){part(r,h);}
                }
                union(){
                        translate([0,0,1.3*h-h/8]){cube([2*r/1.5,thickness,0.3*h],center=true);
                                                                                                cube([thickness,2*r/1.5,0.3*h],center=true);}
                }
        }

        difference(){
                difference(){
                        intersection(){
                                union(){
                                        translate([-thickness/2,thickness-r,0]){cube([thickness,2*r-thickness*2,h]);}
                                        translate([thickness-r,-thickness/2,0]){cube([2*r-thickness*2,thickness,h]);}
                                }
                                resize([2*r-thickness*2,2*r-thickness*2,0]){part(r,h);}
                        }
                        translate([0,0,-0.1]){cylinder(h=h,r=r/1.6-thickness,$fn=100);}
                }
                cylinder(h=h*2,r1=r/1.6-2*thickness,r2=r*0.8,$fn=100);  
        }
        rotate([0,0,45]){
                translate([0,0,h/6]){
                        union(){
                        difference(){
                                difference(){
                                        cube([sqrt(2*pow(r/1.6,2)),sqrt(2*pow(r/1.6,2)),h/3],center=true);
                                        cube([sqrt(2*pow(r/1.6,2))-thickness*2,sqrt(2*pow(r/1.6,2))-thickness*2,h/2],center=true);
                                }
                                rotate([0,90,0]){
                                        translate([0,(sqrt(2*pow(r/1.6,2))+thickness)/4,0]){
                                                cube([1.5*thickness,4*thickness,sqrt(2*pow(r/1.6,2)+thickness)+thickness],center=true);
                                        }
                                }
                        }
                        translate([(sqrt(2*pow(r/1.6,2))-thickness*3)/2,-(sqrt(2*pow(r/1.6,2))+thickness)/4,2.9*h/6]){
                                cube([thickness,thickness*3.95,h*1.3],center=true);}
                        translate([-(sqrt(2*pow(r/1.6,2))-thickness*3)/2,-(sqrt(2*pow(r/1.6,2))+thickness)/4,2.9*h/6]){
                                cube([thickness,thickness*3.95,h*1.3],center=true);}

                        translate([-(sqrt(2*pow(r/1.6,2))-thickness*3)/2-thickness,-(sqrt(2*pow(r/1.6,2))+thickness)/4,h-(1.5*thickness/6)+0.05]){
                                rotate([0,0,90]){
                                        difference(){
                                                cube([thickness*3.95,thickness,thickness],center=true);
                                                translate([-thickness*2,thickness/2,-thickness/2]){rotate([45,0,0]){cube(thickness*4);}}
                                        }
                                }
                        }
                        translate([(sqrt(2*pow(r/1.6,2))-thickness*3)/2+thickness,-(sqrt(2*pow(r/1.6,2))+thickness)/4,h-(1.5*thickness/6)+0.05]){
                                rotate([0,0,-90]){
                                        difference(){
                                                cube([thickness*3.95,thickness,thickness],center=true);
                                                translate([-thickness*2,thickness/2,-thickness/2]){rotate([45,0,0]){cube(thickness*4);}}
                                        }
                                }
                        }
                }
                }
        }
}

module part(r,h){
        difference(){
                intersection(){
                        translate([-r,-r,0]){cube([2*r,2*r,h]);}
                        cylinder(h=h, r=r,$fn=100);
                }
                translate([0,0,h/5]){
                        difference(){
                                translate([-r,-r,0]){cube([r*2,r*2,h+1]);}
                                resize([0,0,h*5/3]){sphere(r=r,$fn=100);}
                        }
                }
        }
        cylinder(h=1.3*h,r=r/1.5,$fn=100);
}


module shield_bottom(){
        difference(){
                difference(){
                        translate([0,0,0.01]){scale(0.999){cylinder(h=1.3*h,r=r/1.5,$fn=100);}}
                        cylinder(h=1.3*h,r=r/1.5-thickness,$fn=100);
                }
                union(){
                        translate([0,0,1.3*h-h/8]){cube([2*r/1.5,thickness,0.3*h],center=true);
                                                                                                cube([thickness,2*r/1.5,0.3*h],center=true);}
                        translate([(sqrt(2*pow(r/1.6,2))-thickness*3)/2,0,19]){rotate([90,0,-45]){cylinder(h=r*2,r=1,$fn=100,center=true);}}
                }
        }

        rotate([0,0,45]){
                translate([0,0,h/6]){
                        translate([(sqrt(2*pow(r/1.6,2))-thickness*3)/2,-(sqrt(2*pow(r/1.6,2))+thickness)/4,2.9*h/6]){
                                cube([thickness,thickness*3.95,h*1.3],center=true);}
                        translate([-(sqrt(2*pow(r/1.6,2))-thickness*3)/2,-(sqrt(2*pow(r/1.6,2))+thickness)/4,2.9*h/6]){
                                cube([thickness,thickness*3.95,h*1.3],center=true);}

                        translate([-(sqrt(2*pow(r/1.6,2))-thickness*3)/2-thickness,-(sqrt(2*pow(r/1.6,2))+thickness)/4,h-(1.5*thickness/6)+0.05]){
                                rotate([0,0,90]){
                                        difference(){
                                                cube([thickness*3.95,thickness,thickness],center=true);
                                                translate([-thickness*2,thickness/2,-thickness/2]){rotate([45,0,0]){cube(thickness*4);}}
                                        }
                                }
                        }
                        translate([(sqrt(2*pow(r/1.6,2))-thickness*3)/2+thickness,-(sqrt(2*pow(r/1.6,2))+thickness)/4,h-(1.5*thickness/6)+0.05]){
                                rotate([0,0,-90]){
                                        difference(){
                                                cube([thickness*3.95,thickness,thickness],center=true);
                                                translate([-thickness*2,thickness/2,-thickness/2]){rotate([45,0,0]){cube(thickness*4);}}
                                        }
                                }
                        }
                }
                difference(){
                        translate([0,-(sqrt(2*pow(r/1.6,2))+thickness)/4,thickness+5]){cube([10+2*thickness,2+2*thickness,10],center=true);}
                        translate([0,-(sqrt(2*pow(r/1.6,2))+thickness)/4,thickness+30]){cube([10,2,60],center=true);}
                }
        }
        difference(){
                cylinder(h=thickness,r=r/1.5-thickness,$fn=100);
                translate([-5,5,0]){cylinder(h=thickness*3,r=6,$fn=100,center=true);}
        }
        difference(){
                difference(){
                        rotate([0,0,-45]){translate([-50-r/1.5,0,7.5]){cube([120,15,15],center=true);}}
                        cylinder(h=3*h,r=r/1.5-thickness,$fn=100,center=true);
                }
                rotate([0,0,-45]){translate([-140,0,0]){cylinder(h=3*20,r=10,center=true,$fn=100);}}
        }
        difference(){
        rotate([0,0,-45]){translate([-140,0,0]){
                difference(){
                        union(){
                                difference(){
                                        cylinder(h=20,r=14,$fn=100);
                                        cylinder(h=3*20,r=10,center=true,$fn=100);
                                }
                                difference(){
                                        translate([2+1,0,10]){cube([4,50,20],center=true);}
                                        cylinder(h=3*20,r=10,center=true,$fn=100);
                                }
                        }
                        translate([-15+1,0,10]){cube(30,center=true);}
                }
        }
        }
        union(){
                rotate([0,0,-45]){translate([-140,19.5,10]){rotate([0,90,0]){cylinder(h=10,r=3,$fn=100);}}}
                rotate([0,0,-45]){translate([-140,-19.5,10]){rotate([0,90,0]){cylinder(h=10,r=3,$fn=100);}}}
        }
        }
}


module bottom2(){
difference(){
        difference(){
                union(){
                        difference(){
                                cylinder(h=20,r=14,$fn=100);
                                cylinder(h=3*20,r=10,center=true,$fn=100);
                        }
                        difference(){
                                translate([2+1,0,10]){cube([4,50,20],center=true);}
                                cylinder(h=3*20,r=10,center=true,$fn=100);
                        }
                }
                translate([-15+1,0,10]){cube(30,center=true);}
        }
        union(){
                translate([0,19.5,10]){rotate([0,90,0]){cylinder(h=10,r=3,$fn=100);}}
                translate([0,-19.5,10]){rotate([0,90,0]){cylinder(h=10,r=3,$fn=100);}}
        }
}
}