]> SALOME platform Git repositories - modules/smesh.git/blobdiff - src/StdMeshers/StdMeshers_Quadrangle_2D.cxx
Salome HOME
0022364: EDF SMESH: Create Mesh dialog box improvement: hide inapplicable algorithms...
[modules/smesh.git] / src / StdMeshers / StdMeshers_Quadrangle_2D.cxx
index 2c4ce511f85a4809e4655ea013fa982421ef4031..89e8042b494892e6ae83b253aee0a57775c2e3db 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -904,6 +904,35 @@ bool StdMeshers_Quadrangle_2D::Evaluate(SMESH_Mesh&         aMesh,
   return true;
 }
 
+//================================================================================
+/*!
+ * \brief Return true if applied compute mesh on this shape
+ */
+//================================================================================
+
+bool StdMeshers_Quadrangle_2D::IsApplicable( const TopoDS_Shape & aShape, bool toCheckAll )
+{
+  int nbFoundFaces = 0;
+  for (TopExp_Explorer exp( aShape, TopAbs_FACE ); exp.More(); exp.Next(), ++nbFoundFaces ){
+    TopoDS_Face aFace = TopoDS::Face(exp.Current());
+    if ( aFace.Orientation() >= TopAbs_INTERNAL ) aFace.Orientation( TopAbs_FORWARD );
+
+    list< TopoDS_Edge > aWire;
+    list< int > nbEdgesInWire;
+    int nbWire = SMESH_Block::GetOrderedEdges (aFace, aWire, nbEdgesInWire);
+
+    int nbNoDegenEdges = 0;
+    list<TopoDS_Edge>::iterator edge = aWire.begin();
+      for ( ; edge != aWire.end(); ++edge ){
+        if ( !SMESH_Algo::isDegenerated( *edge ))
+          ++nbNoDegenEdges;
+      }
+      if( toCheckAll && (nbWire != 1 || nbNoDegenEdges <= 3 ) ) return false;
+      if( !toCheckAll && nbWire == 1 && nbNoDegenEdges > 3 ) return true;
+  }
+  if( toCheckAll && nbFoundFaces != 0) return true;
+  return false;
+};
 
 //================================================================================
 /*!