|
From: Gustavo P. B. <gb...@us...> - 2005-07-13 03:31:22
|
Update of /cvsroot/kimageprocess/kimageprocess/src/libkimageprocess In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21028/src/libkimageprocess Modified Files: ktcalculation.cpp ktfeature.cpp ktfeature.h ktfeaturemanager.cpp ktfeaturemanager.h ktmethod.cpp ktmethod.h Log Message: Re-enabled caching (but this time working) Index: ktfeature.h =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/libkimageprocess/ktfeature.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ktfeature.h 6 Jul 2005 01:34:43 -0000 1.6 +++ ktfeature.h 13 Jul 2005 03:31:13 -0000 1.7 @@ -53,6 +53,8 @@ bool enabled() { return m_enabled; } void setEnabled(bool enable) { m_enabled = enable; } + void clear(); + protected: QString m_featureName; QString m_longName; Index: ktfeature.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/libkimageprocess/ktfeature.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- ktfeature.cpp 6 Jul 2005 01:34:43 -0000 1.9 +++ ktfeature.cpp 13 Jul 2005 03:31:13 -0000 1.10 @@ -54,20 +54,12 @@ float KTFeature::calculate( KTImage *img, int direction ) { - /*if (img == m_img) - { - Cache::iterator value = m_cacheValue.find(direction); - if (value != m_cacheValue.end()) - return value.data(); - } - else - { - m_img = img; - m_cacheValue.clear(); - } - */ + Cache::iterator value = m_cacheValue.find(direction); + if (value != m_cacheValue.end()) + return value.data(); + float result = _calculate(img, direction); - //m_cacheValue[direction] = result; + m_cacheValue[direction] = result; return result; } @@ -84,4 +76,9 @@ return KTFeatureManager::self(); } +void KTFeature::clear() +{ + m_cacheValue.clear(); +} + #include "ktfeature.moc" Index: ktmethod.h =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/libkimageprocess/ktmethod.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- ktmethod.h 1 Jul 2005 00:37:19 -0000 1.10 +++ ktmethod.h 13 Jul 2005 03:31:13 -0000 1.11 @@ -42,8 +42,7 @@ KTMethod(); ~KTMethod(); - ///must be reimplemented by child classes - virtual void calculate(KTImage *img, int imgClass = 0); + void calculate(KTImage *img, int imgClass = 0); QString methodName(); QString longName(); @@ -59,6 +58,10 @@ QString m_longName; bool m_testingData; + + ///must be reimplemented by child classes + virtual void _calculate(KTImage *img, int imgClass = 0); + }; #endif Index: ktfeaturemanager.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/libkimageprocess/ktfeaturemanager.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- ktfeaturemanager.cpp 7 Jul 2005 03:19:54 -0000 1.13 +++ ktfeaturemanager.cpp 13 Jul 2005 03:31:13 -0000 1.14 @@ -188,22 +188,34 @@ for (unsigned int i=0; i < groups.count(); ++i) { - if (groups.item(i).nodeName() == "FeatureGroup") + if (groups.item(i).nodeName() == "FeatureGroup") + { + QDomElement current = groups.item(i).toElement(); + QString groupName = current.attribute("Name"); + FeatureList *list = m_features[groupName]; + if (list) { - QDomElement current = groups.item(i).toElement(); - QString groupName = current.attribute("Name"); - FeatureList *list = m_features[groupName]; - if (list) - { - disableFeatures(groupName); - QStringList features = QStringList::split(',', current.attribute("EnabledFeatures")); - for (QStringList::Iterator it = features.begin(); it != features.end(); ++it ) - { - if ((*list)[*it]) - (*list)[*it]->setEnabled(true); - } - } + disableFeatures(groupName); + QStringList features = QStringList::split(',', current.attribute("EnabledFeatures")); + for (QStringList::Iterator it = features.begin(); it != features.end(); ++it ) + { + if ((*list)[*it]) + (*list)[*it]->setEnabled(true); + } } + } } } + +void KTFeatureManager::clearCache(const QString &group) +{ + FeatureList *features = m_features[group]; + if (!features) + return; + + QDictIterator<KTFeature> it(*features); + for (; it.current(); ++it) + it.current()->clear(); +} + #include "ktfeaturemanager.moc" Index: ktcalculation.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/libkimageprocess/ktcalculation.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- ktcalculation.cpp 9 Jul 2005 16:16:23 -0000 1.15 +++ ktcalculation.cpp 13 Jul 2005 03:31:13 -0000 1.16 @@ -162,7 +162,6 @@ while ( (x + m_window_size.width <= width) && (y + m_window_size.height <= height) && (i < m_iterations || m_iterations == 0) ) { - kdDebug() << "SEQ: using x=" << x << " y=" << y << " w=" << m_window_size.width << " h=" << m_window_size.height << endl; tmpimg = img->returnWindow(x, y, m_window_size.width, m_window_size.height); m_method->calculate(tmpimg, imgClass); delete tmpimg; @@ -183,7 +182,6 @@ while ( (x + m_window_size.width <= width) && (y + m_window_size.height <= height) && (i < m_iterations || m_iterations == 0) ) { - kdDebug() << "CASC: using x=" << x << " y=" << y << " w=" << m_window_size.width << " h=" << m_window_size.height << endl; tmpimg = img->returnWindow(x, y, m_window_size.width, m_window_size.height); m_method->calculate(tmpimg, imgClass); delete tmpimg; Index: ktfeaturemanager.h =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/libkimageprocess/ktfeaturemanager.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- ktfeaturemanager.h 7 Jul 2005 03:19:54 -0000 1.7 +++ ktfeaturemanager.h 13 Jul 2005 03:31:13 -0000 1.8 @@ -57,6 +57,8 @@ QDict<FeatureList> *allFeatures(); + void clearCache(const QString &group); + public slots: void slotSave(QDomDocument *doc, QDomElement *elem); void slotLoad(QDomElement *elem); Index: ktmethod.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/libkimageprocess/ktmethod.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- ktmethod.cpp 23 Jun 2005 23:19:41 -0000 1.8 +++ ktmethod.cpp 13 Jul 2005 03:31:13 -0000 1.9 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2005 by * + * Copyright (C) 2004-2005 by * * Gustavo Pichorim Boiko <gus...@kd...> * * Herton Ronaldo Krzesinski <he...@my...> * * * @@ -22,6 +22,7 @@ #include "ktmethod.h" #include "ktimage.h" #include "ktclassifbackend.h" +#include "ktfeaturemanager.h" KTMethod::KTMethod() { @@ -35,8 +36,18 @@ void KTMethod::calculate(KTImage *img, int imgClass) { + //clear the cache + KTFeatureManager::self()->clearCache(m_methodName); + + _calculate(img, imgClass); +} + +void KTMethod::_calculate( KTImage * img, int imgClass ) +{ Q_UNUSED(img); Q_UNUSED(imgClass); + + //do nothing here } QString KTMethod::methodName() |