From 01e646e9da75d2314a14c94b14c1130c1a374117 Mon Sep 17 00:00:00 2001 From: mzn Date: Fri, 26 Dec 2008 10:47:02 +0000 Subject: [PATCH] Fix for improvement 0019927 (EDF770 SMESH: Analyzing the Mesh Quality: Orphan nodes). --- src/Controls/SMESH_Controls.cxx | 31 ++++++++++++++++++++++++++++++ src/Controls/SMESH_ControlsDef.hxx | 16 +++++++++++++++ src/SMESH_I/SMESH_DumpPython.cxx | 1 + src/SMESH_I/SMESH_Filter_i.cxx | 29 ++++++++++++++++++++++++++++ src/SMESH_I/SMESH_Filter_i.hxx | 14 ++++++++++++++ 5 files changed, 91 insertions(+) diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index 3350a966e..38c8396bc 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -1691,6 +1691,37 @@ void FreeEdges::GetBoreders(TBorders& theBorders) //std::cout<<"theBorders.size() = "<FindNode( theNodeId ); + if (!aNode) + return false; + + return (aNode->NbInverseElements() < 1); +} + +SMDSAbs_ElementType FreeNodes::GetType() const +{ + return SMDSAbs_Node; +} + + /* Class : RangeOfIds Description : Predicate for Range of Ids. diff --git a/src/Controls/SMESH_ControlsDef.hxx b/src/Controls/SMESH_ControlsDef.hxx index 9eea42566..e400e16d4 100644 --- a/src/Controls/SMESH_ControlsDef.hxx +++ b/src/Controls/SMESH_ControlsDef.hxx @@ -380,7 +380,23 @@ namespace SMESH{ const SMDS_Mesh* myMesh; }; typedef boost::shared_ptr FreeEdgesPtr; + + + /* + Class : FreeNodes + Description : Predicate for free nodes + */ + class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{ + public: + FreeNodes(); + virtual void SetMesh( const SMDS_Mesh* theMesh ); + virtual bool IsSatisfy( long theNodeId ); + virtual SMDSAbs_ElementType GetType() const; + protected: + const SMDS_Mesh* myMesh; + }; + /* Class : RangeOfIds diff --git a/src/SMESH_I/SMESH_DumpPython.cxx b/src/SMESH_I/SMESH_DumpPython.cxx index 35ed7f21f..47ffcc970 100644 --- a/src/SMESH_I/SMESH_DumpPython.cxx +++ b/src/SMESH_I/SMESH_DumpPython.cxx @@ -224,6 +224,7 @@ namespace SMESH case FT_Area: myStream<< "aArea"; break; case FT_FreeBorders: myStream<< "aFreeBorders"; break; case FT_FreeEdges: myStream<< "aFreeEdges"; break; + case FT_FreeNodes: myStream<< "aFreeNodes"; break; case FT_MultiConnection: myStream<< "aMultiConnection"; break; case FT_MultiConnection2D:myStream<< "aMultiConnection2D";break; case FT_Length: myStream<< "aLength"; break; diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index a2fc21cdb..be7f625f7 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -1283,6 +1283,21 @@ FunctorType FreeEdges_i::GetFunctorType() return SMESH::FT_FreeEdges; } +/* + Class : FreeNodes_i + Description : Predicate for free nodes +*/ +FreeNodes_i::FreeNodes_i() +{ + myPredicatePtr.reset(new Controls::FreeNodes()); + myFunctorPtr = myPredicatePtr; +} + +FunctorType FreeNodes_i::GetFunctorType() +{ + return SMESH::FT_FreeNodes; +} + /* Class : RangeOfIds_i Description : Predicate for Range of Ids. @@ -1763,6 +1778,14 @@ FreeEdges_ptr FilterManager_i::CreateFreeEdges() return anObj._retn(); } +FreeNodes_ptr FilterManager_i::CreateFreeNodes() +{ + SMESH::FreeNodes_i* aServant = new SMESH::FreeNodes_i(); + SMESH::FreeNodes_var anObj = aServant->_this(); + TPythonDump()<length(); theCriteria->length( i + 1 ); @@ -2257,6 +2281,9 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria case SMESH::FT_FreeEdges: aPredicate = aFilterMgr->CreateFreeEdges(); break; + case SMESH::FT_FreeNodes: + aPredicate = aFilterMgr->CreateFreeNodes(); + break; case SMESH::FT_BelongToGeom: { SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom(); @@ -2515,6 +2542,7 @@ static inline LDOMString toString( CORBA::Long theType ) case FT_RangeOfIds : return "Range of IDs"; case FT_FreeBorders : return "Free borders"; case FT_FreeEdges : return "Free edges"; + case FT_FreeNodes : return "Free nodes"; case FT_MultiConnection : return "Borders at multi-connections"; case FT_MultiConnection2D: return "Borders at multi-connections 2D"; case FT_Length : return "Length"; @@ -2550,6 +2578,7 @@ static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr ) else if ( theStr.equals( "Lying on Geom" ) ) return FT_LyingOnGeom; else if ( theStr.equals( "Free borders" ) ) return FT_FreeBorders; else if ( theStr.equals( "Free edges" ) ) return FT_FreeEdges; + else if ( theStr.equals( "Free nodes" ) ) return FT_FreeNodes; else if ( theStr.equals( "Borders at multi-connections" ) ) return FT_MultiConnection; // else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D; else if ( theStr.equals( "Length" ) ) return FT_Length; diff --git a/src/SMESH_I/SMESH_Filter_i.hxx b/src/SMESH_I/SMESH_Filter_i.hxx index 1939ddab7..c6971b0fd 100644 --- a/src/SMESH_I/SMESH_Filter_i.hxx +++ b/src/SMESH_I/SMESH_Filter_i.hxx @@ -521,6 +521,19 @@ namespace SMESH Controls::FreeEdgesPtr myFreeEdgesPtr; }; + + /* + Class : FreeNodes_i + Description : Predicate for free nodes + */ + class SMESH_I_EXPORT FreeNodes_i: public virtual POA_SMESH::FreeNodes, + public virtual Predicate_i + { + public: + FreeNodes_i(); + FunctorType GetFunctorType(); + }; + /* Class : RangeOfIds_i @@ -816,6 +829,7 @@ namespace SMESH FreeBorders_ptr CreateFreeBorders(); FreeEdges_ptr CreateFreeEdges(); + FreeNodes_ptr CreateFreeNodes(); RangeOfIds_ptr CreateRangeOfIds();