annotate scripts/plot/private/__patch__.m @ 10569:4f2e46473153

Fix the order of calling setdata and setvertexdata for patches (bug #29549)
author David Bateman <dbateman@free.fr>
date Sun, 25 Apr 2010 20:04:02 +0200
parents 95c3e38098bf
children 131d56b6d9a3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8833
diff changeset
1 ## Copyright (C) 2007, 2008, 2009 John W. Eaton, Shai Ayal, Kai Habel
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
2 ##
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
4 ##
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6925
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6925
diff changeset
8 ## your option) any later version.
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
9 ##
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
14 ##
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6925
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6925
diff changeset
17 ## <http://www.gnu.org/licenses/>.
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
18
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8190
diff changeset
19 ## -*- texinfo -*-
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8190
diff changeset
20 ## @deftypefn {Function File} {[@var{h}, @var{fail}] =} __patch__ (@var{p}, @dots{})
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6886
diff changeset
21 ## Undocumented internal function.
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8190
diff changeset
22 ## @end deftypefn
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6886
diff changeset
23
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6886
diff changeset
24 ## __patch__ (p, x, y, c)
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6886
diff changeset
25 ## Create patch object from x and y with color c and parent p.
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
26 ## Return handle to patch object.
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
27
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
28 ## Author: Kai Habel
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
29
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
30 function [h, failed] = __patch__ (p, varargin)
7191
b48a21816f2e [project @ 2007-11-26 21:24:32 by jwe]
jwe
parents: 7189
diff changeset
31
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
32 failed = false;
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
33
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
34 if (isstruct (varargin{1}))
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
35 if (isfield (varargin{1}, "vertices") && isfield (varargin{1}, "faces"))
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
36 args{1} = "faces";
9111
David Bateman <dbateman@free.fr>
parents: 9110
diff changeset
37 args{2} = getfield(varargin{1}, "faces");
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
38 args{3} = "vertices";
9111
David Bateman <dbateman@free.fr>
parents: 9110
diff changeset
39 args{4} = getfield(varargin{1}, "vertices");
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
40 args{5} = "facevertexcdata";
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
41 if (isfield (varargin{1}, "facevertexcdata"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
42 args{6} = getfield(varargin{1}, "facevertexcdata");
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
43 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
44 args{6} = [];
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
45 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
46 args = [args; varargin(2:end)];
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
47 args = setdata (args);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
48 else
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
49 failed = true;
7020
e31f12bb9194 [project @ 2007-10-13 05:13:28 by dbateman]
dbateman
parents: 7016
diff changeset
50 endif
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
51 elseif (isnumeric (varargin{1}))
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
52 if (nargin < 3 || ! isnumeric (varargin{2}))
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
53 failed = true;
7020
e31f12bb9194 [project @ 2007-10-13 05:13:28 by dbateman]
dbateman
parents: 7016
diff changeset
54 else
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
55 x = varargin{1};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
56 y = varargin{2};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
57 iarg = 3;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
58
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
59 if (nargin > 3 && ndims (varargin{3}) == 2 && ndims (x) == 2
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
60 && size_equal(x, varargin{3}) && !ischar(varargin{3}))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
61 z = varargin{3};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
62 iarg++;
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
63 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
64 z = [];
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
65 endif
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
66
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
67 if (isvector (x))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
68 x = x(:);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
69 y = y(:);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
70 z = z(:);
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
71 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
72 args{1} = "xdata";
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
73 args{2} = x;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
74 args{3} = "ydata";
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
75 args{4} = y;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
76 args{5} = "zdata";
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
77 args{6} = z;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
78
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
79 if (isnumeric (varargin{iarg}))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
80 c = varargin{iarg};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
81 iarg++;
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
82
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
83 if (ndims (c) == 3 && size (c, 2) == 1)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
84 c = permute (c, [1, 3, 2]);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
85 endif
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
86
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
87 if (isvector (c) && numel (c) == columns (x))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
88 if (isnan (c))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
89 args{7} = "facecolor";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
90 args{8} = [1, 1, 1];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
91 args{9} = "cdata";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
92 args{10} = c;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
93 elseif (isnumeric (c))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
94 args{7} = "facecolor";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
95 args{8} = "flat";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
96 args{9} = "cdata";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
97 args{10} = c;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
98 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
99 error ("patch: color value not valid");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
100 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
101 elseif (size (c, ndims (c)) == 3)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
102 args{7} = "facecolor";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
103 args{8} = "flat";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
104 args{9} = "cdata";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
105 args{10} = c;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
106 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
107 ## Color Vectors
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
108 if (rows (c) != rows (x) || rows (c) != length (y))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
109 error ("patch: size of x, y, and c must be equal")
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
110 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
111 args{7} = "facecolor";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
112 args{8} = "interp";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
113 args{9} = "cdata";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
114 args{10} = [];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
115 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
116 endif
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
117 elseif (ischar (varargin{iarg}) && rem (nargin - iarg, 2) != 0)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
118 ## Assume that any additional argument over an even number is
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
119 ## color string.
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
120 args{7} = "facecolor";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
121 args{8} = tolower (varargin{iarg});
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
122 args{9} = "cdata";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
123 args{10} = [];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
124 iarg++;
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
125 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
126 args{7} = "facecolor";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
127 args{8} = [0, 1, 0];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
128 args{9} = "cdata";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
129 args{10} = [];
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6895
diff changeset
130 endif
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
131
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
132 args = [args, varargin(iarg:end)];
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
133 args = setvertexdata (args);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
134 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
135 else
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
136 args = varargin;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
137 if (any(cellfun (@(x) strcmpi(x,"faces") || strcmpi(x, "vertices"), args)))
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
138 args = setdata (args);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
139 else
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
140 args = setvertexdata (args);
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
141 endif
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
142 endif
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
143
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
144 if (!failed)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
145 h = __go_patch__ (p, args {:});
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
146
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
147 ## Setup listener functions
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
148 addlistener (h, "xdata", @update_data);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
149 addlistener (h, "ydata", @update_data);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
150 addlistener (h, "zdata", @update_data);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
151 addlistener (h, "cdata", @update_data);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
152
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
153 addlistener (h, "faces", @update_fvc);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
154 addlistener (h, "vertices", @update_fvc);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
155 addlistener (h, "facevertexcdata", @update_fvc);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
156 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
157 endfunction
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
158
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
159 function args = delfields(args, flds)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
160 idx = cellfun (@(x) any (strcmpi (x, flds)), args);
10569
4f2e46473153 Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents: 10549
diff changeset
161 if (rows (idx) == 1)
4f2e46473153 Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents: 10549
diff changeset
162 idx = idx | [false, idx(1:end-1)];
4f2e46473153 Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents: 10549
diff changeset
163 else
4f2e46473153 Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents: 10549
diff changeset
164 idx = idx | [false; idx(1:end-1)];
4f2e46473153 Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents: 10549
diff changeset
165 endif
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
166 args (idx) = [];
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
167 endfunction
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
168
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
169 function args = setdata (args)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
170 args = delfields (args, {"xdata", "ydata", "zdata", "cdata"});
10569
4f2e46473153 Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents: 10549
diff changeset
171 ## Remove the readonly fields as well
4f2e46473153 Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents: 10549
diff changeset
172 args = delfields (args, {"type", "uicontextmenu"});
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
173 nargs = length (args);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
174 idx = find (cellfun (@(x) strcmpi (x, "faces"), args)) + 1;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
175 if (idx > nargs)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
176 faces = [];
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
177 else
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
178 faces = args {idx};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
179 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
180 idx = find (cellfun (@(x) strcmpi (x, "vertices"), args)) + 1;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
181 if (idx > nargs)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
182 vert = [];
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
183 else
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
184 vert = args {idx};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
185 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
186 idx = find (cellfun (@(x) strcmpi (x, "facevertexcdata"), args)) + 1;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
187 if (isempty(idx) || idx > nargs)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
188 fvc = [];
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
189 else
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
190 fvc = args {idx};
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
191 endif
9118
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
192 idx = find (cellfun (@(x) strcmpi (x, "facecolor"), args)) + 1;
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
193 if (isempty(idx) || idx > nargs)
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
194 if (!isempty (fvc))
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
195 fc = "flat";
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
196 else
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
197 fc = [0, 1, 0];
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
198 endif
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
199 args = {"facecolor", fc, args{:}};
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
200 else
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
201 fc = args {idx};
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
202 endif
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
203
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
204 nr = size (faces, 2);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
205 nc = size (faces, 1);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
206 idx = faces .';
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
207 t1 = isnan (idx);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
208 if (any (t1(:)))
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
209 t2 = find (t1 != t1([2:end,end],:));
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
210 idx (t1) = idx (t2 (cell2mat (cellfun (@(x) x(1)*ones(1,x(2)),
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
211 mat2cell ([1 : nc; sum(t1)], 2, ones(1,nc)),
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
212 "UniformOutput", false))));
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
213 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
214 x = reshape (vert(:,1)(idx), size (idx));
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
215 y = reshape (vert(:,2)(idx), size (idx));
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
216 if (size(vert,2) > 2)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
217 z = reshape (vert(:,3)(idx), size (idx));
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
218 else
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
219 z = [];
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
220 endif
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
221
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
222 if (ischar (fc) && (strcmpi (fc, "flat") || strcmpi (fc, "interp")))
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
223 if (size(fvc, 1) == nc || size (fvc, 1) == 1)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
224 c = reshape (fvc, [1, size(fvc)]);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
225 else
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
226 if (size(fvc, 2) == 3)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
227 c = cat(3, reshape (fvc(idx, 1), size(idx)),
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
228 reshape (fvc(idx, 2), size(idx)),
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
229 reshape (fvc(idx, 3), size(idx)));
7020
e31f12bb9194 [project @ 2007-10-13 05:13:28 by dbateman]
dbateman
parents: 7016
diff changeset
230 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
231 c = reshape (fvc(idx), size(idx));
7020
e31f12bb9194 [project @ 2007-10-13 05:13:28 by dbateman]
dbateman
parents: 7016
diff changeset
232 endif
e31f12bb9194 [project @ 2007-10-13 05:13:28 by dbateman]
dbateman
parents: 7016
diff changeset
233 endif
e31f12bb9194 [project @ 2007-10-13 05:13:28 by dbateman]
dbateman
parents: 7016
diff changeset
234 else
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
235 c = [];
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
236 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
237 args = {"xdata", x, "ydata", y, "zdata", z, "cdata", c, args{:}};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
238 endfunction
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
239
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
240 function args = setvertexdata (args)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
241 args = delfields (args, {"vertices", "faces", "facevertexcdata"});
10569
4f2e46473153 Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents: 10549
diff changeset
242 ## Remove the readonly fields as well
4f2e46473153 Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents: 10549
diff changeset
243 args = delfields (args, {"type", "uicontextmenu"});
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
244 nargs = length (args);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
245 idx = find (cellfun (@(x) strcmpi (x, "xdata"), args)) + 1;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
246 if (idx > nargs)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
247 x = [];
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
248 else
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
249 x = args {idx};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
250 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
251 idx = find (cellfun (@(x) strcmpi (x, "ydata"), args)) + 1;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
252 if (idx > nargs)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
253 y = [];
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
254 else
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
255 y = args {idx};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
256 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
257 idx = find (cellfun (@(x) strcmpi (x, "zdata"), args)) + 1;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
258 if (isempty(idx) || idx > nargs)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
259 z = [];
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
260 else
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
261 z = args {idx};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
262 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
263 idx = find (cellfun (@(x) strcmpi (x, "cdata"), args)) + 1;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
264 if (isempty(idx) || idx > nargs)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
265 c = [];
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
266 else
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
267 c = args {idx};
7020
e31f12bb9194 [project @ 2007-10-13 05:13:28 by dbateman]
dbateman
parents: 7016
diff changeset
268 endif
9118
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
269 idx = find (cellfun (@(x) strcmpi (x, "facecolor"), args)) + 1;
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
270 if (isempty(idx) || idx > nargs)
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
271 if (!isempty (c))
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
272 fc = "flat";
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
273 else
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
274 fc = [0, 1, 0];
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
275 endif
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
276 args = {"facecolor", fc, args{:}};
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
277 else
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
278 fc = args {idx};
308311b642b2 Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents: 9111
diff changeset
279 endif
7020
e31f12bb9194 [project @ 2007-10-13 05:13:28 by dbateman]
dbateman
parents: 7016
diff changeset
280
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
281 [nr, nc] = size (x);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
282 if (!isempty (z))
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
283 vert = [x(:), y(:), z(:)];
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
284 else
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
285 vert = [x(:), y(:)];
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
286 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
287 faces = reshape (1:numel(x), rows (x), columns (x));
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
288 faces = faces';
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
289
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
290 if (ischar (fc) && (strcmpi (fc, "flat") || strcmpi (fc, "interp")))
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
291 if (ndims (c) == 3)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
292 fvc = reshape (c, size (c, 1) * size (c, 2), size(c, 3));
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
293 else
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
294 fvc = c(:);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
295 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
296 else
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
297 fvc = [];
7020
e31f12bb9194 [project @ 2007-10-13 05:13:28 by dbateman]
dbateman
parents: 7016
diff changeset
298 endif
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
299
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
300 args = {"faces", faces, "vertices", vert, "facevertexcdata", fvc, args{:}};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
301 endfunction
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
302
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
303 function update_data (h, d)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
304 update_handle (h, false);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
305 endfunction
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
306
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
307 function update_fvc (h, d)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
308 update_handle (h, true);
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
309 endfunction
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
310
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
311 function update_handle (h, isfv)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
312 persistent recursive = false;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
313
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
314 if (! recursive)
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
315 recursive = true;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
316 f = get (h);
10524
1c6ff93c025a Reimplement the other discrete distribution functions using lookup
David Bateman <dbateman@free.fr>
parents: 9896
diff changeset
317 if (isfv)
10569
4f2e46473153 Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents: 10549
diff changeset
318 set (h, setdata ([fieldnames(f), struct2cell(f)].'(:)){:});
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
319 else
10569
4f2e46473153 Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents: 10549
diff changeset
320 set (h, setvertexdata ([fieldnames(f), struct2cell(f)].'(:)){:});
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
321 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
322 recursive = false;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
323 endif
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
324 endfunction