mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-13 18:20:34 +05:00
0020976: EDF 1471 SMESH: New ergonomy to display quality controls
interface SMESH_IDSource { + long NbSatisfying( in SMESH::SMESH_IDSource obj ); interface NumericalFunctor: Functor { + Histogram GetLocalHistogram( in short nbIntervals, in boolean isLogarithmic, + in SMESH::SMESH_IDSource obj );
This commit is contained in:
parent
7567e381c8
commit
38e26e89c3
@ -33,6 +33,7 @@
|
|||||||
#include "SMDS_MeshNode.hxx"
|
#include "SMDS_MeshNode.hxx"
|
||||||
#include "SMESHDS_Mesh.hxx"
|
#include "SMESHDS_Mesh.hxx"
|
||||||
#include "SMESH_Gen_i.hxx"
|
#include "SMESH_Gen_i.hxx"
|
||||||
|
#include "SMESH_Group_i.hxx"
|
||||||
#include "SMESH_PythonDump.hxx"
|
#include "SMESH_PythonDump.hxx"
|
||||||
|
|
||||||
#include <SALOMEDS_wrap.hxx>
|
#include <SALOMEDS_wrap.hxx>
|
||||||
@ -588,12 +589,63 @@ SMESH::Histogram* NumericalFunctor_i::GetHistogram(CORBA::Short nbIntervals, COR
|
|||||||
std::vector<int> elements;
|
std::vector<int> elements;
|
||||||
myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements,0,isLogarithmic);
|
myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements,0,isLogarithmic);
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
nbIntervals = CORBA::Short( min( nbEvents.size(), funValues.size() - 1));
|
|
||||||
#else
|
|
||||||
nbIntervals = CORBA::Short( std::min( nbEvents.size(), funValues.size() - 1));
|
|
||||||
#endif
|
|
||||||
SMESH::Histogram_var histogram = new SMESH::Histogram;
|
SMESH::Histogram_var histogram = new SMESH::Histogram;
|
||||||
|
|
||||||
|
nbIntervals = CORBA::Short( Min( int( nbEvents.size()),
|
||||||
|
int( funValues.size() - 1 )));
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
SMESH::Histogram* NumericalFunctor_i::GetLocalHistogram(CORBA::Short nbIntervals,
|
||||||
|
CORBA::Boolean isLogarithmic,
|
||||||
|
SMESH::SMESH_IDSource_ptr object)
|
||||||
|
{
|
||||||
|
SMESH::Histogram_var histogram = new SMESH::Histogram;
|
||||||
|
|
||||||
|
std::vector<int> nbEvents;
|
||||||
|
std::vector<double> funValues;
|
||||||
|
std::vector<int> elements;
|
||||||
|
|
||||||
|
SMDS_ElemIteratorPtr elemIt;
|
||||||
|
if ( SMESH::DownCast< SMESH_GroupOnFilter_i* >( object ) ||
|
||||||
|
SMESH::DownCast< SMESH::Filter_i* >( object ))
|
||||||
|
{
|
||||||
|
elemIt = SMESH_Mesh_i::GetElements( object, GetElementType() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SMESH::SMESH_Mesh_var mesh = object->GetMesh();
|
||||||
|
SMESH::long_array_var objNbElems = object->GetNbElementsByType();
|
||||||
|
SMESH::long_array_var meshNbElems = mesh-> GetNbElementsByType();
|
||||||
|
if ( meshNbElems[ GetElementType() ] !=
|
||||||
|
objNbElems [ GetElementType() ] )
|
||||||
|
{
|
||||||
|
elements.reserve( objNbElems[ GetElementType() ]);
|
||||||
|
elemIt = SMESH_Mesh_i::GetElements( object, GetElementType() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( elemIt )
|
||||||
|
{
|
||||||
|
while ( elemIt->more() )
|
||||||
|
elements.push_back( elemIt->next()->GetID() );
|
||||||
|
if ( elements.empty() ) return histogram._retn();
|
||||||
|
}
|
||||||
|
|
||||||
|
myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements,0,isLogarithmic);
|
||||||
|
|
||||||
|
nbIntervals = CORBA::Short( Min( int( nbEvents.size()),
|
||||||
|
int( funValues.size() - 1 )));
|
||||||
if ( nbIntervals > 0 )
|
if ( nbIntervals > 0 )
|
||||||
{
|
{
|
||||||
histogram->length( nbIntervals );
|
histogram->length( nbIntervals );
|
||||||
@ -920,6 +972,29 @@ CORBA::Boolean Predicate_i::IsSatisfy( CORBA::Long theId )
|
|||||||
return myPredicatePtr->IsSatisfy( theId );
|
return myPredicatePtr->IsSatisfy( theId );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CORBA::Long Predicate_i::NbSatisfying( SMESH::SMESH_IDSource_ptr obj )
|
||||||
|
{
|
||||||
|
SMESH::SMESH_Mesh_var meshVar = obj->GetMesh();
|
||||||
|
const SMDS_Mesh* meshDS = MeshPtr2SMDSMesh( meshVar );
|
||||||
|
if ( !meshDS )
|
||||||
|
return 0;
|
||||||
|
myPredicatePtr->SetMesh( meshDS );
|
||||||
|
|
||||||
|
SMDSAbs_ElementType elemType = SMDSAbs_ElementType( GetElementType() );
|
||||||
|
|
||||||
|
int nb = 0;
|
||||||
|
SMDS_ElemIteratorPtr elemIt =
|
||||||
|
SMESH::DownCast<SMESH_Mesh_i*>( meshVar )->GetElements( obj, GetElementType() );
|
||||||
|
if ( elemIt )
|
||||||
|
while ( elemIt->more() )
|
||||||
|
{
|
||||||
|
const SMDS_MeshElement* e = elemIt->next();
|
||||||
|
if ( e && e->GetType() == elemType )
|
||||||
|
nb += myPredicatePtr->IsSatisfy( e->GetID() );
|
||||||
|
}
|
||||||
|
return nb;
|
||||||
|
}
|
||||||
|
|
||||||
Controls::PredicatePtr Predicate_i::GetPredicate()
|
Controls::PredicatePtr Predicate_i::GetPredicate()
|
||||||
{
|
{
|
||||||
return myPredicatePtr;
|
return myPredicatePtr;
|
||||||
@ -2702,59 +2777,63 @@ GetElementsId( SMESH_Mesh_ptr theMesh )
|
|||||||
return anArray._retn();
|
return anArray._retn();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class TElement, class TIterator, class TPredicate>
|
|
||||||
static void collectMeshInfo(const TIterator& theItr,
|
|
||||||
TPredicate& thePred,
|
|
||||||
SMESH::long_array& theRes)
|
|
||||||
{
|
|
||||||
if (!theItr)
|
|
||||||
return;
|
|
||||||
while (theItr->more()) {
|
|
||||||
const SMDS_MeshElement* anElem = theItr->next();
|
|
||||||
if ( thePred->IsSatisfy( anElem->GetID() ) )
|
|
||||||
theRes[ anElem->GetEntityType() ]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
* \brief Returns statistic of mesh elements
|
* \brief Returns number of mesh elements per each \a EntityType
|
||||||
*/
|
*/
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
SMESH::long_array* ::Filter_i::GetMeshInfo()
|
SMESH::long_array* ::Filter_i::GetMeshInfo()
|
||||||
{
|
{
|
||||||
SMESH::long_array_var aRes = new SMESH::long_array();
|
SMESH::long_array_var aRes = new SMESH::long_array();
|
||||||
aRes->length(SMESH::Entity_Last);
|
aRes->length(SMESH::Entity_Last);
|
||||||
for (int i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++)
|
for (int i = 0; i < SMESH::Entity_Last; i++)
|
||||||
aRes[i] = 0;
|
aRes[i] = 0;
|
||||||
|
|
||||||
if(!CORBA::is_nil(myMesh) && myPredicate) {
|
if ( !CORBA::is_nil(myMesh) && myPredicate )
|
||||||
const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh);
|
{
|
||||||
SMDS_ElemIteratorPtr it;
|
const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh);
|
||||||
switch( GetElementType() )
|
SMDS_ElemIteratorPtr it = aMesh->elementsIterator( SMDSAbs_ElementType( GetElementType() ));
|
||||||
|
while ( it->more() )
|
||||||
{
|
{
|
||||||
case SMDSAbs_Node:
|
const SMDS_MeshElement* anElem = it->next();
|
||||||
collectMeshInfo<const SMDS_MeshNode*>(aMesh->nodesIterator(),myPredicate,aRes);
|
if ( myPredicate->IsSatisfy( anElem->GetID() ) )
|
||||||
break;
|
aRes[ anElem->GetEntityType() ]++;
|
||||||
case SMDSAbs_Edge:
|
|
||||||
collectMeshInfo<const SMDS_MeshElement*>(aMesh->edgesIterator(),myPredicate,aRes);
|
|
||||||
break;
|
|
||||||
case SMDSAbs_Face:
|
|
||||||
collectMeshInfo<const SMDS_MeshElement*>(aMesh->facesIterator(),myPredicate,aRes);
|
|
||||||
break;
|
|
||||||
case SMDSAbs_Volume:
|
|
||||||
collectMeshInfo<const SMDS_MeshElement*>(aMesh->volumesIterator(),myPredicate,aRes);
|
|
||||||
break;
|
|
||||||
case SMDSAbs_All:
|
|
||||||
default:
|
|
||||||
collectMeshInfo<const SMDS_MeshElement*>(aMesh->elementsIterator(),myPredicate,aRes);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return aRes._retn();
|
return aRes._retn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Returns number of mesh elements of each \a ElementType
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
SMESH::long_array* ::Filter_i::GetNbElementsByType()
|
||||||
|
{
|
||||||
|
SMESH::long_array_var aRes = new SMESH::long_array();
|
||||||
|
aRes->length(SMESH::NB_ELEMENT_TYPES);
|
||||||
|
for (int i = 0; i < SMESH::NB_ELEMENT_TYPES; i++)
|
||||||
|
aRes[i] = 0;
|
||||||
|
|
||||||
|
if ( !CORBA::is_nil(myMesh) && myPredicate ) {
|
||||||
|
const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh);
|
||||||
|
SMDS_ElemIteratorPtr it = aMesh->elementsIterator( SMDSAbs_ElementType( GetElementType() ));
|
||||||
|
CORBA::Long& nbElems = aRes[ GetElementType() ];
|
||||||
|
while ( it->more() )
|
||||||
|
{
|
||||||
|
const SMDS_MeshElement* anElem = it->next();
|
||||||
|
if ( myPredicate->IsSatisfy( anElem->GetID() ) )
|
||||||
|
nbElems++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return aRes._retn();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
/*!
|
/*!
|
||||||
* \brief Return GetElementType() within an array
|
* \brief Return GetElementType() within an array
|
||||||
|
@ -162,7 +162,11 @@ namespace SMESH
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CORBA::Double GetValue( CORBA::Long theElementId );
|
CORBA::Double GetValue( CORBA::Long theElementId );
|
||||||
SMESH::Histogram* GetHistogram(CORBA::Short nbIntervals, CORBA::Boolean isLogarithmic);
|
SMESH::Histogram* GetHistogram(CORBA::Short nbIntervals,
|
||||||
|
CORBA::Boolean isLogarithmic);
|
||||||
|
SMESH::Histogram* GetLocalHistogram(CORBA::Short nbIntervals,
|
||||||
|
CORBA::Boolean isLogarithmic,
|
||||||
|
SMESH::SMESH_IDSource_ptr object);
|
||||||
void SetPrecision( CORBA::Long thePrecision );
|
void SetPrecision( CORBA::Long thePrecision );
|
||||||
CORBA::Long GetPrecision();
|
CORBA::Long GetPrecision();
|
||||||
Controls::NumericalFunctorPtr GetNumericalFunctor();
|
Controls::NumericalFunctorPtr GetNumericalFunctor();
|
||||||
@ -383,6 +387,7 @@ namespace SMESH
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CORBA::Boolean IsSatisfy( CORBA::Long theElementId );
|
CORBA::Boolean IsSatisfy( CORBA::Long theElementId );
|
||||||
|
CORBA::Long NbSatisfying( SMESH::SMESH_IDSource_ptr obj );
|
||||||
Controls::PredicatePtr GetPredicate();
|
Controls::PredicatePtr GetPredicate();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -1029,6 +1034,7 @@ namespace SMESH
|
|||||||
// =========================
|
// =========================
|
||||||
virtual SMESH::long_array* GetIDs();
|
virtual SMESH::long_array* GetIDs();
|
||||||
virtual SMESH::long_array* GetMeshInfo();
|
virtual SMESH::long_array* GetMeshInfo();
|
||||||
|
virtual SMESH::long_array* GetNbElementsByType();
|
||||||
virtual SMESH::array_of_ElementType* GetTypes();
|
virtual SMESH::array_of_ElementType* GetTypes();
|
||||||
virtual SMESH::SMESH_Mesh_ptr GetMesh();
|
virtual SMESH::SMESH_Mesh_ptr GetMesh();
|
||||||
virtual bool IsMeshInfoCorrect() { return true; }
|
virtual bool IsMeshInfoCorrect() { return true; }
|
||||||
|
Loading…
Reference in New Issue
Block a user