From: eap Date: Fri, 19 Nov 2010 16:22:49 +0000 (+0000) Subject: 0020948: EDF 1468 SMESH: Histogram of the quality controls X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cddf6847bcd6d4aef0045a952a3b44fd1791c0e6;p=modules%2Fsmesh.git 0020948: EDF 1468 SMESH: Histogram of the quality controls limit computed histogram to a submesh 0020944: EDF 1464 SMESH: detection of over-constrained elements + class OverConstrainedVolume: public Predicate + class OverConstrainedFace: public Predicate --- diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index 231c36a56..b13588de6 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -283,12 +283,14 @@ double NumericalFunctor::GetValue( long theId ) * \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& nbEvents, - std::vector& funValues) + std::vector& funValues, + const vector& elements) { if ( nbIntervals < 1 || !myMesh || @@ -299,9 +301,18 @@ void NumericalFunctor::GetHistogram(int nbIntervals, // 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::const_iterator id = elements.begin(); + for ( ; id != elements.end(); ++id ) + values.insert( GetValue( *id )); + } // case nbIntervals == 1 funValues[0] = *values.begin(); @@ -1932,6 +1943,59 @@ bool BareBorderFace::IsSatisfy(long theElementId ) 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 diff --git a/src/Controls/SMESH_ControlsDef.hxx b/src/Controls/SMESH_ControlsDef.hxx index 3d55ccf3a..46255a26a 100644 --- a/src/Controls/SMESH_ControlsDef.hxx +++ b/src/Controls/SMESH_ControlsDef.hxx @@ -127,9 +127,10 @@ 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& nbEvents, - std::vector& funValues); + void GetHistogram(int nbIntervals, + std::vector& nbEvents, + std::vector& funValues, + const std::vector& elements); virtual SMDSAbs_ElementType GetType() const = 0; virtual double GetBadRate( double Value, int nbNodes ) const = 0; long GetPrecision() const; @@ -409,6 +410,37 @@ namespace SMESH{ }; typedef boost::shared_ptr 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 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 OverConstrainedFacePtr; + /* Class : FreeEdges Description : Predicate for free Edges