!********************************************** BASIC GEOMETRY MODULE waterpl( REF hull_id >"Select hull surface !"; FLOAT z:=500 >"Vertical position !"; FLOAT heel:=0 >"Heel !"); /* !* Creates a "waterplane" object, ie. a b_plane #1. !* !* This program is free software; you can redistribute it and/or !* modify it under the terms of the GNU General Public License !* as published by the Free Software Foundation; either version 2 !* of the License, or (at your option) any later version. !* !* This program is distributed in the hope that it will be useful, !* but WITHOUT ANY WARRANTY; without even the implied warranty of !* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !* GNU General Public License for more details. !* !* You should have received a copy of the GNU General Public License !* along with this program; if not, write to the Free Software !* Foundation, Inc., 59 Temple Place - Suite 330, Boston, !* MA 02111-1307, USA. !* !* (C)Microform AB 1998-09-23, J.Kjellander !* & Stephan Helma !* !********************************************** */ INT status,nu,nv; FLOAT maxx,minx; VECTOR p1,p2,p3,p4; STRING s*132; FLOAT bmax,k(3); BEGINMODULE hull_id:=global_ref(hull_id,9); !* !***How many patches. !* getsurh(hull_id,"NPATU",nu); getsurh(hull_id,"NPATV",nv); !* !***Calculate and hull dimensions. !* part(#6,caldims(hull_id)); status:=getdat_gm("MAXBEAM",k); bmax:=k(3); !* !***Where does hull begin and end. Sort by increasing X. !* p1:=on(hull_id,vec(0,0)); p2:=on(hull_id,vec(nu,0)); p3:=on(hull_id,vec(0,nv)); p4:=on(hull_id,vec(nu,nv)); if p1.x > p2.x then maxx:=p1.x; minx:=p2.x; else minx:=p1.x; maxx:=p2.x; endif; if maxx < p3.x then maxx:=p3.x; endif; if minx > p3.x then minx:=p3.x; endif; if maxx < p4.x then maxx:=p4.x; endif; if minx > p4.x then minx:=p4.x; endif; ! if p3.x > p2.x then ! p2:=p3; ! endif; ! ! if p1.x > p2.x then ! p3:=p2; ! p2:=p1; ! p1:=p3; ! endif; !* !***Create b_plane. !* csys_1p(#3,"WL",vec(0,0,z),0,0,0:BLANK=1); mode_local(#3); if heel <> 0 then csys_1p(#4,"Heel",vec(0,0,0),heel:BLANK=1); mode_local(#4); endif; b_plane(#1,vec(minx,-0.6*bmax),vec(maxx,-0.6*bmax), vec(maxx, 0.6*bmax),vec(minx, 0.6*bmax):PEN=7); !* !***Text slightly above to be visible. !* csys_1p(#5,"WL-text",vec(0,0,25):BLANK=1); mode_local(#5); s:="WL="+str(z,-1,1); if heel > 0 then s:=s+" Heel="+str(heel,-1,0); endif; text(#2,on(#1,vec(0,0))+vec(bmax/5,bmax/5),0,s :TPMODE=1,TSIZE=bmax/15,TWIDTH=50,PEN=3); !* !***Calculate LWL. !***Create actual waterplane curve by intersecting !***hullsurface with waterplane surface b_plane. !* cur_int(#7,hull_id,#1:BLANK=1); p1:=startp(#7); p2:=endp(#7); del(#7); if p2.x < p1.x then p3:=p1; p1:=p2; p2:=p3; endif; k(1):=(p2.x-p1.x); k(2):=z; status:=deldat_gm("LWL"); status:=putdat_gm("LWL",2,k); ENDMODULE !*****************************************************