From 936b6e5f887f1374cac0dd0712a167918ddc535f Mon Sep 17 00:00:00 2001 From: jgv Date: Tue, 8 Aug 2017 20:57:12 +0300 Subject: [PATCH] First version (without tangential neighbors) --- src/BRepAlgo/BRepAlgo_Loop.cxx | 10 +- src/BRepOffset/BRepOffset_Inter2d.cxx | 298 ++++++++++++++------- src/BRepOffset/BRepOffset_Inter2d.hxx | 3 + src/BRepOffset/BRepOffset_Inter3d.cxx | 116 ++++++-- src/BRepOffset/BRepOffset_Inter3d.hxx | 9 +- src/BRepOffset/BRepOffset_MakeOffset.cxx | 79 +++++- src/BRepOffset/BRepOffset_MakeOffset.hxx | 6 + src/BRepOffset/BRepOffset_MakeOffset_1.cxx | 7 +- src/BRepOffset/BRepOffset_Offset.cxx | 49 +++- src/BRepOffset/BRepOffset_Offset.hxx | 83 ++++-- src/BRepOffset/BRepOffset_Tool.cxx | 37 ++- src/BRepOffset/BRepOffset_Tool.hxx | 13 +- src/BRepTest/BRepTest_FeatureCommands.cxx | 25 ++ src/BiTgte/BiTgte_Blend.cxx | 5 +- 14 files changed, 588 insertions(+), 152 deletions(-) diff --git a/src/BRepAlgo/BRepAlgo_Loop.cxx b/src/BRepAlgo/BRepAlgo_Loop.cxx index 9510e4cd38..01a01f7a44 100644 --- a/src/BRepAlgo/BRepAlgo_Loop.cxx +++ b/src/BRepAlgo/BRepAlgo_Loop.cxx @@ -264,10 +264,10 @@ static void RemovePendingEdges(TopTools_IndexedDataMapOfShapeListOfShape& MVE) //purpose : //======================================================================= -static Standard_Boolean SamePnt2d(TopoDS_Vertex V, - TopoDS_Edge& E1, - TopoDS_Edge& E2, - TopoDS_Face& F) +static Standard_Boolean SamePnt2d(const TopoDS_Vertex& V, + const TopoDS_Edge& E1, + const TopoDS_Edge& E2, + const TopoDS_Face& F) { Standard_Real f1,f2,l1,l2; gp_Pnt2d P1,P2; @@ -649,6 +649,7 @@ void BRepAlgo_Loop::Perform() //-------------------------------------------------- // Add new wire to the set of wires //------------------------------------------------ + /* Standard_Real Tol = 0.001; //5.e-05; //5.e-07; TopExp_Explorer explo( NW, TopAbs_VERTEX ); for (; explo.More(); explo.Next()) @@ -665,6 +666,7 @@ void BRepAlgo_Loop::Perform() TE->Tolerance( Tol ); TE->Modified( Standard_True ); } + */ if (VF.IsSame(CV) && SamePnt2d(VF,EF,CE,myFace)) { diff --git a/src/BRepOffset/BRepOffset_Inter2d.cxx b/src/BRepOffset/BRepOffset_Inter2d.cxx index 778e7d97bd..3a7474e51c 100644 --- a/src/BRepOffset/BRepOffset_Inter2d.cxx +++ b/src/BRepOffset/BRepOffset_Inter2d.cxx @@ -78,6 +78,7 @@ #include #include #include +#include #include #ifdef DRAW @@ -496,6 +497,9 @@ static void RefEdgeInter(const TopoDS_Face& F, const BRepAdaptor_Surface& BAsurf, const TopoDS_Edge& E1, const TopoDS_Edge& E2, + const TopoDS_Vertex& Vref, + const Standard_Boolean IsConstantE1, + const Standard_Boolean IsConstantE2, const Handle(BRepAlgo_AsDes)& AsDes, Standard_Real Tol, Standard_Boolean WithOri, @@ -545,125 +549,170 @@ static void RefEdgeInter(const TopoDS_Face& F, Standard_Boolean WithDegen = BRep_Tool::Degenerated(E1) || BRep_Tool::Degenerated(E2); if (WithDegen) + { + Standard_Integer ideg = (BRep_Tool::Degenerated(E1))? 1 : 2; + TopoDS_Iterator iter( EI[ideg] ); + if (iter.More()) { - Standard_Integer ideg = (BRep_Tool::Degenerated(E1))? 1 : 2; - TopoDS_Iterator iter( EI[ideg] ); - if (iter.More()) - { - const TopoDS_Vertex& vdeg = TopoDS::Vertex(iter.Value()); - DegPoint = BRep_Tool::Pnt(vdeg); - } - else - { - BRepAdaptor_Curve CEdeg( EI[ideg], F ); - DegPoint = CEdeg.Value( CEdeg.FirstParameter() ); - } + const TopoDS_Vertex& vdeg = TopoDS::Vertex(iter.Value()); + DegPoint = BRep_Tool::Pnt(vdeg); + } + else + { + BRepAdaptor_Curve CEdeg( EI[ideg], F ); + DegPoint = CEdeg.Value( CEdeg.FirstParameter() ); } + } // + Handle(Geom2d_Curve) pcurve1 = BRep_Tool::CurveOnSurface(E1, F, f[1], l[1]); Handle(Geom2d_Curve) pcurve2 = BRep_Tool::CurveOnSurface(E2, F, f[2], l[2]); Geom2dAdaptor_Curve GAC1(pcurve1, f[1], l[1]); Geom2dAdaptor_Curve GAC2(pcurve2, f[2], l[2]); - Geom2dInt_GInter Inter2d( GAC1, GAC2, TolDub, TolDub ); + // - if (!Inter2d.IsDone() || !Inter2d.NbPoints()) { - theCoincide = (Inter2d.NbSegments() && - (GAC1.GetType() == GeomAbs_Line) && - (GAC2.GetType() == GeomAbs_Line)); - return; + if (!Vref.IsNull()) + { + gp_Pnt P3d = BRep_Tool::Pnt(Vref); + ResPoints.Append( P3d ); + Standard_Real ParOnFirst, ParOnSecond; + if (IsConstantE1 && IsConstantE2) + { + ParOnFirst = BRep_Tool::Parameter(Vref, E1); + ParOnSecond = BRep_Tool::Parameter(Vref, E2); + } + else if (IsConstantE1) + { + ParOnFirst = BRep_Tool::Parameter(Vref, E1); + gp_Pnt2d aPnt2d = BRep_Tool::Parameters(Vref, F); + //Handle(Geom2d_Curve) pcurve2 = BRep_Tool::CurveOnSurface(E2, F, f[2], l[2]); + //Geom2dAdaptor_Curve GAC2(pcurve2, f[2], l[2]); + Extrema_ExtPC2d Projector(aPnt2d, GAC2); + Standard_Integer imin = 1; + for (Standard_Integer i = 2; i <= Projector.NbExt(); i++) + if (Projector.SquareDistance(i) < Projector.SquareDistance(imin)) + imin = i; + ParOnSecond = Projector.Point(imin).Parameter(); + } + else + { + ParOnSecond = BRep_Tool::Parameter(Vref, E2); + gp_Pnt2d aPnt2d = BRep_Tool::Parameters(Vref, F); + //Handle(Geom2d_Curve) pcurve1 = BRep_Tool::CurveOnSurface(E1, F, f[1], l[1]); + //Geom2dAdaptor_Curve GAC1(pcurve1, f[1], l[1]); + Extrema_ExtPC2d Projector(aPnt2d, GAC1); + Standard_Integer imin = 1; + for (Standard_Integer i = 2; i <= Projector.NbExt(); i++) + if (Projector.SquareDistance(i) < Projector.SquareDistance(imin)) + imin = i; + ParOnFirst = Projector.Point(imin).Parameter(); + } + ResParamsOnE1.Append( ParOnFirst ); + ResParamsOnE2.Append( ParOnSecond ); } - // - for (i = 1; i <= Inter2d.NbPoints(); i++) + else + { + Geom2dInt_GInter Inter2d( GAC1, GAC2, TolDub, TolDub ); + // + if (!Inter2d.IsDone() || !Inter2d.NbPoints()) { + theCoincide = (Inter2d.NbSegments() && + (GAC1.GetType() == GeomAbs_Line) && + (GAC2.GetType() == GeomAbs_Line)); + return; + } + // + for (i = 1; i <= Inter2d.NbPoints(); i++) { gp_Pnt P3d; if (WithDegen) P3d = DegPoint; else - { - gp_Pnt2d P2d = Inter2d.Point(i).Value(); - P3d = BAsurf.Value( P2d.X(), P2d.Y() ); - } + { + gp_Pnt2d P2d = Inter2d.Point(i).Value(); + P3d = BAsurf.Value( P2d.X(), P2d.Y() ); + } ResPoints.Append( P3d ); ResParamsOnE1.Append( Inter2d.Point(i).ParamOnFirst() ); ResParamsOnE2.Append( Inter2d.Point(i).ParamOnSecond() ); } + } //else (without Vref) for (i = 1; i <= ResPoints.Length(); i++) + { + Standard_Real aT1 = ResParamsOnE1(i); //ponc1.Parameter(); + Standard_Real aT2 = ResParamsOnE2(i); //ponc2.Parameter(); + if (Precision::IsInfinite(aT1) || Precision::IsInfinite(aT2)) { - Standard_Real aT1 = ResParamsOnE1(i); //ponc1.Parameter(); - Standard_Real aT2 = ResParamsOnE2(i); //ponc2.Parameter(); - if (Precision::IsInfinite(aT1) || Precision::IsInfinite(aT2)) - { #ifdef OCCT_DEBUG - cout << "Inter2d : Solution rejected due to infinite parameter"< l[1]+Tol) - { - cout << "out of limit"<