function mp= Build_Fountain() % Bulid mp obj (contains models and all arguments) %% init pace=2; Pst=[-30 -30 0]-pace*0.52; Ped=[30 30 15]; Ped=FCM_dV.round_Ped(Pst,Ped,pace); maxdeep=4; order=1; viewxy=[0 15]; Shape.accessThreshold(pace/maxdeep/2/2/2);% Oa=[0 0 0]; Ra=[0 0 0]; rvec=(Ped-Pst)/pace num_cells=rvec(1)*rvec(2)*rvec(3); fprintf("num_cells: %.0f\n",num_cells);% show num of cells %% add SS lib & python path additon_path=pwd; if count(py.sys.path,additon_path) == 0 insert(py.sys.path,int32(0),additon_path); end %% assemble c0 rect_tot=Rect([4 0 0],[20 15 0]); obs_cvs=[(4:2:18)']; num_c_in_obs=length(obs_cvs); obs_cvs=[obs_cvs,obs_cvs*0+15]; obs=OBS(obs_cvs,3,[4 35 0]); % obs.addlistener('propChanged',@obs.auto_convert_cvs); % tmp_ra=RotationZ([0 0 0],[0 0 0],obs); % pla=Plane3D([0 0 15],[0 0 -1]); % pla_csg=CSG();pla_csg.init(pla); % obs_csg=CSG();obs_csg.init(tmp_ra); % obs_csg=obs_csg*pla_csg; diff3=Diff2D(obs,-3); obs_margin=(diff3-obs)*Line([4 0 0],[4 -1 0])*Line([18 0 0],[18 1 0])+Rect([18 12 0],[20 15 0]); tmp_ra=RotationZ([0 0 0],[0 0 0],obs_margin); margin_csg=CSG();margin_csg.init(tmp_ra); num_c_in_cbs=10; cbs_cvs=zeros(num_c_in_cbs,1)+2; cbs_objs=[];%% for i=[4 12 20] for j=[0 10] tmp_cbs=CBS(cbs_cvs,3,[i j 0]); cbs_objs=[cbs_objs tmp_cbs]; end end for i=[8 16] for j=[5] tmp_cbs=CBS(cbs_cvs,3,[i j 0]); cbs_objs=[cbs_objs tmp_cbs]; end end %---------------------------deal each cbs_obj center_xy=zeros(0,2); cbs_csg_objs=[];%% for i_obj=1:length(cbs_objs) cur_obj=cbs_objs(i_obj); center_xy=cat(1,center_xy,cur_obj.Oa(1:2)); tmp_ra=RotationZ([0 0 0],[0 0 0],cur_obj); tmp_CSG=CSG();tmp_CSG.init(tmp_ra); cbs_csg_objs=[cbs_csg_objs tmp_CSG]; end %--------------------------- c2d=(rect_tot-obs); %--------------------------------------------ears ear2d=Rect([-5 -25 0],[5 -19 0])+Circle([0 -25 0],5)-Circle([0 -25 0],2.5); ear_skt1=Sketch([0 0 15-3],[0 0 0],3,ear2d); ear_c1=CSG();ear_c1.init(ear_skt1); ear_skt2=Sketch([0 0 15-3],[0 0 2*pi/3],3,ear2d); ear_c2=CSG();ear_c2.init(ear_skt2); ear_skt3=Sketch([0 0 15-3],[0 0 -2*pi/3],3,ear2d);ear_c3=CSG();ear_c3.init(ear_skt3); ear_c=ear_c1+ear_c2+ear_c3; [tx,ty]=meshgrid(-1:0.1:22); ret=c2d.calSDF([tx(:) ty(:) tx(:)*0]); figure contour(tx,ty,reshape(ret,size(tx)),ShowText="on"); [tx,ty,tz]=meshgrid(-30:0.3:30); figure the_x=[tx(:) ty(:) tz(:)]; ra=RotationZ([0 0 0],[0 0 0],c2d); c=CSG();c.init(ra); union_cbs_csg=cbs_csg_objs(1); for i=2:length(cbs_csg_objs) union_cbs_csg=union_cbs_csg+cbs_csg_objs(i); end c=c-union_cbs_csg+margin_csg+ear_c; ret=c.calSDF(the_x); figure isosurface(tx,ty,tz,reshape(ret,size(tx)),0); axis equal V0=1; % time and calculate Volume tic fcmv=FCM_V(Pst,Ped,pace,maxdeep,order,@c.calSF,@(X) ones(size(X,1),1));% |||1 dV V0=fcmv.calIntegral_V(); fprintf('V0: %f ,Time: %f\n',V0,toc); %% build Dirichlet/Neumann boundary eepsD=1e-1; eepsN=1e-1; DC2d=Circle([0 -25 0],2.5)-Circle([0 -25 0],2.5-eps); DC_skt1=Sketch([0 0 15-3],[0 0 0],3,DC2d); DC_c1=CSG();DC_c1.init(DC_skt1); DC_skt2=Sketch([0 0 15-3],[0 0 2*pi/3],3,DC2d); DC_c2=CSG();DC_c2.init(DC_skt2); DC_skt3=Sketch([0 0 15-3],[0 0 -2*pi/3],3,DC2d);DC_c3=CSG();DC_c3.init(DC_skt3); Dirich_csg=DC_c1+DC_c2+DC_c3; Dirich_csg.saveAs('Dir'); Dirich_csg.judge_func=@(X) abs(X(:,1))<3 & abs(vecnorm(X(:,1:2)-[0 -25],2,2)-2.5)5 & abs(vecnorm(X(:,1:2)-[21.65 12.50],2,2)-2.5)