mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-26 21:50:33 +05:00
Mantis issue 0021432: EDF GEOM: Faces with huge tolerance can be built in GEOM
This commit is contained in:
parent
696a8cf635
commit
2d0d426c67
@ -18,12 +18,11 @@
|
||||
// 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>
|
||||
@ -33,11 +32,14 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -18,11 +18,10 @@
|
||||
// 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 ----------
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user