Voxel export into stl file

29 ビュー (過去 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 Center および File ExchangeSTL (STereoLithography) についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by