]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Mantis issue 0021432: EDF GEOM: Faces with huge tolerance can be built in GEOM
authorjfa <jfa@opencascade.com>
Wed, 23 Nov 2011 13:29:40 +0000 (13:29 +0000)
committerjfa <jfa@opencascade.com>
Wed, 23 Nov 2011 13:29:40 +0000 (13:29 +0000)
src/BuildGUI/BuildGUI_FaceDlg.cxx
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMImpl/GEOMImpl_Block6Explorer.cxx
src/GEOMImpl/GEOMImpl_Block6Explorer.hxx
src/GEOMImpl/GEOMImpl_IShapesOperations.cxx
src/GEOMImpl/GEOMImpl_ShapeDriver.cxx
src/GEOM_I/GEOM_IShapesOperations_i.cc
src/GEOM_SWIG/geompyDC.py

index 15daf9f860ddb853559e11031d553fa6d175f4f9..c1561405b7d2ba0bb0777cf4a1eadebfe576958a 100644 (file)
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
 
 // GEOM GEOMGUI : GUI for Geometry component
 // File   : BuildGUI_FaceDlg.cxx
 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
-//
+
 #include "BuildGUI_FaceDlg.h"
 
 #include <GEOMImpl_Types.hxx>
 #include <GeometryGUI.h>
 #include <GEOMBase.h>
 
-#include <SUIT_ResourceMgr.h>
-#include <SUIT_Session.h>
 #include <SalomeApp_Application.h>
 #include <LightApp_SelectionMgr.h>
 
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_OverrideCursor.h>
+
 //=================================================================================
 // class    : BuildGUI_FaceDlg()
 // purpose  : Constructs a BuildGUI_FaceDlg which is a child of 'parent', with the 
@@ -247,9 +249,17 @@ bool BuildGUI_FaceDlg::execute( ObjectList& objects )
 
   GEOM::GEOM_Object_var anObj = anOper->MakeFaceWires( objlist.in(), GroupWire->CheckButton1->isChecked() );
 
-  if ( !anObj->_is_nil() )
-    objects.push_back( anObj._retn() );
+  if (!anObj->_is_nil()) {
+    objects.push_back(anObj._retn());
+
+    if (!anOper->IsDone() && QString(anOper->GetErrorCode()) == "MAKE_FACE_TOLERANCE_TOO_BIG") {
+      SUIT_OverrideCursor wc;
+      wc.suspend();
+      QString msgw = QObject::tr(anOper->GetErrorCode());
+      SUIT_MessageBox::warning(this, tr("WRN_WARNING"), msgw, tr("BUT_OK"));
+      anOper->SetErrorCode("PAL_NO_ERROR");
+    }
+  }
 
   return true;
 }
-
index 486a2bbc10f8972efde45b3dc111f731b2caa6e7..b312d7ce490594c7c24d07c76b74f5bcbb3d2e29 100644 (file)
@@ -605,6 +605,10 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_FACE_OPT</source>
         <translation>Try to create a planar face</translation>
     </message>
+    <message>
+        <source>MAKE_FACE_TOLERANCE_TOO_BIG</source>
+        <translation>Tolerance of resulting face is too big</translation>
+    </message>
     <message>
         <source>GEOM_FACE_OR_LCS</source>
         <translation>Face or LCS</translation>
index 5086d53c05eeddd85753778263af4020ac2561fc..48f179cf8e71c41dd49f0c959f1895ef57c65fc8 100644 (file)
@@ -18,7 +18,6 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
 
 #include <Standard_Stream.hxx>
 
@@ -79,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;
@@ -1197,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.
@@ -1247,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;
       }
     }
   }
@@ -1263,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;
     }
   }
 
@@ -1346,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();
     }
@@ -1354,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;
@@ -1371,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
@@ -1379,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;
 }
index 9734ae744988f90892520821ceeba25a933adea9..ea47dfe37a18bdf1fda5112aa9e7e79b5dd6f2ca 100644 (file)
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
 
 //  File   : GEOMImpl_Block6Explorer.hxx
 //  Module : GEOMImpl
-//
+
 #ifndef GEOMImpl_Block6Explorer_HeaderFile
 #define GEOMImpl_Block6Explorer_HeaderFile
 
@@ -30,6 +29,7 @@
 #include <TopoDS_Wire.hxx>
 #include <TopTools_Array1OfShape.hxx>
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TCollection_AsciiString.hxx>
 #include <gp_Trsf.hxx>
 
   //  Class GEOMImpl_Block6Explorer gives easy and fast access to a certain sub-elements of hexahedral solid
@@ -214,9 +214,9 @@ class GEOMImpl_Block6Explorer
                                     const Standard_Boolean findAll = Standard_False);
   // returns number of found faces
 
-  static void MakeFace (const TopoDS_Wire&     theWire,
-                        const Standard_Boolean isPlanarWanted,
-                        TopoDS_Shape&          theResult);
+  static TCollection_AsciiString MakeFace (const TopoDS_Wire&     theWire,
+                                           const Standard_Boolean isPlanarWanted,
+                                           TopoDS_Shape&          theResult);
 
  private:
   // ---------- PRIVATE FIELDS ----------
index f74e646e41f71cc4a540eb8cec4143bdc861f986..1f958e17004c4e3eda6f94fc8879cf4e34599c3d 100644 (file)
@@ -83,7 +83,6 @@
 #include <BRepAdaptor_Curve.hxx>
 #include <BRepAdaptor_Surface.hxx>
 #include <BRepBndLib.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
 #include <BRepMesh_IncrementalMesh.hxx>
 
 #include <TopAbs.hxx>
