Salome HOME
Mantis issue 0021425: Accepted object types in 'fillet 2D'
[modules/geom.git] / src / GEOMImpl / GEOMImpl_Block6Explorer.cxx
index 27056c52c354fce18c03978be2420b2a73f4de6a..48f179cf8e71c41dd49f0c959f1895ef57c65fc8 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  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
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  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.
+// 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.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 
 #include <Standard_Stream.hxx>
 
@@ -78,6 +78,8 @@
 #define NBEDGES 12
 #define NBVERTS 8
 
+#define PLANAR_FACE_MAX_TOLERANCE 1e-06
+
 static Standard_Integer mod4 (Standard_Integer nb)
 {
   if (nb <= 0) return nb + 4;
@@ -1196,10 +1198,12 @@ Standard_Integer GEOMImpl_Block6Explorer::FindFace
 //function : MakeFace
 //purpose  :
 //=======================================================================
-void GEOMImpl_Block6Explorer::MakeFace (const TopoDS_Wire&     theWire,
-                                        const Standard_Boolean isPlanarWanted,
-                                        TopoDS_Shape&          theResult)
+TCollection_AsciiString GEOMImpl_Block6Explorer::MakeFace (const TopoDS_Wire&     theWire,
+                                                           const Standard_Boolean isPlanarWanted,
+                                                           TopoDS_Shape&          theResult)
 {
+  TCollection_AsciiString aWarning;
+
   // Workaround for Mantis issue 0020956
   if (isPlanarWanted) {
     // Count the number of points in the wire.
@@ -1246,14 +1250,14 @@ void GEOMImpl_Block6Explorer::MakeFace (const TopoDS_Wire&     theWire,
       BRepBuilderAPI_MakeFace MK (plane, theWire, isPlanarWanted);
       if (MK.IsDone()) {
         theResult = MK.Shape();
-        return;
+        return aWarning;
       }
     }
     else {
       BRepBuilderAPI_MakeFace MK (theWire, isPlanarWanted);
       if (MK.IsDone()) {
         theResult = MK.Shape();
-        return;
+        return aWarning;
       }
     }
   }
@@ -1262,7 +1266,7 @@ void GEOMImpl_Block6Explorer::MakeFace (const TopoDS_Wire&     theWire,
     BRepBuilderAPI_MakeFace MK (theWire, isPlanarWanted);
     if (MK.IsDone()) {
       theResult = MK.Shape();
-      return;
+      return aWarning;
     }
   }
 
@@ -1345,7 +1349,7 @@ void GEOMImpl_Block6Explorer::MakeFace (const TopoDS_Wire&     theWire,
 
     if (!aFS.Found()) {
       aFS.Init(theWire, aToleranceReached, isPlanarWanted);
-      if (!aFS.Found()) return;
+      if (!aFS.Found()) return aWarning;
       aToleranceReached = aFS.ToleranceReached();
       aTol = aFS.Tolerance();
     }
@@ -1353,7 +1357,7 @@ void GEOMImpl_Block6Explorer::MakeFace (const TopoDS_Wire&     theWire,
 
     // Copy the wire, bacause it can be updated with very-very big tolerance here
     BRepBuilderAPI_Copy aMC (theWire);
-    if (!aMC.IsDone()) return;
+    if (!aMC.IsDone()) return aWarning;
     TopoDS_Wire aWire = TopoDS::Wire(aMC.Shape());
     // Update tolerances to <aTol>
     BRep_Builder B;
@@ -1370,7 +1374,9 @@ void GEOMImpl_Block6Explorer::MakeFace (const TopoDS_Wire&     theWire,
     BRepBuilderAPI_MakeFace MK1 (aWire, isPlanarWanted);
     if (MK1.IsDone()) {
       theResult = MK1.Shape();
-      return;
+      if (aTol > PLANAR_FACE_MAX_TOLERANCE)
+        aWarning = "MAKE_FACE_TOLERANCE_TOO_BIG";
+      return aWarning;
     }
 
 #else // After migration on OCCT version, containing PKV's fix. See bug 8293
@@ -1378,8 +1384,10 @@ void GEOMImpl_Block6Explorer::MakeFace (const TopoDS_Wire&     theWire,
     aBMF.Init(theWire, isPlanarWanted, Standard_True);
     if (aBMF.Error() == BRepLib_FaceDone) {
       theResult = aBMF.Shape();
-      return;
+      return aWarning;
     }
 #endif
   }
+
+  return aWarning;
 }