Commit 6d9726ff authored by Robert Frohl's avatar Robert Frohl
Browse files

[CHANGE] changed constructor of WHistogram, number of buckets no longer needed

parent 5179cf8f
......@@ -304,7 +304,7 @@ ELSE()
ADD_CUSTOM_TARGET( fixtures
ALL
COMMAND ${CMAKE_COMMAND} -D OW_SOURCE_DIR:STRING=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/FixturesWin.cmake
COMMENT "Copy fixtures to the right place."
)
......
......@@ -31,29 +31,47 @@
#include "WHistogram.h"
WHistogram::WHistogram( boost::shared_ptr< WValueSetBase > valueSet, unsigned int nBuckets )
WHistogram::WHistogram( boost::shared_ptr< WValueSetBase > valueSet ) //, unsigned int nBuckets )
{
WAssert( nBuckets > 0, "WHistogram::WHistogram : nBuckets has to be greater then zero." );
m_nInitialBuckets = nBuckets;
m_initialBuckets = new unsigned int[m_nInitialBuckets];
m_mappedBuckets = 0;
// initiate array to zero
memset( m_initialBuckets, 0, m_nInitialBuckets * sizeof( unsigned int ) );
//*m_initialBuckets = {0}; // this should works with C++0x (instead memset), TEST IT!
//WAssert( nBuckets > 0, "WHistogram::WHistogram : nBuckets has to be greater then zero." );
// calculate min max
m_minimum = wlimits::MAX_DOUBLE;
m_maximum = wlimits::MIN_DOUBLE;
for( size_t i = 0; i < valueSet->size(); ++i )
double minDistance = wlimits::MAX_DOUBLE;
for( size_t i = 0; i != valueSet->size(); ++i )
{
double tmp = valueSet->getScalarDouble( i );
m_maximum = m_maximum < tmp ? tmp : m_maximum;
m_minimum = m_minimum > tmp ? tmp : m_minimum;
if( m_minimum != tmp )
{
minDistance = tmp - m_minimum < minDistance ? m_minimum - tmp : minDistance;
}
if( m_maximum != tmp )
{
minDistance = m_maximum - tmp < minDistance ? m_maximum - tmp : minDistance;
}
}
m_nInitialBuckets = ( m_maximum - m_minimum ) / minDistance;
m_bucketSize = minDistance;
//if( nBuckets > m_nInitialBuckets )
//{
// m_nInitialBuckets = nBuckets;
//}
m_initialBuckets = new unsigned int[m_nInitialBuckets];
m_mappedBuckets = 0;
m_nMappedBuckets = 0;
// initiate array to zero
memset( m_initialBuckets, 0, m_nInitialBuckets * sizeof( unsigned int ) );
//*m_initialBuckets = {0}; // this should works with C++0x (instead memset), TEST IT!
// create base histogram
m_bucketSize = ( m_maximum - m_minimum ) / static_cast<double>( m_nInitialBuckets );
//m_bucketSize = ( m_maximum - m_minimum ) / static_cast<double>( m_nInitialBuckets );
for( size_t i = 0; i < valueSet->size(); ++i )
{
double tmp = valueSet->getScalarDouble( i );
......@@ -228,6 +246,5 @@ void WHistogram::test()
std::cout << "--";
}
std::cout << "--\n";
std::cout << at( 10 ) << " " << (*this)[10] << std::endl;
}
......@@ -32,7 +32,6 @@
#include <boost/shared_ptr.hpp>
#include "../dataHandler/WValueSet.h"
//#include "../dataHandler/WDataSetScalar.h"
/**
* Used to track (later: display) the occurrence frequencies of values in a value set.
......@@ -119,14 +118,14 @@ class WHistogram
* \param valueSet source of the data for the histogram
* \param nBuckets number of buckets this histogram should display
**/
WHistogram( boost::shared_ptr< WValueSetBase > valueSet, unsigned int nBuckets = 1000 );
explicit WHistogram( boost::shared_ptr< WValueSetBase > valueSet ); //, unsigned int nBuckets = 1000 );
/**
* Copy constructor. If another interval size is given setInterval() is called and a
* the mapped histogram is calculated.
*
* \param histogram another WHisogram
* \param intervalSize the size of one bucket in the mapped histogram
* \param intervalSize the size of one bucket in the mapped histogram
**/
explicit WHistogram( const WHistogram& histogram, double intervalSize = 0.0 );
......
......@@ -63,7 +63,7 @@ WDataSetScalar::WDataSetScalar( boost::shared_ptr< WValueSetBase > newValueSet,
//boost::shared_ptr< WHistogram > hist( new WHistogram( *m_histogram, 15 ) );
//m_histogram->setInterval( 20.0 );
//m_histogram->test();
//hist->setInterval(15.0);
//hist->setInterval( 15.0 );
//hist->test();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment