tp@0
|
1 function edpathsfile = EDB1findpathsISESx(eddatafile,lengthNspecmatrix,lengthNdiffmatrix,...
|
tp@0
|
2 singlediffcol,startindicessinglediff,endindicessinglediff,...
|
tp@0
|
3 ndecimaldivider,PointertoIRcombs,IRoriginsfrom,S,R,isou,irec,...
|
tp@0
|
4 directsound,specorder,difforder,nedgesubs,visplanesfromS,visplanesfromR,...
|
tp@0
|
5 vispartedgesfromS,vispartedgesfromR,desiredfilename)
|
tp@0
|
6 % EDB1findpathsISESx - Finds all possible paths that include direct sound, specular, diffraction.
|
tp@0
|
7 % Finds all possible paths of types direct sound, specular, diffraction
|
tp@0
|
8 % combinations of specular and diffraction.
|
tp@0
|
9 %
|
tp@0
|
10 % Input parameters:
|
tp@0
|
11 % eddatafile Taken directly from the setup-file or created automatically
|
tp@0
|
12 % lengthNspecmatrix, lengthNdiffmatrix
|
tp@0
|
13 % singlediffcol, startindicessinglediff, endindicessinglediff
|
tp@0
|
14 % ndecimaldivider, PointertoIRcombs, IRoriginsfrom
|
tp@0
|
15 % Taken directly from the ISEStree-file
|
tp@0
|
16 % S, R, isou, irec Coordinates and counter number of source and receiver, taken
|
tp@0
|
17 % from the setup file.
|
tp@0
|
18 % directsound, specorder, difforder
|
tp@0
|
19 % Taken directly from the setup-file.
|
tp@0
|
20 % nedgesubs Taken directly from the setup-file.
|
tp@0
|
21 % visplanesfromS, visplanesfromR, vispartedgesfromS, vispartedgesfromR
|
tp@0
|
22 % Taken directly from the srdatafile.
|
tp@0
|
23 % desiredfilename (optional) The desired name of the output file.
|
tp@0
|
24 % ISCOORDS (global) The matrix ISCOORDS from the ISEStreefile
|
tp@0
|
25 % POTENTIALISES (global) The matrix POTENTIALISES from the ISEStreefile
|
tp@0
|
26 % ORIGINSFROM (global)
|
tp@0
|
27 % ISESVISIBILITY (global)
|
tp@0
|
28 % IVNDIFFMATRIX (global) The list IVNDIFFMATRIX from the ISEStreefile
|
tp@0
|
29 % IVNSPECMATRIX (global)
|
tp@0
|
30 % REFLORDER (global)
|
tp@0
|
31 %
|
tp@0
|
32 % See descriptions in EDB1findISEStree, EDB1srgeo and EDB1mainISES
|
tp@0
|
33 %
|
tp@0
|
34 % Output parameters:
|
tp@0
|
35 % edpathsfile The output file name, where the output data is
|
tp@0
|
36 % stored. If the optional input parameter desiredfilename,
|
tp@0
|
37 % is given, then edpathsfile will simple repeat
|
tp@0
|
38 % this name. If desiredfilename was not specified
|
tp@0
|
39 % a file name is created by extracting the file
|
tp@0
|
40 % stem from the input parameter eddatafile, and
|
tp@0
|
41 % with '_edpaths' added.
|
tp@0
|
42 %
|
tp@0
|
43 % Output data in the edpathsfile:
|
tp@0
|
44 % pathtypevec A matrix, [ncombs,specorder], describing the
|
tp@0
|
45 % type of reflection, using 'f' for the direct
|
tp@0
|
46 % sound, 's' for specular reflection and 'd' for
|
tp@0
|
47 % diffraction.
|
tp@0
|
48 % reflpaths A matrix, [ncombs,specorder], giving the plane
|
tp@0
|
49 % and edge numbers involved in each refl. comb.
|
tp@0
|
50 % specextradata A sparse matrix, [ncombs,(specorder+1)*3]
|
tp@0
|
51 % containing the coordinates of the image source
|
tp@0
|
52 % (col 1-3), the image receiver (col 4-6)
|
tp@0
|
53 % and the coordinates of all specular hit points
|
tp@0
|
54 % (only for purely specular combinations).
|
tp@0
|
55 % edgeextradata A sparse matrix, [ncombs,(specorder*2)], with
|
tp@0
|
56 % the visibility of the involved edge, denoted
|
tp@0
|
57 % by two values between 0 and 1.
|
tp@0
|
58 % S The coordinates of the source.
|
tp@0
|
59 % R The coordinates of the receiver.
|
tp@0
|
60 % mainlistguide A matrix, [nposscombs,3], which for each row gives
|
tp@0
|
61 % 1. the number of rows in "reflpaths" and
|
tp@0
|
62 % "pathtypevec" that have one type of combination.
|
tp@0
|
63 % 2. the first row and 3. the last row
|
tp@0
|
64 % mainlistguidepattern A matrix, [nposscombs,specorder] which for each
|
tp@0
|
65 % row gives the description of each possible combination
|
tp@0
|
66 % using 'f', 's' and 'd'.
|
tp@0
|
67 % directsoundrow The value 0 or 1 indicating whether the first row in
|
tp@0
|
68 % mainlistguide & mainlistguidepattern & reflpaths & pathtypevec
|
tp@0
|
69 % contains the direct sound or not.
|
tp@0
|
70 % allspecrows A list, [1,2], containing the first and last row numbers
|
tp@0
|
71 % of mainlistguide & mainlistguidepattern that contain specular
|
tp@0
|
72 % reflections. If there are no specular reflections, allspecrows
|
tp@0
|
73 % contains [0 0].
|
tp@0
|
74 % firstdiffrow A number indicating which is the first row of mainlistguide &
|
tp@0
|
75 % mainlistguidepattern that contain a diffraction component. If
|
tp@0
|
76 % there are no diffraction components, firstdiffrow = 0.
|
tp@0
|
77 % Sinsideplanenumber The plane number that the source is directly at. If the
|
tp@0
|
78 % source is not placed directly at a plane, then
|
tp@0
|
79 % souinsideplanenumber = [];
|
tp@0
|
80 % Rinsideplanenumber The plane number that the receiver is directly at. If the
|
tp@0
|
81 % receiver is not placed directly at a plane, then
|
tp@0
|
82 % recinsideplanenumber = [];
|
tp@0
|
83 %
|
tp@0
|
84 % Uses the functions EDB1strpend EDB1directsound
|
tp@0
|
85 % EDB1speculISES EDB1diffISESx EDB1diff2ISES EDB1diffNISES
|
tp@0
|
86 %
|
tp@0
|
87 % ----------------------------------------------------------------------------------------------
|
tp@0
|
88 % This file is part of the Edge Diffraction Toolbox by Peter Svensson.
|
tp@0
|
89 %
|
tp@0
|
90 % The Edge Diffraction Toolbox is free software: you can redistribute it and/or modify
|
tp@0
|
91 % it under the terms of the GNU General Public License as published by the Free Software
|
tp@0
|
92 % Foundation, either version 3 of the License, or (at your option) any later version.
|
tp@0
|
93 %
|
tp@0
|
94 % The Edge Diffraction Toolbox is distributed in the hope that it will be useful,
|
tp@0
|
95 % but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
tp@0
|
96 % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
tp@0
|
97 %
|
tp@0
|
98 % You should have received a copy of the GNU General Public License along with the
|
tp@0
|
99 % Edge Diffraction Toolbox. If not, see <http://www.gnu.org/licenses/>.
|
tp@0
|
100 % ----------------------------------------------------------------------------------------------
|
tp@0
|
101 % Peter Svensson (svensson@iet.ntnu.no) 20050404
|
tp@0
|
102 %
|
tp@0
|
103 % edpathsfile = EDB1findpathsISES(eddatafile,...
|
tp@0
|
104 % lengthNspecmatrix,lengthNdiffmatrix,singlediffcol,startindicessinglediff,...
|
tp@0
|
105 % endindicessinglediff,ndecimaldivider,PointertoIRcombs,IRoriginsfrom,S,R,isou,irec,...
|
tp@0
|
106 % directsound,specorder,difforder,nedgesubs,visplanesfromS,visplanesfromR,...
|
tp@0
|
107 % vispartedgesfromS,vispartedgesfromR,desiredfilename);
|
tp@0
|
108
|
tp@0
|
109 global SHOWTEXT
|
tp@0
|
110 global POTENTIALISES ISCOORDS IVNDIFFMATRIX
|
tp@0
|
111 global IVNSPECMATRIX ORIGINSFROM ISESVISIBILITY REFLORDER
|
tp@0
|
112
|
tp@0
|
113 eval(['load ',eddatafile])
|
tp@0
|
114 clear cornerinfrontofplane edgeseesplane planeseesplane
|
tp@0
|
115
|
tp@0
|
116 if nargin < 22
|
tp@0
|
117 [filepath,filestem,fileext] = fileparts(eddatafile);
|
tp@0
|
118 edpathsfile = [[filepath,filesep],EDB1strpend(filestem,'_eddata'),'_',int2str(isou),'_',int2str(irec),'_edpaths.mat'];
|
tp@0
|
119 else
|
tp@0
|
120 edpathsfile = desiredfilename;
|
tp@0
|
121 end
|
tp@0
|
122
|
tp@0
|
123 nplanes = length(planeisthin);
|
tp@0
|
124
|
tp@0
|
125 pathtypevec = [];
|
tp@0
|
126 reflpaths = [];
|
tp@0
|
127 specextradata = [];
|
tp@0
|
128 edgeextradata = [];
|
tp@0
|
129 mainlistguide = [];
|
tp@0
|
130 mainlistguidepattern = [];
|
tp@0
|
131
|
tp@0
|
132 %-------------------------------------------------------
|
tp@0
|
133 % #############################
|
tp@0
|
134 % ## DIRECT SOUND ##
|
tp@0
|
135 % #############################
|
tp@0
|
136
|
tp@0
|
137 if directsound == 1
|
tp@0
|
138 if SHOWTEXT >= 2
|
tp@0
|
139 disp(' Direct sound')
|
tp@0
|
140 end
|
tp@0
|
141 dirsoundok = EDB1directsound(eddatafile,S,R,visplanesfromS,visplanesfromR);
|
tp@0
|
142 if dirsoundok == 1
|
tp@0
|
143 pathtypevec = [pathtypevec;['f',zeros(1,specorder-1)]];
|
tp@0
|
144 reflpaths = [reflpaths;zeros(1,specorder)];
|
tp@0
|
145 if specorder > 0
|
tp@0
|
146 specextradata = [specextradata;[S R zeros(1,(specorder-1)*3)]];
|
tp@0
|
147 else
|
tp@0
|
148 specextradata = [specextradata;[S R]];
|
tp@0
|
149 end
|
tp@0
|
150 edgeextradata = [edgeextradata;zeros(1,specorder*2)];
|
tp@0
|
151 mainlistguide = [1 1 1];
|
tp@0
|
152 mainlistguidepattern = ['f' ' '*ones(1,specorder-1)];
|
tp@0
|
153 directsoundrow = 1;
|
tp@0
|
154 else
|
tp@0
|
155 directsoundrow = 0;
|
tp@0
|
156 end
|
tp@0
|
157 else
|
tp@0
|
158 directsoundrow = 0;
|
tp@0
|
159 end
|
tp@0
|
160
|
tp@0
|
161 %-------------------------------------------------------
|
tp@0
|
162 % #############################
|
tp@0
|
163 % ## SPECULAR ##
|
tp@0
|
164 % #############################
|
tp@0
|
165
|
tp@0
|
166 if specorder >= 1
|
tp@0
|
167 if SHOWTEXT >= 2
|
tp@0
|
168 disp(' SPECULAR reflections')
|
tp@0
|
169 end
|
tp@0
|
170 [validISlist,validIScoords,allreflpoints,listguide,listofreflorder] = EDB1speculISES(eddatafile,...
|
tp@0
|
171 S,R,lengthNspecmatrix,specorder,visplanesfromR);
|
tp@0
|
172 [nvalidreflorders,slask] = size(listguide);
|
tp@0
|
173 for ii = 1:nvalidreflorders
|
tp@0
|
174 ncombs = listguide(ii,1);
|
tp@0
|
175 norder = listofreflorder(ii);
|
tp@0
|
176
|
tp@0
|
177 if ncombs > 0
|
tp@0
|
178 pathtypevec = [pathtypevec;['s'*ones(ncombs,norder) zeros(ncombs,specorder-norder)]];
|
tp@0
|
179 reflpaths = [reflpaths;validISlist(listguide(ii,2):listguide(ii,3),:)];
|
tp@0
|
180 if size(pathtypevec,2) > size(reflpaths,2)
|
tp@0
|
181 reflpaths = [reflpaths zeros(size(reflpaths,1),size(pathtypevec,2)-size(reflpaths,2))];
|
tp@0
|
182 end
|
tp@0
|
183 specextradata = [specextradata;[validIScoords(listguide(ii,2):listguide(ii,3),1:3) allreflpoints(listguide(ii,2):listguide(ii,3),:)]];
|
tp@0
|
184 if size(specextradata,2) < (size(pathtypevec,2)+1)*3
|
tp@0
|
185 specextradata = [specextradata zeros(size(specextradata,1),(size(pathtypevec,2)+1)*3-size(specextradata,2))];
|
tp@0
|
186 end
|
tp@0
|
187 edgeextradata = [edgeextradata;zeros(ncombs,specorder*2)];
|
tp@0
|
188 end
|
tp@0
|
189
|
tp@0
|
190 mainlistguidepattern = [mainlistguidepattern;['s'*ones(1,norder) ' '*ones(1,specorder-norder)]];
|
tp@0
|
191
|
tp@0
|
192 end
|
tp@0
|
193
|
tp@0
|
194 [nprevious,slask] = size(mainlistguide);
|
tp@0
|
195 if nprevious > 0
|
tp@0
|
196 listguide(:,2:3) = listguide(:,2:3)+mainlistguide(nprevious,3);
|
tp@0
|
197 end
|
tp@0
|
198 mainlistguide = [mainlistguide;listguide];
|
tp@0
|
199 if nvalidreflorders == 0
|
tp@0
|
200 allspecrows = [0 0];
|
tp@0
|
201 else
|
tp@0
|
202 allspecrows = [min([1 nvalidreflorders]) nvalidreflorders]+directsoundrow;
|
tp@0
|
203 end
|
tp@0
|
204 firstdiffrow = nvalidreflorders + directsoundrow + 1;
|
tp@0
|
205
|
tp@0
|
206 else
|
tp@0
|
207 allspecrows = [0 0];
|
tp@0
|
208 firstdiffrow = directsoundrow + 1;
|
tp@0
|
209 end
|
tp@0
|
210
|
tp@0
|
211 %-------------------------------------------------------
|
tp@0
|
212 % ####################################
|
tp@0
|
213 % ## SINGLE DIFFRACTION ##
|
tp@0
|
214 % ####################################
|
tp@0
|
215
|
tp@0
|
216 if difforder >=1 & ~isempty(lengthNdiffmatrix)
|
tp@0
|
217 if SHOWTEXT >= 2
|
tp@0
|
218 disp(' SINGLE DIFFRACTION combined with any order specular')
|
tp@0
|
219 end
|
tp@0
|
220 [edgedifflist,startandendpoints,prespeclist,postspeclist,validISEDcoords,validEDIRcoords,listguide,listoforders,...
|
tp@0
|
221 bigedgeweightlist] = EDB1diffISESx(eddatafile,S,R,...
|
tp@0
|
222 IVNDIFFMATRIX(1:lengthNdiffmatrix(1),1),singlediffcol,startindicessinglediff,endindicessinglediff,...
|
tp@0
|
223 specorder,visplanesfromR,vispartedgesfromS,vispartedgesfromR,nedgesubs,ndecimaldivider,PointertoIRcombs,IRoriginsfrom);
|
tp@0
|
224 [nvalidcombs,slask] = size(listguide);
|
tp@0
|
225 nprespecs = listoforders(:,2) - 1;
|
tp@0
|
226 npostspecs = listoforders(:,1) - nprespecs - 1;
|
tp@0
|
227
|
tp@0
|
228 [nrows,nsubsegmentcols] = size(startandendpoints);
|
tp@0
|
229 nsubsegments = uint8( (startandendpoints(:,2:2:nsubsegmentcols))~=0 );
|
tp@0
|
230
|
tp@0
|
231 if nrows > 1 & nsubsegmentcols > 2
|
tp@0
|
232 nsubsegments = sum(nsubsegments.').';
|
tp@0
|
233 end
|
tp@0
|
234 nmaxsubsegments = max(nsubsegments);
|
tp@0
|
235
|
tp@0
|
236 expandedlistguide = listguide;
|
tp@0
|
237 for ii = 1:nvalidcombs
|
tp@0
|
238 ncombs = listguide(ii,1);
|
tp@0
|
239 iv = [listguide(ii,2):listguide(ii,3)];
|
tp@0
|
240
|
tp@0
|
241 pathtypevec = [pathtypevec; ['s'*ones(ncombs,nprespecs(ii)) 'd'*ones(ncombs,1) 's'*ones(ncombs,npostspecs(ii)) zeros(ncombs,specorder-listoforders(ii)) ]];
|
tp@0
|
242 reflpaths = [reflpaths; [prespeclist(iv,1:nprespecs(ii)) edgedifflist(iv) postspeclist(iv,1:npostspecs(ii)) zeros(ncombs,specorder-listoforders(ii)) ]];
|
tp@0
|
243 specextradata = [specextradata;[ validISEDcoords(iv,1:3) validEDIRcoords(iv,1:3) zeros(ncombs,(specorder-1)*3) ]];
|
tp@0
|
244 edgeextradata = [edgeextradata;[startandendpoints(iv,1:2) zeros(ncombs,(specorder-1)*2) ]];
|
tp@0
|
245 mainlistguidepattern = [mainlistguidepattern;['s'*ones(1,nprespecs(ii)) 'd' 's'*ones(1,npostspecs(ii)) zeros(1,specorder-listoforders(ii))]];
|
tp@0
|
246 if nmaxsubsegments > 2
|
tp@0
|
247 for jj = 2:nmaxsubsegments
|
tp@0
|
248 ivsub = find(nsubsegments(iv)>=jj);
|
tp@0
|
249 ncombssubset = length(ivsub);
|
tp@0
|
250 if ncombssubset > 0
|
tp@0
|
251 pathtypevec = [pathtypevec; ['s'*ones(ncombssubset,nprespecs(ii)) 'd'*ones(ncombssubset,1) 's'*ones(ncombssubset,npostspecs(ii)) zeros(ncombssubset,specorder-listoforders(ii)) ]];
|
tp@0
|
252 reflpaths = [reflpaths; [prespeclist(iv(ivsub),1:nprespecs(ii)) edgedifflist(iv(ivsub)) postspeclist(iv(ivsub),1:npostspecs(ii)) zeros(ncombssubset,specorder-listoforders(ii)) ]];
|
tp@0
|
253 specextradata = [specextradata;[ validISEDcoords(iv(ivsub),1:3) validEDIRcoords(iv(ivsub),1:3) zeros(ncombssubset,(specorder-1)*3) ]];
|
tp@0
|
254 edgeextradata = [edgeextradata;[startandendpoints(iv(ivsub),(jj-1)*2+1:(jj-1)*2+2) zeros(ncombssubset,(specorder-1)*2) ]];
|
tp@0
|
255 expandedlistguide(ii,1) = expandedlistguide(ii,1) + ncombssubset;
|
tp@0
|
256 expandedlistguide(ii,3) = expandedlistguide(ii,3) + ncombssubset;
|
tp@0
|
257 for kk = ii+1:nvalidcombs
|
tp@0
|
258 expandedlistguide(kk,2:3) = expandedlistguide(kk,2:3) + ncombssubset;
|
tp@0
|
259 end
|
tp@0
|
260 end
|
tp@0
|
261 end
|
tp@0
|
262 end
|
tp@0
|
263 end
|
tp@0
|
264 [n1,n2] = size(mainlistguide);
|
tp@0
|
265 if n1 > 0
|
tp@0
|
266 listoffset = mainlistguide(n1,3);
|
tp@0
|
267 else
|
tp@0
|
268 listoffset = 0;
|
tp@0
|
269 end
|
tp@0
|
270 if size(expandedlistguide,1) > 0
|
tp@0
|
271 mainlistguide = [mainlistguide;[expandedlistguide(:,1) expandedlistguide(:,2:3)+listoffset]];
|
tp@0
|
272 end
|
tp@0
|
273 end
|
tp@0
|
274
|
tp@0
|
275 %-------------------------------------------------------
|
tp@0
|
276 % ################################################
|
tp@0
|
277 % ## DOUBLE AND HIGHER DIFFRACTION ##
|
tp@0
|
278 % ################################################
|
tp@0
|
279
|
tp@0
|
280 for kk = 2:min([specorder difforder])
|
tp@0
|
281
|
tp@0
|
282 if ~isempty(lengthNdiffmatrix)
|
tp@0
|
283
|
tp@0
|
284 if SHOWTEXT >= 2
|
tp@0
|
285 disp([' DIFFRACTION, ORDER ',int2str(kk),' combined with any order specular'])
|
tp@0
|
286 end
|
tp@0
|
287
|
tp@0
|
288 nmaxsubsegments = 0;
|
tp@0
|
289
|
tp@0
|
290 % We will use the spec-edge-spec combs that were found valid for
|
tp@0
|
291 % first-order diffraction, because if higher-order diffraction combs
|
tp@0
|
292 % end with the same edge-spec-spec-... comb we know the visibility
|
tp@0
|
293 % already.
|
tp@0
|
294 % First, pick out only the combs that have postspecs. Second, keep
|
tp@0
|
295 % only a unique set because there will be many repeated combinations.
|
tp@0
|
296
|
tp@0
|
297
|
tp@0
|
298 if kk == 2
|
tp@0
|
299 iv = find(sum(postspeclist.')>0 );
|
tp@0
|
300 edgedifflist = edgedifflist(iv,:);
|
tp@0
|
301 postspeclist = postspeclist(iv,:);
|
tp@0
|
302 bigedgeweightlist = bigedgeweightlist(iv,:);
|
tp@0
|
303 validEDIRcoords = validEDIRcoords(iv,:);
|
tp@0
|
304
|
tp@0
|
305 patternthatisOK = [edgedifflist postspeclist];
|
tp@0
|
306 [patternthatisOK,iv,slask] = unique(patternthatisOK,'rows');
|
tp@0
|
307 edgedifflistin = edgedifflist(iv,:);
|
tp@0
|
308 postspeclistin = postspeclist(iv,:);
|
tp@0
|
309 bigedgeweightlistin = bigedgeweightlist(iv,:);
|
tp@0
|
310 validEDIRcoordsin = validEDIRcoords(iv,:);
|
tp@0
|
311
|
tp@0
|
312 end
|
tp@0
|
313
|
tp@0
|
314 if kk == 2
|
tp@0
|
315 maxrownumber = max(lengthNdiffmatrix(1:2));
|
tp@0
|
316 [edgedifflist,startandendpoints,prespeclist,midspeclist,postspeclist,validISEDcoords,validEDIRcoords,listguide,listofallspecs] = EDB1diff2ISES(eddatafile,S,R,...
|
tp@0
|
317 IVNDIFFMATRIX(1:maxrownumber,1:2),lengthNdiffmatrix(1:2),...
|
tp@0
|
318 specorder,visplanesfromR,vispartedgesfromS,vispartedgesfromR,nedgesubs,ndecimaldivider,edgedifflistin,postspeclistin,...
|
tp@0
|
319 bigedgeweightlistin,validEDIRcoordsin,edgeplaneperptoplane1,edgeplaneperptoplane2);
|
tp@0
|
320
|
tp@0
|
321 [nrows,nsubsegmentcols] = size(startandendpoints);
|
tp@0
|
322 nsubsegments = uint8((startandendpoints(:,2:4:nsubsegmentcols))~=0);
|
tp@0
|
323 if nrows > 1 & nsubsegmentcols > 4
|
tp@0
|
324 nsubsegments = sum(nsubsegments.').';
|
tp@0
|
325 end
|
tp@0
|
326 nmaxsubsegments = max(nsubsegments);
|
tp@0
|
327
|
tp@0
|
328 elseif kk >= 3
|
tp@0
|
329 maxrownumber = max(lengthNdiffmatrix(1:kk));
|
tp@0
|
330
|
tp@0
|
331 [edgedifflist,startandendpoints,prespeclist,postspeclist,validISEDcoords,validEDIRcoords,listguide,listoforders] = EDB1diffNISES(eddatafile,S,R,...
|
tp@0
|
332 IVNDIFFMATRIX(1:maxrownumber,1:kk),lengthNdiffmatrix(1:kk),kk,...
|
tp@0
|
333 specorder,visplanesfromR,vispartedgesfromS,vispartedgesfromR,nedgesubs,ndecimaldivider,edgedifflistin,postspeclistin,...
|
tp@0
|
334 bigedgeweightlistin,validEDIRcoordsin);
|
tp@0
|
335 end
|
tp@0
|
336
|
tp@0
|
337 [nvalidcombs,slask] = size(listguide);
|
tp@0
|
338 if kk >= 3
|
tp@0
|
339 nprespecs = listoforders(:,2) - 1;
|
tp@0
|
340 npostspecs = listoforders(:,1) - nprespecs - kk;
|
tp@0
|
341 else
|
tp@0
|
342 nprespecs = listofallspecs(:,1);
|
tp@0
|
343 nmidspecs = listofallspecs(:,2);
|
tp@0
|
344 npostspecs = listofallspecs(:,3);
|
tp@0
|
345 listoforders = nprespecs+nmidspecs+npostspecs+2;
|
tp@0
|
346 end
|
tp@0
|
347
|
tp@0
|
348 for ii = 1:nvalidcombs
|
tp@0
|
349 ncombs = listguide(ii,1);
|
tp@0
|
350 i1 = listguide(ii,2); i2 = listguide(ii,3);
|
tp@0
|
351 if kk == 2
|
tp@0
|
352 pathtypevec = [pathtypevec; ['s'*ones(ncombs,nprespecs(ii)) 'd'*ones(ncombs,1) 's'*ones(ncombs,nmidspecs(ii)) 'd'*ones(ncombs,1) 's'*ones(ncombs,npostspecs(ii)) zeros(ncombs,specorder-listoforders(ii)) ]];
|
tp@0
|
353 else
|
tp@0
|
354 pathtypevec = [pathtypevec; ['s'*ones(ncombs,nprespecs(ii)) 'd'*ones(ncombs,kk) 's'*ones(ncombs,npostspecs(ii)) zeros(ncombs,specorder-listoforders(ii)) ]];
|
tp@0
|
355 end
|
tp@0
|
356
|
tp@0
|
357 if kk == 2
|
tp@0
|
358 reflpaths = [reflpaths; [prespeclist(i1:i2,1:nprespecs(ii)) edgedifflist(i1:i2,1) midspeclist(i1:i2,1:nmidspecs(ii)) edgedifflist(i1:i2,2) postspeclist(i1:i2,1:npostspecs(ii)) zeros(ncombs,specorder-listoforders(ii)) ]];
|
tp@0
|
359 else
|
tp@0
|
360 reflpaths = [reflpaths; [prespeclist(i1:i2,1:nprespecs(ii)) edgedifflist(i1:i2,1:kk) postspeclist(i1:i2,1:npostspecs(ii)) zeros(ncombs,specorder-listoforders(ii)) ]];
|
tp@0
|
361 end
|
tp@0
|
362
|
tp@0
|
363 specextradata = [specextradata;[ validISEDcoords(i1:i2,1:3) validEDIRcoords(i1:i2,1:3) zeros(ncombs,(specorder-1)*3) ]];
|
tp@0
|
364 edgeextradata = [edgeextradata;[startandendpoints(i1:i2,1:kk*2) zeros(ncombs,(specorder-kk)*2) ]];
|
tp@0
|
365 if kk == 2
|
tp@0
|
366 mainlistguidepattern = [mainlistguidepattern;['s'*ones(1,nprespecs(ii)) 'd' 's'*ones(1,nmidspecs(ii)) 'd' 's'*ones(1,npostspecs(ii)) zeros(1,specorder-listoforders(ii))]];
|
tp@0
|
367 else
|
tp@0
|
368 mainlistguidepattern = [mainlistguidepattern;['s'*ones(1,nprespecs(ii)) 'd'*ones(1,kk) 's'*ones(1,npostspecs(ii)) zeros(1,specorder-listoforders(ii))]];
|
tp@0
|
369 end
|
tp@0
|
370
|
tp@0
|
371 for jj = 2:nmaxsubsegments
|
tp@0
|
372 ivsub = find(nsubsegments(iv)>=jj);
|
tp@0
|
373 ncombssubset = length(ivsub);
|
tp@0
|
374 if ncombssubset > 0
|
tp@0
|
375 pathtypevec = [pathtypevec; ['s'*ones(ncombssubset,nprespecs(ii)) 'd'*ones(ncombssubset,1) 's'*ones(ncombssubset,nmidspecs(ii)) 'd'*ones(ncombssubset,1) 's'*ones(ncombssubset,npostspecs(ii)) zeros(ncombssubset,specorder-listoforders(ii)) ]];
|
tp@0
|
376 reflpaths = [reflpaths; [prespeclist(iv(ivsub),1:nprespecs(ii)) edgedifflist(iv(ivsub),1) midspeclist(iv(ivsub),1:nmidspecs(ii)) edgedifflist(iv(ivsub),2) postspeclist(iv(ivsub),1:npostspecs(ii)) zeros(ncombssubset,specorder-listoforders(ii)) ]];
|
tp@0
|
377 specextradata = [specextradata;[ validISEDcoords(iv(ivsub),1:3) validEDIRcoords(iv(ivsub),1:3) zeros(ncombssubset,(specorder-1)*3) ]];
|
tp@0
|
378 edgeextradata = [edgeextradata;[startandendpoints(iv(ivsub),(jj-1)*4+1:(jj-1)*4+4) zeros(ncombssubset,(specorder-1)*4) ]];
|
tp@0
|
379 expandedlistguide(ii,1) = expandedlistguide(ii,1) + ncombssubset;
|
tp@0
|
380 expandedlistguide(ii,3) = expandedlistguide(ii,3) + ncombssubset;
|
tp@0
|
381 for kk = ii+1:nvalidcombs
|
tp@0
|
382 expandedlistguide(kk,2:3) = expandedlistguide(kk,2:3) + ncombssubset;
|
tp@0
|
383 end
|
tp@0
|
384 end
|
tp@0
|
385 end
|
tp@0
|
386
|
tp@0
|
387 end
|
tp@0
|
388
|
tp@0
|
389 [n1,n2] = size(mainlistguide);
|
tp@0
|
390 if n1 > 0
|
tp@0
|
391 listoffset = mainlistguide(n1,3);
|
tp@0
|
392 else
|
tp@0
|
393 listoffset = 0;
|
tp@0
|
394 end
|
tp@0
|
395 mainlistguide = [mainlistguide;[listguide(:,1) listguide(:,2:3)+listoffset]];
|
tp@0
|
396
|
tp@0
|
397 end
|
tp@0
|
398
|
tp@0
|
399 end
|
tp@0
|
400
|
tp@0
|
401 [n1,n2] = size(mainlistguide);
|
tp@0
|
402 if firstdiffrow > n1
|
tp@0
|
403 firstdiffrow = 0;
|
tp@0
|
404 end
|
tp@0
|
405
|
tp@0
|
406 %-------------------------------------------------------
|
tp@0
|
407 % Is the source or receiver directly at a plane?
|
tp@0
|
408
|
tp@0
|
409 Sinsideplanenumber = find(visplanesfromS==4);
|
tp@0
|
410
|
tp@0
|
411 Rinsideplanenumber = find(visplanesfromR==4);
|
tp@0
|
412
|
tp@0
|
413 %-------------------------------------------------------
|
tp@0
|
414 % Get rid of empty columns
|
tp@0
|
415
|
tp@0
|
416 if ~isempty(pathtypevec)
|
tp@0
|
417 checksum = sum(pathtypevec);
|
tp@0
|
418 ncols = length(checksum);
|
tp@0
|
419 while checksum(ncols) == 0
|
tp@0
|
420 pathtypevec(:,ncols) = [];
|
tp@0
|
421 checksum = sum(pathtypevec);
|
tp@0
|
422 ncols = length(checksum);
|
tp@0
|
423 end
|
tp@0
|
424 end
|
tp@0
|
425
|
tp@0
|
426 %-------------------------------------------------------
|
tp@0
|
427 % Save the output data
|
tp@0
|
428
|
tp@0
|
429 specextradata = sparse(specextradata);
|
tp@0
|
430 edgeextradata = sparse(edgeextradata);
|
tp@0
|
431 pathtypevec = uint8(pathtypevec);
|
tp@0
|
432 [ncombs,slask] = size(reflpaths);
|
tp@0
|
433 if ncombs+1 < 256
|
tp@0
|
434 mainlistguide = uint8(mainlistguide);
|
tp@0
|
435 elseif ncombs+1 < 65536
|
tp@0
|
436 mainlistguide = uint16(mainlistguide);
|
tp@0
|
437 else
|
tp@0
|
438 mainlistguide = uint32(mainlistguide);
|
tp@0
|
439 end
|
tp@0
|
440
|
tp@0
|
441 Varlist = [' pathtypevec reflpaths specextradata edgeextradata S R mainlistguide mainlistguidepattern directsoundrow allspecrows firstdiffrow Sinsideplanenumber Rinsideplanenumber'];
|
tp@0
|
442
|
tp@0
|
443 eval(['save ',edpathsfile,Varlist])
|