from build123d import * def b(x,y,z,c):return Pos(*c)*Box(x,y,z) def cz(r,h,c):return Pos(*c)*Cylinder(r,h) def cy(r,h,c):return Pos(*c)*Rot(90,0,0)*Cylinder(r,h) def tf(r,a,d):return loft([Plane(origin=(0,1-((z-76)/76)**2,z))*Circle(r) for z in [a+(d-a)*i/4 for i in range(5)]],ruled=False) def fk(s):return Pos(0,.8,0)*Rot(0,0,30)*s def fe(s):return Pos(0,.8,0)*Rot(0,0,-26)*s window=fk(b(12,40,72,(0,22,66)));sculpt=tf(21.2,0,152) for z in (93,75,57,39):sculpt=sculpt-(fk(Pos(0,34,z)*Sphere(13))&window) sculpt=sculpt-fe((Pos(0,75,72)*Rot(0,90,0)*Cylinder(54,19))&b(19,40,50,(0,35,72))) ridge=cz(2.5,64,(0,20.9,67))+Pos(0,20.9,35)*Sphere(2.5)+Pos(0,20.9,99)*Sphere(2.5) shell=(sculpt+ridge)-tf(18.2,2.4,149.6)-window for z in (85,59):shell=shell-fe(cy(4.1,40,(0,20,z))) shell=shell-b(10,5.2,8,(0,1.35,1))-cz(1.5,10,(0,-10,150))-b(3,15,2,(-5,21,108))-b(8,16,5,(0,21,17)) main=b(30,1.6,115,(0,-1.2,61.5))-b(20,3,8,(0,-1.2,116));finger=fk(b(8,1.6,68,(0,13.8,66)));epcb=fe(b(18,1.6,48,(0,5.8,72))) reserve=b(22,7,66,(0,-7.5,51));module=b(18.6,3.3,26.5,(0,1.25,112.75));ant=b(18.6,1,7,(0,.1,122.5)) wire=b(2,1,50,(0,-16.5,121));lower=b(2,14,1,(0,-9,96));upper=b(2,3,1,(0,-14.5,145));connector=b(10,8,10,(-6,4,34));power=b(20,6,18,(0,2.6,18));service=b(14,6,10,(0,-7.5,12)) mic=b(10,8,1,(0,-10,146.5))-cz(.5,3,(0,-10,146.5));gasket=cz(2.2,2.6,(0,-10,148.3))-cz(1,3,(0,-10,148.3)) plug=b(8.94,3.26,30.5,(0,1.35,-14.75));over=b(14,8,30,(0,1.35,-15.01));acoustic=cz(.5,6,(0,-10,149)) checks={} def test(n,a,q):checks[n]=(round((a&q).volume,5),round(a.distance_to(q),3)) for n,a in [('wire',wire),('lower',lower),('upper',upper),('plug',plug),('over',over),('acoustic',acoustic),('service',service),('connector',connector)]:test(n+'_shell',a,shell) for n,a in [('wire',wire),('lower',lower),('upper',upper),('service',service),('connector',connector)]: for m,q in [('main',main),('bat',reserve),('finger',finger),('epcb',epcb),('module',module),('power',power)]:test(n+'_'+m,a,q) for n,a in [('mic',mic),('gasket',gasket)]:test('acoustic_'+n,acoustic,a) for n,q in [('shell',shell),('enc',fe(b(15.1,6.4,17.7,(0,9.8,85)))),('epcb',epcb),('wire',wire)]:test('RF_'+n,ant,q) fails={n:v for n,v in checks.items() if v[0]>.0001} report={'checks':len(checks),'failures_volume_distance':fails,'shell_clearances':{n:v[1] for n,v in checks.items() if n.endswith('_shell')},'RF':{n:v[1] for n,v in checks.items() if n.startswith('RF_')},'acoustic_volumes':[checks['acoustic_mic'][0],checks['acoustic_gasket'][0]],'service_min':min(v[1] for n,v in checks.items() if n.startswith('service_'))} reject('AUDIT REPORT ONLY '+str(report)) result=shell