octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #63523] patch: input validation for cdata and


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #63523] patch: input validation for cdata and facevertexcdata needs improvement
Date: Thu, 7 Mar 2024 10:33:27 -0500 (EST)

Update of bug #63523 (group octave):

                 Summary: patch: case where invalid size of facevertexcdata is
not caught => patch: input validation for cdata and facevertexcdata needs
improvement

    _______________________________________________________

Follow-up Comment #3:

looking a little more at the different input handling cases in bug #65421,
input validation for both CData and FaceVertexCData could be significantly
improved.  FaceVertexCData catches a number of malformed entries, but not all.
CData catches very few and produces odd color output as a result. I didn't
test mismatches in vertex/face/point count for the different forms, but
apparently that should be part of it too.  

copying the input checking from the other report below, and broadening the
report title a bit.

6 vertex, 4 face, 2D patch:

close all;
P = [ 2.5, 7.5; 6.5, 7.0; 2.5, 5.5; 6.5, 6.0; 1.0, 6.5; 8.0, 6.5];
T = [5,  3,  1; 1,  4,  2; 1,  3,  4; 4,  6,  2]; 

# D will hold the color data in a form below. e.g.,
D = 20;

# to test CData
hp = patch ('Vertices', P, 'Faces', T, 'CData', D, 'FaceColor', 'interp',
'EdgeColor', 'interp');

#OR to test FaceVertexCData:
# hp = patch ('Vertices', P, 'Faces', T, 'FaceVertexCData', D, 'FaceColor',
'interp', 'EdgeColor', 'interp');

get(hp, 'cdata'),get(hp,'facevertexcdata')




Using Colormap indices:

ONE COLOR:
D = 20
both CData and FaceVertexCData - color all faces the 20th color in the current
colormap


ONE COLOR PER FACE:
D = [10 20 30 40]'  # numel(D) = N = number of faces
Both CData and FaceVertexCData:  color Nth face the Nth index # specified in
the vector

D = [10 20 30 40]  # numel(D) = N = number of faces
CData:  color Nth face the Nth index # specified in the vector
FaceVertexCData:  error - invalid value for property


ONE COLOR PER VERTEX:
D = [10 20 30 40 50 60]'  # numel(D) = M = number of Vertices
Both CData and FaceVertexCData:  color Nth face the Nth index # specified in
the vector

D = [10 20 30 40 50 60]  # numel(D) = M = number of vertices
CData:  color Nth face the Nth index # specified in the vector
FaceVertexCData:  error - invalid value for property


ONE COLOR PER VERTEX, DIFFERENT ON EACH FACE:
D=round(64*rand(size(P,1), size(T,1))) # N x M matrix
CData: specifies one color per vertex per face. if you do facecolor = interp,
you'll see that faces sharing vertices can have diff colors on either side of
the shared edge.
FaceVertexCData: error. invalid value for array property

D=round(64*rand(size(T,1), size(P,1))) # M x N matrix
CData: specifies one color per vertex per face like above. different
color/vertex ordering. Not sure how Octave maps it since the matlab docs say
should be NxM.
FaceVertexCData: error. invalid value for array property


Using RGB color specs:

ONE COLOR:
D = [0.1 0.5 0.7]
CData: odd color results. supposedly expects dim 3 vector. facevertexcdata
stored as column vector.
FaceVertexCData:  single rgb value applied to all faces (checking CData, it
contains the same values changed to a dim3 vector)

D = [0.1 0.5 0.7]'
CData: odd color results. supposedly expects dim 3 vector. facevertexcdata
stored as column vector.
FaceVertexCdata: odd color results. Cdata contains a seemingly random 3x4
numeric array.

D = cat(3,0.1 ,0.5, 0.7)
CData: single rgb value applied to all faces. (facevertexdata, same values
stored as a row vector)
FaceVertexCData: error. invalid value for array property.


ONE COLOR PER FACE:
D = [0 0.1 0.2; 0.3 0.4 0.5; 0.6 0.7 0.8; 0.9 1.0 0.0] #(Nx3 matrix)
CData: odd color results. Cdata stored as 4x3, FaceVertexCData stored as D(:)
(12x1)
FaceVertexCData: One color per face. Cdata stored as 1x4x3 array.

D = D'  #(3xN matrix)
CData: odd color results. Cdata stored as 3x4, FaceVertexCData stored as D(:)
(12x1)
FaceVertexCData: Error - invalid value for property.

D = permute([0 0.1 0.2; 0.3 0.4 0.5; 0.6 0.7 0.8; 0.9 1.0 0.0], [1 3 2])  #
Nx1x3 array
CData: one color per face.  FaceVertexCData stored as 4x3.
FaceVertexCData:  Error - invalid value for property.


ONE COLOR PER VERTEX:
D = [0 0.1 0.2; 0.3 0.4 0.5; 0.6 0.7 0.8; 0.9 1.0 0.0; 0.1 0.2 0.3; 0.4 0.5
0.6] # M x 3 matrix
CData:  odd color values. Cdata is 6x3. FaceVertexCData is 18x1.
FaceVertexCData: one color per vertex. CData stored as 3x4x3

D = D'  #(3xM matrix)
CData: odd color results. Cdata stored as 3x6, FaceVertexCData stored as D(:)
(18x1)
FaceVertexCData: Error - invalid value for property.


D = rand(3x4x3) # dim1&2 size to match x/y/zdata, RGB in dim3
CData: one color per vertex per face. (color can jump across edges).
FaceVertexCData stored as 12x3.
FaceVertexCData: Error - invalid value for property.




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63523>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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