diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index c804e6df3..f9540e004 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -22,31 +22,36 @@ #include "SMESH_ControlsDef.hxx" -#include -#include +#include "SMDS_BallElement.hxx" +#include "SMDS_Iterator.hxx" +#include "SMDS_Mesh.hxx" +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMDS_QuadraticEdge.hxx" +#include "SMDS_QuadraticFaceOfNodes.hxx" +#include "SMDS_VolumeTool.hxx" +#include "SMESHDS_GroupBase.hxx" +#include "SMESHDS_Mesh.hxx" +#include "SMESH_OctreeNode.hxx" #include #include #include - -#include -#include -#include -#include -#include -#include -#include - #include #include #include - #include #include #include #include #include - +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -55,21 +60,12 @@ #include #include -#include "SMDS_Mesh.hxx" -#include "SMDS_Iterator.hxx" -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshNode.hxx" -#include "SMDS_VolumeTool.hxx" -#include "SMDS_QuadraticFaceOfNodes.hxx" -#include "SMDS_QuadraticEdge.hxx" - -#include "SMESHDS_Mesh.hxx" -#include "SMESHDS_GroupBase.hxx" - -#include "SMESH_OctreeNode.hxx" - #include +#include +#include + + /* AUXILIARY METHODS */ @@ -1966,6 +1962,34 @@ void MultiConnection2D::GetValues(MValues& theValues){ } +/* + Class : BallDiameter + Description : Functor returning diameter of a ball element +*/ +double BallDiameter::GetValue( long theId ) +{ + double diameter = 0; + + if ( const SMDS_BallElement* ball = + dynamic_cast( myMesh->FindElement( theId ))) + { + diameter = ball->GetDiameter(); + } + return diameter; +} + +double BallDiameter::GetBadRate( double Value, int /*nbNodes*/ ) const +{ + // meaningless as it is not a quality control functor + return Value; +} + +SMDSAbs_ElementType BallDiameter::GetType() const +{ + return SMDSAbs_Ball; +} + + /* PREDICATES */ @@ -3156,26 +3180,9 @@ void Filter::SetPredicate( PredicatePtr thePredicate ) myPredicate = thePredicate; } -template -inline void FillSequence(const TIterator& theIterator, - TPredicate& thePredicate, - Filter::TIdSequence& theSequence) -{ - if ( theIterator ) { - while( theIterator->more() ) { - TElement anElem = theIterator->next(); - long anId = anElem->GetID(); - if ( thePredicate->IsSatisfy( anId ) ) - theSequence.push_back( anId ); - } - } -} - -void -Filter:: -GetElementsId( const SMDS_Mesh* theMesh, - PredicatePtr thePredicate, - TIdSequence& theSequence ) +void Filter::GetElementsId( const SMDS_Mesh* theMesh, + PredicatePtr thePredicate, + TIdSequence& theSequence ) { theSequence.clear(); @@ -3184,31 +3191,19 @@ GetElementsId( const SMDS_Mesh* theMesh, thePredicate->SetMesh( theMesh ); - SMDSAbs_ElementType aType = thePredicate->GetType(); - switch(aType){ - case SMDSAbs_Node: - FillSequence(theMesh->nodesIterator(),thePredicate,theSequence); - break; - case SMDSAbs_Edge: - FillSequence(theMesh->edgesIterator(),thePredicate,theSequence); - break; - case SMDSAbs_Face: - FillSequence(theMesh->facesIterator(),thePredicate,theSequence); - break; - case SMDSAbs_Volume: - FillSequence(theMesh->volumesIterator(),thePredicate,theSequence); - break; - case SMDSAbs_All: - FillSequence(theMesh->edgesIterator(),thePredicate,theSequence); - FillSequence(theMesh->facesIterator(),thePredicate,theSequence); - FillSequence(theMesh->volumesIterator(),thePredicate,theSequence); - break; + SMDS_ElemIteratorPtr elemIt = theMesh->elementsIterator( thePredicate->GetType() ); + if ( elemIt ) { + while ( elemIt->more() ) { + const SMDS_MeshElement* anElem = elemIt->next(); + long anId = anElem->GetID(); + if ( thePredicate->IsSatisfy( anId ) ) + theSequence.push_back( anId ); + } } } -void -Filter::GetElementsId( const SMDS_Mesh* theMesh, - Filter::TIdSequence& theSequence ) +void Filter::GetElementsId( const SMDS_Mesh* theMesh, + Filter::TIdSequence& theSequence ) { GetElementsId(theMesh,myPredicate,theSequence); } @@ -3872,36 +3867,9 @@ void ElementsOnShape::process() if (myShape.IsNull() || myMesh == 0) return; - if (myType == SMDSAbs_Node) - { - SMDS_NodeIteratorPtr anIter = myMesh->nodesIterator(); - while (anIter->more()) - process(anIter->next()); - } - else - { - if (myType == SMDSAbs_Edge || myType == SMDSAbs_All) - { - SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator(); - while (anIter->more()) - process(anIter->next()); - } - - if (myType == SMDSAbs_Face || myType == SMDSAbs_All) - { - SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); - while (anIter->more()) { - process(anIter->next()); - } - } - - if (myType == SMDSAbs_Volume || myType == SMDSAbs_All) - { - SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator(); - while (anIter->more()) - process(anIter->next()); - } - } + SMDS_ElemIteratorPtr anIter = myMesh->elementsIterator(myType); + while (anIter->more()) + process(anIter->next()); } void ElementsOnShape::process (const SMDS_MeshElement* theElemPtr) @@ -3916,9 +3884,8 @@ void ElementsOnShape::process (const SMDS_MeshElement* theElemPtr) while (aNodeItr->more() && (isSatisfy == myAllNodesFlag)) { - SMDS_MeshNode* aNode = (SMDS_MeshNode*)aNodeItr->next(); - gp_Pnt aPnt (aNode->X(), aNode->Y(), aNode->Z()); - centerXYZ += aPnt.XYZ(); + SMESH_TNodeXYZ aPnt ( aNodeItr->next() ); + centerXYZ += aPnt; switch (myCurShapeType) { @@ -3951,7 +3918,7 @@ void ElementsOnShape::process (const SMDS_MeshElement* theElemPtr) break; case TopAbs_VERTEX: { - isSatisfy = (aPnt.Distance(myCurPnt) <= myToler); + isSatisfy = (myCurPnt.Distance(aPnt) <= myToler); } break; default: diff --git a/src/Controls/SMESH_ControlsDef.hxx b/src/Controls/SMESH_ControlsDef.hxx index 319420fa1..0609c99e7 100644 --- a/src/Controls/SMESH_ControlsDef.hxx +++ b/src/Controls/SMESH_ControlsDef.hxx @@ -331,6 +331,19 @@ namespace SMESH{ void GetValues(MValues& theValues); }; typedef boost::shared_ptr MultiConnection2DPtr; + + /* + Class : BallDiameter + Description : Functor returning diameter of a ball element + */ + class SMESHCONTROLS_EXPORT BallDiameter: public virtual NumericalFunctor{ + public: + virtual double GetValue( long theElementId ); + virtual double GetBadRate( double Value, int nbNodes ) const; + virtual SMDSAbs_ElementType GetType() const; + }; + + /* PREDICATES */