Voxel export into stl file

조회 수: 18 (최근 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에서 Image Processing Toolbox에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by