Ignore:
Timestamp:
Feb 22, 2011, 10:52:00 PM (13 years ago)
Author:
Torben Dannhauer
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • experimental/TerrainTest/ModificationVisitor.cpp

    r256 r257  
    4343void ModificationVisitor::modifyTile(osgTerrain::TerrainTile* tile)
    4444{
    45         OSG_NOTIFY( osg::ALWAYS ) << "ModificationVisitor::modifyTile()" << std::endl;
    46         OpenThreads::Thread::microSleep( 500000 );
    47 
     45        //OSG_NOTIFY( osg::ALWAYS ) << "ModificationVisitor::modifyTile()" << std::endl;
    4846        HeightFieldLayer* hfl = dynamic_cast<HeightFieldLayer*>(tile->getElevationLayer());
    4947        osg::HeightField* h = hfl->getHeightField();
    50         OSG_NOTIFY( osg::ALWAYS ) << "Origin: " << h->getOrigin()[0] <<" | "<<h->getOrigin()[1]<<" | "<<h->getOrigin()[2] << std::endl;
    51         OSG_NOTIFY( osg::ALWAYS ) << "X-Intervall: " << h->getXInterval() << std::endl;
    52         OSG_NOTIFY( osg::ALWAYS ) << "Y-Intervall: " << h->getYInterval() << std::endl;
     48
     49        // ROI to flatten
     50        double dest_lat_min = 48.336808;
     51        double dest_lat_max = 48.370467;
     52        double dest_lon_min = 11.736750;
     53        double dest_lon_max = 11.835322;
     54
     55        // Determine extend of the tile.
     56        int rows = h->getNumRows();
     57        int cols = h->getNumColumns();
     58        double lat_min = h->getOrigin()[1];
     59        double lat_max = lat_min + rows * h->getYInterval();
     60        double lon_min = h->getOrigin()[0];
     61        double lon_max = lon_min + cols * h->getXInterval();
     62
     63        // Check if tile is fully or partially inside ROI:
     64        if(lat_max>dest_lat_min && lat_min<dest_lat_max                 // lat inside ROI
     65                && lon_max>dest_lon_min && lon_min<dest_lon_max )       // lon inside ROI
     66        {
     67                OSG_NOTIFY( osg::ALWAYS ) << "ModificationVisitor::modifyTile() :: affected Tile" << std::endl;
     68                OSG_NOTIFY( osg::ALWAYS ) << "LAT: " << lat_min << " | " << lat_max << std::endl;
     69                OSG_NOTIFY( osg::ALWAYS ) << "LON: " << lon_min << " | " << lon_max << std::endl;
    5370
    5471
    55         // Determine if tile touches ROI
     72                // calculate colum start/end and row start/end of affected vertices
     73                int startX=0,startY=0,endX=cols,endY=rows;
    5674
    57         // calculate colum start/end and row start/end of affected vertices
    5875
    59         // modify height value of affected vertices
     76                // modify height value of affected vertices
     77                h->setHeight( 0,0, 600);
     78
     79        }
     80
     81
     82
     83
     84
     85
     86
     87        //OSG_NOTIFY( osg::ALWAYS ) << "Origin: " << h->getOrigin()[0] << " | " << h->getOrigin()[1] << std::endl;
     88        //OSG_NOTIFY( osg::ALWAYS ) << "X-Intervall: " << h->getXInterval() << std::endl;
     89        //OSG_NOTIFY( osg::ALWAYS ) << "Y-Intervall: " << h->getYInterval() << std::endl;
     90        //if(dest_lat_min<=lat_min && lat_max<=dest_lat_max && dest_lon_min<=lon_min && lon_max<=dest_lon_max)
     91        //{
     92        //      OSG_NOTIFY( osg::ALWAYS ) << "ModificationVisitor::modifyTile() :: affected Tile" << std::endl;
     93        //      OSG_NOTIFY( osg::ALWAYS ) << "LAT: " << lat_min << " | " << lat_max << std::endl;
     94        //      OSG_NOTIFY( osg::ALWAYS ) << "LON: " << lon_min << " | " << lon_max << std::endl;
     95
     96        //      h->setHeight( 0,0, 1000);
     97        //}
     98        //OpenThreads::Thread::microSleep( 50000 );
    6099}
Note: See TracChangeset for help on using the changeset viewer.