// 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
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;
}
-
<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>
// 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>
#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;
//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.
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;
}
}
}
BRepBuilderAPI_MakeFace MK (theWire, isPlanarWanted);
if (MK.IsDone()) {
theResult = MK.Shape();
- return;
+ return aWarning;
}
}
if (!aFS.Found()) {
aFS.Init(theWire, aToleranceReached, isPlanarWanted);
- if (!aFS.Found()) return;
+ if (!aFS.Found()) return aWarning;
aToleranceReached = aFS.ToleranceReached();
aTol = aFS.Tolerance();
}
// 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;
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
aBMF.Init(theWire, isPlanarWanted, Standard_True);
if (aBMF.Error() == BRepLib_FaceDone) {
theResult = aBMF.Shape();
- return;
+ return aWarning;
}
#endif
}
+
+ return aWarning;
}
// 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
#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
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 ----------
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepBndLib.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <TopAbs.hxx>
aCI.SetIsPlanar(isPlanarWanted);
//Compute the Face value
+ Standard_Boolean isWarning = Standard_False;
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
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;
}
aCI.SetIsPlanar(isPlanarWanted);
//Compute the shape
+ Standard_Boolean isWarning = Standard_False;
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
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
}
pd << "], " << (int)isPlanarWanted << ")";
- SetErrorCode(OK);
+ // to provide warning
+ if (!isWarning) SetErrorCode(OK);
return aShape;
}
Standard_Integer aType = aFunction->GetType();
TopoDS_Shape aShape;
+ TCollection_AsciiString aWarning;
+
BRep_Builder B;
if (aType == WIRE_EDGES) {
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");
}
// 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");
}
log.SetTouched(Label());
+ if (!aWarning.IsEmpty())
+ Standard_Failure::Raise(aWarning.ToCString());
+
return 1;
}
//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);
// 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);
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.
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()