Adding thickness for my 3D-object (STL-File) | There is something wrong with my 3D Plot

6 Ansichten (letzte 30 Tage)
clear
name='010010_XBlockBigIsoz'; %Einlesen der Datei
info=dicominfo(name); %Zugreifen auf der Datei
es=(info.BeamSequence.Item_1.RadiationType);
ps=(info.BeamSequence.Item_1.RadiationType);
sz=size(info.BeamSequence.Item_1.BlockSequence.Item_1.BlockData,1); % Größe der Datei
bd=(info.BeamSequence.Item_1.BlockSequence.Item_1.SourceToBlockTrayDistance)/10;
bh=(info.BeamSequence.Item_1.BlockSequence.Item_1.BlockThickness)/10;
b(:,1)=info.BeamSequence.Item_1.BlockSequence.Item_1.BlockData(1:2:sz)/10; %x-Koordinaten
b(:,2)=info.BeamSequence.Item_1.BlockSequence.Item_1.BlockData(2:2:sz)/10;
kx = -10:0.2:10;
ky = -10:0.2:10;
kz = bd:-0.1:bd-bh;
sz_x=size(kx,2);
sz_y=size(ky,2);
sz_z=size(kz,2);
bin=nan(sz_y,sz_x,sz_z);
[X,Y] = meshgrid(kx,ky);
for i=1:sz_z
x=kz(i)*b(:,1)/100;
y=kz(i)*b(:,2)/100;
xi=(x)*.8;
yi=(y)*.8;
tmp=inpolygon (X,Y,x,y);
tmp_i=inpolygon (X,Y,xi,yi);
bin(:,:,i)=xor(tmp,tmp_i);
end
%How can i add a little thickness to my 3D Object ? like 1-3 cm thickness to have a strong wall and not having a failure in my printing

Akzeptierte Antwort

Jan  Nabo
Jan Nabo am 19 Sep. 2019
Bearbeitet: Jan Nabo am 19 Sep. 2019
% adding one layer for the highest and the lowest layer (z-axis) i can close the two walls to one big wall and getting a obejct
% The object is getting smaller.. now i have to change something on my scale.. the block is only 1 cm high but in my dicom file
% it is 5 cm. Maybe changing on my dimension or my scale ? i have to try
clear
name='010010_XBlockBigIsoz'; %Einlesen der Datei
info=dicominfo(name); %Zugreifen auf der Datei
es=(info.BeamSequence.Item_1.RadiationType);
ps=(info.BeamSequence.Item_1.RadiationType);
sz=size(info.BeamSequence.Item_1.BlockSequence.Item_1.BlockData,1); % Größe der Datei
bd=(info.BeamSequence.Item_1.BlockSequence.Item_1.SourceToBlockTrayDistance)/10;
bh=(info.BeamSequence.Item_1.BlockSequence.Item_1.BlockThickness)/10;
b(:,1)=info.BeamSequence.Item_1.BlockSequence.Item_1.BlockData(1:2:sz)/10; %x-Koordinaten
b(:,2)=info.BeamSequence.Item_1.BlockSequence.Item_1.BlockData(2:2:sz)/10;
kx = -10:0.2:10;
ky = -10:0.2:10;
kz = bd:-0.1:bd-bh;
sz_x=size(kx,2);
sz_y=size(ky,2);
sz_z=size(kz,2);
bin=nan(sz_y,sz_x,sz_z);
[X,Y] = meshgrid(kx,ky);
for i=1:sz_z
x=kz(i)*b(:,1)/100;
y=kz(i)*b(:,2)/100;
xi=(x)*.8;
yi=(y)*.8;
tmp=inpolygon (X,Y,x,y);
tmp_i=inpolygon (X,Y,xi,yi);
bin(:,:,i)=xor(tmp,tmp_i);
end
bin = squeeze(bin);
[X,Y,Z] = meshgrid(kx,ky,kz); % add one layer on highest and lowest layer by filling them with zeros to close walls to one big wall
bin=smooth3(bin);
bin(:,:,1)=0;
bin(:,:,end)=0;
Oberfl = isosurface(X,Y,Z,bin(:,:,:),'verbose');
s1 = 'PHOTON';
s2 = 'ELECTRON';
tf = strcmp(es,s2);
tu = strcmp(ps,s1);
if (tf == true) %Ist es eine Elektronenstrahlung ? -> ja dann soll es hierfür speziell geglättet werden
Oberfl=smoothpatch(Oberfl,1,2); %Glättungsfaktor, wie oft soll es geglättet werden
subplot(1,2,2), patch(Oberfl,'FaceColor',[1 0 1],'EdgeAlpha',0); view(3); camlight; % Darstllung des Objekts
stlwrite('test.stl', Oberfl.faces, Oberfl.vertices);
else
%msgbox('No Electron Radiation')
if (tu == true) %Ist es eine Photonenstrahlung ? -> ja dann soll es hierfür speziell geglättet werden
Oberfl=smoothpatch(Oberfl,1,5,1,1)
subplot(1,2,2), patch(Oberfl,'FaceColor',[1 0 1],'EdgeAlpha',0); view(3); camlight;
stlwrite('test.stl', Oberfl.faces, Oberfl.vertices);
%msgbox('No PhotonRadiation');
end
end

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by