Ignore:
Timestamp:
Mar 23, 2012, 3:15:10 PM (8 years ago)
Author:
ldelgass
Message:

Fix Unirect3d::Resample (currently unused)

File:
1 edited

Legend:

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

    r2877 r2881  
    1414extern int GetAxisFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *indexPtr);
    1515
    16 static INLINE char *
     16static inline char *
    1717skipspaces(char *string)
    1818{
     
    2323}
    2424
    25 static INLINE char *
     25static inline char *
    2626getline(char **stringPtr, char *endPtr)
    2727{
     
    662662    // Figure out a good mesh spacing
    663663    double dx, dy, dz;
    664     dx = xfield.rangeMax(Rappture::xaxis) - xfield.rangeMin(Rappture::xaxis);
    665     dy = xfield.rangeMax(Rappture::yaxis) - xfield.rangeMin(Rappture::yaxis);
    666     dz = xfield.rangeMax(Rappture::zaxis) - xfield.rangeMin(Rappture::zaxis);
     664    double lx, ly, lz;
     665    lx = xfield.rangeMax(Rappture::xaxis) - xfield.rangeMin(Rappture::xaxis);
     666    ly = xfield.rangeMax(Rappture::yaxis) - xfield.rangeMin(Rappture::yaxis);
     667    lz = xfield.rangeMax(Rappture::zaxis) - xfield.rangeMin(Rappture::zaxis);
    667668
    668669    double dmin;
    669     dmin = pow((dx*dy*dz)/(nSamples*nSamples*nSamples), 0.333);
    670    
    671     TRACE("dx:%lf dy:%lf dz:%lf dmin:%lf\n", dx, dy, dz, dmin);
     670    dmin = pow((lx*ly*lz)/((nSamples-1)*(nSamples-1)*(nSamples-1)), 0.333);
    672671
    673672    /* Recompute new number of points for each axis. */
    674     _xNum = (size_t)ceil(dx/dmin);
    675     _yNum = (size_t)ceil(dy/dmin);
    676     _zNum = (size_t)ceil(dz/dmin);
     673    _xNum = (size_t)ceil(lx/dmin);
     674    _yNum = (size_t)ceil(ly/dmin);
     675    _zNum = (size_t)ceil(lz/dmin);
    677676
    678677#ifndef HAVE_NPOT_TEXTURES
     
    683682#endif
    684683
     684    dx = lx/(double)(_xNum-1);
     685    dy = ly/(double)(_yNum-1);
     686    dz = lz/(double)(_zNum-1);
     687
     688    TRACE("lx:%lf ly:%lf lz:%lf dmin:%lf dx:%lf dy:%lf dz:%lf\n", lx, ly, lz, dmin, dx, dy, dz);
     689
    685690    size_t n = _nComponents * _xNum * _yNum * _zNum;
    686691    _values = (float *)realloc(_values, sizeof(float) * n);
    687692    memset(_values, 0, sizeof(float) * n);
    688    
     693
    689694    // Generate the uniformly sampled rectangle that we need for a volume
    690695    float *destPtr = _values;
     
    692697        double z;
    693698
    694         z = _zMin + (i * dmin);
     699        z = _zMin + (i * dx);
    695700        for (size_t j = 0; j < _yNum; j++) {
    696701            double y;
    697702               
    698             y = _yMin + (j * dmin);
     703            y = _yMin + (j * dy);
    699704            for (size_t k = 0; k < _xNum; k++) {
    700705                double x;
    701706
    702                 x = _xMin + (k * dmin);
     707                x = _xMin + (k * dz);
    703708                destPtr[0] = xfield.value(x, y, z);
    704709                destPtr[1] = yfield.value(x, y, z);
     
    711716}
    712717
    713 
    714718void
    715 Rappture::Unirect3d::GetVectorRange(void)
     719Rappture::Unirect3d::GetVectorRange()
    716720{
    717721    assert(_nComponents == 3);
Note: See TracChangeset for help on using the changeset viewer.