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

### Jan Nabo (view profile)

on 11 Sep 2019
Latest activity Commented on by Jan Nabo

### Jan Nabo (view profile)

on 19 Sep 2019 at 7:11

### Jan Nabo (view profile)

clear
name='010010_XBlockBigIsoz'; %Einlesen der Datei
info=dicominfo(name); %Zugreifen auf der Datei
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

### Jan Nabo (view profile)

on 19 Sep 2019 at 6:52
Edited by Jan Nabo

### Jan Nabo (view profile)

on 19 Sep 2019 at 6:55

% 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
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
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);