Ignore:
Timestamp:
Jun 21, 2005, 2:21:44 PM (19 years ago)
Author:
darran
Message:
  • refactoring to facilitate storing state
  • segfaulting at the moment ...
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Swollen/swwreader/swwreader.cpp

    r107 r111  
    4040
    4141   // netcdf filename
    42    _filename = new std::string(filename);
     42   _state.swwfilename = new std::string(filename);
    4343
    4444   // netcdf open
    45    _status.push_back( nc_open(_filename->c_str(), NC_NOWRITE, &_ncid) );
     45   _status.push_back( nc_open(filename.c_str(), NC_NOWRITE, &_ncid) );
    4646   if (this->_statusHasError()) return;
    4747
     
    131131
    132132   // alpha-scaling defaults, can be overridden after construction by command line parameters
    133    _alphamin = DEFAULT_ALPHAMIN;
    134    _alphamax = DEFAULT_ALPHAMAX;
    135    _heightmin = DEFAULT_HEIGHTMIN;
    136    _heightmax = DEFAULT_HEIGHTMAX;
     133   _state.alphamin = DEFAULT_ALPHAMIN;
     134   _state.alphamax = DEFAULT_ALPHAMAX;
     135   _state.heightmin = DEFAULT_HEIGHTMIN;
     136   _state.heightmax = DEFAULT_HEIGHTMAX;
    137137
    138138   // steepness culling default, can be overridden after construction by command line parameter
    139    _cullangle = DEFAULT_CULLANGLE;
    140    _culling = DEFAULT_CULLONSTART;
     139   _state.cullangle = DEFAULT_CULLANGLE;
     140   _state.culling = DEFAULT_CULLONSTART;
    141141
    142142   // loop index
     
    270270   _valid = true;
    271271
     272   std::cout << _state.alphamin << std::endl;
     273   std::cout << _state.alphamax << std::endl;
     274   std::cout << _state.heightmin << std::endl;
     275   std::cout << _state.heightmax << std::endl;
     276   std::cout << _state.cullangle << std::endl;
     277   std::cout << _state.culling << std::endl;
     278
     279   std::cout << *_state.swwfilename << std::endl;
     280   std::cout << *_state.bedslopetexturefilename << std::endl;
     281
    272282}
    273283
     
    285295{
    286296   osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] filename: " << filename <<  std::endl;
    287    _bedslopetexture = new std::string(filename);
     297   _state.bedslopetexturefilename = new std::string(filename);
    288298   _bedslopegeodata.hasData = false;
    289299
     
    311321      {
    312322         _bedslopegeodata.xorigin = geodata[0];
    313         _bedslopegeodata.yorigin = geodata[3];
    314         _bedslopegeodata.rotation = geodata[2];
    315         _bedslopegeodata.xpixel = geodata[1];
    316         _bedslopegeodata.ypixel = geodata[5];
    317         _bedslopegeodata.hasData = true;
    318 
    319         osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] xorigin: " << _bedslopegeodata.xorigin <<  std::endl;
    320         osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] yorigin: " << _bedslopegeodata.yorigin <<  std::endl;
    321         osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] xpixel: " << _bedslopegeodata.xpixel <<  std::endl;
    322         osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] ypixel: " << _bedslopegeodata.ypixel <<  std::endl;
    323         osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] rotation: " << _bedslopegeodata.rotation <<  std::endl;
     323        _bedslopegeodata.yorigin = geodata[3];
     324        _bedslopegeodata.rotation = geodata[2];
     325        _bedslopegeodata.xpixel = geodata[1];
     326        _bedslopegeodata.ypixel = geodata[5];
     327        _bedslopegeodata.hasData = true;
     328
     329        osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] xorigin: " << _bedslopegeodata.xorigin <<  std::endl;
     330        osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] yorigin: " << _bedslopegeodata.yorigin <<  std::endl;
     331        osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] xpixel: " << _bedslopegeodata.xpixel <<  std::endl;
     332        osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] ypixel: " << _bedslopegeodata.ypixel <<  std::endl;
     333        osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] rotation: " << _bedslopegeodata.rotation <<  std::endl;
    324334      }
    325335   }
     
    330340osg::Image* SWWReader::getBedslopeTexture()
    331341{
    332    return osgDB::readImageFile( _bedslopetexture->c_str() );
     342   return osgDB::readImageFile( _state.bedslopetexturefilename->c_str() );
    333343}
    334344
     
    350360   else
    351361   {
    352       // decal'd using (x,y) locations scaled by extents into range [0,1]
     362      // decaled using (x,y) locations scaled by extents into range [0,1]
    353363      for( unsigned int iv=0; iv < _npoints; iv++ )
    354364         _bedslopetexcoords->push_back( osg::Vec2( (_px[iv]-_xoffset)*_xscale, (_py[iv]-_yoffset)*_yscale ) );
     
    391401
    392402   // cullangle given in degrees, test is against dot product
    393    float cullthreshold = cos(osg::DegreesToRadians(_cullangle));
     403   float cullthreshold = cos(osg::DegreesToRadians(_state.cullangle));
    394404
    395405   // over all stage triangles
     
    427437   // where a = (alphamax-alphamin)/(hmax-hmin)
    428438   float alpha, height, alphascale;
    429    alphascale = (_alphamax - _alphamin) / (_heightmax - _heightmin);
     439   alphascale = (_state.alphamax - _state.alphamin) / (_state.heightmax - _state.heightmin);
    430440   _stagecolors = new osg::Vec4Array;
    431441   for (iv=0; iv < _npoints; iv++)
     
    434444      height = _stagevertices->at(iv).z() - _bedslopevertices->at(iv).z();
    435445       
    436       if (height < _heightmin)
     446      if (height < _state.heightmin)
    437447         alpha = 0.0;
    438448      else
    439449      {
    440          alpha = alphascale * (height - _heightmin) + _alphamin;
    441          if( alpha > _alphamax )
    442             alpha = _alphamax;
     450         alpha = alphascale * (height - _state.heightmin) + _state.alphamin;
     451         if( alpha > _state.alphamax )
     452            alpha = _state.alphamax;
    443453      }
    444454
     
    447457
    448458   // steep triangle vertices should have alpha=0, overwrite such vertex colours
    449    if( _culling )
     459   if( _state.culling )
    450460   {
    451461      for (iv=0; iv < steeptri->size() ; iv++)
Note: See TracChangeset for help on using the changeset viewer.