* \param nbIntervals - number of intervals
* \param nbEvents - number of mesh elements having values within i-th interval
* \param funValues - boundaries of intervals
+ * \param elements - elements to check vulue of; empty list means "of all"
*/
//================================================================================
void NumericalFunctor::GetHistogram(int nbIntervals,
std::vector<int>& nbEvents,
- std::vector<double>& funValues)
+ std::vector<double>& funValues,
+ const vector<int>& elements)
{
if ( nbIntervals < 1 ||
!myMesh ||
// get all values sorted
std::multiset< double > values;
- SMDS_ElemIteratorPtr elemIt = myMesh->elementsIterator(GetType());
- while ( elemIt->more() )
- values.insert( GetValue( elemIt->next()->GetID() ));
+ if ( elements.empty() )
+ {
+ SMDS_ElemIteratorPtr elemIt = myMesh->elementsIterator(GetType());
+ while ( elemIt->more() )
+ values.insert( GetValue( elemIt->next()->GetID() ));
+ }
+ else
+ {
+ vector<int>::const_iterator id = elements.begin();
+ for ( ; id != elements.end(); ++id )
+ values.insert( GetValue( *id ));
+ }
// case nbIntervals == 1
funValues[0] = *values.begin();
return false;
}
+/*
+ Class : OverConstrainedVolume
+*/
+
+bool OverConstrainedVolume::IsSatisfy(long theElementId )
+{
+ // An element is over-constrained if it has N-1 free borders where
+ // N is the number of edges/faces for a 2D/3D element.
+ SMDS_VolumeTool myTool;
+ if ( myTool.Set( myMesh->FindElement(theElementId)))
+ {
+ int nbSharedFaces = 0;
+ for ( int iF = 0; iF < myTool.NbFaces(); ++iF )
+ if ( !myTool.IsFreeFace( iF ) && ++nbSharedFaces > 1 )
+ break;
+ return ( nbSharedFaces == 1 );
+ }
+ return false;
+}
+
+/*
+ Class : OverConstrainedFace
+*/
+
+bool OverConstrainedFace::IsSatisfy(long theElementId )
+{
+ // An element is over-constrained if it has N-1 free borders where
+ // N is the number of edges/faces for a 2D/3D element.
+ if ( const SMDS_MeshElement* face = myMesh->FindElement(theElementId))
+ if ( face->GetType() == SMDSAbs_Face )
+ {
+ int nbSharedBorders = 0;
+ int nbN = face->NbCornerNodes();
+ for ( int i = 0; i < nbN; ++i )
+ {
+ // check if a link is shared by another face
+ const SMDS_MeshNode* n1 = face->GetNode( i );
+ const SMDS_MeshNode* n2 = face->GetNode( (i+1)%nbN );
+ SMDS_ElemIteratorPtr fIt = n1->GetInverseElementIterator( SMDSAbs_Face );
+ bool isShared = false;
+ while ( !isShared && fIt->more() )
+ {
+ const SMDS_MeshElement* f = fIt->next();
+ isShared = ( f != face && f->GetNodeIndex(n2) != -1 );
+ }
+ if ( isShared && ++nbSharedBorders > 1 )
+ break;
+ }
+ return ( nbSharedBorders == 1 );
+ }
+ return false;
+}
+
/*
Class : FreeBorders
Description : Predicate for free borders
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);
+ void GetHistogram(int nbIntervals,
+ std::vector<int>& nbEvents,
+ std::vector<double>& funValues,
+ const std::vector<int>& elements);
virtual SMDSAbs_ElementType GetType() const = 0;
virtual double GetBadRate( double Value, int nbNodes ) const = 0;
long GetPrecision() const;
};
typedef boost::shared_ptr<BareBorderFace> BareBorderFacePtr;
+ /*
+ OverConstrainedVolume
+ */
+ class SMESHCONTROLS_EXPORT OverConstrainedVolume: public Predicate
+ {
+ public:
+ OverConstrainedVolume():myMesh(0) {}
+ virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
+ virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
+ virtual bool IsSatisfy( long theElementId );
+ protected:
+ const SMDS_Mesh* myMesh;
+ };
+ typedef boost::shared_ptr<OverConstrainedVolume> OverConstrainedVolumePtr;
+
+ /*
+ OverConstrainedFace
+ */
+ class SMESHCONTROLS_EXPORT OverConstrainedFace: public Predicate
+ {
+ public:
+ OverConstrainedFace():myMesh(0) {}
+ virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
+ virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
+ virtual bool IsSatisfy( long theElementId );
+ protected:
+ const SMDS_Mesh* myMesh;
+ std::vector< const SMDS_MeshNode* > myLinkNodes;
+ };
+ typedef boost::shared_ptr<OverConstrainedFace> OverConstrainedFacePtr;
+
/*
Class : FreeEdges
Description : Predicate for free Edges