How do I combine two surfaces to a single surface for conversion to solid to .stl

2 次查看(过去 30 天)
I have two surfaces -- a surface of compiled Bezier surfaces and a semi-sphere. I would like to integrate these two surfaces to one for conversion to a solid, then conversion to .stl. Currently, with the code that I have, the two surfaces remain distinct and the resultant .stl is not a closed piece, which causes issues in printing. Is there some way to take these two function-based surfaces and merge/compile them to form one surface to ease surf2solid and then .stl conversion? I used one surf() fcn to display the two surfaces by combining them in a matrix with the coordinates for the surface 1 and sphere surface separated by a column of NaN.
Relevant code is as follows:
FOOT='r'
%% Insert Builder
figure (1) clf('reset')
Ax=[0 0 0 0 .42 .46 .67 .92 1.18 1.17 1.56 1.93 1.72 2.18 2.60 2.76]; Ay=[0 0.94 2.07 3.1 0.05 1.06 2.21 3.1 .24 1.12 2.15 3.1 .99 1.55 2.22 3.1]; Az=[1.219 0.466 0.19 0 1.268 0.466 0.2925 0.098 1.17 .6305 0.47 .267 1.066 1.156 1.056 .978]; Bx=[0 0 0 0 0.92 .88 1.05 1.22 1.93 1.93 1.91 2.26 2.76 2.98 3.11 3.25;]; By=[3.1 4.06 5.07 6 3.1 4.10 5.06 6 3.1 4.08 5.07 6 3.1 3.89 4.80 6;]; Bz=[0 -.049 .086 .237 .098 .0715 .105 .306 .261 .3335 .38 .53 .978 1.04 1.091 1.219]; Cx=[0 0 0 0 1.22 1.4 1.46 1.45 2.26 2.5 2.7 2.94 3.25 3.45 3.6 3.8;]; Cy=[6 7.67 9.16 10.4 6 7.76 9.17 10.4 6 7.63 9.17 10.4 6 7.56 9.13 10.4;]; Cz=[.237 .56 .708 .697 0.306 0.507 0.532 0.452 0.53 0.718 0.597 0.232 1.219 1.46 1.409 1.37;]; Dx=[0 0 0 0 1.45 1.53 1.36 1.48 2.94 3.02 2.95 2.85 3.8 3.85 3.9 3.9]; Dy=[10.4 12.76 14.91 17. 10.4 12.82 14.96 17 10.4 12.71 14.88 17. 10.4 12.61 14.92 17.]; Dz=[.697 .702 .605 .242 .452 .1145 .075 -.189 .232 .1185 -.069 -.165 1.37 1.148 .741 .3]; Ex=[0 0 0 0 1.48 1.5 1.39 1.29 2.85 2.83 2.74 2.55 3.9 3.92 3.94 3.98]; Ey=[17. 18.1 19.27 20.48 17 17.99 19.09 20.28 17. 17.89 18.52 19.44 17 17.64 18.27 18.78]; Ez=[.242 -.05 .0194 .033 -.189 -.243 -.1 .033 -.165 -.1965 -.1 .196 .3 .295 .402 .446]; Fx=[0 0 0 0 1.29 1.2 1.24 1.14 2.55 2.41 2.43 2.34 3.98 3.95 3.9 3.85]; Fy=[20.48 21.37 21.87 22.84 20.28 20.98 21.47 22.25 19.44 19.92 20.60 21.13 18.78 19.33 19.87 20.34]; Fz=[.033 .169 .6 .5 .033 .166 .6 .5 .196 .488 .5 .45 .446 .49 .5 .5]; Gx=[0 0 0 0 1.14 1.14 1.26 1.6 2.34 2.22 2.57 3.46 3.85 3.8 3.74 3.6]; Gy=[22.84 23.89 24.89 26.11 22.25 22.92 23.81 25.14 21.13 21.6 22. 22.1 20.34 20.83 21.3 21.7]; Gz=[.5 .4 .2 .9 .5 .4 .2 .723 .45 .3 .2 .8 .5 .5 .3 .55]; Nx=[-1.84 -2.44 -2.83 -2.84 -1.35 -1.61 -2.07 -2.12 -0.78 -0.88 -1.08 -1.06 0 0 0 0]; Ny=[0.86 1.59 2.49 3.1 0.24 1.2 2.2 3.1 .12 1.12 2.16 3.1 0 0.94 2.07 3.1]; Nz=[1.249 1.3 1.247 1.103 1.029 .6759 .602 .36 1.097 .5765 .282 .081 1.219 0.466 0.19 0]; Mx=[-2.84 -2.88 -2.91 -2.95 -2.12 -2.11 -2.02 -1.95 -1.06 -1.01 -0.86 -.94 0 0 0 0]; My=[3.1 4.29 5.23 6 3.1 4.25 5.20 6 3.1 4.18 5.2 6 3.1 4.06 5.07 6]; Mz=[1.103 1.187 1.402 1.354 0.36 .4545 .549 .751 .081 .1125 .186 .45 0 -.049 .086 .237]; Lx=[-2.95 -3.1 -3.34 -3.66 -1.95 -2.04 -2.17 -2.58 -.94 -1.01 -1.14 -1.28 0 0 0 0]; Ly=[6 7.55 8.98 10.4 6 7.61 9.16 10.4 6 7.71 9.17 10.4 6 7.67 9.16 10.4]; Lz=[1.354 1.704 2.081 2.359 .751 1.1955 1.4835 1.633 .45 .739 1.017 1.137 .237 .56 .708 .697;]; Kx=[-3.66 -3.73 -3.70 -4.15 -2.58 -2.71 -2.48 -2.69 -1.28 -1.2 -1.12 -1.22 0 0 0 0]; Ky=[10.4 12.79 14.93 17 10.4 12.68 14.85 17 10.4 12.81 14.91 17. 10.4 12.76 14.91 17.]; Kz=[2.359 2.325 1.849 1.463 1.633 1.6 1.293 .756 1.137 1.186 .9635 .662 .697 .702 .605 .242]; Jx=[-4.15 -4.19 -4.57 -4.45 -2.69 -2.83 -2.95 -2.99 -1.22 -1.37 -1.3 -1.54 0 0 0 0]; Jy=[17. 17.92 18.94 20.35 17 18.25 19.34 20.8 17. 18.32 19.28 20.68 17. 18.1 19.27 20.48]; Jz=[1.463 1.217 .854 .95 .756 .546 .3585 .427 .662 .457 .164 .09 .242 -.05 .0194 .033]; Ix=[-4.45 -4.59 -4.63 -4.74 -2.99 -2.94 -3.21 -3.28 -1.54 -1.53 -1.63 -1.14 0 0 0 0]; Iy=[20.35 20.92 21.49 22 20.8 21.29 21.77 22.73 20.68 21.76 22.27 23.43 20.48 21.37 21.87 22.84]; Iz=[0.95 .9 .99 .9 .427 .8035 .66 .56 .09 .4035 .65 .55 .033 .169 .6 .5]; Hx=[-4.74 -4.8 -4.8 -4.6 -3.28 -3.35 -3.68 -4.4 -1.14 -1.14 -1.58 -1.6 0 0 0 0]; Hy=[22 23.15 24. 25 22.73 23.86 25.29 26 23.43 24.67 25.59 27.13 22.84 23.89 24.89 26.11]; Hz=[.9 .81 .2 .6 .56 .46 .2 .9 .55 .45 .3 .9 .5 .4 .2 .9];
if FOOT=='r' n=1:10; a=11:21; nn=n; aa=a-10;
Gz(:,4)=Gz(:,3); Hz(:,4)=Hz(:,3);
elseif FOOT=='l' a=1:10; n=11:21; nn=n-10; aa=a;
end
%%%%%%%% PLOT FOOT SURFACE for j=1:1:11 for i=1:1:11 u=(i-1)/10; w=(j-1)/10; [Axi(i,j),Ayi(i,j),Azi(i,j)]=bez_surf(Ax,Ay,Az,u,w); [Bxi(i,j),Byi(i,j),Bzi(i,j)]=bez_surf(Bx,By,Bz,u,w); [Cxi(i,j),Cyi(i,j),Czi(i,j)]=bez_surf(Cx,Cy,Cz,u,w); [Dxi(i,j),Dyi(i,j),Dzi(i,j)]=bez_surf(Dx,Dy,Dz,u,w); [Exi(i,j),Eyi(i,j),Ezi(i,j)]=bez_surf(Ex,Ey,Ez,u,w); [Fxi(i,j),Fyi(i,j),Fzi(i,j)]=bez_surf(Fx,Fy,Fz,u,w); [Gxi(i,j),Gyi(i,j),Gzi(i,j)]=bez_surf(Gx,Gy,Gz,u,w); [Hxi(i,j),Hyi(i,j),Hzi(i,j)]=bez_surf(Hx,Hy,Hz,u,w); [Ixi(i,j),Iyi(i,j),Izi(i,j)]=bez_surf(Ix,Iy,Iz,u,w); [Jxi(i,j),Jyi(i,j),Jzi(i,j)]=bez_surf(Jx,Jy,Jz,u,w); [Kxi(i,j),Kyi(i,j),Kzi(i,j)]=bez_surf(Kx,Ky,Kz,u,w); [Lxi(i,j),Lyi(i,j),Lzi(i,j)]=bez_surf(Lx,Ly,Lz,u,w); [Mxi(i,j),Myi(i,j),Mzi(i,j)]=bez_surf(Mx,My,Mz,u,w); [Nxi(i,j),Nyi(i,j),Nzi(i,j)]=bez_surf(Nx,Ny,Nz,u,w);
%Heel cup %[HCxi(i,j), HCyi(i,j), HCzi(i,j)] = bez_surf(HCx1, HCy1, HCz1, u,w);
end end
n=1:10; a=11:21; nn=n; aa=a-10;
footx=zeros(21,71); footy=zeros(21,71); footz=zeros(21,71); footx(n,1:10)=Nxi(nn,1:10);footy(n,1:10)=Nyi(nn,1:10);footz(n,1:10)=Nzi(nn,1:10); footx(a,1:10)=Axi(aa,1:10);footy(a,1:10)=Ayi(aa,1:10);footz(a,1:10)=Azi(aa,1:10); footx(n,11:20)=Mxi(nn,1:10);footy(n,11:20)=Myi(nn,1:10);footz(n,11:20)=Mzi(nn,1:10); footx(a,11:20)=Bxi(aa,1:10);footy(a,11:20)=Byi(aa,1:10);footz(a,11:20)=Bzi(aa,1:10); footx(n,21:30)=Lxi(nn,1:10);footy(n,21:30)=Lyi(nn,1:10);footz(n,21:30)=Lzi(nn,1:10); footx(a,21:30)=Cxi(aa,1:10);footy(a,21:30)=Cyi(aa,1:10);footz(a,21:30)=Czi(aa,1:10); footx(n,31:40)=Kxi(nn,1:10);footy(n,31:40)=Kyi(nn,1:10);footz(n,31:40)=Kzi(nn,1:10); footx(a,31:40)=Dxi(aa,1:10);footy(a,31:40)=Dyi(aa,1:10);footz(a,31:40)=Dzi(aa,1:10); footx(n,41:50)=Jxi(nn,1:10);footy(n,41:50)=Jyi(nn,1:10);footz(n,41:50)=Jzi(nn,1:10); footx(a,41:50)=Exi(aa,1:10);footy(a,41:50)=Eyi(aa,1:10);footz(a,41:50)=Ezi(aa,1:10); footx(n,51:60)=Ixi(nn,1:10);footy(n,51:60)=Iyi(nn,1:10);footz(n,51:60)=Izi(nn,1:10); footx(a,51:60)=Fxi(aa,1:10);footy(a,51:60)=Fyi(aa,1:10);footz(a,51:60)=Fzi(aa,1:10); footx(n,61:71)=Hxi(nn,1:11);footy(n,61:71)=Hyi(nn,1:11);footz(n,61:71)=Hzi(nn,1:11); footx(a,61:71)=Gxi(aa,1:11);footy(a,61:71)=Gyi(aa,1:11);footz(a,61:71)=Gzi(aa,1:11);
%% Sphere piece
sphere_num=20; [X,Y,Z]=sphere(sphere_num);
Z(1:8,1:21) = 0; %is a semi-sphere
%% surface (footx) x (footy) x (footz)
%footy(I1:I2,I3:I4) = 2*Y(:,:)+15.5;
footxN = zeros(21,1); footxN(1:21,1) = NaN; footyN = zeros(21,1); footyN(1:21,1) = NaN; footzN = zeros(21,1); footzN(1:21,1) = NaN;
footzM = [footz footzN Z]; footxM = [footx footxN 2*X]; footyM = [footy footyN 2*Y+20];
hold on surf(footxM,footyM,footzM);
xlabel('x') ylabel('y') zlabel('z') axis equal
figure(2) clf('reset')
[solidx, solidy, solidz1] = surf2solid([footx], [footy], [footz]); [SX, SY,SZ] = surf2solid(2*X,2*Y,Z-0.5); solidz = zeros(27,77); solidz(3:25, 3:75) = solidz1(3:25, 3:75)-2.5;
SZ(:,1) = 6; SZ(:,2) = 6; SZ(:,26) =6; SZ(:,27) = 6;
solidxA = [solidx SX/7+1]; solidyA = [solidy SY/7+6]; solidzA = [solidz SZ/7-.3];
surf(solidxA, solidyA, solidzA);
xlabel('x') ylabel('y') zlabel('z') axis equal

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by