翻译一下%% EXAMPLE 1.- How to cut a sphere and close the base to get a semisphere % load an ascii STL sample file (STLGETFORMAT and STLREADASCII) [vertices,faces,normals,name] = stlRead('sphere_ascii.stl'); stlPlot(vertices,faces,name); % the sphere is centered in the origin % now we get a list of vertices to be deleted if (x,y,z<0) minZ = 0; [rows, ~] = find(vertices(:,3) < minZ); list = vertices(rows,:); % if we delete the list of vertices with z<0, we get an opened semisphere % (as the base is not closed) [newv,newf] = stlDelVerts(vertices,faces,list); stlPlot(newv,newf,name); % the next step is to identify a new list with the faces that are opened % (that means all the sides that belong only to a unique triangle) list = stlGetVerts(newv,newf,'opened'); % finally we generate all the new faces that are needed just to close the % base of the semisphere [vsemi,fsemi] = stlAddVerts(newv,newf,list); stlPlot(vsemi,fsemi,'closed semisphere');
时间: 2023-06-24 12:09:02 浏览: 374
示例1:如何切割一个球体并关闭底部以获得半球体
%加载一个ASCII格式的STL样本文件(STLGETFORMAT和STLREADASCII)
[vertices,faces,normals,name] = stlRead('sphere_ascii.stl');
stlPlot(vertices,faces,name);%将球体居中于原点
%现在我们获取一个顶点列表,以便删除它们
if (x,y,z<0)
minZ = 0;
[rows, ~] = find(vertices(:,3) < minZ);
list = vertices(rows,:);
end
%如果我们删除具有z<0的顶点列表,我们将得到一个打开的半球体
%(因为底部没有关闭)
[newv,newf] = stlDelVerts(vertices,faces,list);
stlPlot(newv,newf,name);
%下一步是识别一个新的面列表,这些面是打开的
%(即属于唯一三角形的所有侧面)
list = stlGetVerts(newv,newf,'opened');
%最后,我们生成所有必要的新面来关闭半球体的底部
[vsemi,fsemi] = stlAddVerts(newv,newf,list);
stlPlot(vsemi,fsemi,'closed semisphere');
阅读全文