// Shell for Samsung S6 and S7 // allviews bottom-S6 bottom-S6-notop top-S6 // allviews bottom-S7 bottom-hugo bottom-S7-notop top-S7 // allviews top-S6-transparent top-S7-transparent // viewsopts h1 // viewopts bottom // viewopts bottom_hugo brim5mm // viewopts top // testviews profile_width profile_length // testviews assembly-S6 assembly-S7 assembly-up // testviews testtop-S6 testtop-S7 tube testcorner // testviews testbottom-S6 testbottom-S7 // testviews hinge include use <../cadlib.h> width=70.82+0.5; width2=60; width_top=width+1.0; length2=143; length=130+0.5; sideray=3; thick=8.37+1; ray=3; module profile_test(len){ basew=width-2*sideray; translate([0,-basew/2,0]) cube([len,basew,0.25]); translate([0,-basew/2,thick/2]) rotate([0,90,0]) cylinder(r=sideray,h=len); translate([0, basew/2,thick/2]) rotate([0,90,0]) cylinder(r=sideray,h=len); } // Create a tube acting as a hinge, but cover it smoothly module tube(len,half,holer,endshape){ t2=thick/2; pathhalf=[[-2,0],[0,t2-1],[3,t2+0.5],[0,0],[-2,0]]; pathfull=[[-2,0],[0,t2-1],[3.75,t2+0.8],[1,0],[4,-t2-1],[0,-t2+1],[-2,0]]; rotate([90,0,0]) difference(){ union(){ linear_extrude(len) polygon(half?pathhalf:pathfull); cylinder(r=2,h=len,$fn=40); if (endshape==2){ translate([0,0,len]) cylinder(r1=1.4,r2=0,h=2.8,$fn=40); } } union(){ if (holer > 0) translate([0,0,-1]) cylinder(r=holer,h=len+2,$fn=40); if (endshape==1){ translate([0,0,-0.1]) cylinder(r1=1.5,r2=0,h=3.2,$fn=40); } } } } // Like tube, but remove a stripe on the inside module tube_trim(len,half,holer,endshape){ difference(){ tube (len,half,holer,endshape); trimr=0.8; translate([trimr*3/2,-len-1,-trimr*2]) cube([trimr*2,len+2,trimr*4]); } } module corner_polygon(){ ray=8; h0=thick+3; h1=thick+2; h2=3*thick/4+1.5; h3=thick/4+0.5; h4=0; exh=1; x0=-2; x1=-0.5; x2=1.0; path3=[[x0,h0],[x1,h1],[x2,h2],[x2,h3],[x1,h4], [x0,0],[x1-1,h4],[x2-1,h3],[x2-1,h2],[x1-1,h1]]; polygon(path3); } module testcorner(){ { translate ([0,10,0]) rotate([90,0,90]) linear_extrude(50){ corner_polygon(); } } { h0=thick+1; h1=thick; h2=3*thick/4; h3=thick/4; exh=1; path2=[[1,h0],[0,h1],[-exh,h2],[-exh,h3],[0,0]]; rotate([0,0,-90]) profile(path2,width2,1,0,0.5); } } corner_ray=10; module corner_extrude(offcx,offcy,offx,offy){ ray=corner_ray+0; intersection(){ translate([offcx-1,offcy-1,0]) cube([ray+2,ray+2,ray+5]); translate([offx,offy,0]){ cylinder(r=ray-1,h=1); rotate_extrude($fn=40){ translate([ray,0,0]) corner_polygon(); } } } } module corner(quarter){ ray=corner_ray; if (quarter==1){ corner_extrude(0,-1,ray,ray); }else if (quarter==2){ corner_extrude(-1,-1,-1,ray); }else if (quarter==3){ corner_extrude(0,-3,ray,-2.5); //2.5); }else if (quarter==4){ corner_extrude(-2,0,-1,-2.5); } } module bottom(is_S7, put_hinges, side_buttons_holes){ h0=thick+1; h1=thick; h2=3*thick/4; h3=thick/4; exh=1; path=[[1,h0], [0,h1],[-exh,h2],[-exh,h3],[0,0], [width,0],[width+exh,h3],[width+exh,h2],[width,h1], [width-1,h0]]; path2=[[1,h0],[0,h1],[-exh,h2],[-exh,h3],[0,0]]; difference(){ union(){ thick=2; // Side and bottom translate([0,0,thick/2]) profile(path,length,thick,0,0.5); // Complete the bottom to connect the up and down translate([(width-width2)/2,-(length2-length)/2-0.5,0]) cube([width2,length2+1,thick]); // Top translate([(width-width2)/2+3,length2-(length2-length)/2,thick/2]) rotate([0,0,-90]) profile(path2,width2-6,thick,0,0.5); // Down translate([width-(width-width2)/2-3,-(length2-length)/2,thick/2]) rotate([0,0,90]) profile(path2,width2-6,thick,0,0.5); } union(){ // Hole for the back camera and flash translate([17,is_S7 ? 105 : 107,-1]) round_rectangle(27,15,10,6/2); if(side_buttons_holes) { // Hole for the left side two buttons translate([-2,is_S7 ? 86 : 90,thick/2-1.6]) cube([10,30,9]); // Hole for the right side button hy=is_S7 ? 77.5 : 74 ; translate([width-2,hy,thick/2-2.5]) cube([10,13,10]); } // Make the ends of the hole round translate([width-2,hy+12-0.5,2]) difference(){ cube([thick,thick,thick+1]); translate([-1,thick+1,1]) rotate([0,90,0]) cylinder(r=thick+0.5,h=thick+2,$fn=20); } translate([width-2,hy-7+1,2]) difference(){ cube([thick,thick,thick+1]); translate([-1,-1,1]) rotate([0,90,0]) cylinder(r=thick+0.5,h=thick+2,$fn=20); } // Hole for the USB port offhead=15; translate([width/2-6.5-offhead,-6+3,thick/2-2-4]) rotate([90,0,0]) round_rectangle(13+offhead,7+8,5+2,2); *translate([width/2-6.5,-6+3,thick/2-2-4]) rotate([90,0,0]) round_rectangle(13,7+8,5+2+4,2); // Hole for the speaker translate([width/2+14,-3,thick/2-0.5]) rotate([90,0,0]) round_rectangle(10,4,7,2); // Hole for the head set *translate([is_S7 ? 18.5 : 15.5,-10,thick/2+1.5]) rotate([-90,0,0]) cylinder(r=3.6,h=8,$fn=20); } } // Hinges if (put_hinges){ offx=-4; translate([offx,27+40.5,thick/2+2]) tube(48,false,1,0); hinge2 = is_S7 ? 7 : 5; translate([offx,length-hinge2,thick/2+2]) tube(hinge2,false,0,1); } // Corners // bottom left translate([-1,-7.5,0]) corner(1); // bottom right translate([width-8,-7.5,0]) corner(2); // top left difference(){ translate([-1,length,0]) corner(3); translate([-1,length+8,1]) rotate([0,0,-55]) cube([20,1,thick+2]); } // top right difference(){ translate([width-8,length,0]) corner(4); translate([width-10,length-5,1]) rotate([0,0,55]) cube([20,1,thick+2]); } } module bottom_hugo() { //difference(){ //bottom(true,false,false); //bh = 5; //union(){ //translate([-2,is_S7 ? 86 : 90,thick/2-1.6]) cube([10,30,9]); //translate([-2,90+5,thick/2-1.6]) cube([10,6,9]); //translate([-2,90+20,thick/2-1.6]) cube([10,6,9]); //translate([width-2,hy+3.5,thick/2-0.5]) cube([10,6,10]); // translate([-5,104,bh]) // rotate([90,0,90]) round_rectangle(10,4,7,2); // translate([-5,90,bh]) // rotate([90,0,90]) round_rectangle(10,4,7,2); // translate([68,78.5,bh]) // rotate([90,0,90]) round_rectangle(10,4,7,2); //} //} translate([100,0,0]) round_rectangle(10,1.2,4,0.6); translate([104,0,3]) round_rectangle(1.5,1,3,0.5); } module bottom_test_hugo() { difference(){ bottom(true,false,false); hy=77.5; union(){ //translate([-2,is_S7 ? 86 : 90,thick/2-1.6]) cube([10,30,9]); translate([-2,90+5,thick/2-1.6]) cube([10,6,9]); translate([-2,90+20,thick/2-1.6]) cube([10,6,9]); translate([width-2,hy+3.5,thick/2-0.5]) cube([10,6,10]); } } } topthick=2; holer=0.8; module side_hinge(position,len,slice_begin,slice_end){ offw=(width_top-width2)/2; t1=-thick/2-1; difference(){ union(){ translate([-3-offw,position,t1]) tube_trim(len,true,holer,0); translate([-3-offw-1,position-len,-thick/2+0.4]) rotate([0,30,0]) cube([topthick,len,thick/2+topthick+0.5]); translate([-1-offw,position-len,0]) cube([3.5,len,topthick]); } union(){ if(slice_begin){ // Remove a 45 degre slice at the end of the hinge translate([-10,-6,-8]) rotate([0,0,45]) cube([10,10,10]); } if (slice_end){ translate([-11,length+3.5,-8]) rotate([0,0,45]) cube([10,10,10]); } } } } module top(is_S7,transparent){ difference(){ union(){ cube([width2,length2-1,topthick]); offw=(width_top-width2)/2; translate([-offw,-(length-length2)/2,0]) cube([width_top,length,topthick]); // Put the hinges // bottom side_hinge (25-0.5,20-0.5,true,false); // middle lh2 = length2-(is_S7 ? 51 : 47); lent2 = is_S7 ? 18 : 22; side_hinge(lh2,lent2,false,false); // top lent3 = is_S7 ? 7 : 5; side_hinge(length+6.5,lent3,false,true); // Put the lock w2=width_top-offw+2; // 0.25; l2=6.5; lockl=length; // Side with the hole to turn off the phone difference(){ path=[[-2,0],[2,0],[3,-thick/3],[3,-3*thick/4] ,[3,-thick-1],[2,-thick-2]]; translate([w2-1,l2+5,0.5]) profile(path,length2-25,1,0,0.5); union(){ // Hole to access the button hy=is_S7 ? 81.5 : 78; translate([w2-4,hy,-thick-2]) cube([10,17,thick+4]); // Make the ends of the hole round translate([w2-4,hy+16-0.5,-thick-2]) difference(){ cube([thick,thick,thick]); translate([-1,thick+1,thick+1]) rotate([0,90,0]) cylinder(r=thick+0.5,h=thick+2); } translate([w2-4,hy-7+1,-thick-2]) difference(){ cube([thick,thick,thick]); translate([-1,-1,thick+1]) rotate([0,90,0]) cylinder(r=thick+0.5,h=thick+2); } // Make the ends of the profile round translate([w2-4,10,-thick-2]) difference(){ cube([thick,thick,thick+4]); translate([-1,thick+1,thick+1]) rotate([0,90,0]) cylinder(r=thick+0.5,h=thick+2); } translate([w2-4,length2-20,-thick-2]) difference(){ cube([thick,thick,thick+4]); translate([-1,-1,thick+1]) rotate([0,90,0]) cylinder(r=thick+0.5,h=thick+2); } } } // Put round corner ray=7.5; off=ray-5.5; translate([off,ray,0]) cylinder(r=ray,h=topthick,$fn=20); translate([width2-off,ray,0]) cylinder(r=ray,h=topthick,$fn=20); translate([width2-off,length2-ray-1,0]) cylinder(r=ray,h=topthick,$fn=20); translate([off,length2-ray-1,0]) cylinder(r=ray,h=topthick,$fn=20); } union(){ holew=57; // Hole to see the date depth = transparent ? -2-vs_first_layer_height - vs_layer_height : -1; translate([(width2-holew)/2,100-5+3,depth]) cube([holew,20,3]); // Hole to see the last message translate([(width2-holew)/2,100-5-8-11+5,depth]) cube([holew,11,3]); } } } module test_bottom(is_S7){ intersection(){ translate([-5,-10,0]) cube([100,length2+20,20]); difference(){ translate([0,0,vs_first_layer_height-1]) bottom(is_S7,false,true); translate([5,0,-1]) cube([60,100,3]); } } } module test_top(is_S7){ intersection(){ translate([-80,-10,0]) cube([100,length2+20,20]); difference(){ translate([0,0,vs_first_layer_height-1]) translate([0,0,1]) rotate([0,180,0])top(is_S7,false); translate([-60,5,-2]) cube([width-10,68,10]); } } } module main_view(view){ if (view=="bottom-S6"){ rotate([0,0,90]) bottom(false,true, true); }else if (view=="bottom-S6-notop"){ rotate([0,0,90]) bottom(false,false, true); }else if (view=="top-S6"){ translate([0,0,topthick]) rotate([0,180,90]) top(false,false); }else if (view=="top-S6-transparent"){ translate([0,0,topthick]) rotate([0,180,90]) top(false,true); }else if (view=="bottom-S7"){ rotate([0,0,90]) bottom(true,true, true); }else if (view=="bottom-hugo"){ rotate([0,0,90]) bottom_hugo(); }else if (view=="bottom-S7-notop"){ rotate([0,0,90]) bottom(true,false, true); }else if (view=="top-S7"){ translate([0,0,topthick]) rotate([0,180,90]) top(true,false); }else if (view=="top-S7-transparent"){ translate([0,0,topthick]) rotate([0,180,90]) top(true,true); }else if (view=="profile_width"){ rotate([0,0,90]) intersection(){ translate([-10,-10,-10]) cube([width+20,20,thick+20]); bottom(true,false,true); } }else if (view=="profile_length"){ intersection(){ translate([width/2-20,-10,-10]) cube([20,length2+20,thick+20]); bottom(true,false,true); } }else if (view=="testtop-S6"){ test_top(false); }else if (view=="testtop-S7"){ test_top(true); }else if (view=="assembly-S6"){ bottom(false,true,true); translate([5.5,-6,thick+2]) top(false,false); }else if (view=="assembly-S7"){ bottom(true,true,true); translate([5.5,-6,thick+2]) top(true,false); }else if (view=="assembly-up"){ bottom(false,true,true); translate([5.5,-6,thick+2+5]) top(false,false); }else if (view=="testcorner"){ testcorner(); }else if (view=="testbottom-S6"){ test_bottom(false); }else if (view=="testbottom-S7"){ test_bottom(true); }else if (view=="tube"){ tube(20,false); translate([10,0,0]) tube(20,true); }else if (view=="hinge"){ intersection(){ translate([-10,10,0]) cube([20,30,15]); bottom(true,true,true); } } }