# HG changeset patch # User John W. Eaton # Date 1283146257 14400 # Node ID 56f9c10e9e985738a1c8de2f0ff8e585a3d4cc83 # Parent 91ff0d7ee94b6f3d4487d540bcbdca75b431d5fb don't restrict surface properties alphadata and cdata to double and uint8 diff -r 91ff0d7ee94b -r 56f9c10e9e98 src/ChangeLog --- a/src/ChangeLog Fri Aug 27 21:06:04 2010 -0400 +++ b/src/ChangeLog Mon Aug 30 01:30:57 2010 -0400 @@ -1,3 +1,10 @@ +2010-08-30 John W. Eaton + + * graphics.cc (convert_cdata): Allow cdata to be any type that + can be converted to double. + * graphics.h.in (surface::properties::init): Remove constraints + on cdata and alphadata. + 2010-08-27 Jordi GutiƩrrez Hermoso * graphics.cc (axes::properties::rotate_view): Don't rotate past diff -r 91ff0d7ee94b -r 56f9c10e9e98 src/graphics.cc --- a/src/graphics.cc Fri Aug 27 21:06:04 2010 -0400 +++ b/src/graphics.cc Mon Aug 30 01:30:57 2010 -0400 @@ -598,41 +598,38 @@ double *av = a.fortran_vec (); const double *cmapv = cmap.data (); - const double *cv = 0; - const octave_uint8 *icv = 0; - - if (cdata.is_integer_type ()) - icv = cdata.uint8_array_value ().data (); - else - cv = cdata.array_value ().data (); - - for (octave_idx_type i = 0; i < lda; i++) - { - double x = (cv ? cv[i] : double (icv[i])); - - if (is_scaled) - x = xround ((nc - 1) * (x - clim(0)) / (clim(1) - clim(0))); - else - x = xround (x - 1); - - if (xisnan (x)) + const double *cv = cdata.array_value().data (); + + if (! error_state) + { + for (octave_idx_type i = 0; i < lda; i++) { - av[i] = x; - av[i+lda] = x; - av[i+2*lda] = x; - } - else - { - if (x < 0) - x = 0; - else if (x >= nc) - x = (nc - 1); - - octave_idx_type idx = static_cast (x); - - av[i] = cmapv[idx]; - av[i+lda] = cmapv[idx+nc]; - av[i+2*lda] = cmapv[idx+2*nc]; + double x = cv[i]; + + if (is_scaled) + x = xround ((nc - 1) * (x - clim(0)) / (clim(1) - clim(0))); + else + x = xround (x - 1); + + if (xisnan (x)) + { + av[i] = x; + av[i+lda] = x; + av[i+2*lda] = x; + } + else + { + if (x < 0) + x = 0; + else if (x >= nc) + x = (nc - 1); + + octave_idx_type idx = static_cast (x); + + av[i] = cmapv[idx]; + av[i+lda] = cmapv[idx+nc]; + av[i+2*lda] = cmapv[idx+2*nc]; + } } } diff -r 91ff0d7ee94b -r 56f9c10e9e98 src/graphics.h.in --- a/src/graphics.h.in Fri Aug 27 21:06:04 2010 -0400 +++ b/src/graphics.h.in Mon Aug 30 01:30:57 2010 -0400 @@ -3710,12 +3710,8 @@ xdata.add_constraint (dim_vector (-1, -1)); ydata.add_constraint (dim_vector (-1, -1)); zdata.add_constraint (dim_vector (-1, -1)); - alphadata.add_constraint ("double"); - alphadata.add_constraint ("uint8"); alphadata.add_constraint (dim_vector (-1, -1)); vertexnormals.add_constraint (dim_vector (-1, -1, 3)); - cdata.add_constraint ("double"); - cdata.add_constraint ("uint8"); cdata.add_constraint (dim_vector (-1, -1)); cdata.add_constraint (dim_vector (-1, -1, 3)); }