From: Ekaterina Sukhareva Date: Tue, 10 Oct 2023 14:19:22 +0000 (+0100) Subject: EDF 25230 - Large tolerance delta X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2F37774_LargeTolerance;p=modules%2Fgeom.git EDF 25230 - Large tolerance delta --- diff --git a/src/BuildGUI/BuildGUI_FaceDlg.cxx b/src/BuildGUI/BuildGUI_FaceDlg.cxx index 0cffa8223..b301df8ae 100644 --- a/src/BuildGUI/BuildGUI_FaceDlg.cxx +++ b/src/BuildGUI/BuildGUI_FaceDlg.cxx @@ -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() diff --git a/src/BuildGUI/BuildGUI_FaceDlg.h b/src/BuildGUI/BuildGUI_FaceDlg.h index d9cadafec..641676f08 100644 --- a/src/BuildGUI/BuildGUI_FaceDlg.h +++ b/src/BuildGUI/BuildGUI_FaceDlg.h @@ -84,6 +84,7 @@ private slots: void ActivateThisDialog(); void SelectionIntoArgument(); void SetEditCurrentArgument(); + void OnPlanarCheck(); void onItemClicked( QTreeWidgetItem*, int ); }; diff --git a/src/GEOMAlgo/GEOMAlgo_AlgoTools.hxx b/src/GEOMAlgo/GEOMAlgo_AlgoTools.hxx index 9244e3d2a..0253c0b53 100644 --- a/src/GEOMAlgo/GEOMAlgo_AlgoTools.hxx +++ b/src/GEOMAlgo/GEOMAlgo_AlgoTools.hxx @@ -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, diff --git a/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx index 65fbe73d9..51e1cdb87 100644 --- a/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx +++ b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx @@ -39,10 +39,18 @@ #include #include +#include +#include + #include #include #include +#include +#include +#include +#include + //======================================================================= //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; + +} \ No newline at end of file diff --git a/src/GEOMAlgo/GEOMAlgo_SurfaceTools.hxx b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.hxx index 2ff92f83e..8b09d0282 100644 --- a/src/GEOMAlgo/GEOMAlgo_SurfaceTools.hxx +++ b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.hxx @@ -42,6 +42,7 @@ #include #include +#include //======================================================================= //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 diff --git a/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx b/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx index 8c00accde..13d765af2 100644 --- a/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx +++ b/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx @@ -23,6 +23,7 @@ #include #include +#include #include @@ -43,6 +44,7 @@ #include #include #include +#include #include #include @@ -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