@@ -458,6 +457,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFace (Handle(GEOM_Object) th
   aCI.SetIsPlanar(isPlanarWanted);
 
   //Compute the Face value
+  Standard_Boolean isWarning = Standard_False;
   try {
 #if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
@@ -470,14 +470,20 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFace (Handle(GEOM_Object) th
   catch (Standard_Failure) {
     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
     SetErrorCode(aFail->GetMessageString());
-    return NULL;
+    // to provide warning
+    if (!aFunction->GetValue().IsNull()) {
+      isWarning = Standard_True;
+    } else {
+      return NULL;
+    }
   }
 
   //Make a Python command
   GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFace("
     << theWire << ", " << (int)isPlanarWanted << ")";
 
-  SetErrorCode(OK);
+  // to provide warning
+  if (!isWarning) SetErrorCode(OK);
   return aFace;
 }
 
@@ -522,6 +528,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWires
   aCI.SetIsPlanar(isPlanarWanted);
 
   //Compute the shape
+  Standard_Boolean isWarning = Standard_False;
   try {
 #if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
@@ -534,7 +541,12 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWires
   catch (Standard_Failure) {
     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
     SetErrorCode(aFail->GetMessageString());
-    return NULL;
+    // to provide warning
+    if (!aFunction->GetValue().IsNull()) {
+      isWarning = Standard_True;
+    } else {
+      return NULL;
+    }
   }
 
   //Make a Python command
@@ -551,7 +563,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWires
   }
   pd << "], " << (int)isPlanarWanted << ")";
 
-  SetErrorCode(OK);
+  // to provide warning
+  if (!isWarning) SetErrorCode(OK);
   return aShape;
 }
 
index 37f3937f05e0bbd4d25cba6634ac98986a40755a..f086e4a781e35300ad72bf8d65b1c86845a93f1a 100644 (file)
@@ -121,6 +121,8 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
   Standard_Integer aType = aFunction->GetType();
 
   TopoDS_Shape aShape;
+  TCollection_AsciiString aWarning;
+
   BRep_Builder B;
 
   if (aType == WIRE_EDGES) {
@@ -214,7 +216,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
       Standard_NullObject::Raise
         ("Shape for face construction is neither a wire nor a closed edge");
     }
-    GEOMImpl_Block6Explorer::MakeFace(W, aCI.GetIsPlanar(), aShape);
+    aWarning = GEOMImpl_Block6Explorer::MakeFace(W, aCI.GetIsPlanar(), aShape);
     if (aShape.IsNull()) {
       Standard_ConstructionError::Raise("Face construction failed");
     }
@@ -270,7 +272,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
     // 4.a. Basic face
     TopoDS_Shape aFFace;
     TopoDS_Wire aW1 = TopoDS::Wire(aSeqClosedWires->Value(1));
-    GEOMImpl_Block6Explorer::MakeFace(aW1, aCI.GetIsPlanar(), aFFace);
+    aWarning = GEOMImpl_Block6Explorer::MakeFace(aW1, aCI.GetIsPlanar(), aFFace);
     if (aFFace.IsNull()) {
       Standard_ConstructionError::Raise("Face construction failed");
     }
@@ -914,6 +916,9 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
 
   log.SetTouched(Label());
 
+  if (!aWarning.IsEmpty())
+    Standard_Failure::Raise(aWarning.ToCString());
+
   return 1;
 }
 
index e29a6e763ea86b4d85537f5a3cac1d739a3cc2df..b3a363628074e2d68d827c2f05b48a721c97d310 100644 (file)
@@ -202,7 +202,9 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
 
   //Create the Face
   Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
-  if (!GetOperations()->IsDone() || anObject.IsNull())
+  //if (!GetOperations()->IsDone() || anObject.IsNull())
+  // enable warning status
+  if (anObject.IsNull())
     return aGEOMObject._retn();
 
   return GetObject(anObject);
@@ -236,7 +238,9 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
   // Make Face
   Handle(GEOM_Object) anObject =
     GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
-  if (!GetOperations()->IsDone() || anObject.IsNull())
+  //if (!GetOperations()->IsDone() || anObject.IsNull())
+  // enable warning status
+  if (anObject.IsNull())
     return aGEOMObject._retn();
 
   return GetObject(anObject);
index 9837739056a8346dbd7e0528427a5675988c4c3c..1e0903119d0a3f72d993afc3162ab1134365f76d 100644 (file)
@@ -1731,7 +1731,10 @@ class geompyDC(GEOM._objref_GEOM_Gen):
         def MakeFace(self,theWire, isPlanarWanted):
             # Example: see GEOM_TestAll.py
             anObj = self.ShapesOp.MakeFace(theWire, isPlanarWanted)
-            RaiseIfFailed("MakeFace", self.ShapesOp)
+            if anObj is not None and self.ShapesOp.GetErrorCode() == "MAKE_FACE_TOLERANCE_TOO_BIG":
+                print "WARNING: Tolerance of resulting face is too big."
+            else:
+                RaiseIfFailed("MakeFace", self.ShapesOp)
             return anObj
 
         ## Create a face on the given wires set.
@@ -1744,7 +1747,10 @@ class geompyDC(GEOM._objref_GEOM_Gen):
         def MakeFaceWires(self,theWires, isPlanarWanted):
             # Example: see GEOM_TestAll.py
             anObj = self.ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
-            RaiseIfFailed("MakeFaceWires", self.ShapesOp)
+            if anObj is not None and self.ShapesOp.GetErrorCode() == "MAKE_FACE_TOLERANCE_TOO_BIG":
+                print "WARNING: Tolerance of resulting face is too big."
+            else:
+                RaiseIfFailed("MakeFaceWires", self.ShapesOp)
             return anObj
 
         ## Shortcut to MakeFaceWires()