// Copyright (C) 2014 Setsuo Takato, KETCindy Japan project team // //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 3 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, see // println("ketcindylib3d(20180327) loaded"); //help:start(); Ketinit3d():=Ketinit3d(1); Ketinit3d(sf):=( regional(tmp); tmp=round(4*SW.y)/4; // Ketinit3d(sf,[round(SW.x)+1,tmp-0.5,tmp-1]); Ketinit3d(sf,[-5,tmp-0.5,tmp-1]); ); Ketinit3d(subflg,position):=( //help:Ketinit3d(subflg=1) regional(ctr,tmp,tmp1,tmp2,tmp3,tmp4,xPos,yTh,yPh); // println("KETCindy3d V.2.3.5(2016.02.03)"); BezierNumber3=1; //15.02.28 if(!islist(BZLIST3), BZLIST3=[]; //15.02.28 , tmp=apply(allpoints(),text(#)); tmp1=select(tmp,substring(#,length(#)-1,length(#))=="p"); tmp2=[]; forall(tmp1,ctr, tmp=substring(ctr,0,length(ctr)-1); tmp=select(BZLIST3,#_1==tmp); if(length(tmp)>0, tmp2=append(tmp2,tmp_1); ); ); BZLIST3=tmp2; ); SUBSCR=subflg; Setwindow("Msg=no"); if(length(position)>2, xPos=position_1; yTh=position_2; yPh=position_3; , xPos=0; yTh=position_1; yPh=position_2; ); // THETA=60*pi/180; // PHI=30*pi/180; FocusPoint=[0,0,0]; EyePoint=[5,5,5]; Listplot("th",[[xPos,yTh],[xPos+9,yTh]],["notex","linecolor->[0,1,0]","Msg=no"]); Listplot("ph",[[xPos,yPh],[xPos+9,yPh]],["notex","linecolor->[0,1,0]","Msg=no"]); //16.02.10 PutonCurve("TH",sgth,[xPos,xPos+9,"Msg=no"]); PutonCurve("FI",sgph,[xPos,xPos+9,"Msg=no"]); THETA=(TH.x-xPos)*20*pi/180; PHI=(FI.x-xPos)*40*pi/180; // Defvar("THETA",THETA); // 16.06.20 // Defvar("PHI",PHI); // 16.06.20 drawtext([xPos-0.8,yTh-0.1],Sprintf((TH.x-xPos)*20,2),align->"right"); //17.05.02 drawtext([xPos-0.8,yPh-0.1],Sprintf((FI.x-xPos)*40,2),align->"right"); //17.05.02 tmp="Setangle("+text((TH.x-xPos)*20)+","+text((FI.x-xPos)*40)+")"; GLIST=append(GLIST,tmp); Addax(0); TSIZE=10; TSIZEZ=10; ErrFlg=0; ); Start3d():=Start3d([]); Start3d(ptexception):=( //help:Start3d(); //help:Start3d(execptionptlist); regional(xmn,xMx,ymn,yMx,pt,pt3,pt2, xPos,yTh,yPh,Eps,tmp,tmp1,tmp2,tmp3,tmp4); ConstantListC=[[50,50],[5000,1500,500,200],[0.00001,0.01,0.1]]; FuncListC=[]; CommandListC=[]; GCLIST=[]; GLIST=[]; FUNLIST=[]; COM0thlist=[]; COM1stlist=[]; COM2ndlist=[]; SEG3dlist=[]; OutFileList=[]; FigPdfList=[]; // 16.04.08 ErrFlag=0; OBJCMD=[]; // 16.11.29from OCNAME=Fhead; OCOPTION=["m","v"];// 16.11.29until ArrowlineNumber=1; // 16.01.31 ArrowheadNumber=1; BezierNumber=1; //16.01.31 BezierNumber3=1; //16.08.19 Fnametex=Fhead+".tex"; // 15.04.06 FnameR=Fhead+".r"; FnameRbody=Fhead+"body.r"; Fnameout=Fhead+".txt"; // Ketinit3d(SUBSCR); // 16.06.20 Setwindow("Msg=no"); // 16.06.20from tmp=round(4*SW.y)/4; xPos=-5;yTh=tmp-0.5;yPh=tmp-1; Listplot("th",[[xPos,yTh],[xPos+9,yTh]], ["notex","linecolor->[0,1,0]","Msg=no"]); Listplot("ph",[[xPos,yPh],[xPos+9,yPh]], ["notex","linecolor->[0,1,0]","Msg=no"]); //16.02.10 PutonCurve("TH",sgth,[xPos,xPos+9,"Msg=no"]); PutonCurve("FI",sgph,[xPos,xPos+9,"Msg=no"]); drawtext([xPos-0.8,yTh-0.1],Sprintf((TH.x-xPos)*20,2),align->"right"); //17.05.02 drawtext([xPos-0.8,yPh-0.1],Sprintf((FI.x-xPos)*40,2),align->"right"); //17.05.02 tmp="Setangle(" +format((TH.x-xPos)*20,5)+"," +format((FI.x-xPos)*40,5)+")"; GLIST=append(GLIST,tmp); THETA=(TH.x-xPos)*20*pi/180; PHI=(FI.x-xPos)*40*pi/180; // 16.06.20until if(isselected(TH) % isselected(FI), // 17.05.18from if(length(Ch)>0, ChNum=Ch_(length(Ch)); if(ChNum==0, ChNum=1); , ChNum=1; ); Ch=[0]; );// 17.05.18until if(length(VLIST)==0, // 16.06.20 tmp=remove(allpoints(),[NE,SW,TH,FI,O,X,Y,Z]);//17.06.02 tmp4=remove(tmp,ptexception); forall(tmp4,pt, tmp1=text(pt); tmp=substring(tmp1,length(tmp1)-1,length(tmp1)); if(tmp!="z", tmp=parse(tmp1+"z.y"); pt3=Xyzcoord(pt.x,pt.y,tmp); Defvar(tmp1+"3d",pt3); pt2=Parapt(pt3); // 16.05.28from Defvar(tmp1+"2d",pt2); // 16.05.28until ); ); , if(isselected(NE) % isselected(SW), tmp=remove(allpoints(),[NE,SW,TH,FI]); tmp4=remove(tmp,ptexception); forall(tmp4,pt, tmp1=text(pt); tmp=substring(tmp1,length(tmp1)-1,length(tmp1)); if(tmp!="z", tmp=select(VLIST,#_1==tmp1+"3d"); //17.10.07 pt3=tmp_1_2; tmp=tmp1+".xy=Parapt("+pt3+")_[1,2];"; parse(tmp); // if(SUBSCR==1, // tmp=tmp1+"z"+".x=NE.x-SW.x+"+tmp1+".x"; // parse(tmp); // ); ); ); , tmp=remove(allpoints(),[NE,SW,TH,FI]); tmp4=remove(tmp,ptexception); forall(tmp4,pt, tmp1=text(pt); tmp=substring(tmp1,length(tmp1)-1,length(tmp1)); if(tmp!="z", tmp2=parse(tmp1+"z"); if(isselected(pt) % isselected(tmp2), Defvar(tmp1+"2d",pt.xy); tmp=parse(tmp1+"z.y"); tmp=Xyzcoord(pt.x,pt.y,tmp); Defvar(tmp1+"3d",tmp); ); ); ); ); ); if(SUBSCR==1, xmn=SW.x+NE.x-SW.x; xMx=NE.x+NE.x-SW.x; ymn=SW.y; yMx=NE.y; drawpoly([[xMx,yMx],[xmn,yMx], [xmn,ymn],[xMx,ymn]],color->[1,1,1]); connect([[NE.x-SW.x,yMx],[NE.x-SW.x,ymn]], color->[0.5,0.5,0.5]); ); // for Presentation //17.07.01from letterc=[0.98,0.13,0,0.43]; boxc=[0,0.32,0.52,0]; shadowc=[0,0,0,0.5]; mboxc="yellow"; //17.03.02 regional debugged SlideColorList=[letterc,boxc,boxc,boxc,shadowc,shadowc,6,1.3, letterc,mboxc,mboxc,mboxc,62,2,letterc]; ThinDense=0.1; //17.07.01until Ptseg3data(ptexception); //16.08.23 ); Setangle(theta,phi):=( //16.12.24 //help:Setangle(60,30); regional(xmn,xMx,ymn,yMx,pt,pt3,pt2, xPos,yTh,yPh,Eps,tmp,tmp1,tmp2,tmp3,tmp4); tmp=round(4*SW.y)/4; xPos=-5;yTh=tmp-0.5;yPh=tmp-1; if(theta=="",theta=THETA*180/pi); // 17.01.19 if(phi=="",phi=PHI*180/pi); THETA=theta*pi/180; TH.x=theta/20+xPos; PHI=phi*pi/180; FI.x=phi/40+xPos; // drawtext([xPos-0.8,yTh-0.1],text(theta)); //17.05.05 // drawtext([xPos-0.8,yPh-0.1],text(phi)); tmp="Setangle(" +format(theta,5)+","+format(phi,5)+")"; GLIST=append(GLIST,tmp); if(length(VLIST)==0, // 16.06.20 tmp=remove(allpoints(),[NE,SW,TH,FI]); tmp4=remove(tmp,ptexception); forall(tmp4,pt, tmp1=text(pt); tmp=substring(tmp1,length(tmp1)-1,length(tmp1)); if(tmp!="z", tmp=parse(tmp1+"z.y"); pt3=Xyzcoord(pt.x,pt.y,tmp); Defvar(tmp1+"3d",pt3); pt2=Parapt(pt3); // 16.05.28from Defvar(tmp1+"2d",pt2); // 16.05.28until ); ); , if(isselected(NE) % isselected(SW), tmp=remove(allpoints(),[NE,SW,TH,FI]); tmp4=remove(tmp,ptexception); forall(tmp4,pt, tmp1=text(pt); tmp=substring(tmp1,length(tmp1)-1,length(tmp1)); if(tmp!="z", tmp=select(VLIST,#_1==tmp1+"3d"); pt3=tmp_1_2; tmp=tmp1+".xy=Parapt("+pt3+")_[1,2];"; parse(tmp); ); ); , tmp=remove(allpoints(),[NE,SW,TH,FI]); tmp4=remove(tmp,ptexception); forall(tmp4,pt, tmp1=text(pt); tmp=substring(tmp1,length(tmp1)-1,length(tmp1)); if(tmp!="z", tmp2=parse(tmp1+"z"); if(isselected(pt) % isselected(tmp2), Defvar(tmp1+"2d",pt.xy); tmp=parse(tmp1+"z.y"); tmp=Xyzcoord(pt.x,pt.y,tmp); Defvar(tmp1+"3d",tmp); ); ); ); ); ); forall(Datalist3d(),#, tmp1=replace(#,"3d","2d"); tmp2=Projpara(#,["nodata"]); tmp=tmp1+"="+textformat(tmp2,5); parse(tmp); ); Ptseg3data(ptexception); ); Changestyle3d(nameL,style):=( //help:Changestyle3d(["geoseg3d","ax3d"],["notex"]); regional(nmL,name,tmp,tmp1,tmp2); if(islist(nameL),nmL=nameL,nmL=[nameL]); tmp1=[]; forall(nmL,name, tmp=parse(name); if(isstring(tmp_1), tmp1=concat(tmp1,tmp); , tmp1=append(tmp1,name); ); tmp=apply(tmp1,replace(#,"3d","2d")); Changestyle(tmp,style); tmp=apply(tmp,"sub"+#); // 15.05.24 Changestyle(tmp,style); ); ); Dist3d(pt1):=Dist3d(pt1,[0,0,0]); Dist3d(pt1,pt2):=( //help:Dist3d(A3d,B3d); //help:Dist3d(A,B); //help:Dist3d("A","B"); regional(p1,p2); if(islist(pt1), p1=pt1; , if(ispoint(pt1),p1=text(pt1),p1=pt1); p1=parse(p1+"3d"); ); if(islist(pt2), p2=pt2; , if(ispoint(pt2),p2=text(pt2),p2=pt2); p2=parse(p2+"3d"); ); sqrt((p2-p1)*(p2-p1)); ); Findangle(vec):=( //help:Findangle([2,1,4]); //help:Findangle([0,0,1,0]); regional(vec3,vec2,Eps,th,ph,tmp); Eps=10^(-4); vec3=vec_(1..3); vec2=vec_(1..2); th=arccos(vec_3/|vec3|); if(|vec2|>Eps, ph=arccos(vec_1/|vec2|); if(vec_2<0, ph=2*pi-ph; // 15.03.28 ); , if(length(vec)>3,ph=vec_4*pi/180,ph=PHI); ); [th,ph]; ); Cancoordpara(pc):=( //help:Cancoordpara([1,2,0]); regional(Xz,Yz,Zz,tmp1,tmp2,tmp3); Xz=pc_1; Yz=pc_2; Zz=pc_3; tmp1=-Xz*sin(PHI)-Yz*cos(PHI)*cos(THETA)+Zz*cos(PHI)*sin(THETA); tmp2=Xz*cos(PHI)-Yz*sin(PHI)*cos(THETA)+Zz*sin(PHI)*sin(THETA); tmp3=Yz*sin(THETA)+Zz*cos(THETA); [tmp1,tmp2,tmp3]; ); Zparapt(cc):=( regional(x,y,z); x=cc_1; y=cc_2; z=cc_3; x*cos(PHI)*sin(THETA)+y*sin(PHI)*sin(THETA)+z*cos(THETA); ); Projcoordpara(cc):=( //help:Projcoordpara([3,1,2]); regional(tmp); tmp=Parapt(cc); [tmp_1,tmp_2,Zparapt(cc)]; ); Parapt(pt):=( //help:Parapt([2,1,5]); regional(Xz,Yz); Xz=-pt_1*sin(PHI)+pt_2*cos(PHI); Yz=-pt_1*cos(PHI)*cos(THETA)-pt_2*sin(PHI)*cos(THETA)+pt_3*sin(THETA); [Xz,Yz]; ); ProjCurve(crv):=( //help:Projcurve("sl3d1"); regional(CurveL,Curve,Eps,AnsL,Out,sp,cp,st,,ct,ii,pt, Xz,Yz,tmp,tmp1,tmp2); Eps=10^(-6); sp=sin(PHI); cp=cos(PHI); st=sin(THETA); ct=cos(THETA); if(isstring(crv),CurveL=parse(crv),CurveL=crv); if(MeasureDepth(CurveL)==1,CurveL=[CurveL]); Out=[]; forall(CurveL,Curve, AnsL=[]; forall(1..length(Curve),ii, pt=Curve_ii; if(pt_1!="inf", Xz=-pt_1*sp+pt_2*cp; Yz=-pt_1*cp*ct-pt_2*sp*ct+pt_3*st; tmp=[Xz,Yz]; if(ii==1, AnsL=[tmp]; , tmp1=AnsL_(length(AnsL)); if(tmp1_1=="inf" % |tmp-tmp1|>Eps, AnsL=append(AnsL,tmp); ); ); , AnsL=append(AnsL,["inf"]); ); ); tmp1=[]; tmp2=select(1..length(AnsL),AnsL_#==["inf"]); tmp=1; forall(tmp2, if(#>tmp, tmp1=concat(tmp1,[AnsL_(tmp..(#-1))]) ); tmp=#+1; ); if(tmp0, //17.05.24 name2=replace(name3,"3d","2d"); , name2="para"+name3; ); ptL=Projcurve(name3); ptL=select(ptL,length(#)>1);//17.06.02 if(length(ptL)==1, ptL=ptL_1; ); Out=append(Out,ptL); if(Noflg<3, println("generate projparadata "+name2); tmp=name2+"="+textformat(ptL,5); parse(tmp); tmp=name2+"=Projpara("+name3+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name2); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name2,Ltype,opcindy]); ); ); if(length(Out)==1,Out=Out_1); // Out=Flattenlist(Out); if(length(Out)==1,Out=Out_1); // 15.02.24 tmp=[]; forall(Out, if(length(#)>0,tmp=append(tmp,#)); ); Out=tmp; Out; ); InvparaptPp(pt,pd):=( regional(Eps,fk,nfk,ph,fh,ah,bh,ak,bk,v1,v2, nn,s0,t2,out,tmp,tmp1,tmp2,flg); Eps=10^(-4); if(isstring(pd), fk=pd; , fk=textformat(pd,5); ); nfk=Numptcrv(parse(fk)); flg=0; tmp=pt; if(length(tmp)==1, ph=tmp; fh=pd; , fh=Projpara(fk,["nodata"]); if(nfk>2, tmp1=Nearestpt(tmp,fh); ph=tmp1_2; , ah=Ptcrv(1,fh); bh=Ptcrv(2,fh); v1=tmp-ah; v2=bh-ah; tmp1=Crossprod(v1,v2); if(abs(tmp1)>Eps, println(" Not on the line"); out=[]; flg=1; , ph=Dotprod(v1,v2)/|v2|^2+1; ); ); ); if(flg==0, if(nfk>2, nn=floor(ph); s0=ph-nn; if(ph>Numptcrv(fh)-Eps, out=[Ptend(fk),Numptcrv(fh)]; flg=1; ); , nn=1; s0=ph-1; ); ); if(flg==0, ak=Ptcrv(nn,fk); bk=Ptcrv(nn+1,fk); ah=Ptcrv(nn,fh); bh=Ptcrv(nn+1,fh); ph=(1-s0)*ah+a0*bh; t2=s0; pk=(1-t2)*ak+t2*bk; out=[pk,nn+t2]; ); out; ); Invparapt(pt,pd):=( regional(tmp); tmp=InvparaptPp(pt,pd); tmp_1; ); Subgraph(name,opcindy):=( regional(tht,tmp,tmp1); tht=THETA; THETA=pi/2; tmp=Projpara(name3,["nodata"]); if(length(tmp)>0, //15.08.17 tmp=Translatedata("",[tmp],[NE.x-SW.x,0],["nodata"]); tmp1=replace("sub"+name,"3d","2d"); tmp=tmp1+"="+Textformat(tmp,5); parse(tmp); GCLIST=append(GCLIST,[tmp1,0,opcindy]); ); THETA=tht; // 15.11.03 ); Spaceline(ptlist):=Spaceline(ptlist,[]); // 16.02.22 from Spaceline(Arg1,Arg2):=( regional(name,tmp,tmp1,tmp2); if(isstring(Arg1), Spaceline(Arg1,Arg2,[]); , tmp=text(Arg1); tmp=substring(tmp,1,length(tmp)-1); name="-"+replace(tmp,",",""); Spaceline(name,Arg1,Arg2); ); ); // 16.02.22 until Spaceline(nm,ptlistorg,optionorg):=( //help:Spaceline("1",[[2,5,1],[4,2,3]]); //help:Spaceline([A,B]); regional(name2,name3,options,Out,tmp,tmp1,tmp2, opstr,opcindy,Ltype,Noflg,eqL,ptlist, Msg); ptlist=apply(ptlistorg,if(ispoint(#),parse(text(#)+"3d"),#)); // 16.02.10 if(substring(nm,0,2)=="bz", name2=replace(nm,"bz","bz2d"); name3=replace(nm,"bz","bz3d"); , if(substring(nm,0,1)=="-", tmp=substring(nm,1,length(nm)); if(indexof(tmp,"3d")>0,name3=tmp,name3=tmp+"3d"); name2=replace(name3,"3d","2d"); , name2="sl2d"+nm; name3="sl3d"+nm; ); ); options=select(optionorg,length(#)>0); // 160415 tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; eqL=tmp_5; opcindy=tmp_(length(tmp)); Msg=1; forall(eqL, tmp=substring(#,0,1); if(Toupper(tmp)=="M", tmp=indexof(#,"="); tmp1=substring(#,tmp,tmp+1); if(Toupper(tmp1)=="N", Msg=0; ); ); ); if(Noflg<3, if(Msg==1, println("generate Spaceline "+name3); ); tmp=name3+"="+ptlist; parse(tmp); tmp1=Projpara(name3,["nodata"]); tmp=name2+"="+textformat(tmp1,5); parse(tmp); tmp="["; forall(ptlist, //17.07.13from if(isstring(#), tmp=tmp+#+","; , tmp=tmp+textformat(#,5)+","; ); ); tmp=substring(tmp,0,length(tmp)-1)+"]"; tmp=name3+"=Spaceline("+tmp+")"; //17.07.13until // tmp=name3+"=Spaceline("+textformat(ptlist,5)+")"; //17.05.24 GLIST=append(GLIST,tmp); tmp=name2+"=Projpara("+name3+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name2); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name2,Ltype,opcindy]); if(SUBSCR==1, // 15.02.11 Subgraph(name3,opcindy); ); ); ptlist; ); Spacecurve(nm,funstr,variable):=Spacecurve(nm,funstr,variable,[]); Spacecurve(nm,funstr,variable,optionorg):=( //help:Spacecurve("1","[cos(t),sin(t),0.5*t]","t=[0,4*pi]",["Num=200"]); regional(name2,name3,options,Out,tmp,tmp1,tmp2,vname,tmpfn,str,Rng,Num,Msg, Ec,Exfun,Dc,opstr,opcindy,Fntmp,Vatmp,Ltype,Noflg,eqL,t1,t2,dt,tt,pa,ke); if(substring(nm,0,2)=="bz", name2=replace(nm,"bz","bz2d"); name3=replace(nm,"bz","bz3d"); , name2="sc2d"+nm; name3="sc3d"+nm; ); Eps=10^(-4); Num=50; Ec=[]; Exfun=""; Dc=1000; options=select(optionorg,length(#)>0); // 160415 tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; eqL=tmp_5; opstr=tmp_(length(tmp)-1); opcindy=tmp_(length(tmp)); Msg=1; forall(eqL, tmp=substring(#,0,1); if(Toupper(tmp)=="M", tmp=indexof(#,"="); tmp1=substring(#,tmp,tmp+2); if(Toupper(tmp1)=="NO", Msg=0; ); ); tmp=indexof(#,"N="); if(tmp>0, tmp1=substring(#,tmp+1,length(#)); Num=parse(tmp1); opstr=opstr+",'"+#+"'"; ); tmp=indexof(#,"Num="); if(tmp>0, tmp1=substring(#,tmp+3,length(#)); Num=parse(tmp1); opstr=opstr+",'"+#+"'"; ); tmp=indexof(#,"E="); if(tmp>0, tmp1=substring(#,tmp+1,length(#)); if(substring(tmp1,0,1)=="[", Ec=parse(tmp1); , Exfun=tmp1; ); opstr=opstr+",'"+#+"'"; ); tmp=indexof(#,"Exc="); if(tmp>0, tmp1=substring(#,tmp+3,length(#)); if(substring(tmp1,0,1)=="[", Ec=parse(tmp1); , Exfun=tmp1; ); ); ); tmp=indexof(variable,"="); vname=substring(variable,0,tmp-1); str=substring(variable,tmp,length(variable)); Rng=parse(str); t1=Rng_1; t2=Rng_2; dt=(t2-t1)/Num; // differ from Scilab tmp="tmpfn("+vname+"):="+funstr+";"; parse(tmp); Out=[]; Ec=append(sort(Ec),10000); ke=1; forall(0..Num, pt=[]; tt=Rng_1+#*dt; if(tt-Ec_ke<-Eps, pa=tmpfn(tt); ); if(abs(tt-Ec_ke)<=Eps, if(length(Out)>0, if(Out_(length(Out))_1!="inf", pa=["inf"]; ); ); ); if(tt-Ec_ke>Eps, pa=tmpfn(tt); ke=ke+1; ); if(length(pa)>0, if(pa_1=="inf", Out=append(Out,pa); , if(length(Out)==0, Out=[pa]; , tmp=Out_(length(Out)); if(tmp_1=="inf", Out=append(Out,pa); , if(|tmp-pa|tmp, tmp1=concat(tmp1,[Out_(tmp..(#-1))]) ); tmp=#+1; ); if(tmp0, Subgraph(name3,opcindy); ); // 15.08.17 ); ); Out; ); Partcrv3d(nm,pA,pB,PkLstr):=Partcrv3d(nm,pA,pB,PkLstr,[]); Partcrv3d(nm,pA,pB,PkLstr,options):=( //help:Partcrv3d("1",A,B,"sl3d1"); //help:Partcrv3d("1",1.3,2.5,"sl3d1"); regional(p1,p2,q1,q2,dt1,dts,dt3,tmp,tmp1,tmp2); if(isreal(pA), p1=pA; q1=pA; , if(islist(pA), tmp=pA; , if(ispoint(pA),tmp=text(pA),tmp=pA); tmp=parse(tmp+"3d"); ); p1=parapt(tmp); q1=[p1_1,tmp_3]+[NE.x-SW.x,0]; ); if(isreal(pB), p2=pB; q2=pB; , if(islist(pB), tmp=pB; , if(ispoint(pB),tmp=text(pB),tmp=pB); tmp=parse(tmp+"3d"); ); p2=parapt(tmp); q2=[p2_1,tmp_3]+[NE.x-SW.x,0]; ); tmp=replace(PkLstr,"3d","2d"); dt1=partcrv("",p1,p2,tmp,["nodata"]); dts=partcrv("",q1,q2,"sub"+tmp,["nodata"]); dt=apply(1..length(dt1), Xyzcoord(dt1_#_1,dt1_#_2,dts_#_2)); Spaceline("-part3d"+nm,dt,options); ); Joincrvs3d(nm,plotstrL):=Joincrvs3d(nm,plotstrL,[]);//16.10.06 Joincrvs3d(nm,plotstrL,options):=( //help:Joincrvs3d("1",["bz3da1","bz3da1"]); regional(PtL,Eps,QdL,Flg,Ni,Qd,pP,pS,pQ,pR,rMN, opcindy,tmp,tmp1,tmp2,str,name2,name3,Ltype,Noflg); name2="join2d"+nm; name3="join3d"+nm; QdL=[]; forall(plotstrL,str, if(isstring(str), tmp=parse(str); , tmp=str; ); QdL=append(QdL,tmp); ); Eps=10^(-4); tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_(length(tmp)); tmp1=tmp_6; if(length(tmp1)>0,Eps=tmp1_1); Flg=0; if(length(QdL)==0, PtL=[]; Flg=1; ); if(Flg==0, PtL=QdL_1; forall(2..length(QdL),Ni, Qd=QdL_Ni; if(length(Qd)>1, pP=PtL_1; pS=PtL_(length(PtL)); pQ=Qd_1; pR=Qd_(length(Qd)); rMN=min([norm(pP-pQ),norm(pP-pR), norm(pS-pQ),norm(pS-pR)]); if(rMN==norm(pP-pR), Qd=reverse(Qd); , if(rMN==norm(pS-pQ), PtL=reverse(PtL); , if(rMN==norm(pS-pR), PtL=reverse(PtL); Qd=reverse(Qd); ); ); ); ); if(rMN>Eps, PtL=concat(PtL,Qd); , PtL=concat(PtL,Qd_(2..length(Qd))); ); ); ); if(Noflg<3, println("generate Joincurves3d "+name3); tmp=name3+"="+textformat(PtL,5); parse(tmp); tmp1=Projpara(name3,["nodata"]); tmp=name2+"="+textformat(tmp1,5); parse(tmp); tmp=text(plotstrL); tmp=substring(tmp,1,length(tmp)-1); tmp=name3+"=Joincrvs("+tmp+")"; GLIST=append(GLIST,tmp); tmp=name2+"=Projpara("+name3+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name2); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name2,Ltype,opcindy]); if(SUBSCR==1, // 15.02.11 tmp=parse(name2); // 15.08.17 if(length(tmp)>0, Subgraph(name3,opcindy); ); // 15.08.17 ); ); PtL; ); Xyzax3data(nm,Xrange,Yrange,Zrange):= Xyzax3data(nm,Xrange,Yrange,Zrange,[]); Xyzax3data(nm,Xrange,Yrange,Zrange,options):=( //help:Xyzax3data("","x=[-5,5]","y=[-5,5]","z=[-5,5]"); //help:Xyzax3data(Options2=["a1","Osw"]); regional(name2,name3,Out,tmp,tmp1,tmp2,eqL,reL,strL, opstr,opcindy,Ltype,Noflg,Axname,Arrow,Origin); name2="ax2d"+nm; name3="ax3d"+nm; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; eqL=tmp_5; reL=tmp_6; strL=tmp_7; opcindy=tmp_(length(tmp)); Axname=1; Arrow=0; // 16.08.14 Origin=""; // 16.08.14 if(length(reL)>0, Axname=reL_1; ); forall(strL, // 16.08.14from tmp1=Toupper(substring(#,0,1)); if(tmp1=="A", tmp=substring(#,1,length(#)); if(length(tmp)>0, Arrow=parse(tmp); , Arrow=1; ); ); if(tmp1=="O", tmp=indexof(#,","); if(tmp>0, Origin=substring(#,tmp,length(#)); , tmp=substring(#,1,length(#)); if(length(tmp)>0, Origin=tmp; , Origin="sw"; ); ); ); ); // 16.08.14until tmp1=indexof(Xrange,"="); tmp=parse(substring(Xrange,tmp1,length(Xrange))); Px=[tmp_1,0,0]; Qx=[tmp_2,0,0]; tmp1=indexof(Yrange,"="); tmp=parse(substring(Yrange,tmp1,length(Yrange))); Py=[0,tmp_1,0]; Qy=[0,tmp_2,0]; tmp1=indexof(Zrange,"="); tmp=parse(substring(Zrange,tmp1,length(Zrange))); Pz=[0,0,tmp_1]; Qz=[0,0,tmp_2]; Out=[[Px,Qx],[Py,Qy],[Pz,Qz]]; if(Axname>0, Xyzaxparaname(Xrange,Yrange,Zrange,[Axname]); ); if(Noflg<3, println("generate axes "+name3); tmp=name3+"="+textformat(Out,5); parse(tmp); tmp1=Projpara([name3],["nodata"]); tmp=name2+"="+textformat(tmp1,5); parse(tmp); tmp=name3+"=Xyzax3data("+ Dq+Xrange+Dq+","+Dq+Yrange+Dq+","+Dq+Zrange+Dq+")"; GLIST=append(GLIST,tmp); tmp=name2+"=Projpara("+name3+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name2); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name2,Ltype,opcindy]); if(Noflg<1, // 16.08.14from if(Arrow>0, tmp1=Parapt(Px); tmp2=Parapt(Qx); Arrowhead(tmp2,tmp2-tmp1,[Arrow]); tmp1=Parapt(Py); tmp2=Parapt(Qy); Arrowhead(tmp2,tmp2-tmp1,[Arrow]); tmp1=Parapt(Pz); tmp2=Parapt(Qz); Arrowhead(tmp2,tmp2-tmp1,[Arrow]); ); if(length(Origin)>0, Letter([Parapt([0,0,0]),Origin,"O"]); ); ); // 16.08.14until if(SUBSCR==1, // 15.02.11 Subgraph(name3,opcindy); ); ); Out; ); Xyzaxparaname(Xrange,Yrange,Zrange):= Xyzaxparaname(Xrange,Yrange,Zrange,[]); Xyzaxparaname(Xrange,Yrange,Zrange,options):=( regional(tmp,tmp1,tmp2,Eps,Dr,Noflg,Xname,Yname,Zname, px,qx,py,qy,pz,qz,ph,qh,rr,ch); Eps=10.0^(-6); Dr=0.19*1000/2.54/MilliIn; Noflg=0; forall(options, if(isreal(#),Dr=Dr*#); ); tmp=indexof(Xrange,"="); Xname=substring(Xrange,0,tmp-1); tmp=parse(substring(Xrange,tmp,length(Xrange))); px=[tmp_1,0,0]; qx=[tmp_2,0,0]; tmp=indexof(Yrange,"="); Yname=substring(Yrange,0,tmp-1); tmp=parse(substring(Yrange,tmp,length(Yrange))); py=[0,tmp_1,0]; qy=[0,tmp_2,0]; tmp=indexof(Zrange,"="); Zname=substring(Zrange,0,tmp-1); tmp=parse(substring(Zrange,tmp,length(Zrange))); pz=[0,0,tmp_1]; qz=[0,0,tmp_2]; ph=Parapt(px); qh=Parapt(qx); rr=|ph-qh|; if(rr>Eps, ch=qh+Dr/rr*(qh-ph); Expr(ch,"c",Xname); ); ph=Parapt(py); qh=Parapt(qy); rr=|ph-qh|; if(rr>Eps, ch=qh+Dr/rr*(qh-ph); Expr(ch,"c",Yname); ); ph=Parapt(pz); qh=Parapt(qz); rr=|ph-qh|; if(rr>Eps, ch=qh+Dr/rr*(qh-ph); Expr(ch,"c",Zname); ); ); Datalist3d():=( //help:Datalist3d(); regional(out,tmp,tmp2,tmp3); tmp=apply(GCLIST,#_1); tmp=select(tmp,indexof(#,"2d")>0); tmp2=select(tmp,indexof(#,"sub")==0); tmp3=apply(tmp2,replace(#,"2d","3d")); out=tmp3; ); Datalist2d():=( //help:Datalist2d(); regional(out,tmp,tmp2,tmp3); tmp=apply(GCLIST,#_1); tmp=select(tmp,indexof(#,"2d")>0); tmp2=select(tmp,indexof(#,"sub")==0); // tmp3=apply(tmp2,replace(#,"2d","3d")); out=tmp2; ); Embed(nm,Pd2str,funstr,varstr):= Embed(nm,Pd2str,funstr,varstr,[]); Embed(nm,Pd2str,funstr,varstr,options):=( //help:Embed("1",["gr1"],"A3d+x*(B3d-A3d)+y*(C3d-A3d)","[x,y]"); regional(name2,name3,Pd2L,Pd2,tmp,tmp1,xstr,ystr, Ltype,Noflg,opstr,opcindy,Out); name2="em2d"+nm; name3="em3d"+nm; if(!islist(Pd2str),Pd2L=[Pd2str],Pd2L=Pd2str); // 15.03.06 tmp1=[]; // 15.10.31 forall(Pd2L, if(isstring(#),tmp=parse(#),tmp=#); if(MeasureDepth(tmp)==2, tmp1=concat(tmp1,tmp); ); if(MeasureDepth(tmp)==1, tmp1=append(tmp1,tmp); ); ); Pd2L=tmp1; tmp=substring(varstr,0,1); if(tmp=="[" % tmp=="(", tmp1=substring(varstr,1,length(varstr)-1); , tmp1=varstr; ); tmp=indexof(tmp1,","); xstr=substring(tmp1,0,tmp-1); ystr=substring(tmp1,tmp,length(tmp1)); tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_(length(tmp)); Out=[]; forall(Pd2L,Pd2, tmp1=[]; forall(Pd2, tmp=Assign(funstr,xstr,"("+textformat(#_1,5)+")"); tmp=Assign(tmp,ystr,"("+textformat(#_2,5)+")"); tmp=parse(tmp); tmp1=append(tmp1,tmp); ); Out=append(Out,tmp1); ); if(length(Out)==1, Out=Out_1; ); if(Noflg<3, println("generate Embed "+name3); if(length(Out)>0, tmp=name3+"="+textformat(Out,5); parse(tmp); tmp1=Projpara(name3,["nodata"]); tmp=name2+"="+textformat(tmp1,5); parse(tmp); ); if(!islist(Pd2str), tmp=Pd2str; , tmp=text(Pd2str); tmp="list("+substring(tmp,1,length(tmp)-1)+")"; ); tmp=name3+"=Embed("+tmp+",'"+funstr+"','"+varstr+"'"+")"; GLIST=append(GLIST,tmp); tmp=name2+"=Projpara("+name3+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name2); , if(Noflg==1,Ltype=0); ); if(length(Out)>0, GCLIST=append(GCLIST,[name2,Ltype,opcindy]); if(SUBSCR==1, // 15.02.11 Subgraph(name3,opcindy); ); ); ); Out; ); Rotatept3d(point,w1,w2):=Rotate3pt(point,w1,w2); Rotatept3d(point,w1,w2,center):=Rotate3pt(point,w1,w2,center); //help:Rotatept3d(pt3d,[0,0,1],pi/2); //help:Rotatept3d(pt3d,[0,0,1],pi/2,[1,1,1]); Rotate3pt(point,w1,w2):=Rotate3pt(point,w1,w2,[0,0,0]); Rotate3pt(point,w1,w2,center):=( //help:Rotate3pt(pt3d,[0,0,1],pi/2); //help:Rotate3pt(pt3d,[0,0,1],pi/2,[1,1,1]); regional(Eps,ct,st,v3,v1,v2,Ans,ns,PtL,num, pt,tmp,tmp1,tmp2,Retflg,x,y,z,xx,yy,zz,flg); Eps=10^(-4); Retflg=0; if(length(w2)==1, ct=cos(w2); st=sin(w2); v3=1/|w1|*w1; if(v3_1==0, tmp=[1,0,0]; , tmp=[0,1,0]; ); w1=[tmp_2*v3_3-tmp_3*v3_2, tmp_3*v3_1-tmp_1*v3_3, tmp_1*v3_2-tmp_2*v3_1]; v1=1/|w1|*w1; v2=[v3_2*v1_3-v3_3*v1_2, v3_3*v1_1-v3_1*v1_3, v3_1*v1_2-v3_2*v1_1]; , tmp=[w1_2*w2_3-w1_3*w2_2, w1_3*w2_1-w1_1*w2_3, w1_1*w2_2-w1_2*w2_1]; if(|tmp|0, PtL=point; , PtL=[point]; ); Ans=[]; flg=0; forall(1..length(PtL),num, pt=PtL_num; if(pt_1=="inf", Ans=append(Ans,["inf"]); flg=1; ); if(flg==0, x=pt_1-center_1; y=pt_2-center_2; z=pt_3-center_3; xx=((v1_1*ct+v2_1*st)*v1_1+ (-v1_1*st+v2_1*ct)*v2_1+v3_1^2)*x +((v1_1*ct+v2_1*st)*v1_2+(-v1_1*st+v2_1*ct)*v2_2+v3_1*v3_2)*y +((v1_1*ct+v2_1*st)*v1_3+(-v1_1*st+v2_1*ct)*v2_3+v3_1*v3_3)*z; yy=((v1_2*ct+v2_2*st)*v1_1+(-v1_2*st+v2_2*ct)*v2_1+v3_1*v3_2)*x +((v1_2*ct+v2_2*st)*v1_2+(-v1_2*st+v2_2*ct)*v2_2+v3_2^2)*y +((v1_2*ct+v2_2*st)*v1_3+(-v1_2*st+v2_2*ct)*v2_3+v3_2*v3_3)*z; zz=((v1_3*ct+v2_3*st)*v1_1+(-v1_3*st+v2_3*ct)*v2_1+v3_1*v3_3)*x +((v1_3*ct+v2_3*st)*v1_2+(-v1_3*st+v2_3*ct)*v2_2+v3_2*v3_3)*y +((v1_3*ct+v2_3*st)*v1_3+(-v1_3*st+v2_3*ct)*v2_3+v3_3^2)*z; Ans=append(Ans,center+[xx,yy,zz]); ); ); if(length(Ans)==1, Ans=Ans_1; ); ); Ans; ); Rotatedata3d(nm,P3data,w1,w2):=Rotate3data(nm,P3data,w1,w2); Rotatedata3d(nm,P3data,w1,w2,options):= Rotate3data(nm,P3data,w1,w2,options); //help:Rotatedata3d("1",["sl3d1","sc3d2"],[0,0,1],pi/3); Rotate3data(nm,P3data,w1,w2):=Rotate3data(nm,P3data,w1,w2,[]); Rotate3data(nm,P3data,w1,w2,options):=( regional(name3,name2,center,pdata,Pd3,Pd,Out,tmp,tmp1, Ltype,Noflg,opcindy,opstr); name3="rot3d"+nm; name2="rot2d"+nm; center=[0,0,0]; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opstr=tmp_(length(tmp)-1); opcindy=tmp_(length(tmp)); tmp1=tmp_6; if(length(tmp1)>0, center=tmp1_1; ); if(islist(P3data) & isstring(P3data_1),Pd3=P3data,Pd3=[P3data]); Out=[]; forall(Pd3,Pd, if(isstring(Pd),Pd=parse(Pd)); if(MeasureDepth(Pd)==1,Pd=[Pd]); Ans=[]; forall(Pd, tmp=Rotate3pt(#,w1,w2,center); Ans=append(Ans,tmp); ); Out=append(Out,Ans); ); Out=Flattenlist(Out); if(length(Out)==1,Out=Out_1); if(Noflg<3, println("generate Rotate3data "+name3); tmp=name3+"="+textformat(Out,5); parse(tmp); tmp1=Projpara(name3,["nodata"]); tmp=name2+"="+textformat(tmp1,5); parse(tmp); tmp=textformat(P3data,5); // 17.12.23 tmp=RSform(tmp); // 17.12.23 // tmp=replace(tmp,"[","list("); // tmp=replace(tmp,"]",")"); tmp=name3+"=Rotate3data("+tmp+"," +textformat(w1,5)+","+textformat(w2,5)+opstr+")"; GLIST=append(GLIST,tmp); tmp=name2+"=Projpara("+name3+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name2); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name2,Ltype,opcindy]); if(SUBSCR==1, // 15.02.11 Subgraph(name3,opcindy); ); ); Out; ); Translatept3d(point,w1):=Translate3pt(point,w1); //help:Translatept3d(pt3d,[1,2,3]); Translate3pt(point,w1):=( regional(Eps,Ans,PtL,pt,num,xx,yy,zz,flg); Eps=10^(-4); if(MeasureDepth(point)>0, PtL=point; , PtL=[point]; ); Ans=[]; flg=0; forall(1..length(PtL),num, pt=PtL_num; if(pt_1=="inf", Ans=append(Ans,["inf"]); flg=1; ); if(flg==0, xx=pt_1+w1_1; yy=pt_2+w1_2; zz=pt_3+w1_3; Ans=append(Ans,[xx,yy,zz]); ); ); if(length(Ans)==1, Ans=Ans_1; ); Ans; ); Translatedata3d(nm,P3data,w1):=Translate3data(nm,P3data,w1); Translatedata3d(nm,P3data,w1,options):= Translate3data(nm,P3data,w1,options); //help:Translatedata3d("1",["sl3d1"],[1,2,3]); Translate3data(nm,P3data,w1):=Translate3data(nm,P3data,w1,[]); Translate3data(nm,P3data,w1,options):=( regional(name3,name2,pdata,Pd3,Pd,Out,tmp,tmp1, Ltype,Noflg,opcindy); name3="tra3d"+nm; name2="tra2d"+nm; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_(length(tmp)); if(islist(P3data) & isstring(P3data_1),Pd3=P3data,Pd3=[P3data]); Out=[]; forall(Pd3,Pd, if(isstring(Pd),Pd=parse(Pd)); if(MeasureDepth(Pd)==1,Pd=[Pd]); Ans=[]; forall(Pd, tmp=Translate3pt(#,w1); Ans=append(Ans,tmp); ); Out=append(Out,Ans); ); Out=Flattenlist(Out); if(length(Out)==1,Out=Out_1); if(Noflg<3, println("generate Translate3data "+name3); tmp=name3+"="+textformat(Out,5); parse(tmp); tmp1=Projpara(name3,["nodata"]); tmp=name2+"="+textformat(tmp1,5); parse(tmp); tmp=textformat(P3data,5); // 17.12.23 tmp=RSform(tmp); // 17.12.23 // tmp=text(P3data); // tmp=replace(tmp,"[","list("); // tmp=replace(tmp,"]",")"); tmp=name3+"=Translate3data("+tmp+","+textformat(w1,5)+")"; GLIST=append(GLIST,tmp); tmp=name2+"=Projpara("+name3+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name2); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name2,Ltype,opcindy]); if(SUBSCR==1, // 15.02.11 Subgraph(name3,opcindy); ); ); Out; ); Reflectpoint3d(point,vecL):=Reflect3point(point,vecL); Reflectpt3d(point,vecL):=Reflect3pt(point,vecL); //help:Reflectpoint3d(pt3d,[v1,v2,v3]); Reflect3point(point,vecL):=Reflect3pt(point,vecL); Reflect3pt(point,vecL):=( regional(ans,v1,v2,v3,tmp,tmp1); if(length(vecL)==1, v1=vecL_1; ans=2*v1-point; ); if(length(vecL)==2, v1=vecL_1; v2=vecL_2; v3=(v2-v1)/|v2-v1|; tmp=v1+Dotprod(point-v1,v3)*v3; ans=2*tmp-point; ); if(length(vecL)==3, v1=vecL_1; v2=vecL_2; v3=vecL_3; tmp=Crossprod(v2-v1,v3-v1); tmp1=point-Dotprod(tmp,point-v1)/|tmp|^2*tmp; ans=2*tmp1-point; ); ans; ); Xyzcoord(X,Y,z):=( //help:Xyzcoord(A.x,A.y,Az.y); regional(Eps,x3d,y3d,z3d); x3d=(-X*sin(PHI)*cos(THETA)-Y*cos(PHI)+z*cos(PHI)*sin(THETA))/cos(THETA); y3d=(X*cos(PHI)*cos(THETA)-Y*sin(PHI)+z*sin(PHI)*sin(THETA))/cos(THETA); z3d=z; [x3d,y3d,z3d]; ); PutonCurve3d(name,pdstr):=( //help:PutonCurve3d("T","sc3d1"); regional(pt,pd2str,tmp,tmp1,tmp2); pd2str=replace(pdstr,"3d","2d"); PutonCurve(name,pd2str); pt=parse(name+".xy"); tmp=Nearestpt(pt,pd2str); // 15.03.13 tmp1=ParamonCurve(tmp_1,tmp_2,pd2str); tmp="sub"+pd2str; tmp2=PointonCurve(tmp1,tmp); pt=append(pt,tmp2_2); pt=Xyzcoord(pt_1,pt_2,pt_3); // 15.03.13 tmp=name+"z.xy="+textformat(tmp2,5); parse(tmp); VLIST=select(VLIST,#_1!=name+"3d"); Defvar(name+"3d",pt); ); Mkpointlist():=Mkpointlist([]); //16.11.12 Mkpointlist(options):=( //16.11.12 regional(Eps,pos,ptL,plist,ilist,plistrest, inforest,free,pt,pt3,ptz,par,vlistpre, tmp,tmp1,tmp2,tmp3,tmp4,p1,p2,flg); Eps=10^(-4); tmp=Finddef(NE); free=tmp_1; pos=[NE.x+1,NE.y]; tmp=remove(allpoints(),[NE,SW,TH,FI]); tmp=remove(tmp,options); //16.11.12 plist=select(tmp, substring(text(#),length(text(#))-1,length(text(#)))!="z" ); if(SUBSCR==0,plist=[]); ptL=[]; plistrest=[]; inforest=[]; forall(plist,pt, inspect(pt,"ptsize",3); inspect(pt,"color",2); inspect(pt,"textsize",TSIZE); ptz=text(pt)+"z"; tmp=Finddef(pt); if(indexof(tmp_1,free)>0, // free point tmp=select(VLIST,#_1==text(pt)+"3d"); if(length(tmp)==0, tmp=pt.x+NE.x-SW.x; Putpoint(ptz,[tmp,0],[tmp,parse(ptz+".y")]); pt3=Xyzcoord(pt.x,pt.y,parse(text(ptz)+".y")); Defvar(text(pt)+"3d",pt3); Defvar(text(pt)+"fix",0); vlistpre=VLIST; //16.08.20 ); flg=0; if(isselected(pt), if(parse(text(pt)+"fix")!=1, // 15.03.01 tmp=pt.x+NE.x-SW.x; Putpoint(ptz,[tmp,0],[tmp,parse(ptz+".y")]); pt3=Xyzcoord(pt.x,pt.y,parse(text(ptz)+".y")); VLIST=select(VLIST,#_1!=text(pt)+"3d"); Defvar(text(pt)+"3d",pt3); vlistpre=VLIST; //16.08.20 flg=1; ); ); inspect(parse(ptz),"ptsize",3); inspect(parse(ptz),"color",3); inspect(parse(ptz),"textsize",TSIZEZ); if(isselected(parse(ptz)), if(parse(ptz+"fix")!=1, // 15.03.01 tmp=select(vlistpre,#_1==text(pt)+"3d"); //16.08.20 pt3=tmp_1_2; pt3_3=parse(ptz+".y"); pt.xy=Parapt(pt3); tmp=ptz+".x=pt.x+NE.x-SW.x"; parse(tmp); VLIST=select(VLIST,#_1!=text(pt)+"3d"); Defvar(text(pt)+"3d",pt3); flg=2; ); ); if(flg==0, tmp=select(VLIST,#_1==text(pt)+"3d"); if(length(tmp)>0, //17.10.07 pt3=tmp_1_2; pt.xy=Parapt(pt3); tmp=ptz+".x=pt.x+NE.x-SW.x"; parse(tmp); ); //17.10.07 ); if(isselected(pt) % isselected(parse(ptz)), drawtext(pos,text(pt3)); ); if(!contains(["p","q"],text(pt)), ptL=append(ptL,pt); ); , tmp=Findgeoinfo(pt); tmp1=[parse(tmp_1),parse(tmp_2),parse(tmp_3)]; plistrest=append(plistrest,pt); inforest=append(inforest,tmp); ); ); if(length(plistrest)>0, tmp=Sortpointlist([plistrest,inforest]); plist=tmp_1; ilist=tmp_2; forall(1..length(plist), pt=plist_#; ptz=text(pt)+"z"; tmp=ilist_#; p1=parse(tmp_3); p2=p1+parse(tmp_2)-parse(tmp_1); tmp1=p2-p1; tmp2=pt-p1; if(abs(tmp1_1)>abs(tmp1_2), par=tmp2_1/tmp1_1; , par=tmp2_2/tmp1_2; ); tmp=ilist_#; tmp1=parse(tmp_1+"3d"); tmp2=parse(tmp_2+"3d"); tmp3=parse(tmp_3+"3d"); tmp1=(1-par)*tmp3+par*(tmp3+tmp2-tmp1); Putpoint(ptz,[pt.x+NE.x-SW.x,tmp1_3]); inspect(parse(ptz),"ptsize",3); inspect(parse(ptz),"color",3); inspect(parse(ptz),"textsize",TSIZEZ); pt3=Xyzcoord(pt.x,pt.y,parse(text(ptz)+".y")); VLIST=select(VLIST,#_1!=tmp1+"3d"); Defvar(text(pt)+"3d",pt3); vlistpre=VLIST; //16.08.20 if(isselected(pt) % isselected(parse(ptz)), drawtext(pos,text(pt3)); ); if(!contains(["p","q"],text(pt)), ptL=append(ptL,pt); ); ); ); ptL; ); Mkseg3d():=Mkseg3d([]); Mkseg3d(options):=( regional(seg,nmseg,def,ptA,ptB,segL,opstr,opcindy, name,strg,Ltype,Noflg,tht,tmp,tmp1,tmp2,tmp3); name="geoseg3d"; strg=name+"=list("; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_(length(tmp)); segL=[]; forall(allsegments(),seg, inspect(seg,"labeled",false); tmp=Finddef(seg); def=tmp_1; ptA=tmp_2; ptB=tmp_3; if(ispoint(parse(ptA)) & ispoint(parse(ptB)), tmp1=select(VLIST,indexof(#_1,ptA+"3d")>0); tmp2=select(VLIST,indexof(#_1,ptB+"3d")>0); if(length(tmp1)>0 & length(tmp2)>0, tmp1="["+ptA+"3d,"+ptB+"3d]"; nmseg=ptA+ptB; // Spaceline(nmseg,parse(tmp1),append(options,"Msg=nodisp")); //15.06.15 Spaceline("-"+nmseg+"3d",[ptA+"3d",ptB+"3d"], // 16.04.07 append(options,"Msg=nodisp")); //15.06.15 segL=append(segL,nmseg+"3d");// 16.04.07 strg=strg+nmseg+"3d,";// 16.04.07 ); ); ); println("generate totally "+name); if(length(segL)>0, // 15.03.06 strg=substring(strg,0,length(strg)-1)+")"; if(Noflg<3, GLIST=append(GLIST,strg); ); tmp1=apply(segL,Dq+#+Dq); //15.03.02 tmp=name+"="+text(tmp1); parse(tmp); ); segL; ); Ptseg3data():=Ptseg3data([]); //help:Ptseg3data(); //help:Ptseg3data([A,B]); Ptseg3data(options):=( regional(pt,pt3,plist,tmp,tmp1,tmp2); if(isselected(TH) % isselected(FI), tmp=remove(allpoints(),[NE,SW,TH,FI]); tmp=remove(tmp,options); //16.11.12 tmp=apply(tmp,text(#)); plist=select(tmp,substring(#,length(#)-1,length(#))!="z"); forall(plist,pt, tmp1=text(pt); tmp=select(VLIST,#_1==tmp1+"3d"); //17.10.07 if(length(tmp)>0, pt3=tmp_1_2; tmp=tmp1+".xy=Parapt("+pt3+")_[1,2];"; parse(tmp); if(SUBSCR==1, tmp=tmp1+"z"+".x=NE.x-SW.x+"+tmp1+".x"; parse(tmp); ); ); ); , Mkpointlist(options); // 16.12.18 ); forall(alllines(), #.color=[0.5,0.5,1]; ); SEG3dlist=Mkseg3d(options); SEG3dlist; ); Putonseg3d(name,ptL):=Putonseg3d(name,ptL_1,ptL_2,[]); Putonseg3d(name,Arg1,Arg2):=( if(islist(Arg1), Putonseg3d(name,Arg1_1,Arg1_2,Arg2); , Putonseg3d(name,Arg1,Arg2,[]); ); ); Putonseg3d(name,pt1,pt2,options):=( //help:Putonseg3d("C",[A,B]); //help:Putonseg3d("C",A,B); regional(par,pn1,pn2,tmp,tmp1,tmp2,tmp3); par=0.5; tmp=divoptions(options); if(length(tmp_6)>0, par=tmp_6_1; ); Putonseg(name,pt1,pt2,[par]); inspect(parse(name),"ptsize",3); inspect(parse(name),"color",2); inspect(parse(name),"textsize",TSIZEZ); Putpoint(name+"z",[parse(name+".x"),0]); inspect(parse(name+"z"),"ptsize",3); inspect(parse(name+"z"),"color",3); inspect(parse(name+"z"),"textsize",TSIZEZ); pn1=text(pt1); pn2=text(pt2); tmp1=replace("PTCz.y=PTAz.y+|PTC-PTA|/|PTB-PTA|*(PTBz.y-PTAz.y)","PTC",name); tmp1=replace(tmp1,"PTA",pn1); tmp1=replace(tmp1,"PTB",pn2); tmp2=replace("PTCz.x=PTAz.x+|PTC-PTA|/|PTB-PTA|*(PTBz.x-PTAz.x)","PTC",name); tmp2=replace(tmp2,"PTA",pn1); tmp2=replace(tmp2,"PTB",pn2); parse(tmp2); parse(tmp1); tmp1=parse(name+".x"); tmp2=parse(name+".y"); tmp3=parse(name+"z.y"); tmp=Xyzcoord(tmp1,tmp2,tmp3); Defvar(name+"3d",tmp); ); Putpoint3d(ptslist):=Putpoint3d(ptslist,"",0); Putpoint3d(Arg1,Arg2):=( // 16.03.02 from if(islist(Arg1), Putpoint3d(Arg1,Arg2,0); , Putpoint3d(Arg1,Arg2,"fix"); ); ); Putpoint3d(Arg1,Arg2,Arg3):=( //help:Putpoint3d(["A",[2,1,3]]); //help:Putpoint3d(["A",[2,1,3]],"fix"); //help:Putpoint3d("A",[2,1,3]); //help:Putpoint3d(["A",[2,1,3]],["fix"]); regional(nn,kk,pt,pt3,ptslist,fixstr,tmp,tmp1,tmp2,tmp3); //16.08.19 if(isstring(Arg1), ptslist=[Arg1,Arg2]; fixstr=Arg3; , ptslist=Arg1; fixstr=Arg2; ); if(islist(fixstr),fixstr=fixstr_1);// 16.03.02 until nn=length(ptslist)/2; forall(1..nn,kk, // 16.08.19from tmp1=ptslist_(2*kk-1); pt3=ptslist_(2*kk); // 16.08.19until VLIST=select(VLIST,#_1!=tmp1+"3d"); tmp2=parse(tmp1); if(ispoint(tmp2), // 16.05.26from if(islist(fixstr),tmp=fixstr_1,tmp=fixstr); tmp=Toupper(tmp); if(tmp!="FIX", tmp=Xyzcoord(tmp2.x,tmp2.y,parse(tmp1+"z").y); , tmp=pt3; ); Defvar(tmp1+"3d",tmp); , Defvar(tmp1+"3d",pt3); ); // 16.05.26until Defvar(tmp1+"fix",0); pt=Parapt(pt3); Putpoint(tmp1,pt,parse(tmp1+".xy")); inspect(parse(tmp1),"ptsize",3); inspect(parse(tmp1),"color",2); inspect(parse(tmp1),"textsize",TSIZE); if(SUBSCR==1, tmp2=tmp1+"z"; tmp=[pt.x+NE.x-SW.x,pt3_3]; tmp1="[NE.x-SW.x+"+tmp1+".x,"+tmp2+"y]"; Putpoint(tmp2,tmp,parse(tmp1)); inspect(parse(tmp2),"ptsize",3); inspect(parse(tmp2),"color",3); inspect(parse(tmp2),"textsize",TSIZEZ); ); ); if(islist(fixstr),tmp=fixstr_1,tmp=fixstr); if(tmp=="fix" % tmp=="Fix", Fixpoint3d(ptslist); ); ); Fixpoint3d(ptlist):=( // help:Fixpoint3d(["O",[0,0,0],"X",[1,0,0]]); regional(name,pt3,pt2,tmp,tmp1,tmp2); forall(1..(length(ptlist)/2), name=ptlist_(2*#-1); Defvar(name+"fix",1); pt3=ptlist_(2*#); pt2=Parapt(pt3); tmp1=textformat(pt2_1,5); tmp2=textformat(pt2_2,5); tmp=name+".xy=["+tmp1+","+tmp2+"]"; parse(tmp); tmp1=name+".x+NE.x-SW.x"; tmp2=textformat(pt3_3,5); tmp=name+"z.xy=["+tmp1+","+tmp2+"];"; parse(tmp); ); ); Perppt(name,ptstr,pLstr):=Putperp(name,ptstr,pLstr,"draw"); Perppt(name,ptstr,pLstr,option):=Putperp(name,ptstr,pLstr,option); Putperp(name,ptstr,pLstr):=Putperp(name,ptstr,pLstr,"put"); Putperp(name,ptstr,pLstr,option):=( //help:Perppt("N","O","A-B-C"); //help:Perppt("N","O","A-B-C","put"); //help:Perppt("N","O","A-B","none"); regional(out,Eps,N3d,sgstr,pP,pA,pB,pC,tmp,tmp1,flgpL); Eps=10^(-4); pP=parse(ptstr+"3d"); tmp=indexof(pLstr,"-"); pA=parse(substring(pLstr,0,tmp-1)+"3d"); tmp1=substring(pLstr,tmp,length(pLstr)); tmp=indexof(tmp1,"-"); if(tmp>0, pB=parse(substring(tmp1,0,tmp-1)+"3d"); pC=parse(substring(tmp1,tmp,length(tmp1))+"3d"); flgpL=1; , pB=parse(tmp1+"3d"); flgpL=0; ); if(flgpL==1, tmp=Crossprod(pB-pA,pC-pA); if(abs(tmp)0, // 15.05.28 pP=parse(substring(sgstr,0,tmp-1)+"3d"); pQ=parse(substring(sgstr,tmp,length(sgstr))+"3d"); , tmp1=parse(sgstr); pP=tmp1_1; pQ=tmp1_2; ); ); if(!isstring(pLstr), // 16.02.02 pA=pLstr_1; pB=pLstr_2; pC=pLstr_3; , tmp=indexof(pLstr,"-"); pA=parse(substring(pLstr,0,tmp-1)+"3d"); tmp1=substring(pLstr,tmp,length(pLstr)); tmp=indexof(tmp1,"-"); pB=parse(substring(tmp1,0,tmp-1)+"3d"); pC=parse(substring(tmp1,tmp,length(tmp1))+"3d"); ); nvec=Crossprod(pB-pA,pC-pA); if(abs(Dotprod(nvec,pQ-pP))>Eps, pH=(Reflect3point(pP,[pA,pB,pC])+pP)/2; pK=(Reflect3point(pQ,[pA,pB,pC])+pQ)/2; tmp1=pP-pH; tmp2=tmp1+pK-pQ; tmp=select(tmp2,abs(#)==max(apply(tmp2,abs(#)))); tmp=select(1..3,tmp2_#==tmp_1); tmp=tmp_1; tseg=tmp1_tmp/tmp2_tmp; pR=(1-tseg)*pH+tseg*pK; tmp=substring(opstr,0,1); if(Toupper(tmp)=="P", Putpoint3d([name,pR]); Fixpoint3d([name,pR]); ); if(Toupper(tmp)=="D", Drawpoint3d(pR); ); tmp=Dotprod(pB-pA,pC-pA); tmp1=Dotprod(pB-pA,pB-pA); tmp2=Dotprod(pC-pA,pC-pA); tmp3=Dotprod(pR-pA,pB-pA); tmp4=Dotprod(pR-pA,pC-pA); ss=-(tmp*tmp4-tmp3*tmp2)/(tmp1*tmp2-tmp^2); tt=(tmp1*tmp4-tmp*tmp3)/(tmp1*tmp2-tmp^2); out=[pR,tseg,ss,tt]; , if(Toupper(substring(opstr,0,1))!="N", println(" "+sgstr+","+pLstr+" are parallel"); ); out=[]; ); out; ); Bezier3d(nm,ptctrlist):=Bezier3(nm,ptctrlist); Bezier3d(nm,Ag1,Ag2):=Bezier3(nm,Ag1,Ag2); Bezier3d(nm,ptlistorg,ctrlistorg,options):= Bezier3(nm,ptlistorg,ctrlistorg,options); //help:Bezier3d("1",["A","B","C"],["D","E","F","G"]); Bezier3(nm,ptctrlist):=Bezier3(nm,ptctrlist_1,ptctrlist_2,[]); Bezier3(nm,Ag1,Ag2):=( if(MeasureDepth(Ag1)==0, Bezier3(nm,Ag1,Ag2,[]); , if(MeasureDepth(Ag1)>1, Bezier3(nm,Ag1_1,Ag1_2,Ag2); , if(isstring(Ag_1_1), Bezier3(nm,Ag1,Ag2,[]); , Bezier3(nm,Ag1_1,Ag1_2,Ag2); ); ); ); ); Bezier3(nm,ptlistorg,ctrlistorg,options):=( //17.10.08 greatly changed regional(name,name3,name2,tmp,tmp1,tmp2, Ltype,Noflg,opstr,eqL,Num,ii,knt,ctr,out); name="bz"+nm; name3="bz3d"+nm; name2="bz2d"+nm; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; eqL=tmp_5; opcindy=tmp_(length(tmp)); Num=20; forall(eqL, tmp=indexof(#,"="); tmp1=Toupper(substring(#,0,1)); tmp2=substring(#,tmp,length(#)); if(tmp1=="N", Num=parse(tmp2); ); ); ptlist=ptlistorg; if(isstring(ptlistorg_1),ptlist=apply(ptlistorg,parse(#+"3d"))); ctrlist=ctrlistorg; if(isstring(ctrlistorg_1),ctrlist=apply(ctrlistorg,parse(#+"3d"))); out=[]; forall(1..(length(ptlist)-1),ii, knt=[ptlist_ii,ptlist_(ii+1)]; ctr=[ctrlist_(2*ii-1),ctrlist_(2*ii)]; tmp="Bezierpt(T,ptlist,ctrlist)";//17.01.04 tmp=Assign(tmp,"ptlist",knt); tmp=Assign(tmp,"ctrlist",ctr); Spacecurve(name+text(ii),tmp,"T=[0,1]",append(eqL,"nodisp")); GLIST=GLIST_(1..(length(GLIST)-2)); out=append(out,name3+text(ii)); ); tmp1=[]; forall(1..length(out), tmp=parse(out_#); if(#==1,tmp1=tmp,tmp1=concat(tmp1,tmp_(2..length(tmp)))); ); if(Noflg<3, println("generate Beziercurve "+name3); tmp=name3+"="+tmp1; parse(tmp); tmp1=Projpara(name3,["nodata"]); tmp=name2+"="+textformat(tmp1,5); parse(tmp); ptlist=apply(ptlistorg,#+"3d"); ptlist=RSform(text(ptlist),1); ctrlist=[]; forall(1..(length(ctrlistorg)/2), tmp=[ctrlistorg_(2*#-1),ctrlistorg_(2*#)]; tmp=apply(tmp,#+"3d"); ctrlist=append(ctrlist,tmp); ); ctrlist=RSform(text(ctrlist),0); tmp=name3+"=Bezier("+ptlist+","+ctrlist+","+Dq+"Num="+text(Num)+Dq+")"; GLIST=append(GLIST,tmp); tmp=name2+"=Projpara("+name3+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name2); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name2,Ltype,opcindy]); if(SUBSCR==1, // 15.02.11 Subgraph(name3,opcindy); ); ); out; ); Putbezier3data(name,pt3Lorg):=Putbezier3data(name,pt3Lorg,[]); Putbezier3data(name,pt3Lorg,options):=( // 17.10.08 greatly changed regional(pt3L,psize,Deg,nn,numstr, tmp,tmp1,tmp2,tmp3,pts,ctrpts); tmp=Divoptions(options); Deg=3; tmp1=tmp_5; forall(tmp1, if(substring(#,0,1)=="D", tmp=indexof(#,"="); Deg=parse(substring(#,tmp,length(#))); ); ); pt3L=pt3Lorg; if(isstring(pt3L_1),pt3L=apply(pt3L,parse(#+"3d"))); ctrpts=[]; forall(2..length(pt3L),nn, // 16.08.19from numstr=text(nn-1); // 16.08.19 if(Deg==3, tmp1=name+numstr+"p"; tmp2=(2*pt3L_(nn-1)+pt3L_(nn))/3; VLIST=select(VLIST,#_1!=tmp1+"3d"); // 16.08.19from Putpoint3d([tmp1,tmp2]); ctrpts=append(ctrpts,tmp1); tmp1=name+numstr+"q"; tmp3=(pt3L_(nn-1)+2*pt3L_nn)/3; VLIST=select(VLIST,#_1!=tmp1+"3d"); Putpoint3d([tmp1,tmp3]); ctrpts=append(ctrpts,tmp1); , tmp1=name+numstr+"p"; tmp2=(pt3L_(nn-1)+pt3L_nn)/2; VLIST=select(VLIST,#_1!=tmp1+"3d"); // 16.08.19until Putpoint3d([tmp1,tmp2]); ctrpts=append(ctrpts,tmp1); ); ); ctrpts; ); Mkbezierptcrv3d(ptdata):=Mkbezierptcrv3(ptdata); Mkbezierptcrv3d(ptdata,options):=Mkbezierptcrv3(ptdata,options); //help:Mkbezierptcrv3d(["A","B","C","D"]); Mkbezierptcrv3(ptdata):=Mkbezierptcrv3(ptdata,[]); Mkbezierptcrv3(ptdata,options):=( //17.10.08 greatly changed regional(Eps,name,bz,pt,p1,p2,p13d,p23d,pt3, Out,tt,pos,tmp,tmp1,tmp2); Eps=10^(-4); pos=[NE.x+1,NE.y]; Out=[]; tmp=floor((BezierNumber3-1)/26);// 15.02.23 from if(tmp==0,tmp="",tmp=text(tmp)); tmp2=mod(BezierNumber3,26); if(tmp2==0,tmp2=26); name=unicode(text(96+tmp2),base->10)+tmp; tmp2=Putbezier3data(name,ptdata,options); Bezier3(name,ptdata,tmp2,options); Out=append(Out,tmp2); BezierNumber3=BezierNumber3+1; Out; ); /////////////////////////////////////////// Readobj(filename):=Readobj(filename,[]); Readobj(filename,options):=( //help:Readobj("file.obj",["size=-3"]); regional(eqL,size,vL,fnL,tmp,tmp1,tmp2); size=1; tmp=Divoptions(options); eqL=tmp_5; forall(eqL, if(Toupper(substring(#,0,1))=="S", tmp=indexof(#,"="); size=parse(substring(#,tmp,length(#))); ); ); tmp=load(filename); tmp=tokenize(tmp,"v"); tmp1=tmp_(2..(length(tmp)-1)); tmp2=tmp_(length(tmp)); tmp2=tokenize(tmp2,"f"); tmp1=append(tmp1,tmp2_1); tmp1=apply(tmp1,Removespace(#)); tmp1=apply(tmp1,replace(#," "," ")); tmp1=apply(tmp1,"["+replace(#," ",",")+"]"); vL=apply(tmp1,size*parse(#)); tmp2=tmp2_(2..(length(tmp2))); tmp2=apply(tmp2,Removespace(#)); tmp2=apply(tmp2,replace(#," "," ")); tmp2=apply(tmp2,"["+replace(#," ",",")+"]"); fnL=apply(tmp2,parse(#)); [vL,fnL]; ); ///////////////////////////////////////// Readobj(filename,options):=( //help:Readobj("file.obj",["size=-3"]); regional(eqL,size,vL,fnL,dtL,numer,flg,flg2, tmp,tmp1,tmp2,tmp3,tmp4,tmp5); size=1; tmp=Divoptions(options); eqL=tmp_5; forall(eqL, if(Toupper(substring(#,0,1))=="S", tmp=indexof(#,"="); size=parse(substring(#,tmp,length(#))); ); ); numer="-0123456789"; tmp=load(filename); dtL=tokenize(tmp,"v "); vL=[]; fnL=[]; flg=0; flg2=0; forall(dtL,dt, tmp1=Removespace(dt); if(indexof(numer,substring(tmp1,0,1))>0, tmp2=""; tmp=indexof(tmp1,"f"); if(tmp>0, tmp2=substring(tmp1,tmp-1,length(tmp1)); tmp1=substring(tmp1,0,tmp-1); if(substring(tmp1,length(tmp1)-1,length(tmp1))=="#", tmp2="#"+tmp2; tmp1=substring(tmp1,0,length(tmp1)-1); ); // tmp=indexof(tmp2,"#"); // if(tmp>0, // tmp2=substring(tmp2,0,tmp-1); // ); ); if(flg==1, tmp1=""; flg=0; ); if(length(tmp1)>0, tmp=indexof(tmp1,"#"); if(tmp>0, tmp1=substring(tmp1,0,tmp-1); flg=1; ); tmp=indexof(tmp1,"vt"); if(tmp>0, tmp1=substring(tmp1,0,tmp-1); ); tmp1=replace(tmp1," ",","); tmp1=replace(tmp1," ",","); tmp1="["+tmp1+"]"; tmp1=size*parse(tmp1); vL=append(vL,tmp1); ); if(length(tmp2)>0, tmp2=tokenize(tmp2,"f"); if(length(tmp2_1)==0, tmp2=tmp2_(2..length(tmp2)); // , // if(tmp2_1=="#", // tmp2=tmp2_(2..length(tmp2)); // tmp2_1="#"+tmp2_1; // ); ); forall(1..length(tmp2),tmp3, tmp=tmp2_tmp3; if(substring(tmp,length(tmp)-1,length(tmp))=="#", tmp2_(tmp3+1)="#"+Removespace(tmp2_(tmp3+1)); tmp2_tmp3=substring(tmp,0,length(tmp)-1); ); tmp5=""; if(length(tmp2_tmp3)>0, tmp4=tokenize(tmp2_tmp3," "); forall(tmp4, if(length(text(#))>0, if(indexof(text(#),"/")==0, tmp=text(#); , tmp=tokenize(text(#),"/"); tmp=tmp_1; ); if(length(tmp)>0, tmp5=tmp5+tmp+","; ); ); ); tmp5=substring(tmp5,0,length(tmp5)-1); if(length(tmp5)>0, if(substring(tmp5,0,1)!="#", tmp5="["+tmp5+"]"; fnL=append(fnL,parse(tmp5)); ); ); ); ); ); ); ); [vL,fnL]; ); Concatobj(objL):=Concatobj(objL,[]); Concatobj(objL,options):=( //help:Concatobj([polyhed,triangle]); //help:Concatobj([polyhed,triangle],["Rmf=no"]); //help:Concatobj([[A,B,C],[A,C,D]]); regional(obj,vL,fL,vadd,vtx,faces,fnew,face,jj,kk,vctr,eps, tmp,tmp1,tmp2,tmp3,eqL,rmf); tmp=divoptions(options); eqL=tmp_5; rmf="y"; // 16.08.19 forall(eqL, tmp=indexof(#,"="); tmp1=Toupper(substring(#,0,1)); tmp2=Toupper(substring(#,tmp,tmp+1)); if(tmp1=="R", if(tmp2=="Y",rmf="y"); // 16.08.14 ); ); eps=10^(-4); vL=[]; fL=[]; vctr=0; forall(objL,obj, if(isstring(obj), tmp1=parse(obj); , tmp1=obj; ); if(length(tmp1)>2, // 16.02.28 tmp=1..length(tmp1); tmp1=[tmp1,[tmp]]; ); vtx=tmp1_1; // 16.02.11 from faces=tmp1_2; fnew=faces; vctr=0; vadd=[]; forall(1..length(vtx),jj, tmp1=vtx_jj; tmp=select(1..length(vL),dist3d(vL_#,tmp1)0, tmp1=tmp_1; fnew_kk_tmp1=tmp2; ); ); ); vL=concat(vL,vadd); fL=concat(fL,fnew); // 16.02.11 until ); tmp2=apply(1..length(fL),1); if(rmf=="y", forall(1..length(fL),jj, tmp=fL_jj; tmp1=select((jj+1)..length(fL),fL_#==tmp); forall(tmp1,tmp2_#=0); ); tmp=select(1..length(tmp2),tmp2_#==1); fL=fL_tmp; ); [vL,fL]; ); if(1==0, Mkobjfile(fname,objL):=Mkobjfile(Dirwork,fname,objL); Mkobjfile(path,fnameorg,objL):=( //help:Mkobj(filename,objlist); regional(fname,obj,vtx,face,tmp,tmp1,tmp2); fname=fnameorg; if(indexof(fname,".")==0,fname=fname+".obj"); vtx=objL_1; face=objL_2; setdirectory(path); SCEOUTPUT = openfile(fname); forall(vtx,tmp1, tmp2=tmp1; if(ispoint(tmp1), tmp2=parse(text(tmp1)+"3d"); ); tmp="v "+format(tmp2_1,5)+" "+format(tmp2_2,5)+" "+format(tmp2_3,5); println(SCEOUTPUT,tmp); ); forall(face,tmp1, tmp="f"; forall(tmp1, tmp=tmp+" "+text(#); ); println(SCEOUTPUT,tmp); ); closefile(SCEOUTPUT); setdirectory(Dirwork); ); ); VertexandEdge(nm,vfnL):=VertexEdgeFace(nm,vfnL,[]); VertexandEdge(nm,vfnL,options):=VertexEdgeFace(nm,vfnL,options); VertexEdgeFace(nm,vfnL):=VertexEdgeFace(nm,vfnL,[]); // 16.02.10 //help:VertexEdgeFace("1",[vL,fnL]); //help:VertexEdgeFace("1",["A","B","C"]); //help:VertexEdgeFace(options=["Pt=fix","Edg=geo"]); VertexEdgeFace(nm,vfnLorg,optionorg):=( regional(name3,namev,namee,namef,vfnL,options,Noflg,eqL,strL, vL,eL,enL,face,edge,vtx,vname,fixflg,edgflg,tmp,tmp1,tmp2); name3="phvef"+nm; namev="phv3d"+nm; namee="phe3d"+nm; namef="phf3d"+nm; options=optionorg; vfnL=vfnLorg; // 16.06.19from if(length(vfnL)>2, vfnL=[vfnL,[1..length(vfnL)]]; ); if(length(vfnL)==1, vfnL=[vfnL_1,[1..length(vfnL_1)]]; ); // 16.06.19until tmp=Divoptions(options); Noflg=tmp_2; eqL=tmp_5; strL=tmp_7; fixflg=1; edgflg=1; forall(eqL, tmp1=Toupper(substring(#,0,1)); tmp=indexof(#,"="); tmp2=Toupper(substring(#,tmp,length(#))); if(tmp1=="P", if(tmp2=="FREE", fixflg=0); options=remove(options,[#]); ); if(tmp1=="E", if(substring(tmp2,0,1)=="N", edgflg=0); options=remove(options,[#]); ); ); forall(strL, if(Toupper(#)=="FREE", fixflg=0; options=remove(options,[#]); ); ); vL=[]; forall(1..length(vfnL_1), vtx=vfnL_1_#; // 16.02.10 from if(isstring(vtx),vtx=parse(vtx)); // 16.06.19 if(ispoint(vtx), tmp=parse(text(vtx)+"3d"); vname=text(vtx); // tmp=parse(text(vtx)+"3d"); // tmp="v"+text(#)+"3d="+textformat(tmp,5); // parse(tmp); , vname="v"+text(#); if(fixflg==1, Putpoint3d(["v"+text(#),vtx],"fix"); ); ); vL=append(vL,vname); // 16.02.10 until ); eL=[]; forall(vfnL_2,face, forall(1..length(face), tmp1=face_#; if(#