1 |
function ho=isosurfq(Q,Z,m,constant,slev) |
---|
2 |
|
---|
3 |
%H = isosurfq(Q, Z, MESH, CONSTANT, SLICE_INTERVAL) |
---|
4 |
% |
---|
5 |
%INPUTS: |
---|
6 |
%Q [nn x nnv] = Scalar quantity |
---|
7 |
%Z [nn x nnv] = Vertical locations of nodes |
---|
8 |
%MESH (fem_grid_struct) = mesh information |
---|
9 |
%CONSTANT = value of scalar at isosurface |
---|
10 |
%SLICE_INTERVAL [2] = x and y interpolation interval (1e4) |
---|
11 |
% |
---|
12 |
%OUTPUT STRUCTURE: |
---|
13 |
%H = handles to the triangle, quadrilateral, pentagonal and |
---|
14 |
% hexagonal patches fo the isosurface. |
---|
15 |
% |
---|
16 |
%This code is derived from EQUISURF, available on the MATLAB web site |
---|
17 |
%and uses two mex files found therein: |
---|
18 |
% |
---|
19 |
%POLYGONS |
---|
20 |
%INTERP_EQUISURF (actually referred to as INTERP in the release, but |
---|
21 |
% this conflicts with other MATLAB routines). |
---|
22 |
|
---|
23 |
%OPNML COMPLIANT 3-19-99 CVL |
---|
24 |
|
---|
25 |
newplot; |
---|
26 |
if exist('slev')~=1; |
---|
27 |
slev=[1e4 1e4]; |
---|
28 |
elseif length(slev)==1 |
---|
29 |
slev=[slev slev]; |
---|
30 |
end |
---|
31 |
|
---|
32 |
% INTERPOLATE ONTO RECTANGULAR GRID |
---|
33 |
|
---|
34 |
R=interprect(Q,Z,m,slev); |
---|
35 |
|
---|
36 |
% PAD EDGES |
---|
37 |
|
---|
38 |
%nneighb=conv2(~isnan(R.Q(:,:,1)),ones(3),'same'); |
---|
39 |
%edgemap=nneighb.*isnan(R.Q(:,:,1))>1; |
---|
40 |
R.Q(find(isnan(R.Q)))=0*find(isnan(R.Q)); |
---|
41 |
|
---|
42 |
%for in=1:size(R.Q,3) |
---|
43 |
% R.Q(:,:,in)=R.Q(:,:,in)+... |
---|
44 |
% conv2(R.Q(:,:,in),ones(3,1),'same').*edgemap; |
---|
45 |
%end |
---|
46 |
|
---|
47 |
% DETERMINE POLYGONS OF ISOSURFACE |
---|
48 |
|
---|
49 |
[p3,p4,p5,p6] = polygons(R.Q, [], constant); |
---|
50 |
|
---|
51 |
sh = 'interp'; |
---|
52 |
|
---|
53 |
% DEFAULT PARAMETERS DRAWN FROM SURFL.M |
---|
54 |
|
---|
55 |
if nargin<6 |
---|
56 |
p = [0.55 0.6 0.4 10]; |
---|
57 |
end |
---|
58 |
|
---|
59 |
% DETERMINE VIEW CONTROLS |
---|
60 |
|
---|
61 |
[az,el] = view; |
---|
62 |
|
---|
63 |
if az==0&el==90 |
---|
64 |
az = 322.5; |
---|
65 |
el = 30; |
---|
66 |
end |
---|
67 |
|
---|
68 |
az = az * pi / 180 + pi; |
---|
69 |
el = -el * pi / 180; |
---|
70 |
v = [cos(el)*sin(az), -cos(el)*cos(az), sin(el)]; |
---|
71 |
s = [az*180/pi - 135, -el*180/pi]; |
---|
72 |
saz = s(1) * pi / 180 + pi; |
---|
73 |
sel = -s(2) * pi / 180; |
---|
74 |
s(1) = cos(sel)*sin(saz); |
---|
75 |
s(2) = -cos(sel)*cos(saz); |
---|
76 |
s(3) = sin(sel); |
---|
77 |
|
---|
78 |
view((az-pi)*180/pi, -el*180/pi); |
---|
79 |
|
---|
80 |
% NORMALIZE PARAMETERS |
---|
81 |
|
---|
82 |
p(1:3) = p(1:3) / sum(p(1:3)); |
---|
83 |
|
---|
84 |
% CALCULATE INTERPOLATED SHADINGS |
---|
85 |
|
---|
86 |
[c3,c4,c5,c6] = interp_equisurf(p3, p4, p5, p6, v, s, p); |
---|
87 |
|
---|
88 |
% BEGIN PLOT |
---|
89 |
|
---|
90 |
% Color for this value, |
---|
91 |
cmax=max(max(Q)); |
---|
92 |
cmin=min(min(Q)); |
---|
93 |
crange=cmax-cmin; |
---|
94 |
cmap=colormap; |
---|
95 |
[nc,mc]=size(cmap); |
---|
96 |
col=floor(nc*(constant-cmin)/crange); |
---|
97 |
col=cmap(col,:); |
---|
98 |
|
---|
99 |
h = []; |
---|
100 |
|
---|
101 |
for in=3:6 |
---|
102 |
eval(['p=p',num2str(in),';']) |
---|
103 |
eval(['c=c',num2str(in),';']) |
---|
104 |
|
---|
105 |
in = size(p,2); |
---|
106 |
if in > 0, |
---|
107 |
if strcmp(sh,'flat'), |
---|
108 |
c = mean(c); |
---|
109 |
end |
---|
110 |
in = in / 3; |
---|
111 |
x=p(:,1:in); |
---|
112 |
y=p(:,in+1:2*in); |
---|
113 |
z=p(:,2*in+1:3*in); |
---|
114 |
xr = interp3(R.XG,R.YG,R.ZG,R.X,x+1,y+1,z+1); |
---|
115 |
yr = interp3(R.XG,R.YG,R.ZG,R.Y,x+1,y+1,z+1); |
---|
116 |
zr = interp3(R.XG,R.YG,R.ZG,R.Z,x+1,y+1,z+1); |
---|
117 |
% h = [h;patch(xr,yr,zr,c)]; |
---|
118 |
h = [h;patch(xr,yr,zr,col)]; |
---|
119 |
end |
---|
120 |
end |
---|
121 |
|
---|
122 |
% HANDLE OUTPUT NICELY |
---|
123 |
|
---|
124 |
if nargout |
---|
125 |
ho=h; |
---|
126 |
end |
---|