#include "rampedEllipsoidTechnique.h" rampedEllipsoidTechnique::rampedEllipsoidTechnique() { _height = 0.0; _rampWidthFactor = 0.4; // 10% of ROI is ramp. } rampedEllipsoidTechnique::~rampedEllipsoidTechnique() { } void rampedEllipsoidTechnique::modifyHeightfield(region& modificationROI, osg::HeightField* h, region tileExtends) { //OSG_NOTIFY( osg::ALWAYS ) << "rampedEllipsoidTechnique::modifyHeightfield()" << std::endl; //OSG_NOTIFY( osg::ALWAYS ) << "LAT: " << tileExtends._lat_min << " | " << tileExtends._lat_max << std::endl; //OSG_NOTIFY( osg::ALWAYS ) << "LON: " << tileExtends._lon_min << " | " << tileExtends._lon_max << std::endl; // Determine modificationROI without ramp double deltaLatPerSide = modificationROI.delta_lat() * _rampWidthFactor / 2.0; double deltaLonPerSide = modificationROI.delta_lon() * _rampWidthFactor / 2.0; region coreROI = modificationROI; coreROI._lat_min+=deltaLatPerSide; coreROI._lat_max-=deltaLatPerSide; coreROI._lon_min+=deltaLonPerSide; coreROI._lon_max-=deltaLonPerSide; // Calculate colum start/end and row start/end of affected vertices int Y_start=0, Y_startRamp=0, Y_startCore=0, Y_endCore=0, Y_endRamp=0, Y_end=h->getNumRows(); // Lat int X_start=0, X_startRamp=0, X_startCore=0, X_endCore=0, X_endRamp=0, X_end=h->getNumColumns(); // Lon // Lat Y_startRamp = round((modificationROI._lat_min-tileExtends._lat_min) / h->getYInterval()); Y_startCore = round((coreROI._lat_min-tileExtends._lat_min) / h->getYInterval()); Y_endCore = round((coreROI._lat_max-tileExtends._lat_min) / h->getYInterval()); Y_endRamp = round((modificationROI._lat_max-tileExtends._lat_min) / h->getYInterval()); clampValue(Y_startRamp, Y_start, Y_end); clampValue(Y_startCore, Y_start, Y_end); clampValue(Y_endCore, Y_start, Y_end); clampValue(Y_endRamp, Y_start, Y_end); // Lon X_startRamp = round((modificationROI._lon_min-tileExtends._lon_min) / h->getXInterval()); X_startCore = round((coreROI._lon_min-tileExtends._lon_min) / h->getXInterval()); X_endCore = round((coreROI._lon_max-tileExtends._lon_min) / h->getXInterval()); X_endRamp = round((modificationROI._lon_max-tileExtends._lon_min) / h->getXInterval()); clampValue(X_startRamp, X_start, X_end); clampValue(X_startCore, X_start, X_end); clampValue(X_endCore, X_start, X_end); clampValue(X_endRamp, X_start, X_end); // Modify height value of affected vertices in the core ROI for(int x=X_startRamp;xgetYInterval()+tileExtends._lat_min; double vertex_lon = x*h->getXInterval()+tileExtends._lon_min; // Calculate vertex delta h: h_dest - h_org double height_org = h->getHeight(x,y); double delta_h = _height - height_org; // preset offsetvalue to max and let every region try to lower it... double destination_height = std::numeric_limits::max(); // Calculate vertex height according to the region it is in. if( Y_startCore<=y && ysetHeight( x, y, destination_height); } } }