Changeset 5328 for nanovis/trunk


Ignore:
Timestamp:
Apr 27, 2015, 6:30:28 PM (4 years ago)
Author:
ldelgass
Message:

add delta checks to nanovis unirect DX parser

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nanovis/trunk/Unirect.cpp

    r4895 r5328  
    522522        } else if (sscanf(line, "delta %lg %lg %lg", &ddx, &ddy, &ddz) == 3) {
    523523            /* Found one of the delta lines. */
     524            int count = 0;
    524525            if (ddx != 0.0) {
    525526                dx = ddx;
     527                count++;
    526528            } else if (ddy != 0.0) {
    527529                dy = ddy;
     530                count++;
    528531            } else if (ddz != 0.0) {
    529532                dz = ddz;
     533                count++;
     534            }
     535            if (count > 1) {
     536                ERROR("don't know how to handle multiple non-zero delta values");
     537                return false;
    530538            }
    531539        } else if (sscanf(line, "object %*d class array type %*s shape 3"
     
    555563        ERROR("inconsistent data: expected %d points"
    556564              " but found %d points", nx*ny*nz, npts);
     565        return false;
     566    }
     567    if (npts > 1 && ((dx == dy) && (dx == dz) && (dx == 0.0))) {
     568        ERROR("Missing or invalid deltas in DX file: %g %g %g", dx, dy, dz);
     569        return false;
     570    }
     571    if (dx < 0.0 || dy < 0.0 || dz < 0.0) {
     572        ERROR("Negative deltas not supported in DX file: %g %g %g", dx, dy, dz);
    557573        return false;
    558574    }
Note: See TracChangeset for help on using the changeset viewer.