Salome HOME
022501: [CEA 1076] Impossible to mesh at its position a translated without copy shape...
[modules/smesh.git] / src / StdMeshers / StdMeshers_Quadrangle_2D.cxx
index 6a13513467ff122b2b9d936b4296d805dd622e4c..52bdb0aa560743b64e3cac0db68abdb3e52f726f 100644 (file)
@@ -904,6 +904,42 @@ bool StdMeshers_Quadrangle_2D::Evaluate(SMESH_Mesh&         aMesh,
   return true;
 }
 
+//================================================================================
+/*!
+ * \brief Return true if the algorithm can mesh this shape
+ *  \param [in] aShape - shape to check
+ *  \param [in] toCheckAll - if true, this check returns OK if all shapes are OK,
+ *              else, returns OK if at least one shape is OK
+ */
+//================================================================================
+
+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);
+    if ( nbWire != 1 ) {
+      if ( toCheckAll ) return false;
+      continue;
+    }
+
+    int nbNoDegenEdges = 0;
+    list<TopoDS_Edge>::iterator edge = aWire.begin();
+    for ( ; edge != aWire.end(); ++edge ) {
+      if ( !SMESH_Algo::isDegenerated( *edge ))
+        ++nbNoDegenEdges;
+    }
+    if ( toCheckAll  && nbNoDegenEdges <  3 ) return false;
+    if ( !toCheckAll && nbNoDegenEdges >= 3 ) return true;
+  }
+  return ( toCheckAll && nbFoundFaces != 0 );
+}
 
 //================================================================================
 /*!