Mercurial > hg > octave-terminal
changeset 10921:56f9c10e9e98
don't restrict surface properties alphadata and cdata to double and uint8
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 30 Aug 2010 01:30:57 -0400 |
parents | 91ff0d7ee94b |
children | 015ba76371b9 |
files | src/ChangeLog src/graphics.cc src/graphics.h.in |
diffstat | 3 files changed, 38 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2010-08-30 John W. Eaton <jwe@octave.org> + + * 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 <jordigh@gmail.com> * graphics.cc (axes::properties::rotate_view): Don't rotate past
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -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<octave_idx_type> (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<octave_idx_type> (x); + + av[i] = cmapv[idx]; + av[i+lda] = cmapv[idx+nc]; + av[i+2*lda] = cmapv[idx+2*nc]; + } } }
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -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)); }