mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-31 20:30:32 +05:00
0020948: EDF 1468 SMESH: Histogram of the quality controls
+ Histogram GetHistogram()
This commit is contained in:
parent
52603030d5
commit
8a950e9b2e
@ -74,6 +74,17 @@ module SMESH
|
||||
FT_Undefined
|
||||
};
|
||||
|
||||
/*!
|
||||
* Parameters of a reclangle of histogram
|
||||
*/
|
||||
struct HistogramRectangle
|
||||
{
|
||||
long nbEvents;
|
||||
double min;
|
||||
double max;
|
||||
};
|
||||
typedef sequence<HistogramRectangle> Histogram;
|
||||
|
||||
/*!
|
||||
* Base interface for all functors ( i.e. numerical functors and predicates )
|
||||
*/
|
||||
@ -93,6 +104,8 @@ module SMESH
|
||||
{
|
||||
double GetValue( in long theElementId );
|
||||
|
||||
Histogram GetHistogram( in short nbIntervals );
|
||||
|
||||
/*!
|
||||
* Set precision for calculation. It is a position after point which is
|
||||
* used to functor value after calculation.
|
||||
|
@ -277,6 +277,62 @@ double NumericalFunctor::GetValue( long theId )
|
||||
return 0.;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return histogram of functor values
|
||||
* \param nbIntervals - number of intervals
|
||||
* \param nbEvents - number of mesh elements having values within i-th interval
|
||||
* \param funValues - boundaries of intervals
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void NumericalFunctor::GetHistogram(int nbIntervals,
|
||||
std::vector<int>& nbEvents,
|
||||
std::vector<double>& funValues)
|
||||
{
|
||||
if ( nbIntervals < 1 ||
|
||||
!myMesh ||
|
||||
!myMesh->GetMeshInfo().NbElements( GetType() ))
|
||||
return;
|
||||
nbEvents.resize( nbIntervals, 0 );
|
||||
funValues.resize( nbIntervals+1 );
|
||||
|
||||
// get all values sorted
|
||||
std::multiset< double > values;
|
||||
SMDS_ElemIteratorPtr elemIt = myMesh->elementsIterator(GetType());
|
||||
while ( elemIt->more() )
|
||||
values.insert( GetValue( elemIt->next()->GetID() ));
|
||||
|
||||
// case nbIntervals == 1
|
||||
funValues[0] = *values.begin();
|
||||
funValues[nbIntervals] = *values.rbegin();
|
||||
if ( nbIntervals == 1 )
|
||||
{
|
||||
nbEvents[0] = values.size();
|
||||
return;
|
||||
}
|
||||
// case of 1 value
|
||||
if (funValues.front() == funValues.back())
|
||||
{
|
||||
nbIntervals = 1;
|
||||
nbEvents.resize( nbIntervals, values.size() );
|
||||
funValues.resize( nbIntervals+1);
|
||||
}
|
||||
// generic case
|
||||
std::multiset< double >::iterator min = values.begin(), max;
|
||||
for ( int i = 0; i < nbIntervals; ++i )
|
||||
{
|
||||
double r = (i+1) / double( nbIntervals );
|
||||
funValues[i+1] = funValues.front() * (1-r) + funValues.back() * r;
|
||||
if ( min != values.end() && *min <= funValues[i+1] )
|
||||
{
|
||||
max = values.upper_bound( funValues[i+1] ); // greater than funValues[i+1], or end()
|
||||
nbEvents[i] = std::distance( min, max );
|
||||
min = max;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetValue
|
||||
//purpose :
|
||||
|
@ -127,6 +127,9 @@ namespace SMESH{
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual double GetValue( long theElementId );
|
||||
virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
|
||||
void GetHistogram(int nbIntervals,
|
||||
std::vector<int>& nbEvents,
|
||||
std::vector<double>& funValues);
|
||||
virtual SMDSAbs_ElementType GetType() const = 0;
|
||||
virtual double GetBadRate( double Value, int nbNodes ) const = 0;
|
||||
long GetPrecision() const;
|
||||
|
@ -596,6 +596,28 @@ CORBA::Double NumericalFunctor_i::GetValue( CORBA::Long theId )
|
||||
return myNumericalFunctorPtr->GetValue( theId );
|
||||
}
|
||||
|
||||
SMESH::Histogram* NumericalFunctor_i::GetHistogram(CORBA::Short nbIntervals)
|
||||
{
|
||||
std::vector<int> nbEvents;
|
||||
std::vector<double> funValues;
|
||||
myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues);
|
||||
|
||||
nbIntervals = CORBA::Short( std::min( nbEvents.size(), funValues.size() - 1));
|
||||
SMESH::Histogram_var histogram = new SMESH::Histogram;
|
||||
if ( nbIntervals > 0 )
|
||||
{
|
||||
histogram->length( nbIntervals );
|
||||
for ( int i = 0; i < nbIntervals; ++i )
|
||||
{
|
||||
HistogramRectangle& rect = histogram[i];
|
||||
rect.nbEvents = nbEvents[i];
|
||||
rect.min = funValues[i];
|
||||
rect.max = funValues[i+1];
|
||||
}
|
||||
}
|
||||
return histogram._retn();
|
||||
}
|
||||
|
||||
void NumericalFunctor_i::SetPrecision( CORBA::Long thePrecision )
|
||||
{
|
||||
myNumericalFunctorPtr->SetPrecision( thePrecision );
|
||||
|
@ -157,6 +157,7 @@ namespace SMESH
|
||||
{
|
||||
public:
|
||||
CORBA::Double GetValue( CORBA::Long theElementId );
|
||||
SMESH::Histogram* GetHistogram(CORBA::Short nbIntervals);
|
||||
void SetPrecision( CORBA::Long thePrecision );
|
||||
CORBA::Long GetPrecision();
|
||||
Controls::NumericalFunctorPtr GetNumericalFunctor();
|
||||
|
Loading…
Reference in New Issue
Block a user