From 56575feb459ea3dff7ce810f1efdd8d35dc783f9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Thu, 14 May 2009 17:12:40 +0200 Subject: [PATCH] Some cleanup in stdDomains.* and documentation changes. --- debug.cpp | 28 ++++++++++++++--- interfaces.h | 2 +- matrixUtil.h | 2 +- modules/quadTree.h | 2 +- modules/stdDomains.cpp | 85 +++++++++----------------------------------------- modules/stdDomains.h | 1 + 6 files changed, 41 insertions(+), 79 deletions(-) diff --git a/debug.cpp b/debug.cpp index f1c6d0f..062f98a 100644 --- a/debug.cpp +++ b/debug.cpp @@ -81,8 +81,8 @@ namespace NOSPACE { int rotCounts[9]; vector poolCounts, levelCounts; - RangeInfoAccumulator(const ISquareDomains::PoolList &poolList) - : pools( &poolList ), poolCounts( pools->size(), 0 ), levelCounts( 10, 0 ) { + RangeInfoAccumulator(const ISquareDomains::PoolList &poolList,int maxLevel) + : pools( &poolList ), poolCounts( pools->size(), 0 ), levelCounts( maxLevel+1, 0 ) { for (int i=0; i<9; ++i) rotCounts[i]= 0; } @@ -200,7 +200,8 @@ QWidget* MStandardEncoder::debugModule(QPixmap &pixmap,const QPoint &click) { ); } else { // provide general info - RangeInfoAccumulator info( planeBlock->domains->getPools() ); + int maxLevel= 1 +log2ceil( max(planeBlock->width,planeBlock->height) ); + RangeInfoAccumulator info( planeBlock->domains->getPools(), maxLevel ); info= for_each( ranges.begin(), ranges.end(), info ); {// create a label with various counts info @@ -222,8 +223,6 @@ QWidget* MStandardEncoder::debugModule(QPixmap &pixmap,const QPoint &click) { layout->addWidget( new QLabel(msg) ); } - int maxLevel= 1 +log2ceil( max(planeBlock->width,planeBlock->height) ); - QTableWidget *table= new QTableWidget( maxLevel-2, 3 ); table->setHorizontalHeaderLabels ( QStringList() << "Level" << "Ranges" << "Domain count" ); @@ -292,6 +291,25 @@ QWidget* MQuadTree::debugModule(QPixmap &pixmap,const QPoint &click) { } // MQuadTree::debugModule method +/* +#include +void debugPool(const ISquareDomains::Pool &pool) { + // create and fill the image + QImage image( pool.width, pool.height, QImage::Format_RGB32 ); + + for (int y=0; y { * returns unzoomed densities */ virtual std::vector getLevelDensities(int level,int stdDomCountLog2) =0; - /** Writes all data needed for reconstruction that don't depend on the input (=settings) */ + /** Writes all settings (data needed for reconstruction that don't depend on the input) */ virtual void writeSettings(std::ostream &file) =0; /** Reads all settings (like ::writeSettings) */ virtual void readSettings(std::istream &file) =0; diff --git a/matrixUtil.h b/matrixUtil.h index d748bf7..12e299f 100644 --- a/matrixUtil.h +++ b/matrixUtil.h @@ -517,6 +517,6 @@ namespace MatrixWalkers { template void operator()(R1 &res,R2 f) const { res= checkBoundsFunc( min, f*toMul+toAdd, max ); } }; -} +} // MatrixWalkers namespace #endif // MATRIXUTIL_HEADER_ diff --git a/modules/quadTree.h b/modules/quadTree.h index 7794e49..0b5c5b1 100644 --- a/modules/quadTree.h +++ b/modules/quadTree.h @@ -120,7 +120,7 @@ protected: void toFile(BitWriter &file,NodeExtremes extremes); /** Loads sons from a stream (extremes contain the min.\ and max.\ block level) */ void fromFile(BitReader &file,NodeExtremes extremes); - }; + }; // MQuadTree::Node class }; #endif // QUADTREE_HEADER_ diff --git a/modules/stdDomains.cpp b/modules/stdDomains.cpp index fa8df4a..8c015ca 100644 --- a/modules/stdDomains.cpp +++ b/modules/stdDomains.cpp @@ -5,29 +5,6 @@ enum { MinDomSize=8, MinRngSize=4 }; using namespace std; - -/* -#include -void debugPool(const ISquareDomains::Pool &pool) { - // create and fill the image - QImage image( pool.width, pool.height, QImage::Format_RGB32 ); - - for (int y=0; y(pool.width,zoom+1); int h= rShift(pool.height,zoom+1); @@ -132,8 +109,7 @@ void MStdDomains::fillPixelsInPools(PlaneBlock &planeBlock) { } // we have the right procedure -> fill the first pool ASSERT( begin->level == 1 ); - shrinkProc( planeBlock.pixels, begin->pixels - , begin->width, begin->height ); + shrinkProc( planeBlock.pixels, begin->pixels, begin->width, begin->height ); // fill the rest (in the same-type interval) while (++begin != end) { ASSERT( halfShrinkOK(begin-1,begin,zoom) ); @@ -177,7 +153,7 @@ void MStdDomains::fillPixelsInPools(PlaneBlock &planeBlock) { namespace NOSPACE { /** Computes the ideal domain density for pool, level and max.\ domain count, * the density is push_back-ed, returns the generated domain count (used once) - * \relates MStandardDomains */ + * \relates MStdDomains */ inline static int bestDomainDensity( PoolIt pool, int level, int maxCount, int zoom , vector &result) { level-= zoom; @@ -189,42 +165,9 @@ namespace NOSPACE { result.push_back(0); return 0; } - /* - int dens= 1+(int)floor(sqrt( float(wms*hms)/maxCount )); - int wdd= wms/dens, hdd= hms/dens; - int count= (wdd+1)*(hdd+1); - if (count>maxCount) { - int wdiff= wms-wdd*dens, hdiff= hms-hdd*dens; - dens+= 1+(int)(min( wdiff/float(wdd), hdiff/float(hdd) )); - count= (wms/dens+1)*(hms/dens+1); - ASSERT(count<=maxCount)x; - } - result.push_back(dens); - return count; - */ - /* - int xLowCount= (int)floor( sqrt(maxCount*wms/(double)hms) -1 ); - int yLowCount= (int)floor( sqrt(maxCount*hms/(double)wms) -1 ); - int dens= (int)ceil(max( wms/(double)xLowCount, hms/(double)yLowCount )); - - if (count<=maxCount) { - dens= (short)floor(min( wms/xHighCount, hms/yHighCount )); - ASSERT( wms/dens==xHighCount && hms/dens==yHighCount ); - } else { - dens= (short)floor(max( wms/xHighCount, hms/yHighCount )); - count= (wms/dens+1)*(hms/dens+1); - - if (count>maxCount) { - dens= (short)floor(min( wms/xLowCount, hms/yLowCount )); - count= (xLowCount+1)*(yLowCount+1); - ASSERT( wms/dens==xLowCount && hms/dens==yLowCount ); - } - } - */ - //int dens= (int)ceil(sqrt( wms*hms/(double)maxCount )); int dens; if (maxCount>1) { - double temp= ( wms+hms+sqrt( sqr(wms+hms) +double(4*wms*hms)*(maxCount-1) ) ) + Real temp= ( wms+hms+sqrt( sqr(wms+hms) +Real(4*wms*hms)*(maxCount-1) ) ) / ( 2*(maxCount-1) ); dens= (int)ceil(temp); } else @@ -242,7 +185,7 @@ namespace NOSPACE { /** Generates (\p results.push_back) densities for domains on level \p level for * all pools of one type. It distributes at most \p maxCount domains among * the pools' scale-levels in one of three ways (\p divType) - * and returns the number of generated domains \relates MStandardDomains */ + * and returns the number of generated domains \relates MStdDomains */ static int divideDomsInType( PoolIt begin, PoolIt end, int maxCount, int level , char divType, int zoom, vector &results ) { ASSERT( begin!=end && divType>=0 && divType<=2 ); @@ -427,29 +370,29 @@ namespace NOSPACE { using namespace MatrixWalkers; /** Performs a simple 50\%^2 image shrink (dimensions belong to the destination) - * \relates MStandardDomains */ + * \relates MStdDomains */ void shrinkToHalf( CSMatrix src, SMatrix dest, int width, int height ) { walkOperate( Checked(dest,Block(0,0,width,height)) , HalfShrinker(src), ReverseAssigner() ); } - /** Performs a simple 50\% image horizontal shrink (dimensions belong to the destination) - * \relates MStandardDomains */ + /** Performs a simple 33\%x66\% image horizontal shrink + * (dimensions belong to the destination) \relates MStdDomains */ void shrinkHorizontally( CSMatrix src, SMatrix dest, int width, int height ) { walkOperate( Checked(dest,Block(0,0,width,height)) , HorizShrinker(src), ReverseAssigner() ); } - /** Performs a simple 50\% image vertical shrink (dimensions belong to the destination) - * \relates MStandardDomains */ + /** Performs a simple 66\%x33\% image vertical shrink + * (dimensions belong to the destination) \relates MStdDomains */ void shrinkVertically( CSMatrix src, SMatrix dest, int width, int height ) { walkOperate( Checked(dest,Block(0,0,width,height)) , VertShrinker(src), ReverseAssigner() ); } - /** Performs 50\% shrink with 45-degree anticlockwise rotation (\p side - the length of - * the destination square; \p sx0, \p sy0 - the top-left of the enclosing source square) - * \relates MStandardDomains */ + /** Performs 50\% shrink with 45-degree anticlockwise rotation + * (\p side - the length of the destination square; + * \p sx0, \p sy0 - the top-left of the enclosing source square) \relates MStdDomains */ void shrinkToDiamond( CSMatrix src, SMatrix dest, int side ) { walkOperate( Checked(dest,Block(0,0,side,side)) , DiamShrinker(src,side), ReverseAssigner() ); diff --git a/modules/stdDomains.h b/modules/stdDomains.h index 920e66d..f484d1e 100644 --- a/modules/stdDomains.h +++ b/modules/stdDomains.h @@ -3,6 +3,7 @@ #include "../interfaces.h" +/// \ingroup modules /** Standard domain-pool generator. Available settings: * - the decrease of max. number of domains per level * - how many of more-downscaled domains to use -- 2.11.4.GIT