Ignore:
Timestamp:
Mar 25, 2013, 4:17:55 PM (7 years ago)
Author:
ldelgass
Message:

Use normalizeScalar common function where possible. Also, don't set NaNs? to
-1 in unnormalized data since -1 could be a valid data value. Need to make
sure gradient filtering properly handles NaNs?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/dxReader.cpp

    r3502 r3574  
    288288
    289289        // make sure that we read all of the expected points
    290         if (nread != nx*ny*nz) {
     290        if (nread != npts) {
    291291            result.addError("inconsistent data: expected %d points"
    292                             " but found %d points", nx*ny*nz, nread);
     292                            " but found %d points", npts, nread);
    293293            return NULL;
    294294        }
    295295
    296296#ifndef DOWNSAMPLE_DATA
    297         double dv = vmax - vmin;
    298         if (dv == 0.0) {
    299             dv = 1.0;
    300         }
    301 
    302         int ngen = 0;
    303         const int step = 4;
    304         for (int i = 0; i < nx*ny*nz; ++i) {
    305             double v = data[ngen];
    306             // scale all values [0-1], -1 => out of bounds
    307             v = (isnan(v)) ? -1.0 : (v - vmin)/dv;
    308 
    309             data[ngen] = v;
    310             ngen += step;
    311         }
    312 
     297
     298        // scale all values [0-1], -1 => out of bounds
     299        normalizeScalar(data, npts, 4, vmin, vmax);
    313300        computeSimpleGradient(data, nx, ny, nz,
    314301                              dx, dy, dz);
     
    370357                    }
    371358#ifdef FILTER_GRADIENTS
    372                     // NOT normalized, -1 => out of bounds
    373                     v = (isnan(v)) ? -1.0 : v;
     359                    // NOT normalized, may have NaNs (FIXME: how does gradient filter handle NaN?)
    374360                    cdata[ngen] = v;
    375361#else // !FILTER_GRADIENTS
     
    422408
    423409        // make sure that we read all of the expected points
    424         if (nread != nxy*nz) {
     410        if (nread != npts) {
    425411            result.addError("inconsistent data: expected %d points"
    426                             " but found %d points", nxy*nz, nread);
     412                            " but found %d points", npts, nread);
    427413            return NULL;
    428414        }
Note: See TracChangeset for help on using the changeset viewer.