-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_production_files.m
142 lines (129 loc) · 5.03 KB
/
create_production_files.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
function create_production_files(human, pattern)
%% check name
% replace ä,ö,ü,ß
human.name = strrep(human.name,'ä','ae');
human.name = strrep(human.name,'ö','oe');
human.name = strrep(human.name,'ü','ue');
human.name = strrep(human.name,'ß','ss');
% check if only letters
temp = isstrprop(human.name,'alpha');
if any(~temp)
human.name(~temp)=[];
warning('Input of name: Letters are allowed, any other character was deleted.')
end
%% make directory
directory = strcat('Production_Files_',human.name);
mkdir(directory);
%% create svg-file of pattern
% front part
position = find(pattern.part_names == 'front_part');
separator = [1; find(isnan(pattern.production_pattern(:,1)) & isnan(pattern.production_pattern(:,2)))];
PL = pattern.production_pattern(separator(position):separator(position+1),:);
if isequaln(PL(end,:),[NaN NaN])% delete NaN at end of CPL
PL = PL(1:end-1,:);
end
if isequaln(PL(1,:),[NaN NaN]) % delete NaN at start of CPL
PL = PL(2:end,:);
end
PL = PL.*10; % from cm to mm
PL = [1 0; 0 -1]*PL'; PL = PL'; % mirror on x-axis
filename = fullfile(directory, 'Front_Part');
PLwriteSVG2(PL, 'fName', filename);
filename = fullfile(directory, 'Front_Part.dxf');
FID = dxf_open(filename);
dxf_polyline(FID,PL(:,1),PL(:,2),zeros(length(PL),1));
dxf_close(FID);
% back part
position = find(pattern.part_names == 'back_part');
separator = [1; find(isnan(pattern.production_pattern(:,1)) & isnan(pattern.production_pattern(:,2)))];
PL = pattern.production_pattern(separator(position):separator(position+1),:);
if isequaln(PL(end,:),[NaN NaN])% delete NaN at end of CPL
PL = PL(1:end-1,:);
end
if isequaln(PL(1,:),[NaN NaN]) % delete NaN at start of CPL
PL = PL(2:end,:);
end
PL = PL.*10; % from cm to mm
%PL = [-1 0; 0 1]*PL'; PL = PL'; % rotation 180 deg
filename = fullfile(directory, 'Back_Part');
PLwriteSVG2(PL, 'fName', filename);
filename = fullfile(directory, 'Back_Part.dxf');
FID = dxf_open(filename);
dxf_polyline(FID,PL(:,1),PL(:,2),zeros(length(PL),1));
dxf_close(FID);
% sleeve
position = find(pattern.part_names == 'sleeve');
if ~isempty(position)
separator = [1; find(isnan(pattern.production_pattern(:,1)) & isnan(pattern.production_pattern(:,2)))];
PL = pattern.production_pattern(separator(position):separator(position+1),:);
if isequaln(PL(end,:),[NaN NaN])% delete NaN at end of CPL
PL = PL(1:end-1,:);
end
if isequaln(PL(1,:),[NaN NaN]) % delete NaN at start of CPL
PL = PL(2:end,:);
end
PL = PL.*10; % from cm to mm
PL = [0 -1; 1 0]*PL'; PL = PL'; % rotation 90 deg
filename = fullfile(directory, 'Sleeve');
PLwriteSVG2(PL, 'fName', filename);
filename = fullfile(directory, 'Sleeve.dxf');
FID = dxf_open(filename);
dxf_polyline(FID,PL(:,1),PL(:,2),zeros(length(PL),1));
dxf_close(FID);
end
% cuffs neckline
position = find(pattern.part_names == 'cuffs_neckline_simple');
if ~isempty(position)
separator = [1; find(isnan(pattern.production_pattern(:,1)) & isnan(pattern.production_pattern(:,2)))];
PL = pattern.production_pattern(separator(position):separator(position+1),:);
if isequaln(PL(end,:),[NaN NaN])% delete NaN at end of CPL
PL = PL(1:end-1,:);
end
if isequaln(PL(1,:),[NaN NaN]) % delete NaN at start of CPL
PL = PL(2:end,:);
end
PL = PL.*10; % from cm to mm
filename = fullfile(directory, 'Cuffs_neckline_simple');
PLwriteSVG2(PL, 'fName', filename);
filename = fullfile(directory, 'cuffs_neckline_simple.dxf');
FID = dxf_open(filename);
dxf_polyline(FID,PL(:,1),PL(:,2),zeros(length(PL),1));
dxf_close(FID);
end
position = find(pattern.part_names == 'cuffs_neckline');
if ~isempty(position)
separator = [1; find(isnan(pattern.production_pattern(:,1)) & isnan(pattern.production_pattern(:,2)))];
PL = pattern.production_pattern(separator(position):separator(position+1),:);
if isequaln(PL(end,:),[NaN NaN])% delete NaN at end of CPL
PL = PL(1:end-1,:);
end
if isequaln(PL(1,:),[NaN NaN]) % delete NaN at start of CPL
PL = PL(2:end,:);
end
PL = PL.*10; % from cm to mm
filename = fullfile(directory, 'Cuffs_neckline');
PLwriteSVG2(PL, 'fName', filename);
filename = fullfile(directory, 'cuffs_neckline.dxf');
FID = dxf_open(filename);
dxf_polyline(FID,PL(:,1),PL(:,2),zeros(length(PL),1));
dxf_close(FID);
end
%% create label
text = fileread('Template_Label.svg');
text = strrep(text,'Name',human.name);
d = date;
text = strrep(text,'Date',d);
filename = fullfile(directory, 'Label.svg');
fileID = fopen(filename,'w');
fprintf(fileID,text);
fclose(fileID);
%% save human for documentation
fname = strcat(directory,'/',d,'_Measurement_Data',human.name);
save(fname,'human');
%% save dart length
if isfield(pattern.construction_points,'dart_right') % if dart exists
fname = strcat(directory,'/',d,'_dart_length',human.name);
dart_length = pattern.construction_dimensions.dart_length;
save(fname,'dart_length');
end
end