Changeset 103


Ignore:
Timestamp:
Jun 8, 2005, 1:29:23 PM (19 years ago)
Author:
darran
Message:
  • xllcorner,yllcorner offset working
Location:
Swollen
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Swollen/doc/contract2_hours.txt

    r97 r103  
    222nd Contract Hours
    33------------------
     4
     5
     68 June, Wednesday (3 hours)
     7- use of xllcorner,yllcorner in sww file
     8- bug that "texture" image is looking in rundir
     9
     106 June, Monday (2 hours)
     11- added command line specification of bedslope spotlight position (-lightpos option)
     12- changed to "texture" global attribute usage
     13
     14
    415
    516total = 154 hours (4.1 weeks)
  • Swollen/include/swwreader.h

    r92 r103  
    158158    float _xcenter, _ycenter, _zcenter;
    159159
     160    // sww file can contain optional global offset attributes
     161    float _xllcorner, _yllcorner;
     162
    160163    // stack of return values from netcdf function calls
    161164    std::vector<int> _status;
  • Swollen/swollen/main.cpp

    r100 r103  
    4545    arguments.getApplicationUsage()->addCommandLineOption("-alphamin <float 0-1>","Transparency value at hmin");
    4646    arguments.getApplicationUsage()->addCommandLineOption("-alphamax <float 0-1>","Maximum transparency clamp value");
    47     arguments.getApplicationUsage()->addCommandLineOption("-lightpos <float>,<float>,<float>","x,y,z of bedslope directional light (default is overhead)");
     47    arguments.getApplicationUsage()->addCommandLineOption("-lightpos <float>,<float>,<float>","x,y,z of bedslope directional light (z is up, default is overhead)");
    4848    arguments.getApplicationUsage()->addCommandLineOption("-nosky","Omit background sky");
    4949    arguments.getApplicationUsage()->addCommandLineOption("-texture <file>","Image to use for bedslope topography");
  • Swollen/swollen/version.cpp

    r100 r103  
    1 const char* version() { const char* s = "Revision: 98:99M"; return s; }
     1const char* version() { const char* s = "Revision: 102M"; return s; }
  • Swollen/swwreader/swwreader.cpp

    r99 r103  
    9292    }
    9393
     94    // sww file can optionally contain georeference offset
     95    int status1 = nc_get_att_float(_ncid, NC_GLOBAL, "xllcorner", &_xllcorner);
     96    int status2 = nc_get_att_float(_ncid, NC_GLOBAL, "yllcorner", &_yllcorner);
     97    if( status1 == NC_NOERR && status2 == NC_NOERR)
     98    {
     99       osg::notify(osg::INFO) << "[SWWReader] xllcorner: " << _xllcorner <<  std::endl;
     100       osg::notify(osg::INFO) << "[SWWReader] yllcorner: " << _yllcorner <<  std::endl;
     101    }
     102    else
     103    {
     104       _xllcorner = 0.0;  // default value
     105       _yllcorner = 0.0;
     106    }
     107
     108
    94109    // loop index
    95110    size_t iv;
     
    98113    unsigned int v1index, v2index, v3index;
    99114
    100     // bedslope extents and resultant scale factors
     115    // bedslope range and resultant scale factors (note, these don't take into
     116    // account any xllcorner, yllcorner offsets - used during texture coord assignment)
    101117    float xmin, xmax, xrange;
    102118    float ymin, ymax, yrange;
    103119    float zmin, zmax, zrange;
    104120    float aspect_ratio;
    105     xmin = _px[0]; xmax = _px[0];
    106     ymin = _py[0]; ymax = _py[0];
    107     zmin = _pz[0]; zmax = _pz[0];
     121    xmin = _px[0];
     122    xmax = _px[0];
     123    ymin = _py[0];
     124    ymax = _py[0];
     125    zmin = _pz[0];
     126    zmax = _pz[0];
    108127    for( iv=1; iv < _npoints; iv++ )
    109128    {
    110             if( _px[iv] < xmin ) xmin = _px[iv];
    111             if( _px[iv] > xmax ) xmax = _px[iv];
    112             if( _py[iv] < ymin ) ymin = _py[iv];
    113             if( _py[iv] > ymax ) ymax = _py[iv];
    114             if( _pz[iv] < zmin ) zmin = _pz[iv];
    115             if( _pz[iv] > zmax ) zmax = _pz[iv];
     129       if( _px[iv] < xmin ) xmin = _px[iv];
     130       if( _px[iv] > xmax ) xmax = _px[iv];
     131       if( _py[iv] < ymin ) ymin = _py[iv];
     132       if( _py[iv] > ymax ) ymax = _py[iv];
     133       if( _pz[iv] < zmin ) zmin = _pz[iv];
     134       if( _pz[iv] > zmax ) zmax = _pz[iv];
    116135    }
    117136
     
    135154    if( aspect_ratio > 1.0 )
    136155    {
    137         _scale = 1.0 / xrange;
     156        _scale = 1.0/xrange;
    138157        _ycenter /= aspect_ratio;
    139158    }
    140159    else
    141160    {
    142         _scale = 1.0 / yrange;
     161        _scale = 1.0/yrange;
    143162        _xcenter /= aspect_ratio;
    144163    }
     164
     165
     166    osg::notify(osg::INFO) << "[SWWReader] xscale: " << _xscale <<  std::endl;
     167    osg::notify(osg::INFO) << "[SWWReader] yscale: " << _yscale <<  std::endl;
     168    osg::notify(osg::INFO) << "[SWWReader] zmin: " << zmin <<  std::endl;
     169    osg::notify(osg::INFO) << "[SWWReader] zmax: " << zmax <<  std::endl;
     170    osg::notify(osg::INFO) << "[SWWReader] zscale: " << _zscale <<  std::endl;
     171
     172
    145173
    146174    // alpha-scaling defaults
     
    149177    _heightmin = 0.0;
    150178    _heightmax = 1.0;   
    151 
    152     osg::notify(osg::INFO) << "[SWWReader] xmin: " << xmin <<  std::endl;
    153     osg::notify(osg::INFO) << "[SWWReader] xmax: " << xmax <<  std::endl;
    154     osg::notify(osg::INFO) << "[SWWReader] xscale: " << _xscale <<  std::endl;
    155     osg::notify(osg::INFO) << "[SWWReader] ymin: " << ymin <<  std::endl;
    156     osg::notify(osg::INFO) << "[SWWReader] ymax: " << ymax <<  std::endl;
    157     osg::notify(osg::INFO) << "[SWWReader] yscale: " << _yscale <<  std::endl;
    158     osg::notify(osg::INFO) << "[SWWReader] zmin: " << zmin <<  std::endl;
    159     osg::notify(osg::INFO) << "[SWWReader] zmax: " << zmax <<  std::endl;
    160     osg::notify(osg::INFO) << "[SWWReader] zscale: " << _zscale <<  std::endl;
    161179
    162180
     
    292310        float yrange = _bedslopegeodata.ypixel * _bedslopegeodata.yresolution;
    293311        for( unsigned int iv=0; iv < _npoints; iv++ )
    294             _bedslopetexcoords->push_back( osg::Vec2( (_px[iv] - xorigin)/xrange, (_py[iv] - yorigin)/yrange ) );           }
     312            _bedslopetexcoords->push_back( osg::Vec2( (_px[iv] + _xllcorner - xorigin)/xrange,
     313                                                      (_py[iv] + _yllcorner - yorigin)/yrange ) );
     314    }
    295315    else
    296316    {
Note: See TracChangeset for help on using the changeset viewer.