-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_production_files_lc.m
220 lines (196 loc) · 8.1 KB
/
create_production_files_lc.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
function directory = create_production_files_lc(human, pattern, varargin)
%% directory = create_production_files_lc(human, pattern, [directory]) - creates production files for laser cutting
% (created by Christina M. Hein, 2019-May-15)
% (last changes by Christina M. Hein, 2019-October-28)
%
% This function creates all files necessary for the production using a
% laser cutter. The following files are created in a folder with the name
% of the object human 'Production_Files_name' in the working directory:
% - svg-files of back part, front part, label
% - object human with measurement data (for documentation)
% - optional (depending on pattern type): svg files of sleeves and cuffs,
% - variable containing dart-length (necessary for sewing)
%
%
% create_production_files_lc(human, pattern)
%
% === INPUT ARGUMENTS ===
% human = struct of type human (name, type, body dimensions)
% pattern = struct for pattern, yet filled with construction
% points and optionally with other part's basic pattern
% created by create_pattern_shirt
% directory = directory name (string)
%
% === OUTPUT ARGUMENTS ===
% directory = directory name (string)
%
%% 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
d = date;
if length(varargin)==0 % create directory name if no directory as input argument
directory = strcat(d,'_Production_Files_lc_',human.name);
else % or use directory input name
directory = varargin{1};
end
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);
% 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);
% 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);
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);
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);
end
%% create label
text = fileread('Template_Label.svg');
text = strrep(text,'Name',human.name);
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
%% copy relevant tutorials
directory = strcat(directory,'/Tutorials');
mkdir(directory);
% Important information
destination = strcat(directory,'/1_Important_information.pdf');
if strcmp(pattern.property.hemtype, 'simple_cuff')
copyfile('Tutorials_templates/01a_Important_information_cuff.pdf', destination);
elseif strcmp(pattern.property.hemtype, 'plain_hem')
copyfile('Tutorials_templates/01b_Important_information_hem.pdf', destination);
elseif strcmp(pattern.property.hemtype, 'rolled_hem')
copyfile('Tutorials_templates/01c_Important_information_rolled_hem.pdf', destination);
end
% cutting
copyfile('Tutorials_templates/02_Cut.pdf', strcat(directory,'/2_Cut.pdf'));
copyfile('Tutorials_templates/Help-Terminology_fabric_cutting.pdf', strcat(directory,'/Help-Terminology_fabric_cutting.pdf'));
% Breast dart
n=3;
if isfield(pattern.construction_points,'dart_right') % if dart exists
copyfile('Tutorials_templates/03_Breast_dart.pdf', strcat(directory,'/3_Breast_dart.pdf'));
n=n+1;
end
% shoulder seam
nstring = num2str(n);
copyfile('Tutorials_templates/04_Shoulder_seam.pdf', strcat(directory,'/',nstring, '_Cutting.pdf'));
n=n+1;
% arm seam
nstring = num2str(n);
copyfile('Tutorials_templates/05_Arm_seam.pdf', strcat(directory,'/',nstring, '_Arm_seam.pdf'));
n=n+1;
% side seam
nstring = num2str(n);
destination = strcat(directory,'/', nstring,'_Side_seam.pdf');
if strcmp(pattern.property.sleeve_length,'sleeveless')
copyfile('Tutorials_templates/07_Side_seam_without_arm.pdf', destination);
else
copyfile('Tutorials_templates/06_Side_seam_with_arm.pdf', destination);
end
n=n+1;
% neck
if ~strcmp(pattern.property.hemtype, 'rolled_hem')
nstring = num2str(n);
destination = strcat(directory,'/', nstring,'_Neck.pdf');
if strcmp(pattern.property.neckline,'round')
copyfile('Tutorials_templates/08_Round_neck.pdf', destination);
elseif strcmp(pattern.property.neckline,'v')
copyfile('Tutorials_templates/09_V_neck.pdf', destination);
end
n=n+1;
end
% hem or cuff
nstring = num2str(n);
if strcmp(pattern.property.hemtype,'simple_cuff')
copyfile('Tutorials_templates/10_Cuff.pdf', strcat(directory,'/', nstring,'_Cuff.pdf'));
elseif strcmp(pattern.property.hemtype,'plain_hem')
copyfile('Tutorials_templates/11_Hem.pdf', strcat(directory,'/', nstring,'_Hem.pdf'));
elseif strcmp(pattern.property.hemtype,'rolled_hem')
copyfile('Tutorials_templates/11_Hem.pdf', strcat(directory,'/', nstring,'_Rolled_hem.pdf'));
end
end