octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[changeset] Support for structure array input argument in __patch__


From: Thomas Treichl
Subject: [changeset] Support for structure array input argument in __patch__
Date: Sun, 08 Mar 2009 21:00:11 +0100
User-agent: Thunderbird 2.0.0.19 (Macintosh/20081209)

Hi,

the current implementation of patch resp. the file __patch__.m doesn't allow to be the first input argument of type structure array with the fields 'faces', 'vertices' and 'facevertexcdata'. Pleas find attached a changeset that should fix this...

Best regards,

  Thomas
# HG changeset patch
# User Thomas Treichl <address@hidden>
# Date 1236542034 -3600
# Node ID 8892764198ac40ac38f8c74d965f3aa08d4afec6
# Parent  d707aa3bbc36ebbbb85ec7d5ee867d18971f4fb4
Support structure array input argument.

diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,7 @@
+2009-03-08  Thomas Treichl <address@hidden>
+
+       * plot/__patch__.m: Support structure array input argument.
+
 2009-03-06  Ben Abbott <address@hidden>
 
        * plot/__go_draw_axes__.m: Preserve the order of axes' children
diff --git a/scripts/plot/__patch__.m b/scripts/plot/__patch__.m
--- a/scripts/plot/__patch__.m
+++ b/scripts/plot/__patch__.m
@@ -32,13 +32,32 @@
   fail = false;
 
   if (nargin < 3)
-    fail = true;
-    return;
+    if (! (nargin == 2 && isstruct (varargin{1})))
+      fail = true;
+      return;
+    endif
   endif
 
   iarg = 1;
   have_x = have_z = have_c = have_faces = false;
-  if (isnumeric (varargin{1}))
+  if (isstruct (varargin{1}))
+    fld = fieldnames (varargin{1});
+    idx = find (strcmpi (fld, "faces"));
+    if (idx)
+      faces = varargin{1}.(fld{idx});
+      idx = find (strcmpi (fld, "vertices"));
+      if (idx)
+       vert = varargin{1}.(fld{idx});
+       idx = find (strcmpi (fld, "facevertexcdata"));
+       if (idx)
+         varargin{nargin} = "FaceVertexCData";
+         varargin{nargin+1} = varargin{1}.(fld{idx});
+       endif
+       have_faces = true;
+       iarg += 1;
+      endif
+    endif
+  elseif (isnumeric (varargin{1}))
     if (! isnumeric (varargin{2}))
       fail = true;
       return;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]