!************************************************ BASIC GEOMETRY MODULE wlines( FLOAT dy:=500 >"Vertical spacing !"; FLOAT heel:=0 >"Heel !"); !* Generates waterlines with equal vertical !* spacing. !* !* (C)Microform AB, J.Kjellander !* !*********************************************** INT i,j,k,l,n,nu; FLOAT y,ymin,ymax; VECTOR p1; REF hull_id,l_id,r_id; STRING s*132; BEGINMODULE !* !***Check spacing. !* if dy < 1 then exit("Spacing is too small !"); endif; !* !***Global ID of hull. !* set_root_gm(); hull_id:=get_next_gm(1,16384,"hull"); !* !***ID of left and right hull surface. !* s:=rstr(hull_id); l_id:=rval(s+"#30#30"); r_id:=rval(s+"#30#33"); !* !***How many patches in U-direction ? !* getsurh(l_id,"NPATU",nu); !* !***Find highest point on hull. !* ymax:=-1E10; for i:=0 to 50*nu do p1:=on(l_id,vec(i/50.0,0)); if p1.y > ymax then ymax:=p1.y; endif; endfor; !* !***Find lowest point on hull. !* ymin:=1E10; for i:=0 to 50*nu do p1:=on(l_id,vec(i/50.0,0)); if p1.y < ymin then ymin:=p1.y; endif; endfor; !* !***Create waterlines. !* i:=1; y:=ymin+dy/2; loop: csys_1p(#1,"Cutplane",vec(0,y,0),90-heel,0,0:BLANK=1); n:=n_cur_int(l_id,refc(1,i)); for j:=1 to n do cur_int(#2,l_id,refc(1,i),j:BLANK=0,PEN=2); if heel <> 0 then l:=n_cur_int(r_id,refc(1,i)); for k:=1 to l do cur_int(#3,r_id,refc(1,i),k:BLANK=0,PEN=2); endfor; endif; endfor; y:=y+dy; i:=i+1; if y < ymax-dy then goto loop; endif; ENDMODULE !**************************************************