0020948]: EDF 1468 SMESH: Histogram of the quality controls

Add arg to limit range of values
       void GetHistogram(int                   nbIntervals,
                         std::vector<int>&     nbEvents,
                         std::vector<double>&    funValues,
                         const std::vector<int>& elements,
+                        const double*           minmax=0);
This commit is contained in:
eap 2010-11-22 17:48:38 +00:00
parent 16a840f9c1
commit 938bc72f7a
2 changed files with 25 additions and 8 deletions

View File

@ -284,13 +284,15 @@ double NumericalFunctor::GetValue( long theId )
* \param nbEvents - number of mesh elements having values within i-th interval * \param nbEvents - number of mesh elements having values within i-th interval
* \param funValues - boundaries of intervals * \param funValues - boundaries of intervals
* \param elements - elements to check vulue of; empty list means "of all" * \param elements - elements to check vulue of; empty list means "of all"
* \param minmax - boundaries of diapason of values to divide into intervals
*/ */
//================================================================================ //================================================================================
void NumericalFunctor::GetHistogram(int nbIntervals, void NumericalFunctor::GetHistogram(int nbIntervals,
std::vector<int>& nbEvents, std::vector<int>& nbEvents,
std::vector<double>& funValues, std::vector<double>& funValues,
const vector<int>& elements) const vector<int>& elements,
const double* minmax)
{ {
if ( nbIntervals < 1 || if ( nbIntervals < 1 ||
!myMesh || !myMesh ||
@ -314,9 +316,17 @@ void NumericalFunctor::GetHistogram(int nbIntervals,
values.insert( GetValue( *id )); values.insert( GetValue( *id ));
} }
if ( minmax )
{
funValues[0] = minmax[0];
funValues[nbIntervals] = minmax[1];
}
else
{
funValues[0] = *values.begin();
funValues[nbIntervals] = *values.rbegin();
}
// case nbIntervals == 1 // case nbIntervals == 1
funValues[0] = *values.begin();
funValues[nbIntervals] = *values.rbegin();
if ( nbIntervals == 1 ) if ( nbIntervals == 1 )
{ {
nbEvents[0] = values.size(); nbEvents[0] = values.size();
@ -334,15 +344,21 @@ void NumericalFunctor::GetHistogram(int nbIntervals,
std::multiset< double >::iterator min = values.begin(), max; std::multiset< double >::iterator min = values.begin(), max;
for ( int i = 0; i < nbIntervals; ++i ) for ( int i = 0; i < nbIntervals; ++i )
{ {
// find end value of i-th interval
double r = (i+1) / double( nbIntervals ); double r = (i+1) / double( nbIntervals );
funValues[i+1] = funValues.front() * (1-r) + funValues.back() * r; funValues[i+1] = funValues.front() * (1-r) + funValues.back() * r;
// count values in the i-th interval if there are any
if ( min != values.end() && *min <= funValues[i+1] ) if ( min != values.end() && *min <= funValues[i+1] )
{ {
max = values.upper_bound( funValues[i+1] ); // greater than funValues[i+1], or end() // find the first value out of the interval
max = values.upper_bound( funValues[i+1] ); // max is greater than funValues[i+1], or end()
nbEvents[i] = std::distance( min, max ); nbEvents[i] = std::distance( min, max );
min = max; min = max;
} }
} }
// add values larger than minmax[1]
nbEvents.back() += std::distance( min, values.end() );
} }
//======================================================================= //=======================================================================

View File

@ -127,10 +127,11 @@ namespace SMESH{
virtual void SetMesh( const SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual double GetValue( long theElementId ); virtual double GetValue( long theElementId );
virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;}; virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
void GetHistogram(int nbIntervals, void GetHistogram(int nbIntervals,
std::vector<int>& nbEvents, std::vector<int>& nbEvents,
std::vector<double>& funValues, std::vector<double>& funValues,
const std::vector<int>& elements); const std::vector<int>& elements,
const double* minmax=0);
virtual SMDSAbs_ElementType GetType() const = 0; virtual SMDSAbs_ElementType GetType() const = 0;
virtual double GetBadRate( double Value, int nbNodes ) const = 0; virtual double GetBadRate( double Value, int nbNodes ) const = 0;
long GetPrecision() const; long GetPrecision() const;