!********************************************************** !* BASIC GEOMETRY MODULE hull( REF sl >"Sheerline !"; REF bl >"Bottomline !"; FLOAT pv1:=0.5 >"Fore P-value !"; FLOAT pv2:=0.5 >"Mid P-value !"; FLOAT pv3:=0.5 >"Aft P-value !"; INT ns:=10 >"Number of sections !"); !* Creates a hull, and saves ID of hull surfaces in DB. !* !* 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 !* !* 2000-02-25 New csys, J.Kjellander !* !********************************************************** INT font,nsgeo,nsgra,npatu,npatv,status; FLOAT lgt,diff,k(2); REF slt,blt,spine,pvalf,sl_id,slt_id,bl_id,blt_id; VECTOR sl_start,sl_end,bl_end; STRING s(1)*20; BEGINMODULE !* !***Initialization. !* bl:=global_ref(bl,9); sl:=global_ref(sl,9); !* !***ID of sheerline tangent. !* set_root_gm(); slt:=get_next_gm(1,16384,"shslope"); if slt = #0.1 then exit("No topside angles defined !"); endif; slt:=rval(rstr(slt)+"#1"); !* !***ID of bottomline tangent. !* set_root_gm(); blt:=get_next_gm(1,16384,"blslope"); if blt = #0.1 then exit("No deadrise angles defined !"); endif; blt:=rval(rstr(blt)+"#1"); !* !***A spine curve for the sur_conic(). !* part(#1,spine(sl,bl,spine)); !* !***A P-value function for the sur_conic(). !* part(#2,pvalf(spine,pv1,pv2,pv3,pvalf)); !* !***End of sheerline and bottomline. !* sl_end:=endp(sl); bl_end:=endp(bl); diff:=abs(sl_end.x-bl_end.x); !* !***Positive or negative stern angle, wich curve needs to be extended ? !* sl_id:=sl; slt_id:=slt; bl_id:=bl; blt_id:=blt; if sl_end.x > bl_end.x then getcurh(sl,font,lgt,nsgeo,nsgra); lin_free(#3,endp(sl),endp(sl) + 2*diff*tang(sl,nsgeo):BLANK=1); cur_comp(#4,sl,#3:BLANK=1,PEN=3); sl_id:=#4; lin_free(#5,endp(slt),endp(slt) + 2*diff*tang(slt,nsgeo):BLANK=1); cur_comp(#6,slt,#5:BLANK=1,PEN=4); slt_id:=#6; elif sl_end.x < bl_end.x then getcurh(bl,font,lgt,nsgeo,nsgra); lin_free(#7,endp(bl),endp(bl) + 2*diff*tang(bl,nsgeo):BLANK=1); cur_comp(#8,bl,#7:BLANK=1,PEN=3); bl_id:=#8; lin_free(#9,endp(blt),endp(blt) + 2*diff*tang(blt,nsgeo):BLANK=1); cur_comp(#10,blt,#9:BLANK=1,PEN=3); blt_id:=#10; endif; !* !***The hull surface. !* sur_conic(#20,spine, bl_id,blt_id,"P",pvalf, sl_id,slt_id :BLANK=1,PEN=2,SDASHL=300); sur_approx(#21,#20,"CUB_SUR",1,3,20:BLANK=1,PEN=3,SDASHL=300); del(#20); !* !***Bicubic approximation of real hull. !* part(#30,bicubic(bl,sl,global_ref(#21),ns):LEVEL=1); del(#21); !* !***Store hull surface global ID's in DB. !* s(1):=rstr(global_ref(#30#30)); status:=putdat_gm("HULL_ID_RIGHT",1,s); s(1):=rstr(global_ref(#30#33)); status:=putdat_gm("HULL_ID_LEFT",1,s); !* !***Stern. !* getsurh(#30#30,"NPATU",npatu); getsurh(#30#30,"NPATV",npatv); cur_iso(#35,#30#30,"U",npatu,0,npatv:LEVEL=0,PEN=2,BLANK=1); cur_iso(#36,#30#33,"U",0,0,npatv:LEVEL=0,PEN=2,BLANK=1); cur_comp(#37,#35,#36:BLANK=1,PEN=2); cur_iso(#38,#30#30,"V",npatv,0,npatu:BLANK=1,PEN=3); csys_3p(#39,"STERN",startp(#37)+vec(0,0,-5), endp(#37)+vec(0,0,-5), on(#38,0.5)+vec(0,0,-5):BLANK=1,PEN=4); mode_local(#39); arc_2pos(#40,startp(#37)+vec(0,0,25), endp(#37)+vec(0,0,-25), vecl(startp(#37)-endp(#37)):LEVEL=0,PEN=2,BLANK=1); cur_approx(#41,#37,"CUBIC",1,1:BLANK=1); sur_ruled(#42,#41,#40,1:BLANK=1); sur_approx(#50,#42,"CUB_SUR",1,1,1:BLANK=0,PEN=4,SDASHL=300,LEVEL=1); del(#42); ENDMODULE !**********************************************************