clc;
clear all;

numOFpc = 7

for i = 1:numOFpc

filename = sprintf("%02d.xyz", i)

cloud = dlmread(filename,' '); # Naèti xyz file.
cloud = cloud(:,1:3);
numOFpoints = size(cloud,1)

cloudCUT1 = cloud(cloud(:,1)>120 & cloud(:,1)<200 & cloud(:,2)>-25 & cloud(:,2)<70, :);
cloudCUT2 = cloud(cloud(:,1)>30 & cloud(:,1)<50 & cloud(:,2)>-45 & cloud(:,2)<10, :);
##cloudCUT3 = cloud(cloud(:,1)>95 & cloud(:,1)<141 & cloud(:,2)>120 & cloud(:,2)<156, :);

filename1 = sprintf("%02d_cut1.xyz", i)
filename2 = sprintf("%02d_cut2.xyz", i)
##filename3 = sprintf("%02d_cut3.xyz", i)

dlmwrite (filename1, cloudCUT1, " ")
dlmwrite (filename2, cloudCUT2, " ")
##dlmwrite (filename3, cloudCUT3, " ")

disp ("xyz saved")

endfor