Mercurial > hg > octave-nkf
comparison scripts/plot/isosurface.m @ 17078:18137205f57d
isosurface.m: Update to new version of newplot().
* scripts/plot/isosurface.m: Update to new version of newplot().
Identify function in warning messages.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 24 Jul 2013 23:12:46 -0700 |
parents | 905329f73b4a |
children | df4c4b7708a4 |
comparison
equal
deleted
inserted
replaced
17077:f8b485d09ac6 | 17078:18137205f57d |
---|---|
148 calc_colors = true; | 148 calc_colors = true; |
149 endif | 149 endif |
150 endif | 150 endif |
151 if (calc_colors) | 151 if (calc_colors) |
152 if (nargout == 2) | 152 if (nargout == 2) |
153 warning ( "Colors will be calculated, but you did not specify an output argument for it!" ); | 153 warning ("isosurface: colors will be calculated, but no output argument to receive it."); |
154 endif | 154 endif |
155 [fvc.faces, fvc.vertices, fvc.facevertexcdata] = __marching_cube__ (x, y, z, val, iso, colors); | 155 [fvc.faces, fvc.vertices, fvc.facevertexcdata] = __marching_cube__ (x, y, z, val, iso, colors); |
156 else | 156 else |
157 [fvc.faces, fvc.vertices] = __marching_cube__ (x, y, z, val, iso); | 157 [fvc.faces, fvc.vertices] = __marching_cube__ (x, y, z, val, iso); |
158 endif | 158 endif |
159 | 159 |
160 if (isempty (fvc.vertices) || isempty (fvc.faces)) | 160 if (isempty (fvc.vertices) || isempty (fvc.faces)) |
161 warning ( "The resulting triangulation is empty" ); | 161 warning ("isosurface: triangulation is empty"); |
162 endif | 162 endif |
163 | 163 |
164 switch (nargout) | 164 switch (nargout) |
165 case 0 | 165 case 0 |
166 ## plot the calculated surface | 166 ## plot the calculated surface |
167 newplot (); | 167 hax = newplot (); |
168 if (calc_colors) | 168 if (calc_colors) |
169 pa = patch ("Faces", fvc.faces, "Vertices", fvc.vertices, | 169 pa = patch ("Faces", fvc.faces, "Vertices", fvc.vertices, |
170 "FaceVertexCData", fvc.facevertexcdata, | 170 "FaceVertexCData", fvc.facevertexcdata, |
171 "FaceColor", "flat", "EdgeColor", "none"); | 171 "FaceColor", "flat", "EdgeColor", "none"); |
172 else | 172 else |
173 pa = patch ("Faces", fvc.faces, "Vertices", fvc.vertices, | 173 pa = patch ("Faces", fvc.faces, "Vertices", fvc.vertices, |
174 "FaceColor", "g", "EdgeColor", "k"); | 174 "FaceColor", "g", "EdgeColor", "k"); |
175 endif | 175 endif |
176 if (! ishold ()) | 176 if (! ishold ()) |
177 set (gca (), "view", [-37.5, 30], | 177 set (hax, "view", [-37.5, 30], |
178 "xgrid", "on", "ygrid", "on", "zgrid", "on"); | 178 "xgrid", "on", "ygrid", "on", "zgrid", "on"); |
179 endif | 179 endif |
180 case 1 | 180 case 1 |
181 varargout = {fvc}; | 181 varargout = {fvc}; |
182 case 2 | 182 case 2 |
183 varargout = {fvc.faces, fvc.vertices}; | 183 varargout = {fvc.faces, fvc.vertices}; |
198 | 198 |
199 %!shared x, y, z, val | 199 %!shared x, y, z, val |
200 %! [x, y, z] = meshgrid (0:1, 0:1, 0:1); # Points for single | 200 %! [x, y, z] = meshgrid (0:1, 0:1, 0:1); # Points for single |
201 %! val = [0, 0; 0, 0]; # cube and a 3-D | 201 %! val = [0, 0; 0, 0]; # cube and a 3-D |
202 %! val(:,:,2) = [0, 0; 1, 0]; # array of values | 202 %! val(:,:,2) = [0, 0; 1, 0]; # array of values |
203 | |
203 %!test | 204 %!test |
204 %! fv = isosurface (x, y, z, val, 0.3); | 205 %! fv = isosurface (x, y, z, val, 0.3); |
205 %! assert (isfield (fv, "vertices"), true); | 206 %! assert (isfield (fv, "vertices"), true); |
206 %! assert (isfield (fv, "faces"), true); | 207 %! assert (isfield (fv, "faces"), true); |
207 %! assert (size (fv.vertices), [3 3]); | 208 %! assert (size (fv.vertices), [3 3]); |
208 %! assert (size (fv.faces), [1 3]); | 209 %! assert (size (fv.faces), [1 3]); |
210 | |
209 %!test | 211 %!test |
210 %! fvc = isosurface (x, y, z, val, .3, y); | 212 %! fvc = isosurface (x, y, z, val, .3, y); |
211 %! assert (isfield (fvc, "vertices"), true); | 213 %! assert (isfield (fvc, "vertices"), true); |
212 %! assert (isfield (fvc, "faces"), true); | 214 %! assert (isfield (fvc, "faces"), true); |
213 %! assert (isfield (fvc, "facevertexcdata"), true); | 215 %! assert (isfield (fvc, "facevertexcdata"), true); |
214 %! assert (size (fvc.vertices), [3 3]); | 216 %! assert (size (fvc.vertices), [3 3]); |
215 %! assert (size (fvc.faces), [1 3]); | 217 %! assert (size (fvc.faces), [1 3]); |
216 %! assert (size (fvc.facevertexcdata), [3 1]); | 218 %! assert (size (fvc.facevertexcdata), [3 1]); |
219 | |
217 %!test | 220 %!test |
218 %! [f, v] = isosurface (x, y, z, val, .3); | 221 %! [f, v] = isosurface (x, y, z, val, .3); |
219 %! assert (size (f), [1 3]); | 222 %! assert (size (f), [1 3]); |
220 %! assert (size (v), [3 3]); | 223 %! assert (size (v), [3 3]); |
224 | |
221 %!test | 225 %!test |
222 %! [f, v, c] = isosurface (x, y, z, val, .3, y); | 226 %! [f, v, c] = isosurface (x, y, z, val, .3, y); |
223 %! assert (size (f), [1 3]); | 227 %! assert (size (f), [1 3]); |
224 %! assert (size (v), [3 3]); | 228 %! assert (size (v), [3 3]); |
225 %! assert (size (c), [3 1]); | 229 %! assert (size (c), [3 1]); |