Voxel export into stl file

11 次查看(过去 30 天)
Hege
Hege 2020-6-27
评论: M.S. Khan 2020-8-28
I developed 3D matric as per my intention as below and now I want to export it to a STL file and view it. As I am new to the Matlab I downloaded the code from https://uk.mathworks.com/matlabcentral/fileexchange/27733-converting-a-3d-logical-array-into-an-stl-surface-mesh?focused=5235499&tab=function (Used the convert voxels to stl example file) and tried to develop my function. But I could not successful as there was a error with a mat.file. I tried to rectify the mat.file issue.Still unsuccessful.
My SUCCESSFUL voxel code
% Building the 10X10X10 Voxel Cube
B=zeros(10,10,10);
B([1,10],:,:)=1;
B(:,[1,10],:)=1;
B(:,:,[1,10])=1;
nnz(B==1)
nnz(B==0)
My UNSUCCESSFUL voxel conversion to stl code
%Load an example dataset. The contents are as follows:
% gridDATA 30x30x30 216000 double array
% gridX 1x30 240 double array
% gridY 1x30 240 double array
% gridZ 1x30 240 double array
load ('cube.mat','B')
%Convert the binary data to an STL mesh:
[faces,vertices] = CONVERT_voxels_to_stl('temp.stl',gridINPUT,gridX,gridY,gridZ,'ascii');
%Plot the original data:
figure;
imagesc(squeeze(sum(gridINPUT,3)));
colormap(gray);
axis equal tight
%Load and plot the stl file:
figure
[stlcoords] = READ_stl('temp.stl');
xco = squeeze( stlcoords(:,1,:) )';
yco = squeeze( stlcoords(:,2,:) )';
zco = squeeze( stlcoords(:,3,:) )';
[hpat] = patch(xco,yco,zco,'b');
axis equal
Note== Always error in load command!!. I downloaded this code from the above link and trying to match for my work.
Appreciate your comments

回答(1 个)

darova
darova 2020-6-28
What about isosurface?
clc,clear
clf
r = 10;
[x,y,z] = meshgrid(-r:r);
v = x.^2+y.^2+z.^2<r^2;
h = isosurface(x,y,z,v,0.9);
patch(h,'facecolor','r')
axis vis3d
  1 个评论
M.S. Khan
M.S. Khan 2020-8-28
Hi Darova, how i want to apply on cone. Please guide me. Regards

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by