!********************************************** MACRO GEOMETRY MODULE caldims( REF hull_id >"Global ID of hull surface !"); !* Calculates and stores principal dimensions !* of hull surface. !* !* (C)Microform AB, J.Kjellander !* !********************************************** INT status,i,nu,nv; VECTOR p1,p2,p3; FLOAT bmax,xbmax,ybmax; FLOAT tmax,xtmax,ztmax; FLOAT k(3); BEGINMODULE psh_pmt("Calculating hull dimensions !"); !* !***How many patches. !* getsurh(hull_id,"NPATU",nu); getsurh(hull_id,"NPATV",nv); !* !***MAXBEAM. !***Where is max beam. Step along both !***edges of the hull surface in increasing !***U-direction and check Z-coordinates. !*** !***MAXDRAUGHT. !***Similar to MAXBEAM but check Y-coordinates. !***Stores draught respectively to coordinate system. !* !FIXME: MAXDRAUGHT and MAXBEAM finds only maximums if ! they are located on one of the two edges. ! What happens if there i a thumblehome? ! MAXBEAM should be called MAXBEAMDECK... mode_basic(); bmax:=0.0; !*We cannot start with t:=0.0 since coord can be everywhere... p1:=on(hull_id,vec(0,0)); tmax:=p1.y; xtmax:=p1.x; for i:=0 to 50*nu do p1:=on(hull_id,vec(i/50.0,nv)); p2:=on(hull_id,vec(i/50.0,0)); if abs(p1.z) > bmax then bmax:=abs(p1.z); xbmax:=p1.x; ybmax:=p1.y; endif; if abs(p2.z) > bmax then bmax:=abs(p2.z); xbmax:=p2.x; ybmax:=p2.y; endif; if p1.y < tmax then tmax:=p1.y; xtmax:=p1.x; ztmax:=p1.z; endif; if p2.y < tmax then tmax:=p2.y; xtmax:=p2.x; ztmax:=p2.z; endif; endfor; k(3):=2*bmax; k(1):=xbmax; k(2):=ybmax; status:=deldat_gm("MAXBEAM"); status:=putdat_gm("MAXBEAM",3,k); k(2):=tmax; k(1):=xtmax; k(3):=ztmax; status:=deldat_gm("MAXDRAUGHT"); status:=putdat_gm("MAXDRAUGHT",3,k); !* !***LOA. !* p1:=on(hull_id,vec(0,0)); p2:=on(hull_id,vec(nu,0)); p3:=on(hull_id,vec(nu,nv)); if p3.x > p2.x then p2:=p3; endif; if p1.x > p2.x then p3:=p2; p2:=p1; p1:=p3; endif; k(1):=(p2.x-p1.x); status:=deldat_gm("LOA"); status:=putdat_gm("LOA",1,k); !* !***End. !* pop_pmt(); ENDMODULE !*****************************************************