1 |
function vizicq4_volume(command,option) |
---|
2 |
|
---|
3 |
get_VIZICQ4_handles; |
---|
4 |
setptr(VIZICQ4_Figure,'watch') |
---|
5 |
|
---|
6 |
switch command |
---|
7 |
|
---|
8 |
case 'SelRegion' |
---|
9 |
% Mouse-driven region selection |
---|
10 |
|
---|
11 |
%FORCE AXES ROTATION OFF |
---|
12 |
set(VIZICQ4_Slicer_Rotation,'ToolTipString','Deactivate 3-D Rotation') |
---|
13 |
set(VIZICQ4_Slicer_Rotation,'String','Rotate On') |
---|
14 |
axes(VIZICQ4_Slice_Axes) |
---|
15 |
rotate3d off |
---|
16 |
|
---|
17 |
delete(findobj(VIZICQ4_Figure,'Type','line','Tag','VIZICQ4_Region_Box')) |
---|
18 |
%Make GRID Axes vis and current |
---|
19 |
% move axes off-screen |
---|
20 |
invisaxstdpos=get(VIZICQ4_LabCont,'UserData'); |
---|
21 |
axstdpos=get(VIZICQ4_DelCont,'UserData'); |
---|
22 |
set(VIZICQ4_Grid_Axes,'Position',axstdpos) |
---|
23 |
set(VIZICQ4_Slice_Axes,'Position',invisaxstdpos) |
---|
24 |
set(VIZICQ4_Grid_Axes,'Visible','on') |
---|
25 |
set(VIZICQ4_Slice_Axes,'Visible','off') |
---|
26 |
axes(VIZICQ4_Grid_Axes) |
---|
27 |
str='Click and drag mouse to select region (lower-left to upper-right)'; |
---|
28 |
vizicq4_guts('Info',str) |
---|
29 |
waitforbuttonpress; |
---|
30 |
Pt1=get(gca,'CurrentPoint'); |
---|
31 |
rbbox([get(gcf,'CurrentPoint') 0 0],get(gcf,'CurrentPoint')); |
---|
32 |
Pt2=get(gca,'CurrentPoint'); |
---|
33 |
vizicq4_guts('Info',['']) |
---|
34 |
|
---|
35 |
% Draw box around drogue grid |
---|
36 |
line([Pt1(1) Pt2(1) Pt2(1) Pt1(1) Pt1(1)],... |
---|
37 |
[Pt1(3) Pt1(3) Pt2(3) Pt2(3) Pt1(3)],'Tag','VIZICQ4_Region_Box') |
---|
38 |
|
---|
39 |
xmin=Pt1(1); |
---|
40 |
ymin=Pt1(3); |
---|
41 |
xmax=Pt2(1); |
---|
42 |
ymax=Pt2(3); |
---|
43 |
|
---|
44 |
set(VIZICQ4_Region_Xmin,'String',xmin,'Enable','on') |
---|
45 |
set(VIZICQ4_Region_Xmax,'String',xmax,'Enable','on') |
---|
46 |
set(VIZICQ4_Region_Ymin,'String',ymin,'Enable','on') |
---|
47 |
set(VIZICQ4_Region_Ymax,'String',ymax,'Enable','on') |
---|
48 |
|
---|
49 |
case 'MapScalar' |
---|
50 |
% Determine which component of the .icq4 has been selected. |
---|
51 |
state=get(VIZICQ4_icq4_select_button,'Value'); |
---|
52 |
field=[]; |
---|
53 |
for i=1:length(state) |
---|
54 |
if state{i}==1 |
---|
55 |
field=get(VIZICQ4_icq4_select_button(i),'String'); |
---|
56 |
break |
---|
57 |
end |
---|
58 |
end |
---|
59 |
if isempty(field) |
---|
60 |
vizicq4_guts('Error','No Icq4 Var selected.'); |
---|
61 |
break |
---|
62 |
end |
---|
63 |
|
---|
64 |
badlist={'HMID';'UMID';'VMID';'HOLD';'UOLD';'VOLD';'ZMID';'ZOLD'}; |
---|
65 |
if any(strcmp(badlist,field)) |
---|
66 |
vizicq4_guts('Error',['Field ' field ' not yet supported.']); |
---|
67 |
break |
---|
68 |
end |
---|
69 |
|
---|
70 |
vizicq4_guts('Error',['']); |
---|
71 |
|
---|
72 |
% If the basis is not yet computed, compute it. |
---|
73 |
basis_struct=get(VIZICQ4_Comp_Basis,'UserData'); |
---|
74 |
if isempty(basis_struct) |
---|
75 |
vizicq4_volume('CompBasis') |
---|
76 |
basis_struct=get(VIZICQ4_Comp_Basis,'UserData'); |
---|
77 |
end |
---|
78 |
|
---|
79 |
jXY=basis_struct.jXY; |
---|
80 |
X3D=basis_struct.X3D; |
---|
81 |
Y3D=basis_struct.Y3D; |
---|
82 |
Z3D=basis_struct.Z3D; |
---|
83 |
phi=basis_struct.phi; |
---|
84 |
N1=basis_struct.N1_3D; |
---|
85 |
N2=basis_struct.N2_3D; |
---|
86 |
B1=basis_struct.B1_3D; |
---|
87 |
B2=basis_struct.B2_3D; |
---|
88 |
FDZgrid=basis_struct.sgrid; |
---|
89 |
|
---|
90 |
fem_icq4_struct=get(VIZICQ4_Slice_Axes,'UserData'); |
---|
91 |
eval(['scalar=fem_icq4_struct.' eval('field') ';']) |
---|
92 |
|
---|
93 |
fem_grid_struct=get(VIZICQ4_Grid_Axes,'UserData'); |
---|
94 |
|
---|
95 |
[m,n,p]=size(X3D); |
---|
96 |
ztemp=reshape(Z3D(1,1,:),1,p)'; |
---|
97 |
S=map_scalar_mex5(phi,N1,N2,... |
---|
98 |
B1,B2,FDZgrid,... |
---|
99 |
ztemp,scalar,fem_grid_struct.e,jXY); |
---|
100 |
|
---|
101 |
% Store FD volume |
---|
102 |
set(VIZICQ4_Map_Scalar,'UserData',S) |
---|
103 |
|
---|
104 |
vizicq4_guts('Info',['Field ' field ' mapped to FD grid.']); |
---|
105 |
set(VIZICQ4_Ix_GO,'ForeGroundColor','g'); |
---|
106 |
set(VIZICQ4_Iy_GO,'ForeGroundColor','g'); |
---|
107 |
set(VIZICQ4_Iz_GO,'ForeGroundColor','g'); |
---|
108 |
set(VIZICQ4_ALL_GO,'ForeGroundColor','g'); |
---|
109 |
|
---|
110 |
case 'MakeVolume' |
---|
111 |
basis_struct=get(VIZICQ4_Comp_Basis,'UserData'); |
---|
112 |
S=get(VIZICQ4_Map_Scalar,'UserData'); |
---|
113 |
if isempty(S) |
---|
114 |
vizicq4_guts('Error','No Scalar Mapped'); |
---|
115 |
else |
---|
116 |
|
---|
117 |
% move axes off-screen |
---|
118 |
invisaxstdpos=get(VIZICQ4_LabCont,'UserData'); |
---|
119 |
axstdpos=get(VIZICQ4_DelCont,'UserData'); |
---|
120 |
set(VIZICQ4_Grid_Axes,'Position',invisaxstdpos) |
---|
121 |
set(VIZICQ4_Slice_Axes,'Position',axstdpos) |
---|
122 |
set(VIZICQ4_Grid_Axes,'Visible','off') |
---|
123 |
set(VIZICQ4_Slice_Axes,'Visible','on') |
---|
124 |
|
---|
125 |
% Get current shade setting |
---|
126 |
shadeval=find([get(VIZICQ4_Volume_Shading_Interp,'Value'); |
---|
127 |
get(VIZICQ4_Volume_Shading_Flat,'Value'); |
---|
128 |
get(VIZICQ4_Volume_Shading_Faceted,'Value')]); |
---|
129 |
|
---|
130 |
if isempty(shadeval),shadeval=3;,end |
---|
131 |
switch shadeval |
---|
132 |
case 1 |
---|
133 |
ec='none';fc='interp'; |
---|
134 |
case 2 |
---|
135 |
ec='none';fc='flat'; |
---|
136 |
case 3 |
---|
137 |
ec='flat';fc='flat'; |
---|
138 |
end |
---|
139 |
|
---|
140 |
axes(VIZICQ4_Slice_Axes) |
---|
141 |
hold on |
---|
142 |
colormap(jet(16)) |
---|
143 |
jXY=basis_struct.jXY; |
---|
144 |
X3D=basis_struct.X3D; |
---|
145 |
Y3D=basis_struct.Y3D; |
---|
146 |
Z3D=basis_struct.Z3D; |
---|
147 |
ix=eval(get(VIZICQ4_Ix,'String')); |
---|
148 |
iy=eval(get(VIZICQ4_Iy,'String')); |
---|
149 |
iz=eval(get(VIZICQ4_Iz,'String')); |
---|
150 |
xunique=X3D(1,:,1); |
---|
151 |
yunique=Y3D(:,1,1); |
---|
152 |
zunique=Z3D(1,1,:); |
---|
153 |
if any(ix>length(xunique)) |
---|
154 |
vizicq4_guts('Error',['Ix exceeds x-discretization']); |
---|
155 |
elseif any(iy>length(yunique)) |
---|
156 |
vizicq4_guts('Error',['Iy exceeds y-discretization']); |
---|
157 |
elseif any(iz>length(zunique)) |
---|
158 |
vizicq4_guts('Error',['Iz exceeds z-discretization']); |
---|
159 |
else |
---|
160 |
xslice=xunique(ix); |
---|
161 |
yslice=yunique(iy); |
---|
162 |
zslice=zunique(iz); |
---|
163 |
switch option |
---|
164 |
case 'X' |
---|
165 |
h=slice(X3D,Y3D,Z3D,S,xslice,0,0,'linear'); |
---|
166 |
l=length(h); |
---|
167 |
delete(h([l-1 l]));h([l-1 l])=[]; |
---|
168 |
case 'Y' |
---|
169 |
h=slice(X3D,Y3D,Z3D,S,0,yslice,0,'linear'); |
---|
170 |
l=length(h); |
---|
171 |
delete(h([1 l]));h([1 l])=[]; |
---|
172 |
case 'Z' |
---|
173 |
h=slice(X3D,Y3D,Z3D,S,0,0,zslice,'linear'); |
---|
174 |
delete(h(1:2));h(1:2)=[]; |
---|
175 |
case 'ALL' |
---|
176 |
h=slice(X3D,Y3D,Z3D,S,xslice,yslice,zslice,'linear'); |
---|
177 |
otherwise, |
---|
178 |
disp('Hole on Make Slice switch') |
---|
179 |
end |
---|
180 |
set(h,'Tag','VIZICQ4_Volume'); |
---|
181 |
set(h,'EdgeColor',ec,'FaceColor',fc); |
---|
182 |
end |
---|
183 |
end |
---|
184 |
|
---|
185 |
case 'CompBasis' |
---|
186 |
|
---|
187 |
fem_grid_struct=get(VIZICQ4_Grid_Axes,'UserData'); |
---|
188 |
fem_icq4_struct=get(VIZICQ4_Slice_Axes,'UserData'); |
---|
189 |
if isempty(fem_grid_struct) |
---|
190 |
vizicq4_guts('Error','No Domain Loaded'); |
---|
191 |
elseif isempty(fem_icq4_struct) |
---|
192 |
vizicq4_guts('Error','No Icq4 File Loaded'); |
---|
193 |
else |
---|
194 |
|
---|
195 |
% Set "GO!!" buttins to RED |
---|
196 |
set(VIZICQ4_Ix_GO,'ForeGroundColor','r'); |
---|
197 |
set(VIZICQ4_Iy_GO,'ForeGroundColor','r'); |
---|
198 |
set(VIZICQ4_Iz_GO,'ForeGroundColor','r'); |
---|
199 |
set(VIZICQ4_ALL_GO,'ForeGroundColor','r'); |
---|
200 |
drawnow |
---|
201 |
|
---|
202 |
vizicq4_guts('Info','Computing 3-D interp basis...'); |
---|
203 |
% Get Nx, Ny, Nz |
---|
204 |
nx=eval(get(VIZICQ4_Nx,'String')); |
---|
205 |
ny=eval(get(VIZICQ4_Ny,'String')); |
---|
206 |
nz=eval(get(VIZICQ4_Nz,'String')); |
---|
207 |
|
---|
208 |
% Get region limits from Volume Popup |
---|
209 |
minx=eval(get(VIZICQ4_Region_Xmin,'String')); |
---|
210 |
maxx=eval(get(VIZICQ4_Region_Xmax,'String')); |
---|
211 |
miny=eval(get(VIZICQ4_Region_Ymin,'String')); |
---|
212 |
maxy=eval(get(VIZICQ4_Region_Ymax,'String')); |
---|
213 |
minz=min(fem_grid_struct.z); |
---|
214 |
maxz=0; |
---|
215 |
|
---|
216 |
S=fd_cube([nx ny nz],[minx maxx miny maxy minz maxz]); |
---|
217 |
X3D=S.X3D;Y3D=S.Y3D;Z3D=S.Z3D; |
---|
218 |
X2D=squeeze(X3D(:,:,1)); |
---|
219 |
Y2D=squeeze(Y3D(:,:,1)); |
---|
220 |
|
---|
221 |
jXY=findelem(fem_grid_struct,[X2D(:) Y2D(:)]); |
---|
222 |
jXY=reshape(jXY,nx+1,ny+1); |
---|
223 |
phi=basis2d(fem_grid_struct,[X2D(:) Y2D(:)],jXY(:)) ; |
---|
224 |
|
---|
225 |
zmesh=fem_icq4_struct.ZMID; |
---|
226 |
nnv=fem_icq4_struct.nnv; |
---|
227 |
|
---|
228 |
% Get bottom depth below X2D,Y2D |
---|
229 |
temp=interp_scalar(fem_grid_struct,fem_grid_struct.z,X2D,Y2D,jXY); |
---|
230 |
zbot=reshape(temp,nx+1,ny+1); |
---|
231 |
temp=interp_scalar(fem_grid_struct,zmesh(:,nnv),X2D,Y2D,jXY); |
---|
232 |
zeta=reshape(temp,nx+1,ny+1); |
---|
233 |
|
---|
234 |
dzbl=zmesh(1,2)-zmesh(1,1); |
---|
235 |
FDZgrid=-sinegrid(zbot(:),zeta(:),nnv,dzbl); |
---|
236 |
FDZgrid=reshape(FDZgrid,nx+1,ny+1,nnv); |
---|
237 |
|
---|
238 |
N1_3D=NaN*ones(size(X3D)); |
---|
239 |
B1_3D=NaN*ones(size(X3D)); |
---|
240 |
N2_3D=NaN*ones(size(X3D)); |
---|
241 |
B2_3D=NaN*ones(size(X3D)); |
---|
242 |
|
---|
243 |
hwaitbar=waitbar(0.,'Computing Basis...'); |
---|
244 |
tic; |
---|
245 |
for i=1:(nx+1) |
---|
246 |
waitbar((i-1)/nx) |
---|
247 |
for j=1:(ny+1) |
---|
248 |
if ~isnan(jXY(i,j)) |
---|
249 |
zref=FDZgrid(i,j,:); |
---|
250 |
for k=1:nz+1 |
---|
251 |
[b2,n2,b1,n1]=basis1d2(zref,Z3D(i,j,k)); |
---|
252 |
N1_3D(i,j,k)=n1; |
---|
253 |
B1_3D(i,j,k)=b1; |
---|
254 |
N2_3D(i,j,k)=n2; |
---|
255 |
B2_3D(i,j,k)=b2; |
---|
256 |
end |
---|
257 |
end |
---|
258 |
end |
---|
259 |
end |
---|
260 |
elapsed_time=toc; |
---|
261 |
delete(hwaitbar) |
---|
262 |
|
---|
263 |
% Store basis information on "Comp Basis" button UserData |
---|
264 |
basis_struct.jXY=jXY; |
---|
265 |
basis_struct.X3D=X3D; |
---|
266 |
basis_struct.Y3D=Y3D; |
---|
267 |
basis_struct.Z3D=Z3D; |
---|
268 |
basis_struct.phi=phi; |
---|
269 |
basis_struct.sgrid=FDZgrid; |
---|
270 |
basis_struct.N1_3D=N1_3D; |
---|
271 |
basis_struct.N2_3D=N2_3D; |
---|
272 |
basis_struct.B1_3D=B1_3D; |
---|
273 |
basis_struct.B2_3D=B2_3D; |
---|
274 |
set(VIZICQ4_Comp_Basis,'UserData',basis_struct) |
---|
275 |
str=['Done: elapsed time (sec) = ' num2str(elapsed_time) '. Map Scalar.']; |
---|
276 |
vizicq4_guts('Info',str); |
---|
277 |
|
---|
278 |
% otherwise, |
---|
279 |
% vizicq4_guts('Error','No mouse selection yet enabled'); |
---|
280 |
% end |
---|
281 |
end |
---|
282 |
case 'Rotate_Toggle' |
---|
283 |
state=get(VIZICQ4_Rotation,'String'); |
---|
284 |
if strcmp(state,'Rotate On') |
---|
285 |
% move axes off-screen |
---|
286 |
invisaxstdpos=get(VIZICQ4_LabCont,'UserData'); |
---|
287 |
axstdpos=get(VIZICQ4_DelCont,'UserData'); |
---|
288 |
set(VIZICQ4_Grid_Axes,'Position',invisaxstdpos) |
---|
289 |
set(VIZICQ4_Slice_Axes,'Position',axstdpos) |
---|
290 |
set(VIZICQ4_Grid_Axes,'Visible','off') |
---|
291 |
set(VIZICQ4_Slice_Axes,'Visible','on') |
---|
292 |
set(VIZICQ4_Rotation,'String','Rotate Off') |
---|
293 |
set(VIZICQ4_Rotation,'ToolTipString','Activate 3-D Rotation') |
---|
294 |
axes(VIZICQ4_Slice_Axes) |
---|
295 |
rotate3d on |
---|
296 |
else |
---|
297 |
set(VIZICQ4_Rotation,'ToolTipString','Deactivate 3-D Rotation') |
---|
298 |
set(VIZICQ4_Rotation,'String','Rotate On') |
---|
299 |
axes(VIZICQ4_Slice_Axes) |
---|
300 |
rotate3d off |
---|
301 |
end |
---|
302 |
|
---|
303 |
case 'Reset_View' |
---|
304 |
axes(VIZICQ4_Grid_Axes);view(2) |
---|
305 |
axes(VIZICQ4_Slice_Axes);view(2) |
---|
306 |
|
---|
307 |
case 'Shading' |
---|
308 |
% move axes off-screen |
---|
309 |
invisaxstdpos=get(VIZICQ4_LabCont,'UserData'); |
---|
310 |
axstdpos=get(VIZICQ4_DelCont,'UserData'); |
---|
311 |
set(VIZICQ4_Grid_Axes,'Position',invisaxstdpos) |
---|
312 |
set(VIZICQ4_Slice_Axes,'Position',axstdpos) |
---|
313 |
set(VIZICQ4_Grid_Axes,'Visible','off') |
---|
314 |
set(VIZICQ4_Slice_Axes,'Visible','on') |
---|
315 |
axes(VIZICQ4_Slice_Axes) |
---|
316 |
switch option |
---|
317 |
case 'Flat' |
---|
318 |
shading flat |
---|
319 |
set(VIZICQ4_Volume_Shading_Faceted,'Value',0) |
---|
320 |
set(VIZICQ4_Volume_Shading_Interp,'Value',0) |
---|
321 |
case 'Interp' |
---|
322 |
shading interp |
---|
323 |
set(VIZICQ4_Volume_Shading_Faceted,'Value',0) |
---|
324 |
set(VIZICQ4_Volume_Shading_Flat,'Value',0) |
---|
325 |
case 'Faceted' |
---|
326 |
shading faceted |
---|
327 |
set(VIZICQ4_Volume_Shading_Interp,'Value',0) |
---|
328 |
set(VIZICQ4_Volume_Shading_Flat,'Value',0) |
---|
329 |
end |
---|
330 |
|
---|
331 |
case 'Pop' |
---|
332 |
% Toggle the visibility of the volume popup figure |
---|
333 |
% Get current visibility state. |
---|
334 |
state=get(VIZICQ4_Volume_Fig,'Visible'); |
---|
335 |
if strcmp(state,'on') |
---|
336 |
set(VIZICQ4_Volume_Fig,'Visible','off'); |
---|
337 |
else |
---|
338 |
set(VIZICQ4_Volume_Fig,'Visible','on'); |
---|
339 |
end |
---|
340 |
|
---|
341 |
case 'Colorbar' |
---|
342 |
delete(VIZICQ4_Colorbar_Axes) |
---|
343 |
h=axes('Parent',VIZICQ4_Figure,... |
---|
344 |
'Units','normalized',... |
---|
345 |
'Position',[.825 .15 .15 .025],... |
---|
346 |
'Tag','VIZICQ4_Colorbar_Axes'); |
---|
347 |
|
---|
348 |
axes(VIZICQ4_Slice_Axes) |
---|
349 |
colorbar(h) |
---|
350 |
set(h,'Tag','VIZICQ4_Colorbar_Axes') |
---|
351 |
|
---|
352 |
case 'DelVolume' |
---|
353 |
VIZICQ4_Slice=findobj(VIZICQ4_Slice_Axes,'Tag','VIZICQ4_Slice'); |
---|
354 |
if isempty(VIZICQ4_Slice) |
---|
355 |
vizicq4_guts('Info','No Slices to Delete'); |
---|
356 |
else |
---|
357 |
set(VIZICQ4_Rotation,'ToolTipString','Deactivate 3-D Rotation') |
---|
358 |
set(VIZICQ4_Rotation,'String','Rotate On') |
---|
359 |
rotate3d off |
---|
360 |
switch option |
---|
361 |
case 'one' |
---|
362 |
vizicq4_guts('Info','Click on Slice to Delete'); |
---|
363 |
waitforbuttonpress; |
---|
364 |
target=get(gco,'Tag'); |
---|
365 |
if strcmp(target,'VIZICQ4_Slice') |
---|
366 |
delete(gco) |
---|
367 |
else |
---|
368 |
vizicq4_guts('Info','Target NOT a VIZICQ4_Slice'); |
---|
369 |
end |
---|
370 |
case 'all' |
---|
371 |
delete(VIZICQ4_Slice) |
---|
372 |
end |
---|
373 |
end |
---|
374 |
case 'Close' |
---|
375 |
set(VIZICQ4_Volume_Fig','Visible','off') |
---|
376 |
|
---|
377 |
case 'Help' |
---|
378 |
disp('Help on Volume not yet available') |
---|
379 |
|
---|
380 |
otherwise |
---|
381 |
disp('argument fallthrough in vizicq4_volume') |
---|
382 |
end |
---|
383 |
setptr(VIZICQ4_Figure,'arrow') |
---|