annotate scripts/plot/draw/private/__patch__.m @ 21261:f982cfe3df03

When concatenating cells, suppress empty matrices (bug #43511). * pt-mat.cc (cellify): Replace [] by {}, not by {[]}. * __patch__.m: Change concatenation to guarantee reproducibility.
author Lachlan <lachlanbis@gmail.com>
date Tue, 26 Jan 2016 15:52:21 +1100
parents 516bb87ea72e
children ffad2baa90f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
1 ## Copyright (C) 2007-2015 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 -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20735
diff changeset
20 ## @deftypefn {} {[@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
13954
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
32 h = NaN;
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
33 failed = false;
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
34
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
35 is_numeric_arg = cellfun (@isnumeric, varargin);
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
36
13115
cd808de114c1 Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents: 12931
diff changeset
37 if (isempty (varargin))
18901
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18894
diff changeset
38 args = varargin;
13115
cd808de114c1 Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents: 12931
diff changeset
39 elseif (isstruct (varargin{1}))
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 if (isfield (varargin{1}, "vertices") && isfield (varargin{1}, "faces"))
20380
85dcbed19753 Pass all fields in face/vertex structure through to patch() (bug #45593).
Rik <rik@octave.org>
parents: 19833
diff changeset
41 fvs = varargin{1};
85dcbed19753 Pass all fields in face/vertex structure through to patch() (bug #45593).
Rik <rik@octave.org>
parents: 19833
diff changeset
42 fvc = cell (1, 2*numfields (fvs));
85dcbed19753 Pass all fields in face/vertex structure through to patch() (bug #45593).
Rik <rik@octave.org>
parents: 19833
diff changeset
43 fvc(1:2:end) = fieldnames (fvs);
85dcbed19753 Pass all fields in face/vertex structure through to patch() (bug #45593).
Rik <rik@octave.org>
parents: 19833
diff changeset
44 fvc(2:2:end) = struct2cell (fvs);
21261
f982cfe3df03 When concatenating cells, suppress empty matrices (bug #43511).
Lachlan <lachlanbis@gmail.com>
parents: 20852
diff changeset
45 args = [fvc(:)', varargin(2:end)];
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
46 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
47 failed = true;
7020
e31f12bb9194 [project @ 2007-10-13 05:13:28 by dbateman]
dbateman
parents: 7016
diff changeset
48 endif
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
49 elseif (is_numeric_arg(1))
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
50 if (nargin < 3 || ! is_numeric_arg(2))
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 failed = true;
7020
e31f12bb9194 [project @ 2007-10-13 05:13:28 by dbateman]
dbateman
parents: 7016
diff changeset
52 else
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
53 if (nargin > 4 && all (is_numeric_arg(1:4)))
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
54 x = varargin{1};
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
55 y = varargin{2};
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
56 z = varargin{3};
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
57 c = varargin{4};
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
58 iarg = 5;
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
59 elseif (nargin > 3 && all (is_numeric_arg(1:3)))
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
60 x = varargin{1};
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
61 y = varargin{2};
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
62 iarg = 4;
13308
9a83ec29aec9 Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents: 13299
diff changeset
63 if (rem (nargin - iarg, 2) == 1)
18307
a97ed15d1ea8 __patch__.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents: 17744
diff changeset
64 c = varargin{iarg};
13308
9a83ec29aec9 Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents: 13299
diff changeset
65 z = varargin{3};
9a83ec29aec9 Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents: 13299
diff changeset
66 iarg = 5;
9a83ec29aec9 Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents: 13299
diff changeset
67 else
9a83ec29aec9 Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents: 13299
diff changeset
68 z = [];
9a83ec29aec9 Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents: 13299
diff changeset
69 c = varargin{3};
9a83ec29aec9 Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents: 13299
diff changeset
70 endif
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
71 elseif (nargin > 2 && all (is_numeric_arg(1:2)))
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
72 x = varargin{1};
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
73 y = varargin{2};
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
74 z = [];
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
75 iarg = 3;
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
76 if (rem (nargin - iarg, 2) == 1)
18307
a97ed15d1ea8 __patch__.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents: 17744
diff changeset
77 c = varargin{iarg};
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20380
diff changeset
78 iarg += 1;
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
79 else
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
80 c = [];
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
81 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
82 endif
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
83
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
84 if (isvector (x))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
85 x = x(:);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
86 y = y(:);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
87 z = z(:);
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
88 if (isnumeric (c))
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
89 if (isvector (c) && numel (c) == numel (x))
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
90 c = c(:);
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
91 elseif (rows (c) != numel (x) && columns (c) == numel (x))
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
92 c = c.';
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
93 endif
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
94 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
95 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
96 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
97 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
98 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
99 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
100 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
101 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
102
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
103 if (isnumeric (c))
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
104
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
105 if (ndims (c) == 3 && columns (c) == 1)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
106 c = permute (c, [1, 3, 2]);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
107 endif
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
108
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
109 if (isvector (c) && numel (c) == columns (x))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
110 if (isnan (c))
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} = [1, 1, 1];
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} = c;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
115 elseif (isnumeric (c))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
116 args{7} = "facecolor";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
117 args{8} = "flat";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
118 args{9} = "cdata";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
119 args{10} = c;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
120 else
18307
a97ed15d1ea8 __patch__.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents: 17744
diff changeset
121 error ("patch: color data C must be numeric");
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
122 endif
13954
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
123 elseif (isvector (c) && numel (c) == 3)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
124 args{7} = "facecolor";
13808
d5bfaa582eaa correctly handle RGB color spec for patch object
John W. Eaton <jwe@octave.org>
parents: 13779
diff changeset
125 args{8} = c;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
126 args{9} = "cdata";
13808
d5bfaa582eaa correctly handle RGB color spec for patch object
John W. Eaton <jwe@octave.org>
parents: 13779
diff changeset
127 args{10} = [];
13954
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
128 elseif (ndims (c) == 3 && size (c, 3) == 3)
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
129 ## CDATA is specified as RGB data
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
130 if ((rows (c) == 1 && columns (c) == 1) ...
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
131 || (rows (c) == 1 && columns (c) == columns (x)))
13954
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
132 ## Single patch color or per-face color
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
133 args{7} = "facecolor";
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
134 args{8} = "flat";
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
135 args{9} = "cdata";
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
136 args{10} = c;
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
137 elseif (rows (c) == rows (x) && columns (c) == columns (x))
13954
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
138 ## Per-vertex color
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
139 args{7} = "facecolor";
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
140 args{8} = "interp";
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
141 args{9} = "cdata";
17347
1391dc953ae2 __patch__.m: Fix typo and close bug #34417.
Rik <rik@octave.org>
parents: 17338
diff changeset
142 args{10} = c;
13954
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
143 else
18307
a97ed15d1ea8 __patch__.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents: 17744
diff changeset
144 error ("patch: Invalid TrueColor data C");
13954
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
145 endif
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
146 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
147 ## Color Vectors
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
148 if (isempty (c))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
149 args{7} = "facecolor";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
150 args{8} = "interp";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
151 args{9} = "cdata";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
152 args{10} = [];
18307
a97ed15d1ea8 __patch__.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents: 17744
diff changeset
153 elseif (size_equal (c, x) && size_equal (c, y))
13308
9a83ec29aec9 Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents: 13299
diff changeset
154 args{7} = "facecolor";
9a83ec29aec9 Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents: 13299
diff changeset
155 args{8} = "interp";
9a83ec29aec9 Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents: 13299
diff changeset
156 args{9} = "cdata";
9a83ec29aec9 Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents: 13299
diff changeset
157 args{10} = c;
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
158 else
18307
a97ed15d1ea8 __patch__.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents: 17744
diff changeset
159 error ("patch: size of X, Y, and C must be equal");
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
160 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
161 endif
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
162 elseif (ischar (c) && rem (nargin - iarg, 2) == 0)
18307
a97ed15d1ea8 __patch__.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents: 17744
diff changeset
163 ## Assume any additional argument over an even number is a color string.
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
164 args{7} = "facecolor";
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
165 args{8} = tolower (c);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
166 args{9} = "cdata";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
167 args{10} = [];
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
168 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
169 args{7} = "facecolor";
18894
24332f256940 Set default patch color to black rather than green for Matlab compatibility.
Rik <rik@octave.org>
parents: 18307
diff changeset
170 args{8} = [0, 0, 0];
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
171 args{9} = "cdata";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
172 args{10} = [];
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6895
diff changeset
173 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
174
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 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
176 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
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 args = varargin;
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
179 endif
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
180
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
181 if (! failed)
18307
a97ed15d1ea8 __patch__.m: Follow Octave coding conventions.
Rik <rik@octave.org>
parents: 17744
diff changeset
182 h = __go_patch__ (p, args{:});
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
183 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
184 endfunction