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 )
*/
{
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.
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 :
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;
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 );
{
public:
CORBA::Double GetValue( CORBA::Long theElementId );
+ SMESH::Histogram* GetHistogram(CORBA::Short nbIntervals);
void SetPrecision( CORBA::Long thePrecision );
CORBA::Long GetPrecision();
Controls::NumericalFunctorPtr GetNumericalFunctor();