From 3b8abfa87513ac345379436a98d97c1ea0707baa Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 5 Oct 2004 15:08:54 +0000 Subject: [PATCH] Added ability to alter the verbosity of the notify messages with the running of osgTerrain::DataSet via a static s/getNotifyOffset(int) method. --- examples/osgsimulation/osgsimulation.cpp | 4 +- include/osgTerrain/DataSet | 12 +- src/osgTerrain/DataSet.cpp | 326 ++++++++++++----------- 3 files changed, 182 insertions(+), 160 deletions(-) diff --git a/examples/osgsimulation/osgsimulation.cpp b/examples/osgsimulation/osgsimulation.cpp index a4732d464..ed8effafa 100644 --- a/examples/osgsimulation/osgsimulation.cpp +++ b/examples/osgsimulation/osgsimulation.cpp @@ -26,7 +26,6 @@ class GraphicsContext { rs->useBorder(false); rs->useConfigEventThread(false); rs->realize(); - std::cout<<"Realized window"< dataSet = new osgTerrain::DataSet; // register the source imagery diff --git a/include/osgTerrain/DataSet b/include/osgTerrain/DataSet index e0a823225..2a2f6c558 100644 --- a/include/osgTerrain/DataSet +++ b/include/osgTerrain/DataSet @@ -991,6 +991,14 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced const std::string& getCommentString() const { return _comment; } + void setWriteNodeBeforeSimplification(bool flag) { _writeNodeBeforeSimplification = flag; } + bool getWriteNodeBeforeSimplification() const { return _writeNodeBeforeSimplification; } + + + static void setNotifyOffset(int level); + static int setNotifyOffset(); + + CompositeDestination* createDestinationGraph(CompositeDestination* parent, osg::CoordinateSystemNode* cs, const osg::BoundingBox& extents, @@ -1067,7 +1075,9 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced bool _decorateWithCoordinateSystemNode; std::string _comment; - + + bool _writeNodeBeforeSimplification; + osg::ref_ptr _rootNode; }; diff --git a/src/osgTerrain/DataSet.cpp b/src/osgTerrain/DataSet.cpp index a2cb0ca19..06a656a62 100644 --- a/src/osgTerrain/DataSet.cpp +++ b/src/osgTerrain/DataSet.cpp @@ -44,6 +44,14 @@ using namespace osgTerrain; + +static int s_notifyOffset = 0; +void DataSet::setNotifyOffset(int level) { s_notifyOffset = level; } +int DataSet::setNotifyOffset() { return s_notifyOffset; } + +inline std::ostream& my_notify(osg::NotifySeverity level) { return osg::notify(osg::NotifySeverity(s_notifyOffset+level)); } + + std::string osgTerrain::DataSet::coordinateSystemStringToWTK(const std::string& coordinateSystem) { std::string wtkString; @@ -63,7 +71,7 @@ std::string osgTerrain::DataSet::coordinateSystemStringToWTK(const std::string& } else { - osg::notify(osg::WARN)<<"Warning: coordinateSystem string not recognised."<GetValue(),"GEOCCS")==0) my_notify(osg::INFO)<<" lhsSR. is GEOCENTRIC "<GetValue(),"GEOCCS")==0) return GEOCENTRIC; @@ -123,7 +131,7 @@ double getAngularUnits(const osg::CoordinateSystemNode* lhs) char* str; double result = lhsSR.GetAngularUnits(&str); - osg::notify(osg::INFO)<<"lhsSR.GetAngularUnits("<_geoTransform.set( 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, @@ -337,7 +345,7 @@ const DataSet::SpatialProperties& DataSet::SourceData::computeSpatialProperties( if (_gdalDataSet) { - //osg::notify(osg::INFO)<<"Projecting bounding volume for "<<_source->getFileName()<getFileName()<getType()) { case(Source::IMAGE): - osg::notify(osg::INFO)<<"B.1"<s()*(intersect_bb.xMax()-d_bb.xMin())/(d_bb.xMax()-d_bb.xMin())),(int)destination._image->s())-destX; int destHeight = osg::minimum((int)ceilf((float)destination._image->t()*(intersect_bb.yMax()-d_bb.yMin())/(d_bb.yMax()-d_bb.yMin())),(int)destination._image->t())-destY; - osg::notify(osg::INFO)<<" copying from "<GetRasterCount() >= 3; bool hasColorTable = _gdalDataSet->GetRasterCount() >= 1 && _gdalDataSet->GetRasterBand(1)->GetColorTable(); @@ -465,7 +473,7 @@ void DataSet::SourceData::readImage(DestinationData& destination) int lineSpace=-(int)(destination._image->getRowSizeInBytes()); unsigned char* imageData = destination._image->data(destX,destY+destHeight-1); - osg::notify(osg::INFO) << "reading RGB"<getNumColumns()*(intersect_bb.xMax()-d_bb.xMin())/(d_bb.xMax()-d_bb.xMin())),(int)destination._heightField->getNumColumns())-destX; int destHeight = osg::minimum((int)ceilf((float)destination._heightField->getNumRows()*(intersect_bb.yMax()-d_bb.yMin())/(d_bb.yMax()-d_bb.yMin())),(int)destination._heightField->getNumRows())-destY; - osg::notify(osg::INFO)<<" copying from "<GetUnitType()) osg::notify(osg::INFO) << "bandSelected->GetUnitType()=" << bandSelected->GetUnitType()<GetUnitType()= null" <GetUnitType()) my_notify(osg::INFO) << "bandSelected->GetUnitType()=" << bandSelected->GetUnitType()<GetUnitType()= null" <GetNoDataValue(&success); if (success) { - osg::notify(osg::INFO)<<"We have NoDataValue = "<GetOffset(&success); if (success) { - osg::notify(osg::INFO)<<"We have Offset = "<GetScale(&success); if (success) { - osg::notify(osg::INFO)<<"We have Scale = "<getConvertFromGeographicToGeocentric()*/) ? 1.0f/111319.0f : 1.0f; } - osg::notify(osg::INFO)<<"********* getLinearUnits = "<RasterIO(GF_Read,windowX,_numValuesY-(windowY+windowHeight),windowWidth,windowHeight,floatdata,destWidth,destHeight,GDT_Float32,numBytesPerZvalue,lineSpace); bandSelected->RasterIO(GF_Read,windowX,_numValuesY-(windowY+windowHeight),windowWidth,windowHeight,heightData,destWidth,destHeight,GDT_Float32,0,0); - osg::notify(osg::INFO)<<" scaling height field"<_cs = _cs; - osg::notify(osg::INFO)<<"assigning CS from Source to Data."<_cs; - osg::notify(osg::INFO)<<"assigning CS from Data to Source."<_geoTransform = _geoTransform; - osg::notify(osg::INFO)<<"assigning GeoTransform from Source to Data."<<_geoTransform<_geoTransform = _geoTransform; - osg::notify(osg::INFO)<<"assigning GeoTransform from Source to Data."<<_geoTransform<_geoTransform; - osg::notify(osg::INFO)<<"assigning GeoTransform from Data to Source."<<_geoTransform<computeExtents(); @@ -871,13 +879,13 @@ bool DataSet::Source::needReproject(const osg::CoordinateSystemNode* cs, double // always need to reproject imagery with GCP's. if (_sourceData->_hasGCPs) { - osg::notify(osg::INFO)<<"Need to to reproject due to presence of GCP's"<0.0f) { - osg::notify(osg::INFO)<<"recomputing the target transform size"<getCoordinateSystem()<getCoordinateSystem()<padfSrcNoDataReal[i] = noDataValue; psWO->padfSrcNoDataImag[i] = 0.0; @@ -1113,7 +1121,7 @@ DataSet::Source* DataSet::Source::doReproject(const std::string& filename, osg:: double new_noDataValue = 0.0; if (success) { - osg::notify(osg::INFO)<<"\tassinging no data value "<padfSrcNoDataReal[i] = noDataValue; psWO->padfSrcNoDataImag[i] = 0.0; @@ -1154,7 +1162,7 @@ DataSet::Source* DataSet::Source::doReproject(const std::string& filename, osg:: GDALGetRasterYSize( hDstDS ) ); } - osg::notify(osg::INFO)<<"new projection is "<_heightField->setYInterval(dem_dy); //float xMax = _terrain->_heightField->getOrigin().x()+_terrain->_heightField->getXInterval()*(float)(dem_numColumns-1); - //osg::notify(osg::INFO)<<"ErrorX = "<_image.get() : 0; osg::Image* image2 = tile2->_imagery.valid()?tile2->_imagery->_image.get() : 0; - //osg::notify(osg::INFO)<<"Equalizing edge "<_level<<"\t"<_tileX<<"\t"<_tileY<getDataType()==GL_UNSIGNED_BYTE) { - //osg::notify(osg::INFO)<<" Equalizing image1= "<data()<<" with data2 = 0x"<<(int)image2->data()<data()<<" with data2 = 0x"<<(int)image2->data()<data(image2->s()-1,1); // RIGHT hand side delta2 = image2->getRowSizeInBytes(); num = (image1->t()==image2->t())?image2->t()-2:0; // note miss out corners. - //osg::notify(osg::INFO)<<" left "<data(1,0); // BELOW hand side @@ -1731,7 +1739,7 @@ void DataSet::DestinationTile::equalizeEdge(Position position) data2 = image2->data(1,image2->t()-1); // ABOVE hand side delta2 = 3; num = (image1->s()==image2->s())?image2->s()-2:0; // note miss out corners. - //osg::notify(osg::INFO)<<" below "<data(image1->s()-1,1); // LEFT hand side @@ -1739,7 +1747,7 @@ void DataSet::DestinationTile::equalizeEdge(Position position) data2 = image2->data(0,1); // RIGHT hand side delta2 = image2->getRowSizeInBytes(); num = (image1->t()==image2->t())?image2->t()-2:0; // note miss out corners. - //osg::notify(osg::INFO)<<" right "<data(1,image1->t()-1); // ABOVE hand side @@ -1747,10 +1755,10 @@ void DataSet::DestinationTile::equalizeEdge(Position position) data2 = image2->data(1,0); // BELOW hand side delta2 = 3; num = (image1->s()==image2->s())?image2->s()-2:0; // note miss out corners. - //osg::notify(osg::INFO)<<" above "<dirtyTextureObject(); - osg::notify(osg::INFO)<<">>>>>>>>>>>>>>>compressed image.<<<<<<<<<<<<<<"<>>>>>>>>>>>>>>compressed image.<<<<<<<<<<<<<<"<getMipMappingMode()==DataSet::MIP_MAPPING_IMAGERY) { - osg::notify(osg::NOTICE)<<"Non compressed mipmapped not yet supported yet"<_heightField.valid()) { - osg::notify(osg::INFO)<<"--- Have terrain build tile ----"<_heightField.get(); @@ -2033,7 +2041,7 @@ osg::Node* DataSet::DestinationTile::createHeightField() } else { - osg::notify(osg::INFO)<<"**** No terrain to build tile from use flat terrain fallback ****"<allocate(2,2); @@ -2092,7 +2100,7 @@ static inline osg::Vec3 computeLocalSkirtVector(const osg::EllipsoidModel* et, c osg::Node* DataSet::DestinationTile::createPolygonal() { - osg::notify(osg::INFO)<<"--------- DataSet::DestinationTile::createDrawableGeometry() ------------- "<getEllipsoidModel(); bool mapLatLongsToXYZ = _dataSet->mapLatLongsToXYZ(); @@ -2102,7 +2110,7 @@ osg::Node* DataSet::DestinationTile::createPolygonal() if (_terrain.valid() && _terrain->_heightField.valid()) { - osg::notify(osg::INFO)<<"--- Have terrain build tile ----"<_heightField.get(); } else @@ -2119,7 +2127,7 @@ osg::Node* DataSet::DestinationTile::createPolygonal() if (longitude_range>45.0) numColumns = (unsigned int)ceilf((float)numColumns*sqrtf(longitude_range/45.0)); if (latitude_range>45.0) numRows = (unsigned int)ceilf((float)numRows*sqrtf(latitude_range/45.0)); - osg::notify(osg::INFO)<<"numColumns = "<addDrawable(geometry); -#if 1 - osgDB::writeNodeFile(*geode,"NodeBeforeSimplification.osg"); -#endif + if (_dataSet->getWriteNodeBeforeSimplification()) + { + osgDB::writeNodeFile(*geode,"NodeBeforeSimplification.osg"); + } unsigned int targetMaxNumVertices = 2048; float sample_ratio = (numVertices <= targetMaxNumVertices) ? 1.0f : (float)targetMaxNumVertices/(float)numVertices; @@ -2560,7 +2569,7 @@ void DataSet::DestinationTile::readFrom(CompositeSource* sourceGraph) { allocate(); - osg::notify(osg::INFO)<<"DestinationTile::readFrom() "<getSourceData(); if (data) { - osg::notify(osg::INFO)<<"DataSet::DestinationTile::readFrom -> SourceData::read() "<getMinLevel()<<"\t"<getMaxLevel()< SourceData::read() "<getMinLevel()<<"\t"<getMaxLevel()<read(*_imagery); if (_terrain.valid()) data->read(*_terrain); } @@ -2660,7 +2669,7 @@ void DataSet::CompositeDestination::addRequiredResolutions(CompositeSource* sour void DataSet::CompositeDestination::readFrom(CompositeSource* sourceGraph) { - osg::notify(osg::INFO)<<"CompositeDestination::readFrom() "<get(); - osg::notify(osg::INFO)<<" unref tile level="<_level<<" X="<_tileX<<" Y="<_tileY<_cs.valid()) { _destinationCoordinateSystem = sd->_cs; - osg::notify(osg::INFO)<<"Setting coordinate system to "<<_destinationCoordinateSystem->getCoordinateSystem()<getCoordinateSystem()<getExtents(_intermediateCoordinateSystem.get())); - osg::notify(osg::INFO)<<"local_extents = xMin()"<get(); if (source) { - osg::notify(osg::INFO)<<"Source File "<getFileName()<getFileName()<getRequiredResolutions(); - osg::notify(osg::INFO)<<" resolutions.size() "<consolodateRequiredResolutions(); - osg::notify(osg::INFO)<<" consolodated resolutions.size() "<getFileName()<getFileName()<setSortValueFromSourceDataResolution(); - osg::notify(osg::INFO)<<"sort "<getFileName()<<" value "<getSortValue()<getFileName()<<" value "<getSortValue()<sort(); } - osg::notify(osg::INFO)<<"Using source_lod_iterator itr"<get(); if (source) { - osg::notify(osg::INFO)<<" LOD "<<(*csitr)->getFileName()<getFileName()<get(); - osg::notify(osg::NOTICE)<<" reading tile level="<_level<<" X="<_tileX<<" Y="<_tileY<get(); - osg::notify(osg::NOTICE)<<" equalizing tile level="<_level<<" X="<_tileX<<" Y="<_tileY<getFileName()<getFileName().c_str()); } } @@ -3652,7 +3662,7 @@ public: void DataSet::_writeRow(Row& row) { - osg::notify(osg::NOTICE)<<"_writeRow "<getSubTileName(); if (node.valid()) { - osg::notify(osg::NOTICE)<<" writeSubTile filename="<second); @@ -3821,12 +3831,12 @@ void DataSet::_buildDestination(bool writeToDisk) } } } - osg::notify(osg::NOTICE)<<"completed DataSet::writeDestination("<