Changeset 62


Ignore:
Timestamp:
Dec 15, 2004, 12:51:55 AM (20 years ago)
Author:
darran
Message:
  • SWWReader is now extracting geospatial data from image passed via -texture <file> option
  • probably won't compile under Windows without changes to the solution file (I'll do this tommorrow)
Location:
Swollen
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • Swollen/doc/contract2_hours.txt

    r48 r62  
    44
    55
     6
     715 December, Tuesday (4 hours)
     8- added -texture <filename> option for bedslope image
     9- other code cleanups related to handling georeferenced data
     10- small amount of work on background thread for data read
     11
    61214 December, Monday (6 hours)
    713- visit to GA, swollen now compiling on-site under Windows/Visual Studio .NET
    814- added command line params for tweaking transparency (see "swollen -help")
     15- added -nosky option to omit surrounding sky map
     16
     17
     18
     19total = 113 hours (3.0 weeks)
     20subtotal = 8 hours
     21
    922
    102312 December, Saturday (4 hours)
     
    17307 December, Wednesday (4 hours)
    1831- new distro released
     32
    1933
    2034
     
    3650- searching for "popping" triangles in cairns sww file
    3751- gdal installation and recompilation (support for georef tiff)
     52
    3853
    3954
     
    5974
    6075
     76
    6177total = 79 hours (2 weeks)
    6278subtotal = 33 hours
     
    809615 October, Friday (3 hours)
    8197- memory leaks
     98
    8299
    83100
  • Swollen/doc/contract2_priorities.txt

    r60 r62  
    9595  "sww file couldn't read" [1]
    9696- add -version command line flag synced with Subversion revision number (useful for debugging) [?]
     97- prune -help documentation removing irrelevant options [?]
    9798
    9899
  • Swollen/include/swwreader.h

    r61 r62  
    6868    virtual osg::ref_ptr<osg::DrawElementsUShort> getBedslopeIndexArray() {return _bedslopeindices;}
    6969    virtual osg::ref_ptr<osg::Vec3Array> getBedslopeCentroidArray() {return _bedslopecentroids;}
    70     virtual osg::ref_ptr<osg::Vec2Array> getBedslopeTextureCoords() {return _bedslopetexcoords;}
     70    virtual osg::ref_ptr<osg::Vec2Array> getBedslopeTextureCoords();
     71
     72    virtual void setBedslopeTexture( std::string filename );
     73    virtual osg::Image* getBedslopeTexture();
     74
    7175
    7276    // stage
     
    9094    virtual void setHeightMin( float value ) {_heightmin = value;}     
    9195    virtual void setHeightMax( float value ) {_heightmax = value;}       
    92 
    9396   
    9497    virtual triangle_list getConnectivity(unsigned int index) {return _connectivity.at(index);}
     
    134137    osg::ref_ptr<osg::Vec4Array> _stagecolors;
    135138
     139    // optional bedslope texture map
     140    std::string* _bedslopetexture;
     141
    136142    // bedslope vertex scale and shift factors (for normalizing to unit cube)
    137143    float _xscale, _yscale, _zscale, _scale;
  • Swollen/swollen/bedslope.cpp

    r45 r62  
    55#include <osg/BoundingBox>
    66#include <osg/Texture2D>
    7 #include <osgDB/Registry>
    8 #include <osgDB/ReadFile>
    97#include <osg/TexEnv>
    108
     
    1513BedSlope::BedSlope(SWWReader* sww)
    1614{
    17 
    1815    // persistent
    1916    _sww = sww;
     
    4138    texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
    4239    texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
    43     texture->setImage(osgDB::readImageFile("bedslope.jpg"));
     40    texture->setImage( _sww->getBedslopeTexture() );
    4441   
    4542    _stateset = new osg::StateSet;
  • Swollen/swollen/main.cpp

    r60 r62  
    3939    arguments.getApplicationUsage()->addCommandLineOption("-help","Display this information");
    4040    arguments.getApplicationUsage()->addCommandLineOption("-scale <float>","Vertical scale factor");
    41     arguments.getApplicationUsage()->addCommandLineOption("-tps <rate>","timesteps per second");
    42     arguments.getApplicationUsage()->addCommandLineOption("-hmin <float>","height below which transparency is set to zero");   
     41    arguments.getApplicationUsage()->addCommandLineOption("-tps <rate>","Timesteps per second");
     42    arguments.getApplicationUsage()->addCommandLineOption("-hmin <float>","Height below which transparency is set to zero");   
    4343    arguments.getApplicationUsage()->addCommandLineOption("-hmax <float>","Height above which transparency is set to alphamax");       
    44     arguments.getApplicationUsage()->addCommandLineOption("-alphamin <float>","transparency value at hmin");   
    45     arguments.getApplicationUsage()->addCommandLineOption("-alphamax <float>","maximum transparency clamp value");
    46     arguments.getApplicationUsage()->addCommandLineOption("-nosky","omit background sky");
     44    arguments.getApplicationUsage()->addCommandLineOption("-alphamin <float>","Transparency value at hmin");   
     45    arguments.getApplicationUsage()->addCommandLineOption("-alphamax <float>","Maximum transparency clamp value");
     46    arguments.getApplicationUsage()->addCommandLineOption("-nosky","Omit background sky");
     47    arguments.getApplicationUsage()->addCommandLineOption("-texture <file>","Image to use for bedslope topography");
    4748
    4849    // construct the viewer.
     
    8990    float vscale;
    9091    if( !arguments.read("-scale",vscale) ) vscale = 1.0;
     92
     93    std::string bedslopetexture;
     94    if( arguments.read("-texture",bedslopetexture) ) sww->setBedslopeTexture( bedslopetexture );
    9195
    9296    float tmpfloat;
  • Swollen/swollen/watersurface.cpp

    r61 r62  
    3636    _node->setStateSet(_stateset);
    3737
    38     // FIXME: if set to true, wireframe doesn't work - need to dirty to force update?
    39     _geom->setUseDisplayList( false );
     38    _geom->setUseDisplayList( true );
    4039
    4140    // initial geometry
  • Swollen/swwreader/Makefile

    r6 r62  
    1111OSG_INCLUDE      =  ${OSGHOME}/include
    1212LOCAL_INCLUDE    =  $(TOPDIR)/include
    13 INCLUDES         =  -I $(LOCAL_INCLUDE) -I $(NETCDF_INCLUDE) -I $(OSG_INCLUDE)
     13GDAL_INCLUDE     =  `gdal-config --cflags`
     14INCLUDES         =  -I $(LOCAL_INCLUDE) -I $(NETCDF_INCLUDE) -I $(OSG_INCLUDE) $(GDAL_INCLUDE)
    1415
    1516CARBON_LIB       =  -framework Carbon
     
    1718NETCDF_LIBS      =  -lnetcdf
    1819X_LIBS           =  -lX11
     20GDAL_LIBS        =  `gdal-config --libs`
    1921OTHER_LIBS       =  -lm -lstdc++ -lobjc
    20 LIBS            +=  -losg -lOpenThreads $(NETCDF_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) $(CARBON_LIB)
     22LIBS            +=  -losg -losgDB -lOpenThreads $(NETCDF_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) $(CARBON_LIB) $(GDAL_LIBS)
    2123LIBDIRS          =  -L/usr/lib -L/usr/X11R6/lib -L/sw/lib -L/usr/local/lib
    2224
  • Swollen/swwreader/swwreader.cpp

    r61 r62  
    33
    44    Reader of SWW files from within OpenSceneGraph.
    5 
    6     An SWW file is the visualization output of the pyVolution
    7     Shallow Water Wave equation solver.  SWW files contain bedslope
    8     geometry and a sequence of stages at known timesteps.  The
    9     internal format is NetCDF:
    10 
    11     netcdf demo.sww {
    12         dimensions:
    13             number_of_volumes = <integer> ;
    14             number_of_vertices = 3 ;
    15             number_of_points = <integer> ;
    16             number_of_timesteps = UNLIMITED ;
    17         variables:
    18             float x(number_of_points) ;
    19             float y(number_of_points) ;
    20             float z(number_of_points) ;
    21             int volumes(number_of_volumes, number_of_vertices) ;
    22             float time(number_of_timesteps) ;
    23             float stage(number_of_timesteps, number_of_points) ;
    245
    256    copyright (C) 2004 Geoscience Australia
     
    3213#include <osg/Notify>
    3314
     15#include <osgDB/Registry>
     16#include <osgDB/ReadFile>
     17
    3418#include <stdlib.h>
    3519#include <stdio.h>
     20#include <gdal_priv.h>
    3621
    3722
     
    148133
    149134
     135    // default texture map
     136    _bedslopetexture = new std::string("bedslope.jpg");
     137
     138
    150139    osg::notify(osg::INFO) << "[SWWReader] xmin: " << xmin <<  std::endl;
    151140    osg::notify(osg::INFO) << "[SWWReader] xmax: " << xmax <<  std::endl;
     
    186175
    187176
    188     // bedslope texture coords based on (x,y) locations scaled by extents into range [0,1]
    189     _bedslopetexcoords = new osg::Vec2Array;
    190     for( iv=0; iv < _npoints; iv++ )
    191       _bedslopetexcoords->push_back( osg::Vec2( (_px[iv]-_xoffset)*_xscale, (_py[iv]-_yoffset)*_yscale ) );
    192 
    193 
    194177    // calculate bedslope primitive normal and centroid arrays
    195178    _bedslopenormals = new osg::Vec3Array;
     
    226209    _status.push_back( nc_close(_ncid) );
    227210    delete[]( _px, _py, _pz, _ptime, _pvolumes, _pstage );
     211}
     212
     213
     214
     215void SWWReader::setBedslopeTexture( std::string filename )
     216{
     217    osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] filename: " << filename <<  std::endl;
     218   _bedslopetexture = new std::string(filename);
     219
     220   // attempt to extract geospatial metadata from image file
     221   GDALDataset  *poDataset;
     222   GDALAllRegister();
     223   poDataset = (GDALDataset *) GDALOpen( filename.c_str(), GA_ReadOnly );
     224   if( poDataset == NULL )
     225      osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] GDAL unable to open file: " << filename <<  std::endl;
     226   else
     227   {
     228      // extract metadata
     229      double adfGeoTransform[6];
     230
     231      printf( "Driver: %s/%s\n",
     232              poDataset->GetDriver()->GetDescription(),
     233              poDataset->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME ) );
     234
     235      printf( "Size is %dx%dx%d\n",
     236              poDataset->GetRasterXSize(), poDataset->GetRasterYSize(),
     237              poDataset->GetRasterCount() );
     238
     239      if( poDataset->GetProjectionRef()  != NULL )
     240         printf( "Projection is `%s'\n", poDataset->GetProjectionRef() );
     241
     242      if( poDataset->GetGeoTransform( adfGeoTransform ) == CE_None )
     243      {
     244         printf( "Origin = (%.6f,%.6f)\n",
     245                 adfGeoTransform[0], adfGeoTransform[3] );
     246
     247         printf( "Pixel Size = (%.6f,%.6f)\n",
     248                 adfGeoTransform[1], adfGeoTransform[5] );
     249      }
     250   }
     251
     252}
     253
     254
     255
     256osg::Image* SWWReader::getBedslopeTexture()
     257{
     258   return osgDB::readImageFile( _bedslopetexture->c_str() );
     259}
     260
     261
     262
     263osg::ref_ptr<osg::Vec2Array> SWWReader::getBedslopeTextureCoords()
     264{
     265
     266   // bedslope texture coords based on (x,y) locations scaled by extents into range [0,1]
     267   _bedslopetexcoords = new osg::Vec2Array;
     268   for( unsigned int iv=0; iv < _npoints; iv++ )
     269      _bedslopetexcoords->push_back( osg::Vec2( (_px[iv]-_xoffset)*_xscale, (_py[iv]-_yoffset)*_yscale ) );
     270
     271   return _bedslopetexcoords;
    228272}
    229273
Note: See TracChangeset for help on using the changeset viewer.