Browse files

Réécriture et généralisation de Histogram et Interval avec impact sur…

… les autres classes.
  • Loading branch information...
1 parent 35f77c4 commit 6e8d0d2353fa2458a5fc9d9088b8bb5d8d2b5abd @akrah committed Sep 30, 2012
View
5 TKDetection.pro
@@ -35,9 +35,6 @@ SOURCES = main.cpp \
contourcurve.cpp \
datexport.cpp \
dicomreader.cpp \
- histoexport.cpp \
- interval.cpp \
- intervalscomputer.cpp \
mainwindow.cpp \
marrow.cpp \
marrowextractor.cpp \
@@ -63,10 +60,8 @@ HEADERS = billon.h \
datexport.h \
dicomreader.h \
global.h \
- histoexport.h \
histogram.h \
interval.h \
- intervalscomputer.h \
intervalscomputerdefaultparameters.h \
mainwindow.h \
marrow.h \
View
8 inc/billon.h
@@ -176,8 +176,8 @@ qreal BillonTpl<T>::getRestrictedAreaBoudingBoxRadius( const Marrow *marrow, con
radius = 0.;
for ( k=0 ; k<depth ; ++k ) {
const arma::Mat<T> &currentSlice = this->slice(k);
- const int xCenter = (marrow != 0 && marrow->interval().containsClosed(k))?marrow->at(k-marrow->interval().minValue()).x:width/2;
- const int yCenter = (marrow != 0 && marrow->interval().containsClosed(k))?marrow->at(k-marrow->interval().minValue()).y:height/2;
+ const int xCenter = (marrow != 0 && marrow->interval().containsClosed(k))?marrow->at(k-marrow->interval().min()).x:width/2;
+ const int yCenter = (marrow != 0 && marrow->interval().containsClosed(k))?marrow->at(k-marrow->interval().min()).y:height/2;
orientation = 0.;
counter = 0;
@@ -222,8 +222,8 @@ qreal BillonTpl<T>::getRestrictedAreaMeansRadius( const Marrow *marrow, const in
radius = 0.;
for ( k=0 ; k<depth ; ++k ) {
const arma::Mat<T> &currentSlice = this->slice(k);
- const int xCenter = (marrow != 0 && marrow->interval().containsClosed(k))?marrow->at(k-marrow->interval().minValue()).x:width/2;
- const int yCenter = (marrow != 0 && marrow->interval().containsClosed(k))?marrow->at(k-marrow->interval().minValue()).y:height/2;
+ const int xCenter = (marrow != 0 && marrow->interval().containsClosed(k))?marrow->at(k-marrow->interval().min()).x:width/2;
+ const int yCenter = (marrow != 0 && marrow->interval().containsClosed(k))?marrow->at(k-marrow->interval().min()).y:height/2;
orientation = 0.;
for ( i=0 ; i<nbPolygonPoints ; ++i )
View
4 inc/datexport.h
@@ -4,10 +4,10 @@
#include <QString>
#include "billon_def.h"
-class Interval;
+template<typename T> class Interval;
namespace DatExport {
- void process( const Billon &billon, const Interval &slicesInterval, const Interval &intensityIntervale, const QString &fileName, const int &resolution = 1, const qreal &contrastFactor = 1. );
+ void process( const Billon &billon, const Interval<int> &slicesInterval, const Interval<int> &intensityIntervale, const QString &fileName, const int &resolution = 1, const qreal &contrastFactor = 1. );
}
#endif // DATEXPORT_H
View
15 inc/histoexport.h
@@ -1,15 +0,0 @@
-#ifndef HISTOEXPORT_H
-#define HISTOEXPORT_H
-
-#include <QString>
-#include "slicehistogram.h"
-#include "billon_def.h"
-class Interval;
-class Marrow;
-
-namespace HistoExport {
- void process( const SliceHistogram &sliceHisto, const Interval &interval, const QString &fileName);
-}
-
-
-#endif // OFSEXPORT_H
View
264 inc/histogram.h
@@ -1,164 +1,193 @@
#ifndef HISTOGRAM_H
#define HISTOGRAM_H
-#include"intervalscomputerdefaultparameters.h"
-#include <QVector>
+#include "intervalscomputerdefaultparameters.h"
#include "interval.h"
#include <numeric>
+#include <QVector>
+#include <QTextStream>
+
+/*######################################################
+ # DECLARATION
+ ######################################################*/
template <typename T>
-class Histogram
+class Histogram : public QVector<T>
{
public:
Histogram();
virtual ~Histogram();
- int size() const;
- T value( int i ) const;
+ const QVector<int> & maximums() const;
+ const QVector< Interval<int> > & intervals() const;
+
+ T min() const;
+ T max() const;
int nbMaximums() const;
int maximumIndex( int i ) const;
int nbIntervals() const;
int intervalIndex( int i ) const;
- T maxValue() const;
- T minValue() const;
T thresholdOfMaximums( const int percentage ) const;
T firstdDerivated( int i, bool loop ) const;
void meansSmoothing( int smoothingRadius, bool loop );
- void maximumsComputing( int minimumHeightPercentageOfMaximum, int neighborhoodOfMaximums, bool loop );
- void intervalsComputing( int derivativesPercentage, int minimumWidthOfIntervals, bool loop );
+ void computeMaximums( int minimumHeightPercentageOfMaximum, int neighborhoodOfMaximums, bool loop );
+ void computeIntervals( int derivativesPercentage, int minimumWidthOfIntervals, bool loop );
void computeAll( int smoothingRadius, int minimumHeightPercentageOfMaximum, int neighborhoodOfMaximums, int derivativesPercentage, int minimumWidthOfIntervals, bool loop );
+
protected:
- QVector<T> _datas;
QVector<int> _maximums;
- QVector<Interval> _intervals;
+ QVector< Interval<int> > _intervals;
};
+template <typename T>
+QTextStream & operator <<( QTextStream & stream, const Histogram<T> &histogram )
+{
+ for ( int i=0 ; i<histogram.size() ; ++i ) {
+ stream << i << " " << histogram[i] << endl;
+ }
+ return stream;
+}
+
+
+/*######################################################
+ # INSTANCIATION
+ ######################################################*/
+
+/**********************************
+ * Public constructors/destructors
+ **********************************/
+
template <typename T> Histogram<T>::Histogram() {}
template <typename T> Histogram<T>::~Histogram() {}
-/*******************************
+/**********************************
* Public getters
- *******************************/
+ **********************************/
template <typename T>
-int Histogram<T>::size() const
+inline const QVector<int> & Histogram<T>::maximums() const
{
- return _datas.size();
+ return _maximums;
}
template <typename T>
-T Histogram<T>::value( int i ) const
+inline const QVector< Interval<int> > & Histogram<T>::intervals() const
{
- if (i < 0 || i >= size()) return T();
- return _datas[i];
+ return _intervals;
}
template <typename T>
-int Histogram<T>::nbMaximums() const
+T Histogram<T>::min() const
{
- return _maximums.size();
+ typename QVector<T>::const_iterator begin = this->begin();
+ typename QVector<T>::const_iterator end = this->end();
+
+ T min = begin != end ? (*begin++) : T();
+ while ( begin != end ) min = qMin(min,*begin++);
+
+ return min;
}
template <typename T>
-int Histogram<T>::maximumIndex( int i ) const
+T Histogram<T>::max() const
{
- if ( i<0 || i>=_maximums.size() ) return -1;
- return _maximums[i];
+ typename QVector<T>::const_iterator begin = this->begin();
+ typename QVector<T>::const_iterator end = this->end();
+
+ T max = begin != end ? (*begin++) : T();
+ while ( begin != end ) max = qMax(max,*begin++);
+
+ return max;
}
template <typename T>
-int Histogram<T>::nbIntervals() const
+inline int Histogram<T>::nbMaximums() const
{
- return _intervals.size();
+ return _maximums.size();
}
template <typename T>
-int Histogram<T>::intervalIndex( int i ) const
+int Histogram<T>::maximumIndex( int i ) const
{
- if ( i<0 || i>=_maximums.size() ) return -1;
- return (_intervals[i].minValue()+_intervals[i].maxValue())/2;
+ if ( i<0 || i>=nbMaximums() ) return -1;
+ return _maximums[i];
}
template <typename T>
-T Histogram<T>::minValue() const
+inline int Histogram<T>::nbIntervals() const
{
- typename QVector<T>::const_iterator begin = _datas.begin();
- typename QVector<T>::const_iterator end = _datas.end();
-
- T res = T();
- while ( begin != end ) res = qMin(res,*begin++);
- return res;
+ return _intervals.size();
}
template <typename T>
-T Histogram<T>::maxValue() const
+int Histogram<T>::intervalIndex( int i ) const
{
- typename QVector<T>::const_iterator begin = _datas.begin();
- typename QVector<T>::const_iterator end = _datas.end();
-
- T res = T();
- while ( begin != end ) res = qMax(res,*begin++);
- return res;
+ if ( i<0 || i>=nbMaximums() ) return -1;
+ return (_intervals[i].min()+_intervals[i].max())/2;
}
template <typename T>
T Histogram<T>::thresholdOfMaximums( const int percentage ) const
{
- const T min = minValue();
- const T max = maxValue();
+ const T min = this->min();
+ const T max = this->max();
return (max-min)*(percentage/100.)+min;
}
template <typename T>
T Histogram<T>::firstdDerivated( int i, bool loop ) const
{
- return i>0 ? _datas[i] - _datas[i-1] : loop ? _datas[0] - _datas.last() : _datas[1] - _datas[0];
+ Q_ASSERT_X( i>=0 && i<size(), "Histogram::firstDerivated", "index en dehors des bornes de l'histogramme" );
+ return i>1 ? this->at(i) - this->at(i-2) : loop && this->size()>1 ? this->at(i) - this->at(this->size()-2+i) : T();
}
-/*******************************
+/**********************************
* Public setters
- *******************************/
+ **********************************/
template <typename T>
void Histogram<T>::meansSmoothing( int smoothingRadius, bool loop )
{
- const int sizeHist = size();
- const int maskWidth = 2*smoothingRadius+1;
- int i;
-
- QVector<T> copy;
- copy.reserve( sizeHist + 2*smoothingRadius );
- if ( loop ) {
- for ( i=sizeHist-smoothingRadius ; i<sizeHist ; ++i ) copy << _datas[i];
- copy << _datas;
- for ( i=0 ; i<smoothingRadius ; ++i ) copy << _datas[i];
- }
- else
+ const int sizeHist = this->size();
+ if ( sizeHist > 0 )
{
- for ( i=sizeHist-smoothingRadius ; i<sizeHist ; ++i ) copy << _datas[0];
- copy << _datas;
- for ( i=sizeHist-smoothingRadius ; i<sizeHist ; ++i ) copy << _datas[sizeHist-1];
- }
+ const int maskWidth = 2*smoothingRadius+1;
+ int i;
- typename QVector<T>::const_iterator copyIterBegin = copy.begin();
- typename QVector<T>::const_iterator copyIterEnd = copyIterBegin+(2*smoothingRadius+1);
+ QVector<T> copy;
+ copy.reserve( sizeHist + 2*smoothingRadius );
+ if ( loop ) {
+ for ( i=sizeHist-smoothingRadius ; i<sizeHist ; ++i ) copy << this->at(i);
+ copy << (*this);
+ for ( i=0 ; i<smoothingRadius ; ++i ) copy << this->at(i);
+ }
+ else
+ {
+ for ( i=sizeHist-smoothingRadius ; i<sizeHist ; ++i ) copy << this->at(0);
+ copy << (*this);
+ for ( i=sizeHist-smoothingRadius ; i<sizeHist ; ++i ) copy << this->at(sizeHist-1);
+ }
- typename QVector<T>::iterator histIter = _datas.begin();
- const typename QVector<T>::const_iterator histEnd = _datas.end();
+ typename QVector<T>::const_iterator copyIterBegin = copy.begin();
+ typename QVector<T>::const_iterator copyIterEnd = copyIterBegin+(2*smoothingRadius+1);
- while ( histIter != histEnd )
- {
- *histIter++ = std::accumulate( copyIterBegin++, copyIterEnd++, T() )/static_cast<T>(maskWidth);
+ typename QVector<T>::iterator histIter = this->begin();
+ const typename QVector<T>::const_iterator histEnd = this->end();
+
+ while ( histIter != histEnd )
+ {
+ *histIter++ = std::accumulate( copyIterBegin++, copyIterEnd++, T() )/static_cast<T>(maskWidth);
+ }
}
}
template <typename T>
-void Histogram<T>::maximumsComputing( int minimumHeightPercentageOfMaximum, int neighborhoodOfMaximums, bool loop )
+void Histogram<T>::computeMaximums( int minimumHeightPercentageOfMaximum, int neighborhoodOfMaximums, bool loop )
{
- const int sizeHist = size();
+ const int sizeHist = this->size();
_maximums.clear();
if ( sizeHist > 0 )
{
@@ -168,24 +197,24 @@ void Histogram<T>::maximumsComputing( int minimumHeightPercentageOfMaximum, int
{
for ( int i=sizeHist-neighborhoodOfMaximums ; i<sizeHist ; ++i )
{
- copy << _datas[i];
+ copy << this->at(i);
}
- copy << _datas;
+ copy << (*this);
for ( int i=0 ; i<neighborhoodOfMaximums ; ++i )
{
- copy << _datas[i];
+ copy << this->at(i);
}
}
else
{
for ( int i=sizeHist-neighborhoodOfMaximums ; i<sizeHist ; ++i )
{
- copy << _datas[0];
+ copy << this->at(0);
}
- copy << _datas;
+ copy << (*this);
for ( int i=0 ; i<neighborhoodOfMaximums ; ++i )
{
- copy << _datas[sizeHist-1];
+ copy << this->at(sizeHist-1);
}
}
@@ -219,20 +248,20 @@ void Histogram<T>::maximumsComputing( int minimumHeightPercentageOfMaximum, int
}
template <typename T>
-void Histogram<T>::intervalsComputing( int derivativesPercentage, int minimumWidthOfIntervals, bool loop )
+void Histogram<T>::computeIntervals( int derivativesPercentage, int minimumWidthOfIntervals, bool loop )
{
_intervals.clear();
if ( !_maximums.isEmpty() )
{
- const int sizeHist = size();
+ const int sizeHist = this->size();
int cursorMax, cursorMin, derivativeThreshold;
bool fusionLast, fusionFirst;
cursorMax = -1;
for ( int i=0 ; i<nbMaximums() ; ++i )
{
cursorMin = _maximums[i];
- derivativeThreshold = _datas[cursorMin]*derivativesPercentage/100.;
- while ( _datas[cursorMin] > derivativeThreshold )
+ derivativeThreshold = this->at(cursorMin)*derivativesPercentage/100.;
+ while ( this->at(cursorMin) > derivativeThreshold )
{
cursorMin--;
if ( cursorMin < 0 ) cursorMin = sizeHist-1;
@@ -246,7 +275,7 @@ void Histogram<T>::intervalsComputing( int derivativesPercentage, int minimumWid
cursorMax = _maximums[i]+1;
if ( cursorMax == sizeHist ) cursorMax = 0;
- while ( _datas[cursorMax] > derivativeThreshold )
+ while ( this->at(cursorMax) > derivativeThreshold )
{
cursorMax++;
if ( cursorMax == sizeHist ) cursorMax = 0;
@@ -261,110 +290,109 @@ void Histogram<T>::intervalsComputing( int derivativesPercentage, int minimumWid
if ( cursorMax>cursorMin && (cursorMax-cursorMin) >= minimumWidthOfIntervals )
{
- if ( _intervals.isEmpty() || _intervals.last().maxValue() <= cursorMin )
+ if ( _intervals.isEmpty() || _intervals.last().max() <= cursorMin )
{
- _intervals.append(Interval(cursorMin,cursorMax));
+ _intervals.append(Interval<int>(cursorMin,cursorMax));
}
else if ( _intervals.last().isValid() )
{
- _intervals.last().setMin( qMin(_intervals.last().minValue(), cursorMin) );
- _intervals.last().setMax( qMax(_intervals.last().maxValue(), cursorMax) );
+ _intervals.last().setMin( qMin(_intervals.last().min(), cursorMin) );
+ _intervals.last().setMax( qMax(_intervals.last().max(), cursorMax) );
if ( _intervals.size() > 1 )
{
- Interval &previousOfLast = _intervals[_intervals.size()-2];
- if ( previousOfLast.maxValue() > _intervals.last().minValue() )
+ Interval<int> &previousOfLast = _intervals[_intervals.size()-2];
+ if ( previousOfLast.max() > _intervals.last().min() )
{
- previousOfLast.setMin( qMin(previousOfLast.minValue(), _intervals.last().minValue()) );
- previousOfLast.setMax( qMax(previousOfLast.maxValue(), _intervals.last().maxValue()) );
+ previousOfLast.setMin( qMin(previousOfLast.min(), _intervals.last().min()) );
+ previousOfLast.setMax( qMax(previousOfLast.max(), _intervals.last().max()) );
_intervals.pop_back();
}
}
- cursorMin = _intervals.last().minValue();
- cursorMax = _intervals.last().maxValue();
+ cursorMin = _intervals.last().min();
+ cursorMax = _intervals.last().max();
}
else
{
- _intervals.last().setMax( qMax(_intervals.last().maxValue(), cursorMax) );
- cursorMax = _intervals.last().maxValue();
+ _intervals.last().setMax( qMax(_intervals.last().max(), cursorMax) );
+ cursorMax = _intervals.last().max();
}
}
else if ( cursorMax<cursorMin && (sizeHist-cursorMin+cursorMax) >= minimumWidthOfIntervals )
{
if ( loop )
{
- if ( _intervals.isEmpty() || (_intervals.last().isValid() && _intervals.last().maxValue() <= cursorMin && _intervals.first().isValid() && _intervals.first().minValue() >= cursorMax) )
+ if ( _intervals.isEmpty() || (_intervals.last().isValid() && _intervals.last().max() <= cursorMin && _intervals.first().isValid() && _intervals.first().min() >= cursorMax) )
{
- _intervals.append(Interval(cursorMin,cursorMax));
+ _intervals.append(Interval<int>(cursorMin,cursorMax));
}
else
{
fusionLast = false;
- if ( _intervals.last().isValid() && _intervals.last().maxValue() > cursorMin )
+ if ( _intervals.last().isValid() && _intervals.last().max() > cursorMin )
{
- _intervals.last().setMin( qMin(_intervals.last().minValue(), cursorMin) );
+ _intervals.last().setMin( qMin(_intervals.last().min(), cursorMin) );
_intervals.last().setMax(cursorMax);
fusionLast = true;
}
if ( !_intervals.last().isValid() )
{
- _intervals.last().setMin( qMin(_intervals.last().minValue(), cursorMin) );
- _intervals.last().setMax( qMax(_intervals.last().maxValue(), cursorMax) );
+ _intervals.last().setMin( qMin(_intervals.last().min(), cursorMin) );
+ _intervals.last().setMax( qMax(_intervals.last().max(), cursorMax) );
fusionLast = true;
}
- if ( !fusionLast ) _intervals.append( Interval(cursorMin, cursorMax) );
+ if ( !fusionLast ) _intervals.append( Interval<int>(cursorMin, cursorMax) );
else
{
- cursorMin = _intervals.last().minValue();
- cursorMax = _intervals.last().maxValue();
+ cursorMin = _intervals.last().min();
+ cursorMax = _intervals.last().max();
}
fusionFirst = false;
- if ( _intervals.first().isValid() && _intervals.first().minValue() < _intervals.last().maxValue() )
+ if ( _intervals.first().isValid() && _intervals.first().min() < _intervals.last().max() )
{
- _intervals.first().setMin( _intervals.last().minValue() );
- _intervals.first().setMax( qMax(_intervals.first().maxValue(), _intervals.last().maxValue()) );
+ _intervals.first().setMin( _intervals.last().min() );
+ _intervals.first().setMax( qMax(_intervals.first().max(), _intervals.last().max()) );
fusionFirst = true;
}
if ( !_intervals.first().isValid() )
{
- _intervals.first().setMin( qMin(_intervals.first().minValue(), _intervals.last().minValue()) );
- _intervals.first().setMax( qMax(_intervals.first().maxValue(), _intervals.last().maxValue()) );
+ _intervals.first().setMin( qMin(_intervals.first().min(), _intervals.last().min()) );
+ _intervals.first().setMax( qMax(_intervals.first().max(), _intervals.last().max()) );
fusionFirst = true;
}
if (fusionFirst)
{
_intervals.pop_back();
- cursorMin = _intervals.first().minValue();
- cursorMax = _intervals.first().maxValue();
+ cursorMin = _intervals.first().min();
+ cursorMax = _intervals.first().max();
}
}
}
else if ( _intervals.isEmpty() )
{
- _intervals.append(Interval(0,cursorMax));
+ _intervals.append(Interval<int>(0,cursorMax));
cursorMin = 0;
}
else
{
- _intervals.append(Interval(cursorMin,sizeHist-1));
+ _intervals.append(Interval<int>(cursorMin,sizeHist-1));
cursorMax = sizeHist-1;
}
}
}
- if ( !_intervals.first().isValid() && _intervals.last().isValid() && _intervals.first().minValue() < _intervals.last().maxValue() )
+ if ( !_intervals.first().isValid() && _intervals.last().isValid() && _intervals.first().min() < _intervals.last().max() )
{
- _intervals.first().setMin( qMin(_intervals.first().minValue(),_intervals.last().minValue()) );
+ _intervals.first().setMin( qMin(_intervals.first().min(),_intervals.last().min()) );
_intervals.pop_back();
}
}
}
-
template <typename T>
void Histogram<T>::computeAll( int smoothingRadius, int minimumHeightPercentageOfMaximum, int neighborhoodOfMaximums, int derivativesPercentage, int minimumWidthOfIntervals, bool loop )
{
meansSmoothing( smoothingRadius, loop );
- maximumsComputing( minimumHeightPercentageOfMaximum, neighborhoodOfMaximums, loop );
- intervalsComputing( derivativesPercentage, minimumWidthOfIntervals, loop );
+ computeMaximums( minimumHeightPercentageOfMaximum, neighborhoodOfMaximums, loop );
+ computeIntervals( derivativesPercentage, minimumWidthOfIntervals, loop );
}
#endif // HISTOGRAM_H
View
151 inc/interval.h
@@ -1,42 +1,149 @@
#ifndef INTERVAL_H
#define INTERVAL_H
-#include <QObject>
+/*######################################################
+ # DECLARATION
+ ######################################################*/
-class Interval : public QObject
+template <typename T>
+class Interval
{
- Q_OBJECT
public:
Interval();
- Interval( const int &minValue, const int &maxValue );
+ Interval( T min, T max );
Interval( const Interval &interval );
+ virtual ~Interval();
- int minValue() const;
- int maxValue() const;
- int count() const;
- int size() const;
- int width() const;
- bool contains( const int &value ) const;
- bool contains( const Interval &interval ) const;
- bool containsOpen( const int &value ) const;
+ T min() const;
+ T max() const;
+ T size() const;
+ T width() const;
+ bool containsOpen( const T &value ) const;
bool containsOpen( const Interval &interval ) const;
- bool containsClosed( const int &value ) const;
+ bool containsClosed( const T &value ) const;
bool containsClosed( const Interval &interval ) const;
-
bool isValid() const;
+ Interval<T> inverted() const;
- Interval inverted() const;
- Interval& operator =(const Interval& other);
+ Interval<T>& operator =( const Interval& other );
-public slots:
- void setMin( const int &minValue );
- void setMax( const int &maxValue );
- void setBounds( const int &minValue, const int &maxValue );
+ void setMin( const T &min );
+ void setMax( const T &max );
+ void setBounds( const T &min, const T &max );
protected:
- int _min;
- int _max;
+ T _min;
+ T _max;
};
+/*######################################################
+ # INSTANCIATION
+ ######################################################*/
+
+/**********************************
+ * Public constructors/destructors
+ **********************************/
+
+template <typename T> Interval<T>::Interval() : _min(T()), _max(T()) {}
+template <typename T> Interval<T>::Interval( T min, T max ) : _min(min), _max(max) {}
+template <typename T> Interval<T>::Interval( const Interval &interval ) : _min(interval._min), _max(interval._max) {}
+template <typename T> Interval<T>::~Interval() {}
+
+/**********************************
+ * Public getters
+ **********************************/
+
+template <typename T>
+inline T Interval<T>::min() const
+{
+ return _min;
+}
+
+template <typename T>
+inline T Interval<T>::max() const
+{
+ return _max;
+}
+
+template <typename T>
+inline T Interval<T>::size() const
+{
+ return _max - _min;
+}
+
+template <typename T>
+inline T Interval<T>::width() const
+{
+ return size();
+}
+
+template <typename T>
+inline bool Interval<T>::containsOpen( const T &value ) const
+{
+ return (value > _min) && (value < _max);
+}
+
+template <typename T>
+inline bool Interval<T>::containsOpen( const Interval &interval ) const
+{
+ return (_min < interval._min) && (_max > interval._max);
+}
+
+template <typename T>
+inline bool Interval<T>::containsClosed( const T &value ) const
+{
+ return (value >= _min) && (value <= _max);
+}
+
+template <typename T>
+inline bool Interval<T>::containsClosed( const Interval &interval ) const
+{
+ return (_min <= interval._min) && (_max >= interval._max);
+}
+
+template <typename T>
+inline bool Interval<T>::isValid() const
+{
+ return _min<=_max;
+}
+
+template <typename T>
+inline Interval<T> Interval<T>::inverted() const
+{
+ return Interval(_max,_min);
+}
+
+/**********************************
+ * Public setters
+ **********************************/
+
+template <typename T>
+Interval<T> &Interval<T>::operator =( const Interval<T>& other )
+{
+ _min = other._min;
+ _max = other._max;
+ return *this;
+}
+
+template <typename T>
+void Interval<T>::setMin( const T &min )
+{
+ _min = min;
+}
+
+template <typename T>
+void Interval<T>::setMax( const T &max )
+{
+
+ _max = max;
+}
+
+template <typename T>
+void Interval<T>::setBounds( const T &min, const T &max )
+{
+ setMin(min);
+ setMax(max);
+}
+
#endif // INTERVAL_H
View
2 inc/intervalscomputerdefaultparameters.h
@@ -4,7 +4,7 @@
#define DEFAULT_MASK_RADIUS 2
#define DEFAULT_MINIMUM_WIDTH_OF_NEIGHBORHOOD 10
#define DEFAULT_MINIMUM_WIDTH_OF_INTERVALS 10
-#define DEFAULT_PERCENTAGE_FOR_MAXIMUM_CANDIDATE 0.3
+#define DEFAULT_PERCENTAGE_FOR_MAXIMUM_CANDIDATE 30
// Types de coupe possibles
namespace SmoothingType {
View
4 inc/mainwindow.h
@@ -94,7 +94,7 @@ private slots:
void initComponentsValues();
void updateUiComponentsValues();
void enabledComponents();
- void computeSectorsHistogramForInterval( const Interval &interval );
+ void computeSectorsHistogramForInterval( const Interval<int> &interval );
private:
Ui::MainWindow *_ui;
@@ -118,7 +118,7 @@ private slots:
QwtPlotHistogram _histogramDistanceMarrowToNearestPoint;
QwtPlotCurve _histogramDistanceMarrowToNearestPointCursor;
- Interval _knotIntervalInDistanceMarrowToNearestPointHistogram;
+ Interval<int> _knotIntervalInDistanceMarrowToNearestPointHistogram;
int _currentSlice;
int _currentMaximum;
View
4 inc/marrow.h
@@ -14,12 +14,12 @@ class Marrow : public QList<iCoord2D>
Marrow( const int &begin, const int &end );
Marrow( const Marrow &marrow );
- const Interval &interval() const;
+ const Interval<int> &interval() const;
void draw( QImage &image, const int &sliceIdx ) const;
private:
- Interval _interval;
+ Interval<int> _interval;
};
#endif // MARROW_H
View
28 inc/ofsexport.h
@@ -5,24 +5,24 @@
#include <QPair>
#include "billon_def.h"
-class Interval;
+template<typename T> class Interval;
class Marrow;
class PiePart;
namespace OfsExport {
- void process( const Billon &billon, const Marrow &marrow, const Interval &interval,
- const QString &fileName, const int &nbEdgesPerSlice = 4,
- const int &radiusOfTubes = 10, bool normalized=true);
- void processOnSector( const Billon &billon, const Marrow &marrow, const Interval &interval,
- const QString &fileName, const qreal &rightAngle,
- const qreal &leftAngle, const int &nbEdgesPerSlice = 4,
- bool normalized=true);
- void processOnAllSectorInAllIntervals( const Billon &billon, const Marrow &marrow,
- const QVector< QPair< Interval, QPair<qreal,qreal> > > &intervals,
- const QString &fileName, const int &nbEdgesPerSlice = 4, bool normalized=true );
- void processRestrictedMesh( const Billon &billon, const Marrow &marrow, const Interval &interval,
- const QString &fileName, const int &resolutionCercle = 100,
- const int &seuilContour = -900, bool normalized=true, bool displayBegEndFaces=true ) ;
+ void process( const Billon &billon, const Marrow &marrow, const Interval<int> &interval,
+ const QString &fileName, const int &nbEdgesPerSlice = 4,
+ const int &radiusOfTubes = 10, bool normalized=true);
+ void processOnSector( const Billon &billon, const Marrow &marrow, const Interval<int> &interval,
+ const QString &fileName, const qreal &rightAngle,
+ const qreal &leftAngle, const int &nbEdgesPerSlice = 4,
+ bool normalized=true);
+ void processOnAllSectorInAllIntervals( const Billon &billon, const Marrow &marrow,
+ const QVector< QPair< Interval<int>, QPair<qreal,qreal> > > &intervals,
+ const QString &fileName, const int &nbEdgesPerSlice = 4, bool normalized=true );
+ void processRestrictedMesh( const Billon &billon, const Marrow &marrow, const Interval<int> &interval,
+ const QString &fileName, const int &resolutionCercle = 100,
+ const int &seuilContour = -900, bool normalized=true, bool displayBegEndFaces=true ) ;
}
View
9 inc/piechartdiagrams.h
@@ -16,21 +16,22 @@ class PieChart;
class QwtPlot;
class QwtPolarPlot;
class QwtIntervalSample;
-class Interval;
+template<typename T> class Interval;
class PieChartDiagrams : public Histogram<qreal>
{
public:
PieChartDiagrams();
~PieChartDiagrams();
- const QVector<Interval> &branchesSectors() const;
+ const QVector< Interval<int> > &knotIntervals() const;
void attach( QwtPolarPlot * const polarPlot );
void attach( QwtPlot * const plot );
void clear();
- void compute( const Billon &billon, const Marrow *marrow, const PieChart &pieChart, const Interval &slicesInterval, const Interval &intensity, const Interval &motionInterval,
+ void compute( const Billon &billon, const Marrow *marrow, const PieChart &pieChart,
+ const Interval<int> &slicesInterval, const Interval<int> &intensity, const Interval<int> &motionInterval,
const int &smoothingRadius, const int &minimumHeightPercentageOfMaximum, const int &maximumsNeighborhood,
const int &derivativePercentage, const int &minimumIntervalWidth, const int &radiusAroundPith );
void highlightCurve( const int &index );
@@ -45,7 +46,7 @@ class PieChartDiagrams : public Histogram<qreal>
private:
QwtPolarCurve _curve;
PointPolarSeriesData *_datasCurve;
- QwtPlotHistogram _histogram;
+ QwtPlotHistogram _plotHistogram;
QwtPolarCurve _curveMaximums;
PointPolarSeriesData *_datasCurveMaximums;
View
8 inc/slicehistogram.h
@@ -13,22 +13,22 @@ class Marrow;
class QwtPlot;
class QwtIntervalSample;
class QwtInterval;
-class Interval;
+template<typename T> class Interval;
class SliceHistogram : public Histogram<qreal>
{
public:
SliceHistogram();
- ~SliceHistogram();
+ virtual ~SliceHistogram();
- const QVector<Interval> &branchesAreas() const;
+ const QVector< Interval<int> > & knotAreas() const;
void attach( QwtPlot * const plot );
void detach();
void clear();
- void constructHistogram( const Billon &billon, const Marrow *marrow, const Interval &intensity, const Interval &motionInterval,
+ void constructHistogram( const Billon &billon, const Marrow *marrow, const Interval<int> &intensity, const Interval<int> &motionInterval,
const int &smoothingRadius, const int &minimumHeightPercentageOfMaximum, const int &maximumsNeighborhood,
const int &derivativePercentage, const int &minimumIntervalWidth, const int &borderPercentageToCut,
const int &radiusAroundPith );
View
16 inc/sliceview.h
@@ -5,7 +5,7 @@
#include "sliceview_def.h"
#include "billon_def.h"
-#include "interval.h"
+template<typename T> class Interval;
class QImage;
class Marrow;
@@ -34,16 +34,16 @@ class SliceView
void setCannyMinimumGradient( const qreal &minimumGradient );
void setCannyMinimumDeviation( const qreal &minimumDeviation );
- void drawSlice( QImage &image, const Billon &billon, const Marrow *marrow, const int &sliceNumber, const Interval &intensityInterval, const Interval &motionInterval );
+ void drawSlice( QImage &image, const Billon &billon, const Marrow *marrow, const int &sliceNumber, const Interval<int> &intensityInterval, const Interval<int> &motionInterval );
private :
- void drawCurrentSlice( QImage &image, const Billon &billon, const int &sliceNumber, const Interval &intensityInterval );
- void drawAverageSlice( QImage &image, const Billon &billon, const Interval &intensityInterval );
- void drawMedianSlice( QImage &image, const Billon &billon, const Interval &intensityInterval );
- void drawMovementSlice( QImage &image, const Billon &billon, const int &sliceNumber, const Interval &intensityInterval, const Interval &motionInterval );
- void drawEdgeDetectionSlice( QImage &image, const Billon &billon, const Marrow *marrow, const int &sliceNumber, const Interval &intensityInterval );
+ void drawCurrentSlice( QImage &image, const Billon &billon, const int &sliceNumber, const Interval<int> &intensityInterval );
+ void drawAverageSlice( QImage &image, const Billon &billon, const Interval<int> &intensityInterval );
+ void drawMedianSlice( QImage &image, const Billon &billon, const Interval<int> &intensityInterval );
+ void drawMovementSlice( QImage &image, const Billon &billon, const int &sliceNumber, const Interval<int> &intensityInterval, const Interval<int> &motionInterval );
+ void drawEdgeDetectionSlice( QImage &image, const Billon &billon, const Marrow *marrow, const int &sliceNumber, const Interval<int> &intensityInterval );
void drawFlowSlice( QImage &image, const Billon &billon, const int &sliceNumber );
- void drawRestrictedArea( QImage &image, const Billon &billon, const Marrow *marrow, const int &sliceNumber, const Interval &intensityInterval );
+ void drawRestrictedArea( QImage &image, const Billon &billon, const Marrow *marrow, const int &sliceNumber, const Interval<int> &intensityInterval );
private:
SliceType::SliceType _typeOfView;
View
4 inc/v3dexport.h
@@ -4,10 +4,10 @@
#include "billon_def.h"
class QString;
class Marrow;
-class Interval;
+template<typename T> class Interval;
namespace V3DExport {
- void process( const Billon &billon, const Marrow *marrow, const QString &fileName, const Interval &interval, const int &threshold );
+ void process( const Billon &billon, const Marrow *marrow, const QString &fileName, const Interval<int> &interval, const int &threshold );
}
#endif // V3DEXPORT_H
View
12 src/datexport.cpp
@@ -9,22 +9,22 @@
namespace DatExport
{
- void process( const Billon &billon, const Interval &slicesInterval, const Interval &intensityInterval, const QString &fileName, const int &resolution, const qreal &contrastFactor )
+ void process( const Billon &billon, const Interval<int> &slicesInterval, const Interval<int> &intensityInterval, const QString &fileName, const int &resolution, const qreal &contrastFactor )
{
QFile file(fileName);
if ( file.open(QIODevice::WriteOnly) )
{
- const int firstSlice = slicesInterval.minValue();
- const int lastSlice = slicesInterval.maxValue();
+ const int firstSlice = slicesInterval.min();
+ const int lastSlice = slicesInterval.max();
const int width = billon.n_cols;
const int height = billon.n_rows;
- const int minValue = intensityInterval.minValue();
- const int maxValue = intensityInterval.maxValue();
+ const int minValue = intensityInterval.min();
+ const int maxValue = intensityInterval.max();
const int shift = resolution-1;
const qreal fact = 255.0/(intensityInterval.size());
QTextStream tStream(&file);
- tStream << "1 " << width/resolution << " " << height/resolution << " " << slicesInterval.count() << " 1 1 1 1";
+ tStream << "1 " << width/resolution << " " << height/resolution << " " << slicesInterval.width()+1 << " 1 1 1 1";
tStream.flush();
QDataStream dStream(&file);
View
19 src/histoexport.cpp
@@ -1,19 +0,0 @@
-#include "inc/histoexport.h"
-
-#include "inc/interval.h"
-
-#include <QFile>
-#include <QTextStream>
-
-namespace HistoExport {
- void process( const SliceHistogram &sliceHisto, const Interval &interval, const QString &fileName) {
- QFile file(fileName);
- if ( file.open(QIODevice::WriteOnly) ) {
- QTextStream stream(&file);
- for ( int i=interval.minValue() ; i<=interval.maxValue() ; i++ ) {
- stream << i << " " << sliceHisto.value(i) << endl;
- }
- file.close();
- }
- }
-}
View
14 src/interval.cpp
@@ -17,7 +17,7 @@ int Interval::minValue() const
return _min;
}
-int Interval::maxValue() const
+int Interval::max() const
{
return _max;
}
@@ -49,32 +49,32 @@ bool Interval::contains( const Interval &interval ) const
bool Interval::containsOpen( const int &value ) const
{
- return (value > minValue()) && (value < maxValue());
+ return (value > minValue()) && (valmaxValue());
}
bool Interval::containsOpen( const Interval &interval ) const
{
- return (minValue() < interval.minValue()) && (maxValue() > interval.maxValue());
+ return (minValue() < interval.minValmax (maxValue() >maxl.maxValue());
}
bool Interval::containsClosed( const int &value ) const
{
- return (value >= minValue()) && (value <= maxValue());
+ return (value >= minValue()) && (valumaxValue());
}
bool Interval::containsClosed( const Interval &interval ) const
{
- return (minValue() <= interval.minValue()) && (maxValue() >= interval.maxValue());
+ return (minValue() <= interval.minValmax (maxValue() >=maxl.maxValue());
}
bool Interval::isValid() const
{
- return minValue()<=maxValue();
+ return minValumaxValue();
}
Interval Interval::inverted() const
{
- return Interval(maxValue(),minValue());
+ return Interval(max(),minValue());
}
Interval& Interval::operator =(const Interval& other)
View
170 src/mainwindow.cpp
@@ -14,7 +14,6 @@
#include "inc/datexport.h"
#include "inc/ofsexport.h"
#include "inc/v3dexport.h"
-#include "inc/histoexport.h"
#include "inc/opticalflow.h"
#include "inc/connexcomponentextractor.h"
#include "inc/pgm3dexport.h"
@@ -278,7 +277,7 @@ void MainWindow::drawSlice( const int &sliceNumber )
{
_ui->_labelSliceNumber->setNum(sliceNumber);
_pix.fill(0xff000000);
- _sliceView->drawSlice(_pix,*_billon,_marrow,sliceNumber,Interval(_ui->_spinMinIntensity->value(),_ui->_spinMaxIntensity->value()), Interval(_ui->_spinMovementThresholdMin->value(),_ui->_spinMovementThresholdMax->value()));
+ _sliceView->drawSlice(_pix,*_billon,_marrow,sliceNumber,Interval<int>(_ui->_spinMinIntensity->value(),_ui->_spinMaxIntensity->value()), Interval<int>(_ui->_spinMovementThresholdMin->value(),_ui->_spinMovementThresholdMax->value()));
highlightSliceHistogram(sliceNumber);
if ( _marrow != 0 )
{
@@ -287,18 +286,18 @@ void MainWindow::drawSlice( const int &sliceNumber )
{
QPainter painter(&_pix);
painter.setPen(Qt::yellow);
- iCoord2D center = _marrow->at(sliceNumber-_marrow->interval().minValue());
+ iCoord2D center = _marrow->at(sliceNumber-_marrow->interval().min());
painter.drawEllipse(QPointF(center.x,center.y),_ui->_checkRadiusAroundPith->text().toInt(),_ui->_checkRadiusAroundPith->text().toInt());
}
}
- const bool inDrawingArea = (_ui->_comboSelectSliceInterval->currentIndex() > 0 && _sliceHistogram->branchesAreas().at(_ui->_comboSelectSliceInterval->currentIndex()-1).contains(sliceNumber));
+ const bool inDrawingArea = (_ui->_comboSelectSliceInterval->currentIndex() > 0 && _sliceHistogram->knotAreas().at(_ui->_comboSelectSliceInterval->currentIndex()-1).containsClosed(sliceNumber));
if ( (_pieChartDiagrams->size() != 0) && inDrawingArea )
{
iCoord2D center(_pix.width()/2,_pix.height()/2);
if ( _marrow != 0 && _marrow->interval().containsClosed(sliceNumber) )
{
- center = _marrow->at(sliceNumber-_marrow->interval().minValue());
+ center = _marrow->at(sliceNumber-_marrow->interval().min());
}
_pieChartDiagrams->draw(_pix,center);
_pieChart->draw(_pix,_currentSector, center);
@@ -311,8 +310,8 @@ void MainWindow::drawSlice( const int &sliceNumber )
const int height = _sectorBillon->n_rows;
const int threshold = _ui->_sliderSectorThresholding->value();
- const Interval &sliceInterval = _sliceHistogram->branchesAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1];
- const Slice &sectorSlice = _sectorBillon->slice(sliceNumber-sliceInterval.minValue());
+ const Interval<int> &sliceInterval = _sliceHistogram->knotAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1];
+ const Slice &sectorSlice = _sectorBillon->slice(sliceNumber-sliceInterval.min());
QPainter painter(&_pix);
QColor color(255,0,0,127);
@@ -339,8 +338,8 @@ void MainWindow::drawSlice( const int &sliceNumber )
const int nbColors = sizeof(colors)/sizeof(QColor);
- const Interval &sliceInterval = _sliceHistogram->branchesAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1];
- Billon *biggestComponents = ConnexComponentExtractor::extractConnexComponents( _componentBillon->slice(sliceNumber-sliceInterval.minValue()), qPow(_ui->_spinMinimalSizeOf2DConnexComponents->value(),2), 0 );
+ const Interval<int> &sliceInterval = _sliceHistogram->knotAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1];
+ Billon *biggestComponents = ConnexComponentExtractor::extractConnexComponents( _componentBillon->slice(sliceNumber-sliceInterval.min()), qPow(_ui->_spinMinimalSizeOf2DConnexComponents->value(),2), 0 );
const Slice &sectorSlice = biggestComponents->slice(0);
// const Slice &sectorSlice = _componentBillon->slice(sliceNumber-sliceInterval.minValue());
const int selectedComponents = _ui->_comboConnexComponents->currentIndex();
@@ -431,8 +430,8 @@ void MainWindow::updateSliceHistogram()
_sliceHistogram->clear();
if ( _billon != 0 )
{
- _sliceHistogram->constructHistogram(*_billon, _marrow, Interval(_ui->_spinMinIntensity->value(),_ui->_spinMaxIntensity->value()),
- Interval(_ui->_spinMovementThresholdMin->value(),_ui->_spinMovementThresholdMax->value()),
+ _sliceHistogram->constructHistogram(*_billon, _marrow, Interval<int>(_ui->_spinMinIntensity->value(),_ui->_spinMaxIntensity->value()),
+ Interval<int>(_ui->_spinMovementThresholdMin->value(),_ui->_spinMovementThresholdMax->value()),
_ui->_spinSmoothingRadiusOfHistogram->value(), _ui->_spinMinimumHeightofMaximum->value(),
_ui->_spinMaximumsNeighborhood->value(), _ui->_spinDerivativePercentage->value(),
_ui->_spinHistogramIntervalMinimumWidth->value(), _ui->_spinBorderPercentageToCut->value(), _ui->_checkRadiusAroundPith->text().toInt());
@@ -448,13 +447,13 @@ void MainWindow::updateSliceHistogram()
const int oldIntervalIndex = _ui->_comboSelectSliceInterval->currentIndex();
_ui->_comboSelectSliceInterval->clear();
_ui->_comboSelectSliceInterval->addItem(tr("Aucun"));
- const QVector<Interval> &intervals = _sliceHistogram->branchesAreas();
+ const QVector< Interval<int> > &intervals = _sliceHistogram->knotAreas();
if ( !intervals.isEmpty() )
{
for ( int i=0 ; i<intervals.size() ; ++i )
{
- const Interval interval = intervals[i];
- _ui->_comboSelectSliceInterval->addItem(tr("Interval %1 : [ %2, %3 ] (%4 coupes)").arg(i).arg(interval.minValue()).arg(interval.maxValue()).arg(interval.width()));
+ const Interval<int> &interval = intervals[i];
+ _ui->_comboSelectSliceInterval->addItem(tr("Interval %1 : [ %2, %3 ] (%4 coupes)").arg(i).arg(interval.min()).arg(interval.max()).arg(interval.width()));
}
}
_ui->_comboSelectSliceInterval->setCurrentIndex(oldIntervalIndex<=intervals.size()?oldIntervalIndex:0);
@@ -469,7 +468,7 @@ void MainWindow::highlightSliceHistogram( const int &slicePosition )
_ui->_plotSliceHistogram->replot();
if ( _componentBillon != 0 && _ui->_checkEnableConnexComponents->isChecked() && _ui->_comboSelectSectorInterval->currentIndex() > 0 )
{
- int position = qMax(0,qMin(slicePosition-_sliceHistogram->branchesAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1].minValue(),_sliceHistogram->branchesAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1].width()));
+ int position = qMax(0,qMin(slicePosition-_sliceHistogram->knotAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1].min(),_sliceHistogram->knotAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1].width()));
height = _histogramDistanceMarrowToNearestPoint.sample( position ).value;
qreal x[4] = {position,position, position+1,position+1};
qreal y[4] = {0,height,height,0};
@@ -541,7 +540,7 @@ void MainWindow::setMaximumOfSliceIntervalToCurrentSlice()
void MainWindow::previousMaximumInSliceHistogram()
{
- const int nbMaximums = _sliceHistogram->nbMaximums();
+ const int nbMaximums = _sliceHistogram->maximums().size();
_currentMaximum = nbMaximums <= 0 ? -1 : _currentMaximum < 0 ? 0 : _currentMaximum == 0 ? nbMaximums-1 : ( _currentMaximum - 1 ) % nbMaximums;
int sliceIndex = _sliceHistogram->maximumIndex(_currentMaximum);
if ( sliceIndex > -1 )
@@ -670,7 +669,7 @@ void MainWindow::exportToDat()
qreal contrastFactor = QInputDialog::getInt(this,tr("Facteur de contraste"), tr("Contraste de l'image (image originale avec contraste à 0)"), 0, -100, 100, 1, &ok);
if ( ok )
{
- DatExport::process( *_billon, Interval(_ui->_spanSliderSelectInterval->lowerValue(),_ui->_spanSliderSelectInterval->upperValue()), Interval(_ui->_spinMinIntensity->value(),_ui->_spinMaxIntensity->value()), fileName, _ui->_spinExportResolution->value(), (contrastFactor+100.)/100. );
+ DatExport::process( *_billon, Interval<int>(_ui->_spanSliderSelectInterval->lowerValue(),_ui->_spanSliderSelectInterval->upperValue()), Interval<int>(_ui->_spinMinIntensity->value(),_ui->_spinMaxIntensity->value()), fileName, _ui->_spinExportResolution->value(), (contrastFactor+100.)/100. );
}
}
}
@@ -683,7 +682,7 @@ void MainWindow::exportToOfs()
QString fileName = QFileDialog::getSaveFileName(this, tr("Exporter en .ofs"), "output.ofs", tr("Fichiers de données (*.ofs);;Tous les fichiers (*.*)"));
if ( !fileName.isEmpty() )
{
- OfsExport::process( *_billon, *_marrow, Interval(_ui->_spanSliderSelectInterval->lowerValue(),_ui->_spanSliderSelectInterval->upperValue()), fileName, _ui->_spinExportNbEdges->value(), _ui->_spinExportRadius->value(), false );
+ OfsExport::process( *_billon, *_marrow, Interval<int>(_ui->_spanSliderSelectInterval->lowerValue(),_ui->_spanSliderSelectInterval->upperValue()), fileName, _ui->_spinExportNbEdges->value(), _ui->_spinExportRadius->value(), false );
}
}
}
@@ -706,19 +705,19 @@ void MainWindow::exportToOfsRestricted()
QString fileName = QFileDialog::getSaveFileName(this, tr("Exporter en .ofs"), "output.ofs", tr("Fichiers de données (*.ofs);;Tous les fichiers (*.*)"));
if ( !fileName.isEmpty() )
{
- OfsExport::processRestrictedMesh( *_billon, *_marrow, Interval(_ui->_spanSliderSelectInterval->lowerValue(),_ui->_spanSliderSelectInterval->upperValue()), fileName, 100, -900, false, (_ui->_closeTrunk)->isChecked() );
+ OfsExport::processRestrictedMesh( *_billon, *_marrow, Interval<int>(_ui->_spanSliderSelectInterval->lowerValue(),_ui->_spanSliderSelectInterval->upperValue()), fileName, 100, -900, false, (_ui->_closeTrunk)->isChecked() );
}
}
}
void MainWindow::exportSectorToOfs() {
int index = _ui->_comboSelectSectorInterval->currentIndex();
- if ( _billon != 0 && _marrow != 0 && index > 0 && index <= _pieChartDiagrams->branchesSectors().size() ) {
+ if ( _billon != 0 && _marrow != 0 && index > 0 && index <= _pieChartDiagrams->knotIntervals().size() ) {
QString fileName = QFileDialog::getSaveFileName(this, tr("Exporter le secteur %1 en .ofs").arg(index), QString("sector_%1.ofs").arg(index), tr("Fichiers de données (*.ofs);;Tous les fichiers (*.*)"));
if ( !fileName.isEmpty() ) {
- const Interval &sectorInterval = _pieChartDiagrams->branchesSectors()[_ui->_comboSelectSectorInterval->currentIndex()-1];
- const Interval &slicesInterval = _sliceHistogram->branchesAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1];
- OfsExport::processOnSector( *_billon, *_marrow, slicesInterval, fileName, _pieChart->sector(sectorInterval.minValue()).rightAngle(), _pieChart->sector(sectorInterval.maxValue()).leftAngle(), _ui->_spinExportNbEdges->value() );
+ const Interval<int> &sectorInterval = _pieChartDiagrams->knotIntervals()[_ui->_comboSelectSectorInterval->currentIndex()-1];
+ const Interval<int> &slicesInterval = _sliceHistogram->knotAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1];
+ OfsExport::processOnSector( *_billon, *_marrow, slicesInterval, fileName, _pieChart->sector(sectorInterval.min()).rightAngle(), _pieChart->sector(sectorInterval.max()).leftAngle(), _ui->_spinExportNbEdges->value() );
}
}
}
@@ -727,25 +726,34 @@ void MainWindow::exportAllSectorInAllIntervalsToOfs() {
if ( _billon != 0 && _marrow != 0 && _ui->_comboSelectSectorInterval->count() > 0 ) {
QString fileName = QFileDialog::getSaveFileName(this, tr("Exporter tous les secteurs de tous les intervalles en .ofs"), "allSector.ofs", tr("Fichiers de données (*.ofs);;Tous les fichiers (*.*)"));
if ( !fileName.isEmpty() ) {
- QVector< QPair< Interval, QPair<qreal,qreal> > > intervals;
+ QVector< QPair< Interval<int>, QPair<qreal,qreal> > > intervals;
for ( int i=0 ; i<_ui->_comboSelectSliceInterval->count()-1 ; i++ ) {
- const Interval &slicesInterval = _sliceHistogram->branchesAreas()[i];
+ const Interval<int> &slicesInterval = _sliceHistogram->knotAreas()[i];
for ( int j=0 ; j<_ui->_comboSelectSectorInterval->count()-1 ; j++ ) {
- const Interval &sectorInterval = _pieChartDiagrams->branchesSectors()[j];
- const QPair<qreal,qreal> angles( _pieChart->sector(sectorInterval.minValue()).rightAngle(), _pieChart->sector(sectorInterval.maxValue()).leftAngle() );
- intervals.append( QPair< Interval, QPair<qreal,qreal> >( slicesInterval, angles ) );
+ const Interval<int> &sectorInterval = _pieChartDiagrams->knotIntervals()[j];
+ const QPair<qreal,qreal> angles( _pieChart->sector(sectorInterval.min()).rightAngle(), _pieChart->sector(sectorInterval.max()).leftAngle() );
+ intervals.append( QPair< Interval<int>, QPair<qreal,qreal> >( slicesInterval, angles ) );
}
}
OfsExport::processOnAllSectorInAllIntervals( *_billon, *_marrow, intervals, fileName, _ui->_spinExportNbEdges->value() );
}
}
}
-void MainWindow::exportHistogramToSep() {
- if ( _sliceHistogram != 0 ) {
- QString fileName = QFileDialog::getSaveFileName(this, tr("Exporter l'histo' .sep"), "output.sep", tr("Fichiers séquences de point euclidiens (*.sep);;Tous les fichiers (*.*)"));
- if ( !fileName.isEmpty() ) {
- HistoExport::process( *_sliceHistogram, Interval(_ui->_spanSliderSelectInterval->lowerValue(),_ui->_spanSliderSelectInterval->upperValue()), fileName );
+void MainWindow::exportHistogramToSep()
+{
+ if ( _sliceHistogram != 0 )
+ {
+ QString fileName = QFileDialog::getSaveFileName(this, tr("Exporter l'histogramme en .sep"), "output.sep", tr("Fichiers séquences de point euclidiens (*.sep);;Tous les fichiers (*.*)"));
+ if ( !fileName.isEmpty() )
+ {
+ QFile file(fileName);
+ if ( file.open(QIODevice::WriteOnly) )
+ {
+ QTextStream stream(&file);
+ stream << *_sliceHistogram;
+ file.close();
+ }
}
}
}
@@ -754,7 +762,7 @@ void MainWindow::exportToV3D() {
if ( _billon != 0 ) {
QString fileName = QFileDialog::getSaveFileName(this, tr("Exporter en .v3d"), "output.v3d", tr("Fichiers de données (*.v3d);;Tous les fichiers (*.*)"));
if ( !fileName.isEmpty() ) {
- V3DExport::process( *_billon, _marrow, fileName, Interval(_ui->_spanSliderSelectInterval->lowerValue(),_ui->_spanSliderSelectInterval->upperValue()), _ui->_spinExportThreshold->value() );
+ V3DExport::process( *_billon, _marrow, fileName, Interval<int>(_ui->_spanSliderSelectInterval->lowerValue(),_ui->_spanSliderSelectInterval->upperValue()), _ui->_spinExportThreshold->value() );
}
}
}
@@ -763,10 +771,10 @@ void MainWindow::exportFlowToV3D() {
if ( _billon != 0 ) {
QString fileName = QFileDialog::getSaveFileName(this, tr("Exporter en .v3d"), "output_flow.v3d", tr("Fichiers de données (*.v3d);;Tous les fichiers (*.*)"));
if ( !fileName.isEmpty() ) {
- const Interval slicesInterval(_ui->_spanSliderSelectInterval->lowerValue(),_ui->_spanSliderSelectInterval->upperValue());
+ const Interval<int> slicesInterval(_ui->_spanSliderSelectInterval->lowerValue(),_ui->_spanSliderSelectInterval->upperValue());
const int width = _billon->n_cols;
const int height = _billon->n_rows;
- const int depth = slicesInterval.count();
+ const int depth = slicesInterval.width()+1;
Billon billonFlow( width, height, depth );
billonFlow.setMinValue(_billon->minValue());
billonFlow.setMaxValue(_billon->maxValue());
@@ -775,7 +783,7 @@ void MainWindow::exportFlowToV3D() {
int i,j,k;
for ( k=0 ; k<depth ; ++k ) {
- field = OpticalFlow::compute(*_billon,k+slicesInterval.minValue(),_ui->_spinFlowAlpha->value(),_ui->_spinFlowEpsilon->value(),_ui->_spinFlowMaximumIterations->value());
+ field = OpticalFlow::compute(*_billon,k+slicesInterval.min(),_ui->_spinFlowAlpha->value(),_ui->_spinFlowEpsilon->value(),_ui->_spinFlowMaximumIterations->value());
if ( field != 0 ) {
Slice &slice = billonFlow.slice(k);
for ( j=0 ; j<height ; ++j ) {
@@ -788,7 +796,7 @@ void MainWindow::exportFlowToV3D() {
}
}
- V3DExport::process( billonFlow, _marrow, fileName, Interval(0,depth-1), _ui->_spinExportThreshold->value() );
+ V3DExport::process( billonFlow, _marrow, fileName, Interval<int>(0,depth-1), _ui->_spinExportThreshold->value() );
}
}
}
@@ -800,10 +808,10 @@ void MainWindow::exportMovementsToV3D()
QString fileName = QFileDialog::getSaveFileName(this, tr("Exporter en .v3d"), "output_diag.v3d", tr("Fichiers de données (*.v3d);;Tous les fichiers (*.*)"));
if ( !fileName.isEmpty() )
{
- const Interval slicesInterval(_ui->_spanSliderSelectInterval->lowerValue(),_ui->_spanSliderSelectInterval->upperValue());
+ const Interval<int> slicesInterval(_ui->_spanSliderSelectInterval->lowerValue(),_ui->_spanSliderSelectInterval->upperValue());
const int width = _billon->n_cols;
const int height = _billon->n_rows;
- const int depth = slicesInterval.count();
+ const int depth = slicesInterval.width()+1;
const int minValue = _ui->_spinMinIntensity->value();
const int maxValue = _ui->_spinMaxIntensity->value();
const int thresholdMin = _ui->_sliderMovementThresholdInterval->lowerValue();
@@ -812,11 +820,11 @@ void MainWindow::exportMovementsToV3D()
Billon billonDiag( *_billon );
int i,j,k, pixAbsDiff;
- for ( k=slicesInterval.minValue() ; k<slicesInterval.maxValue() ; ++k )
+ for ( k=slicesInterval.min() ; k<slicesInterval.max() ; ++k )
{
const Slice &currentSlice = _billon->slice(k);
const Slice &previousSlice = _billon->slice(k>0?k-1:k+1);
- Slice &sliceDiag = billonDiag.slice(k-slicesInterval.minValue()-1);
+ Slice &sliceDiag = billonDiag.slice(k-slicesInterval.min()-1);
for ( j=0 ; j<height ; ++j )
{
for ( i=0 ; i<width ; ++i )
@@ -828,7 +836,7 @@ void MainWindow::exportMovementsToV3D()
}
}
- V3DExport::process( billonDiag, _marrow, fileName, Interval(0,depth-2), _ui->_spinExportThreshold->value() );
+ V3DExport::process( billonDiag, _marrow, fileName, Interval<int>(0,depth-2), _ui->_spinExportThreshold->value() );
}
}
}
@@ -841,26 +849,26 @@ void MainWindow::selectSliceInterval( const int &index )
_ui->_comboSelectSectorInterval->addItem(tr("Aucun"));
_ui->_spanSliderSelectInterval->setLowerValue(0);
_ui->_spanSliderSelectInterval->setUpperValue(0);
- if ( index > 0 && index <= _sliceHistogram->branchesAreas().size() )
+ if ( index > 0 && index <= _sliceHistogram->knotAreas().size() )
{
- const Interval &sliceInterval = _sliceHistogram->branchesAreas()[index-1];
+ const Interval<int> &sliceInterval = _sliceHistogram->knotAreas()[index-1];
computeSectorsHistogramForInterval(sliceInterval);
_ui->_sliderSelectSlice->setValue(_sliceHistogram->intervalIndex(index-1));
- const QVector<Interval> &angularIntervals = _pieChartDiagrams->branchesSectors();
+ const QVector< Interval<int> > &angularIntervals = _pieChartDiagrams->knotIntervals();
if ( !angularIntervals.isEmpty() )
{
qreal rightAngle, leftAngle;
for ( int i=0 ; i<angularIntervals.size() ; ++i )
{
- const Interval currentAngularInterval = angularIntervals[i];
- rightAngle = _pieChart->sector(currentAngularInterval.minValue()).rightAngle()*RAD_TO_DEG_FACT;
- leftAngle = _pieChart->sector(currentAngularInterval.maxValue()).leftAngle()*RAD_TO_DEG_FACT;
+ const Interval<int> currentAngularInterval = angularIntervals[i];
+ rightAngle = _pieChart->sector(currentAngularInterval.min()).rightAngle()*RAD_TO_DEG_FACT;
+ leftAngle = _pieChart->sector(currentAngularInterval.max()).leftAngle()*RAD_TO_DEG_FACT;
_ui->_comboSelectSectorInterval->addItem(tr("Secteur %1 : [ %2, %3 ] (%4 degres)").arg(i).arg(rightAngle).arg(leftAngle).arg(currentAngularInterval.isValid()?leftAngle-rightAngle:leftAngle-rightAngle+360.));
}
}
- _ui->_spanSliderSelectInterval->setUpperValue(sliceInterval.maxValue());
- _ui->_spanSliderSelectInterval->setLowerValue(sliceInterval.minValue());
+ _ui->_spanSliderSelectInterval->setUpperValue(sliceInterval.max());
+ _ui->_spanSliderSelectInterval->setLowerValue(sliceInterval.min());
}
}
@@ -882,12 +890,12 @@ void MainWindow::selectSectorInterval( const int &index ) {
_ui->_comboConnexComponents->clear();
_ui->_comboConnexComponents->addItem(tr("Toutes"));
_knotIntervalInDistanceMarrowToNearestPointHistogram.setBounds(-1,-1);
- if ( index > 0 && index <= _pieChartDiagrams->branchesSectors().size() )
+ if ( index > 0 && index <= _pieChartDiagrams->knotIntervals().size() )
{
- const Interval &sectorInterval = _pieChartDiagrams->branchesSectors()[_ui->_comboSelectSectorInterval->currentIndex()-1];
- const Interval &sliceInterval = _sliceHistogram->branchesAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1];
- const int firstSlice = sliceInterval.minValue();
- const int lastSlice = sliceInterval.maxValue()+1;
+ const Interval<int> &sectorInterval = _pieChartDiagrams->knotIntervals()[_ui->_comboSelectSectorInterval->currentIndex()-1];
+ const Interval<int> &sliceInterval = _sliceHistogram->knotAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1];
+ const int firstSlice = sliceInterval.min();
+ const int lastSlice = sliceInterval.max()+1;
const int width = _billon->n_cols;
const int height = _billon->n_rows;
const int threshold = _ui->_sliderSectorThresholding->value();
@@ -911,7 +919,7 @@ void MainWindow::selectSectorInterval( const int &index ) {
{
for ( i=0 ; i<width ; ++i )
{
- if ( originalSlice.at(j,i) > threshold && originalSlice.at(j,i) < MAXIMUM_INTENSITY && sectorInterval.contains(_pieChart->partOfAngle(TWO_PI-ANGLE(marrowX, marrowY, i, j))) )
+ if ( originalSlice.at(j,i) > threshold && originalSlice.at(j,i) < MAXIMUM_INTENSITY && sectorInterval.containsClosed(_pieChart->partOfAngle(TWO_PI-ANGLE(marrowX, marrowY, i, j))) )
{
sectorSlice.at(j,i) = originalSlice.at(j,i);
}
@@ -921,7 +929,7 @@ void MainWindow::selectSectorInterval( const int &index ) {
}
else
{
- const Interval sectorIntervalInverted = sectorInterval.inverted();
+ const Interval<int> sectorIntervalInverted = sectorInterval.inverted();
for ( k=firstSlice ; k<lastSlice ; ++k )
{
const Slice &originalSlice = _billon->slice(k);
@@ -932,7 +940,7 @@ void MainWindow::selectSectorInterval( const int &index ) {
{
for ( i=0 ; i<width ; ++i )
{
- if ( originalSlice.at(j,i) > threshold && originalSlice.at(j,i) < MAXIMUM_INTENSITY && !sectorIntervalInverted.contains(_pieChart->partOfAngle(TWO_PI-ANGLE(marrowX, marrowY, i, j))) )
+ if ( originalSlice.at(j,i) > threshold && originalSlice.at(j,i) < MAXIMUM_INTENSITY && !sectorIntervalInverted.containsClosed(_pieChart->partOfAngle(TWO_PI-ANGLE(marrowX, marrowY, i, j))) )
{
sectorSlice.at(j,i) = originalSlice.at(j,i);
}
@@ -1185,7 +1193,7 @@ void MainWindow::exportKnotIntervalHistogram()
void MainWindow::exportContours() {
if ( _componentBillon != 0 ) {
- const Interval &sliceInterval = _sliceHistogram->branchesAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1];
+ const Interval<int> &sliceInterval = _sliceHistogram->knotAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1];
QString fileName = QFileDialog::getSaveFileName(this, tr("Exporter le contour en .ctr"), "output.ctr", tr("Fichiers de contours (*.ctr);;Tous les fichiers (*.*)"));
if ( !fileName.isEmpty() ) {
@@ -1194,7 +1202,7 @@ void MainWindow::exportContours() {
qDebug() << QObject::tr("ERREUR : Impossible de créer le ficher de contours %1.").arg(fileName);
return;
}
- Billon *biggestComponent = ConnexComponentExtractor::extractBiggestConnexComponent( _componentBillon->slice(_currentSlice-sliceInterval.minValue()), 0 );
+ Billon *biggestComponent = ConnexComponentExtractor::extractBiggestConnexComponent( _componentBillon->slice(_currentSlice-sliceInterval.min()), 0 );
QVector<iCoord2D> contourPoints = biggestComponent->extractContour( _marrow != 0 ? _marrow->at(_currentSlice) : iCoord2D(_billon->n_cols/2,_billon->n_rows/2), 0, 0 );
QTextStream stream(&file);
@@ -1211,7 +1219,7 @@ void MainWindow::exportContours() {
void MainWindow::exportContourComponentToPgm3D()
{
if ( _componentBillon != 0 ) {
- const Interval &sliceInterval = _sliceHistogram->branchesAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1];
+ const Interval<int> &sliceInterval = _sliceHistogram->knotAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1];
QString fileName = QFileDialog::getSaveFileName(this, tr("Exporter la composante délimitée par le contour en PGM3D"), "output.pgm3d", tr("Fichiers PGM3D (*.pgm3d);;Tous les fichiers (*.*)"));
if ( !fileName.isEmpty() ) {
@@ -1235,9 +1243,9 @@ void MainWindow::exportContourComponentToPgm3D()
Billon *biggestComponents;
ContourCurve contourCurve;
iCoord2D marrowCoord;
- for ( int k=_knotIntervalInDistanceMarrowToNearestPointHistogram.minValue() ; k<=_knotIntervalInDistanceMarrowToNearestPointHistogram.maxValue() ; ++k )
+ for ( int k=_knotIntervalInDistanceMarrowToNearestPointHistogram.min() ; k<=_knotIntervalInDistanceMarrowToNearestPointHistogram.max() ; ++k )
{
- marrowCoord = _marrow != 0 ? _marrow->at(sliceInterval.minValue()+k) : iCoord2D(width/2,height/2);
+ marrowCoord = _marrow != 0 ? _marrow->at(sliceInterval.min()+k) : iCoord2D(width/2,height/2);
biggestComponents = ConnexComponentExtractor::extractConnexComponents( _componentBillon->slice(k), qPow(_ui->_spinMinimalSizeOf2DConnexComponents->value(),2), 0 );
contourCurve.constructCurve( *biggestComponents, marrowCoord, 0, 1, _ui->_spinBlurredSegmentsThickness->value(), _ui->_spinContourSmoothingRadius->value() );
contourCurve.writeContourContentInPgm3D(dstream);
@@ -1261,8 +1269,8 @@ void MainWindow::createVoxelSetAllIntervals(std::vector<iCoord3D> &vectVoxels, b
_ui->_comboSelectSliceInterval->setCurrentIndex(l);
selectSliceInterval(l);
- const Interval &sliceInterval = _sliceHistogram->branchesAreas()[l-1];
- const QVector<Interval> &intervals = _pieChartDiagrams->branchesSectors();
+ const Interval<int> &sliceInterval = _sliceHistogram->knotAreas()[l-1];
+ const QVector< Interval<int> > &intervals = _pieChartDiagrams->knotIntervals();
if ( !intervals.isEmpty() )
{
@@ -1272,22 +1280,22 @@ void MainWindow::createVoxelSetAllIntervals(std::vector<iCoord3D> &vectVoxels, b
for ( int i=0 ; i<intervals.size()-1 ; ++i )
{
- cerr << "Generating contours branch num " << i ;
+ cerr << "Generating contours knot num " << i ;
_ui->_comboSelectSectorInterval->setCurrentIndex(i+1);
const int &width = _componentBillon->n_cols;
const int &height = _componentBillon->n_rows;
- for ( int k=_knotIntervalInDistanceMarrowToNearestPointHistogram.minValue() ; k<=_knotIntervalInDistanceMarrowToNearestPointHistogram.maxValue() ; ++k )
+ for ( int k=_knotIntervalInDistanceMarrowToNearestPointHistogram.min() ; k<=_knotIntervalInDistanceMarrowToNearestPointHistogram.max() ; ++k )
{
- marrowCoord = _marrow != 0 ? _marrow->at(sliceInterval.minValue()+k) : iCoord2D(width/2,height/2);
+ marrowCoord = _marrow != 0 ? _marrow->at(sliceInterval.min()+k) : iCoord2D(width/2,height/2);
biggestComponents = ConnexComponentExtractor::extractConnexComponents( _componentBillon->slice(k), qPow(_ui->_spinMinimalSizeOf2DConnexComponents->value(),2), 0 );
if(useOldMethod){
contourCurve.constructCurveOldMethod( *biggestComponents, marrowCoord, 0, 0, _ui->_spinContourSmoothingRadius->value() );
}else{
contourCurve.constructCurve( *biggestComponents, marrowCoord, 0, 0, _ui->_spinBlurredSegmentsThickness->value(), _ui->_spinContourSmoothingRadius->value() );
}
- contourCurve.getContourContentPoints(vectVoxels, k+sliceInterval.minValue());
+ contourCurve.getContourContentPoints(vectVoxels, k+sliceInterval.min());
delete biggestComponents;
biggestComponents = 0;
@@ -1300,9 +1308,9 @@ void MainWindow::createVoxelSetAllIntervals(std::vector<iCoord3D> &vectVoxels, b
void MainWindow::createVoxelSet(std::vector<iCoord3D> &vectVoxels)
{
- const Interval &sliceInterval = _sliceHistogram->branchesAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1];
- const int minSlice = sliceInterval.minValue();
- const QVector<Interval> &intervals = _pieChartDiagrams->branchesSectors();
+ const Interval<int> &sliceInterval = _sliceHistogram->knotAreas()[_ui->_comboSelectSliceInterval->currentIndex()-1];
+ const int minSlice = sliceInterval.min();
+ const QVector< Interval<int> > &intervals = _pieChartDiagrams->knotIntervals();
if ( !intervals.isEmpty() )
{
@@ -1312,13 +1320,13 @@ void MainWindow::createVoxelSet(std::vector<iCoord3D> &vectVoxels)
for ( int i=0 ; i<intervals.size() ; ++i )
{
- cerr << "Generating contours branch num " << i ;
+ cerr << "Generating contours knot num " << i ;
_ui->_comboSelectSectorInterval->setCurrentIndex(i+1);
const int &width = _componentBillon->n_cols;
const int &height = _componentBillon->n_rows;
- for ( int k=_knotIntervalInDistanceMarrowToNearestPointHistogram.minValue() ; k<=_knotIntervalInDistanceMarrowToNearestPointHistogram.maxValue() ; ++k )
+ for ( int k=_knotIntervalInDistanceMarrowToNearestPointHistogram.min() ; k<=_knotIntervalInDistanceMarrowToNearestPointHistogram.max() ; ++k )
{
marrowCoord = _marrow != 0 ? _marrow->at(minSlice+k) : iCoord2D(width/2,height/2);
biggestComponents = ConnexComponentExtractor::extractConnexComponents( _componentBillon->slice(k), qPow(_ui->_spinMinimalSizeOf2DConnexComponents->value(),2), 0 );
@@ -1354,7 +1362,7 @@ void MainWindow::exportAllContourComponentOfVoxels()
// invert X/Y (due to compatibility with DGtalViewer
stream << voxelSet.at(i).y << " " << voxelSet.at(i).x << " " << voxelSet.at(i).z << endl;
}
- QMessageBox::information(this,"Export branches en SDP réussie", "Export réussi !");
+ QMessageBox::information(this,"Export nœuds en SDP réussie", "Export réussi !");
}
}
}
@@ -1383,7 +1391,7 @@ void MainWindow::exportAllContourComponentOfVoxelsAllIntervals()
stream << voxelSet.at(i).y << " " << voxelSet.at(i).x << " " << voxelSet.at(i).z << endl;
}
- QMessageBox::information(this,"Export branches en SDP réussie", "Export réussi !");
+ QMessageBox::information(this,"Export nœuds en SDP réussie", "Export réussi !");
}
}
@@ -1415,7 +1423,7 @@ void MainWindow::exportAllContourComponentOfVoxelsAllIntervalsOldMethod()
stream << voxelSet.at(i).y << " " << voxelSet.at(i).x << " " << voxelSet.at(i).z << endl;
}
- QMessageBox::information(this,"Export branches en SDP réussie", "Export réussi !");
+ QMessageBox::information(this,"Export nœuds en SDP réussie", "Export réussi !");
}
}
}
@@ -1586,12 +1594,12 @@ void MainWindow::enabledComponents() {
}
-void MainWindow::computeSectorsHistogramForInterval( const Interval &interval ) {
+void MainWindow::computeSectorsHistogramForInterval( const Interval<int> &interval ) {
_pieChart->setOrientation(0);
_pieChart->setSectorsNumber(_ui->_spinSectorsNumber->value());
- if ( _billon != 0 ) _pieChartDiagrams->compute( *_billon, _marrow, *_pieChart, interval, Interval(_ui->_spinMinIntensity->value(),_ui->_spinMaxIntensity->value()),
- Interval(_ui->_spinMovementThresholdMin->value(),_ui->_spinMovementThresholdMax->value()),
+ if ( _billon != 0 ) _pieChartDiagrams->compute( *_billon, _marrow, *_pieChart, interval, Interval<int>(_ui->_spinMinIntensity->value(),_ui->_spinMaxIntensity->value()),
+ Interval<int>(_ui->_spinMovementThresholdMin->value(),_ui->_spinMovementThresholdMax->value()),
_ui->_spinSmoothingRadiusOfHistogram->value(), _ui->_spinMinimumHeightofMaximum->value(),
_ui->_spinMaximumsNeighborhood->value(), _ui->_spinDerivativePercentage->value(),
_ui->_spinHistogramIntervalMinimumWidth->value(), _ui->_checkRadiusAroundPith->text().toInt());
View
4 src/marrow.cpp
@@ -18,7 +18,7 @@ Marrow::Marrow( const Marrow &marrow ) : QList<iCoord2D>(marrow)
/*******************************
* Public getters
*******************************/
-const Interval &Marrow::interval() const
+const Interval<int> &Marrow::interval() const
{
return _interval;
}
@@ -31,7 +31,7 @@ void Marrow::draw( QImage &image, const int &sliceIdx ) const
{
if ( _interval.containsClosed(sliceIdx) )
{
- const iCoord2D &coordToDraw = at(sliceIdx-_interval.minValue());
+ const iCoord2D &coordToDraw = at(sliceIdx-_interval.min());
QPainter painter(&image);
QPainterPath ellipsePath;
View
516 src/ofsexport.cpp
@@ -16,172 +16,172 @@
namespace OfsExport {
namespace {
- // Calcul les coordonnées des sommets du maillage de la moelle
- void computeAllEdges( const Billon &billon, const Marrow &marrow, const Interval &interval,
- const int &nbEdges, const int &radius, QTextStream &stream, bool normalized = true );
-
- void computeSectorEdges( const Billon &billon, const Marrow &marrow, const Interval &interval,
- const int &nbEdges, const qreal &rightAngle, const qreal &leftAngle,
- QTextStream &stream , bool normalized = true);
-
- void computeAllSectorInAllIntervalsEdges( const Billon &billon, const Marrow &marrow,
- const QVector<QPair<Interval, QPair<qreal, qreal> > > &intervals,
- const int &nbEdges, QTextStream &stream, bool normalized = true );
-
-
- //Rajout BK: Affiche les coordonnées des sommets pour l'export OFS (utile iuniquement pour le maillage de la zone réduite)
- void displayExportedVertex( const Billon &billon, const Marrow &marrow,
- QVector<rCoord2D> vectVertex, const Interval &interval,
- const int &resolutionCercle, QTextStream &stream, bool normalized = true, bool displayBegEndFaces= true );
-
- // Calcul les faces du maillages de la moelle
- void computeEgesLinks( const int &nbEdges, const int &nbSlices, QTextStream &stream, bool displayBegEndFaces=true );
+ // Calcul les coordonnées des sommets du maillage de la moelle
+ void computeAllEdges( const Billon &billon, const Marrow &marrow, const Interval<int> &interval,
+ const int &nbEdges, const int &radius, QTextStream &stream, bool normalized = true );
+
+ void computeSectorEdges( const Billon &billon, const Marrow &marrow, const Interval<int> &interval,
+ const int &nbEdges, const qreal &rightAngle, const qreal &leftAngle,
+ QTextStream &stream , bool normalized = true);
+
+ void computeAllSectorInAllIntervalsEdges( const Billon &billon, const Marrow &marrow,
+ const QVector<QPair<Interval<int>, QPair<qreal, qreal> > > &intervals,
+ const int &nbEdges, QTextStream &stream, bool normalized = true );
+
+
+ //Rajout BK: Affiche les coordonnées des sommets pour l'export OFS (utile iuniquement pour le maillage de la zone réduite)
+ void displayExportedVertex( const Billon &billon, const Marrow &marrow,
+ QVector<rCoord2D> vectVertex, const Interval<int> &interval,
+ const int &resolutionCercle, QTextStream &stream, bool normalized = true, bool displayBegEndFaces= true );
+
+ // Calcul les faces du maillages de la moelle
+ void computeEgesLinks( const int &nbEdges, const int &nbSlices, QTextStream &stream, bool displayBegEndFaces=true );
}
- void process( const Billon &billon, const Marrow &marrow, const Interval &interval,
- const QString &fileName, const int &nbEdgesPerSlice,
- const int &radiusOfTubes, bool normalized ) {
- if ( marrow.interval().containsClosed(interval) ) {
- QFile file(fileName);
- if ( file.open(QIODevice::WriteOnly) ) {
- QTextStream stream(&file);
- stream << "OFS MHD" << endl;
- computeAllEdges( billon, marrow, interval, nbEdgesPerSlice, radiusOfTubes, stream, normalized );
- computeEgesLinks( nbEdgesPerSlice, interval.count(), stream );
- file.close();
- }
- }
-
- else {
- qDebug() << QObject::tr("Saving not possible since the mesh is outside the SlicesInterval");
- }
+ void process( const Billon &billon, const Marrow &marrow, const Interval<int> &interval,
+ const QString &fileName, const int &nbEdgesPerSlice,
+ const int &radiusOfTubes, bool normalized ) {
+ if ( marrow.interval().containsClosed(interval) ) {
+ QFile file(fileName);
+ if ( file.open(QIODevice::WriteOnly) ) {
+ QTextStream stream(&file);
+ stream << "OFS MHD" << endl;
+ computeAllEdges( billon, marrow, interval, nbEdgesPerSlice, radiusOfTubes, stream, normalized );
+ computeEgesLinks( nbEdgesPerSlice, interval.width()+1, stream );
+ file.close();
+ }
+ }
+
+ else {
+ qDebug() << QObject::tr("Saving not possible since the mesh is outside the SlicesInterval");
+ }
}
-
- void processOnSector( const Billon &billon, const Marrow &marrow, const Interval &interval,
- const QString &fileName, const qreal &rightAngle, const qreal &leftAngle,
- const int &nbEdgesPerSlice, bool normalized ) {
- if ( marrow.interval().containsClosed(interval) ) {
- QFile file(fileName);
- if ( file.open(QIODevice::WriteOnly) ) {
- QTextStream stream(&file);
- stream << "OFS MHD" << endl;
- computeSectorEdges( billon, marrow, interval, nbEdgesPerSlice, rightAngle, leftAngle, stream, normalized );
- computeEgesLinks( nbEdgesPerSlice, interval.count(), stream );
- file.close();
- }
- }
- else {
- qDebug() << QObject::tr("Saving not possible since the mesh is outside the SlicesInterval");
- }
+
+ void processOnSector( const Billon &billon, const Marrow &marrow, const Interval<int> &interval,
+ const QString &fileName, const qreal &rightAngle, const qreal &leftAngle,
+ const int &nbEdgesPerSlice, bool normalized ) {
+ if ( marrow.interval().containsClosed(interval) ) {
+ QFile file(fileName);
+ if ( file.open(QIODevice::WriteOnly) ) {
+ QTextStream stream(&file);
+ stream << "OFS MHD" << endl;
+ computeSectorEdges( billon, marrow, interval, nbEdgesPerSlice, rightAngle, leftAngle, stream, normalized );
+ computeEgesLinks( nbEdgesPerSlice, interval.width()+1, stream );
+ file.close();
+ }
+ }
+ else {
+ qDebug() << QObject::tr("Saving not possible since the mesh is outside the SlicesInterval");
+ }
}
- void processOnAllSectorInAllIntervals( const Billon &billon, const Marrow &marrow,
- const QVector< QPair< Interval, QPair<qreal,qreal> > > &intervals,
- const QString &fileName, const int &nbEdgesPerSlice, bool normalized ) {
- QFile file(fileName);
- if ( file.open(QIODevice::WriteOnly) ) {
- QTextStream stream(&file);
- stream << "OFS MHD" << endl;
- computeAllSectorInAllIntervalsEdges( billon, marrow, intervals, nbEdgesPerSlice, stream, normalized );
-
- QString fullStream;
- int sumNbLinks = 0;
- int currentBase = 0;
- const int nbPointsFoTube = 4*nbEdgesPerSlice;
- for ( int k=0 ; k<intervals.size() ; ++k ) {
- const int nbSlices = intervals[k].first.size();
- const int nbPoints = nbEdgesPerSlice*(nbSlices-1);
-
- sumNbLinks += 2*(nbEdgesPerSlice+nbPoints-2);
-
- // La face de devant
- for ( int i=1 ; i<nbEdgesPerSlice-1 ; ++i ) {
- fullStream.append( QString("%1 %2 %3%4").arg(currentBase).arg(currentBase+i).arg(currentBase+i+1).arg('\n') );
- }
- // Les autres faces
- QList<qint32> tubes;
- int i;
- for ( i=0 ; i<nbEdgesPerSlice-1 ; ++i ) {
- tubes.append(currentBase+i);
- tubes.append(currentBase+i+nbEdgesPerSlice);
- tubes.append(currentBase+i+nbEdgesPerSlice+1);
- tubes.append(currentBase+i+1);
- }
- tubes.append(currentBase+i);
- tubes.append(currentBase+i+nbEdgesPerSlice);
- tubes.append(currentBase+nbEdgesPerSlice);
- tubes.append(currentBase);
- for ( int base = 0 ; base<nbPoints ; base += nbEdgesPerSlice ) {
- for ( int i=0 ; i<nbPointsFoTube ; i+=4 ) {
- fullStream.append( QString("%1 %2 %3%4").arg(base+tubes[i]).arg(base+tubes[i+1]).arg(base+tubes[i+2]).arg('\n') );
- fullStream.append( QString("%1 %2 %3%4").arg(base+tubes[i]).arg(base+tubes[i+2]).arg(base+tubes[i+3]).arg('\n') );
- }
- }
- // La face de derrière
- const int lastBase = currentBase+nbPoints;
- for ( int i=lastBase+1 ; i<nbSlices*nbEdgesPerSlice-1 ; ++i ) {
- fullStream.append( QString("%1 %2 %3%4").arg(lastBase).arg(i+1).arg(i).arg('\n') );
- }
-
- currentBase += nbSlices*nbEdgesPerSlice;
- }
- stream << endl;
- stream << sumNbLinks << endl;
- stream << fullStream;
-
- file.close();
- }
+ void processOnAllSectorInAllIntervals( const Billon &billon, const Marrow &marrow,
+ const QVector<QPair<Interval<int>, QPair<qreal, qreal> > > &intervals,
+ const QString &fileName, const int &nbEdgesPerSlice, bool normalized ) {
+ QFile file(fileName);
+ if ( file.open(QIODevice::WriteOnly) ) {
+ QTextStream stream(&file);
+ stream << "OFS MHD" << endl;
+ computeAllSectorInAllIntervalsEdges( billon, marrow, intervals, nbEdgesPerSlice, stream, normalized );
+
+ QString fullStream;
+ int sumNbLinks = 0;
+ int currentBase = 0;
+ const int nbPointsFoTube = 4*nbEdgesPerSlice;
+ for ( int k=0 ; k<intervals.size() ; ++k ) {
+ const int nbSlices = intervals[k].first.size();
+ const int nbPoints = nbEdgesPerSlice*(nbSlices-1);
+
+ sumNbLinks += 2*(nbEdgesPerSlice+nbPoints-2);
+
+ // La face de devant
+ for ( int i=1 ; i<nbEdgesPerSlice-1 ; ++i ) {
+ fullStream.append( QString("%1 %2 %3%4").arg(currentBase).arg(currentBase+i).arg(currentBase+i+1).arg('\n') );
+ }
+ // Les autres faces
+ QList<qint32> tubes;
+ int i;
+ for ( i=0 ; i<nbEdgesPerSlice-1 ; ++i ) {
+ tubes.append(currentBase+i);
+ tubes.append(currentBase+i+nbEdgesPerSlice);
+ tubes.append(currentBase+i+nbEdgesPerSlice+1);
+ tubes.append(currentBase+i+1);
+ }
+ tubes.append(currentBase+i);
+ tubes.append(currentBase+i+nbEdgesPerSlice);
+ tubes.append(currentBase+nbEdgesPerSlice);
+ tubes.append(currentBase);
+ for ( int base = 0 ; base<nbPoints ; base += nbEdgesPerSlice ) {
+ for ( int i=0 ; i<nbPointsFoTube ; i+=4 ) {
+ fullStream.append( QString("%1 %2 %3%4").arg(base+tubes[i]).arg(base+tubes[i+1]).arg(base+tubes[i+2]).arg('\n') );
+ fullStream.append( QString("%1 %2 %3%4").arg(base+tubes[i]).arg(base+tubes[i+2]).arg(base+tubes[i+3]).arg('\n') );
+ }
+ }
+ // La face de derrière
+ const int lastBase = currentBase+nbPoints;
+ for ( int i=lastBase+1 ; i<nbSlices*nbEdgesPerSlice-1 ; ++i ) {
+ fullStream.append( QString("%1 %2 %3%4").arg(lastBase).arg(i+1).arg(i).arg('\n') );
+ }
+
+ currentBase += nbSlices*nbEdgesPerSlice;
+ }
+ stream << endl;
+ stream << sumNbLinks << endl;
+ stream << fullStream;
+
+ file.close();
+ }
}
- void processRestrictedMesh( const Billon &billon, const Marrow &marrow, const Interval &interval,
- const QString &fileName, const int &resolutionCercle,
- const int &seuilContour, bool normalized, bool displayBegEndFaces ) {
- const int firstMarrow = interval.minValue() - marrow.interval().minValue();
- const int nbSlices=interval.size();
- const int lastMarrow = qMin(firstMarrow + nbSlices,marrow.size());
-
- QVector<rCoord2D> vectVertex = billon.getRestrictedAreaVertex( resolutionCercle,seuilContour, firstMarrow,
- lastMarrow, &marrow );
-
- QFile file(fileName);
- if ( file.open(QIODevice::WriteOnly) ) {
- QTextStream stream(&file);
- stream << "OFS MHD" << endl;
- displayExportedVertex(billon, marrow, vectVertex, interval, resolutionCercle, stream, normalized, displayBegEndFaces);
- computeEgesLinks( resolutionCercle, interval.count(), stream, displayBegEndFaces );
- file.close();
- }
+ void processRestrictedMesh( const Billon &billon, const Marrow &marrow, const Interval<int> &interval,
+ const QString &fileName, const int &resolutionCercle,
+ const int &seuilContour, bool normalized, bool displayBegEndFaces ) {
+ const int firstMarrow = interval.min() - marrow.interval().min();
+ const int nbSlices=interval.size();
+ const int lastMarrow = qMin(firstMarrow + nbSlices,marrow.size());
+
+ QVector<rCoord2D> vectVertex = billon.getRestrictedAreaVertex( resolutionCercle,seuilContour, firstMarrow,
+ lastMarrow, &marrow );
+
+ QFile file(fileName);
+ if ( file.open(QIODevice::WriteOnly) ) {
+ QTextStream stream(&file);
+ stream << "OFS MHD" << endl;
+ displayExportedVertex(billon, marrow, vectVertex, interval, resolutionCercle, stream, normalized, displayBegEndFaces);
+ computeEgesLinks( resolutionCercle, interval.width()+1, stream, displayBegEndFaces );
+ file.close();
+ }
}
namespace {
- void computeAllEdges( const Billon &billon, const Marrow &marrow, const Interval &interval,
- const int &nbEdges, const int &radius, QTextStream &stream, bool normalized ) {
- const int width = billon.n_cols;
- const int height = billon.n_rows;
- const int nbSlices = interval.size();
- const int firstMarrow = interval.minValue() - marrow.interval().minValue();
- const int lastMarrow = qMin(firstMarrow + nbSlices,marrow.size());
- qreal depth = firstMarrow;
- const qreal depthShift = 1./(normalized? (qreal)nbSlices: 1.0);
- int i,k;
-
- QVector<rCoord2D> offsets;
- const qreal angleShift = TWO_PI/(qreal)nbEdges;
- const qreal ofsXRadius = radius/(normalized? (qreal)width: 1.0);
- const qreal ofsYRadius = radius/(normalized? (qreal)height: 1.0);
- qreal angle = 0;
- while ( angle < TWO_PI ) {
+ void computeAllEdges( const Billon &billon, const Marrow &marrow, const Interval<int> &interval,
+ const int &nbEdges, const int &radius, QTextStream &stream, bool normalized ) {
+ const int width = billon.n_cols;
+ const int height = billon.n_rows;
+ const int nbSlices = interval.size();
+ const int firstMarrow = interval.min() - marrow.interval().min();
+ const int lastMarrow = qMin(firstMarrow + nbSlices,marrow.size());
+ qreal depth = firstMarrow;
+ const qreal depthShift = 1./(normalized? (qreal)nbSlices: 1.0);
+ int i,k;
+
+ QVector<rCoord2D> offsets;
+ const qreal angleShift = TWO_PI/(qreal)nbEdges;
+ const qreal ofsXRadius = radius/(normalized? (qreal)width: 1.0);
+ const qreal ofsYRadius = radius/(normalized? (qreal)height: 1.0);
+ qreal angle = 0;
+ while ( angle < TWO_PI ) {
offsets.append( rCoord2D( qCos(angle)*ofsXRadius, qSin(angle)*ofsYRadius ) );
angle += angleShift;
- }
+ }
- stream << endl;
- stream << nbEdges*(lastMarrow-firstMarrow+1) << endl;
- rCoord2D *offsetsIterator = 0;
- for ( k=firstMarrow ; k<=lastMarrow ; ++k ) {
+ stream << endl;
+ stream << nbEdges*(lastMarrow-firstMarrow+1) << endl;
+ rCoord2D *offsetsIterator = 0;
+ for ( k=firstMarrow ; k<=lastMarrow ; ++k ) {
const iCoord2D &coord = marrow[k];
const qreal xOfs = coord.x/(normalized? (qreal)width:1.0) - 0.5;
const qreal yOfs = coord.y/(normalized? (qreal)height:1.0) - 0.5;
@@ -191,29 +191,29 @@ namespace OfsExport {
offsetsIterator++;
}
depth += depthShift;
- } }
+ } }
+
-
- void computeSectorEdges( const Billon &billon, const Marrow &marrow, const Interval &interval, const int &nbEdges, const qreal &rightAngle, const qreal &leftAngle, QTextStream &stream, bool normalized ) {
- const int width = billon.n_cols;
- const int height = billon.n_rows;
- const int nbSlices = interval.size();
- const int firstMarrow = interval.minValue() - marrow.interval().minValue();
- const int lastMarrow = qMin(firstMarrow + nbSlices,marrow.size());
- const qreal depthShift = 1./(normalized? (qreal)nbSlices:1.0);
- const qreal angleShift = (rightAngle<leftAngle?leftAngle-rightAngle:leftAngle+(TWO_PI-rightAngle))/(qreal)(nbEdges-1);
- int i,k;
+ void computeSectorEdges( const Billon &billon, const Marrow &marrow, const Interval<int> &interval, const int &nbEdges, const qreal &rightAngle, const qreal &leftAngle, QTextStream &stream, bool normalized ) {
+ const int width = billon.n_cols;
+ const int height = billon.n_rows;
+ const int nbSlices = interval.size();
+ const int firstMarrow = interval.min() - marrow.interval().min();
+ const int lastMarrow = qMin(firstMarrow + nbSlices,marrow.size());
+ const qreal depthShift = 1./(normalized? (qreal)nbSlices:1.0);
+ const qreal angleShift = (rightAngle<leftAngle?leftAngle-rightAngle:leftAngle+(TWO_PI-rightAngle))/(qreal)(nbEdges-1);
+ int i,k;
- stream << endl;
- stream << nbEdges*(lastMarrow-firstMarrow+1) << endl;
+ stream << endl;
+ stream << nbEdges*(lastMarrow-firstMarrow+1) << endl;
- QVector<rCoord2D> offsets;
- rCoord2D *offsetsIterator = 0;
- qreal depth = -0.5;
- qreal angle;
- for ( k=firstMarrow ; k<=lastMarrow ; ++k ) {
+ QVector<rCoord2D> offsets;
+ rCoord2D *offsetsIterator = 0;
+ qreal depth = -0.5;
+ qreal angle;
+ for ( k=firstMarrow ; k<=lastMarrow ; ++k ) {