EDF 25230 - Large tolerance delta

This commit is contained in:
Ekaterina Sukhareva 2023-10-10 15:19:22 +01:00
parent a501322551
commit 0c6ec0b5a4
6 changed files with 121 additions and 15 deletions

View File

@ -216,12 +216,16 @@ void BuildGUI_FaceDlg::Init()
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( myGroupWire->LineEdit1, SIGNAL( returnPressed()), this, SLOT( LineEditReturnPressed() ) );
connect( myGroupWire->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( myGroupWire->CheckButton1, SIGNAL( toggled(bool) ), this, SLOT( OnPlanarCheck() ) );
connect( myGroupSurf->LineEdit1, SIGNAL( returnPressed()), this, SLOT( LineEditReturnPressed() ) );
connect( myGroupSurf->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( myGroupSurf->LineEdit2, SIGNAL( returnPressed()), this, SLOT( LineEditReturnPressed() ) );
connect( myGroupSurf->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( myGroupWireConstraints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( myGroupWireConstraints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
@ -534,6 +538,15 @@ void BuildGUI_FaceDlg::SetEditCurrentArgument()
SelectionIntoArgument();
}
//=================================================================================
// function : OnPlanarCheck()
// purpose :
//=================================================================================
void BuildGUI_FaceDlg::OnPlanarCheck()
{
erasePreview();
displayPreview( true, false, true, true, -1, -1, -1, true );
}
//=================================================================================
// function : ActivateThisDialog()

View File

@ -84,6 +84,7 @@ private slots:
void ActivateThisDialog();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void OnPlanarCheck();
void onItemClicked( QTreeWidgetItem*, int );
};

View File

@ -184,7 +184,6 @@ class GEOMAlgo_AlgoTools {
const TopoDS_Edge& aEnew,
const TopoDS_Face& aF,
const Handle(IntTools_Context)& aCtx) ;
//
Standard_EXPORT
static void FindChains(const GEOMAlgo_ListOfCoupleOfShapes& aLCS,

View File

@ -39,10 +39,18 @@
#include <gp_Ax1.hxx>
#include <gp_Vec.hxx>
#include <BRep_Tool.hxx>
#include <TopLoc_Location.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <IntSurf_Quadric.hxx>
#include <TopoDS.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Edge.hxx>
#include <Geom2d_Curve.hxx>
//=======================================================================
//function : GetState
@ -232,3 +240,75 @@ Standard_Boolean GEOMAlgo_SurfaceTools::IsConformState
}
return bRet;
}
//=======================================================================
//function : IsBelongsToSameSurface
//purpose : Returns true if all edges of theShape have a reference to
// the same surface
//=======================================================================
Standard_Boolean GEOMAlgo_SurfaceTools::IsBelongsToSameSurface
(const TopoDS_Shape& theShape)
{
Standard_Boolean aResult = false;
TopExp_Explorer ex;
ex.Init(theShape,TopAbs_EDGE);
if (!ex.More()) return aResult; // no edges ....
TopoDS_Edge anEdge = TopoDS::Edge(ex.Current());
Standard_Real f,l,ff,ll;
Handle(Geom2d_Curve) PC,aPPC;
Handle(Geom_Surface) aSurface, aCurSurface;
TopLoc_Location aLoc, aCurLoc;
Standard_Integer i = 0,j;
// iterate on the surfaces of the first edge
for(;;)
{
i++;
BRep_Tool::CurveOnSurface(anEdge,PC,aSurface,aLoc,f,l,i);
if (aSurface.IsNull())
{
break;
}
// check the other edges
for (ex.Init(theShape,TopAbs_EDGE); ex.More(); ex.Next())
{
if (!anEdge.IsSame(ex.Current()))
{
j = 0;
for(;;)
{
j++;
BRep_Tool::CurveOnSurface(TopoDS::Edge(ex.Current()),aPPC,aCurSurface,aCurLoc,ff,ll,j);
if (aCurSurface.IsNull()) {
break;
}
if ((aCurSurface == aSurface) && (aCurLoc.IsEqual(aLoc)))
{
break;
}
aCurSurface.Nullify();
}
if (aCurSurface.IsNull())
{
aSurface.Nullify();
break;
}
}
}
if (!aSurface.IsNull())
{
break;
}
}
if (!aSurface.IsNull())
{
aResult = Standard_True;
}
return aResult;
}

View File

@ -42,6 +42,7 @@
#include <gp_Pln.hxx>
#include <gp_Sphere.hxx>
#include <TopoDS_Shape.hxx>
//=======================================================================
//function : GEOMAlgo_SurfaceTools
@ -77,5 +78,9 @@ class GEOMAlgo_SurfaceTools
Standard_EXPORT
static TopAbs_State ReverseState(const TopAbs_State aSt) ;
//! Returns true if all edges of theShape have a reference to the same surface
Standard_EXPORT
static Standard_Boolean IsBelongsToSameSurface(const TopoDS_Shape& theShape) ;
};
#endif

View File

@ -23,6 +23,7 @@
#include <Standard_Stream.hxx>
#include <GEOMImpl_Block6Explorer.hxx>
#include <GEOMAlgo_SurfaceTools.hxx>
#include <ShHealOper_ShapeProcess.hxx>
@ -43,6 +44,7 @@
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_Transform.hxx>
#include <BRepBuilderAPI_FindPlane.hxx>
#include <TopAbs.hxx>
#include <TopoDS.hxx>
@ -1224,6 +1226,17 @@ TCollection_AsciiString GEOMImpl_Block6Explorer::MakeFace (const TopoDS_Wire&
const Standard_Boolean isPlanarWanted,
TopoDS_Shape& theResult)
{
TCollection_AsciiString aWarning;
BRepBuilderAPI_FindPlane aFindPlane(theWire);
if (aFindPlane.Found())
{
BRepBuilderAPI_MakeFace MK (theWire, isPlanarWanted);
if (MK.IsDone()) {
theResult = MK.Shape();
return aWarning;
}
}
if (!isPlanarWanted)
return MakeAnyFace(theWire, theResult);
@ -1232,14 +1245,6 @@ TCollection_AsciiString GEOMImpl_Block6Explorer::MakeFace (const TopoDS_Wire&
// If required tolerance increase will be
// higher than PLANAR_FACE_MAX_TOLERANCE,
// we will try to build a non-planar face.
TCollection_AsciiString aWarning;
BRepBuilderAPI_MakeFace MK (theWire, isPlanarWanted);
if (MK.IsDone()) {
theResult = MK.Shape();
return aWarning;
}
// try to update wire tolerances to build a planar face
// Find a deviation
@ -1300,12 +1305,15 @@ TCollection_AsciiString GEOMImpl_Block6Explorer::MakeAnyFace (const TopoDS_Wire&
TopoDS_Shape& theResult)
{
TCollection_AsciiString aWarning;
// try to build a face on any surface under the edges of the wire
BRepBuilderAPI_MakeFace MK (theWire, Standard_False);
if (MK.IsDone()) {
theResult = MK.Shape();
return aWarning;
//check if all edges already belong to the some surface
if(GEOMAlgo_SurfaceTools::IsBelongsToSameSurface(theWire))
{
BRepBuilderAPI_MakeFace MK (theWire, false);
if (MK.IsDone()) {
theResult = MK.Shape();
return aWarning;
}
}
// try to construct filling surface