From eff3eff916f16bbae5a4b1de52bc6a64dfb98848 Mon Sep 17 00:00:00 2001 From: jgv Date: Fri, 20 Sep 2019 13:52:10 +0300 Subject: [PATCH] 0030940: BRepFilletAPI_MakeFillet algorithm fails on closed shell 1. Add check of configuration of corner in the end of spine. 2. Correct treatment of "smooth corners". --- dox/dev_guides/upgrade/upgrade.md | 6 + src/BRepFill/BRepFill_Evolved.cxx | 31 +--- src/BRepOffset/BRepOffset_Analyse.cxx | 175 ++---------------- src/BRepOffset/BRepOffset_Analyse.hxx | 32 +++- src/BRepOffset/BRepOffset_Inter3d.cxx | 14 +- src/BRepOffset/BRepOffset_Interval.cxx | 2 +- src/BRepOffset/BRepOffset_Interval.hxx | 12 +- src/BRepOffset/BRepOffset_Interval.lxx | 4 +- src/BRepOffset/BRepOffset_MakeOffset.cxx | 64 +++---- src/BRepOffset/BRepOffset_Tool.cxx | 24 +-- src/BRepOffset/BRepOffset_Tool.hxx | 4 - src/BRepOffset/FILES | 1 - src/BRepTest/BRepTest_CheckCommands.cxx | 16 ++ src/BRepTools/BRepTools.cxx | 17 ++ src/BRepTools/BRepTools.hxx | 4 + src/BiTgte/BiTgte_Blend.cxx | 14 +- src/ChFi3d/ChFi3d.cxx | 145 +++++++++++++++ src/ChFi3d/ChFi3d.hxx | 8 + src/ChFi3d/ChFi3d_Builder_0.cxx | 6 +- src/ChFi3d/ChFi3d_Builder_1.cxx | 88 +++++---- src/ChFi3d/ChFi3d_FilBuilder.cxx | 18 +- src/ChFiDS/ChFiDS_Spine.hxx | 8 + src/ChFiDS/ChFiDS_Spine.lxx | 21 +++ .../ChFiDS_TypeOfConcavity.hxx} | 18 +- src/ChFiDS/FILES | 1 + src/TKFillet/EXTERNLIB | 1 + tests/bugs/modalg_7/bug30940_1 | 23 +++ tests/bugs/modalg_7/bug30940_2 | 25 +++ tests/bugs/modalg_7/bug30940_3 | 25 +++ tests/bugs/modalg_7/bug30940_4 | 25 +++ tests/bugs/modalg_7/bug30940_5 | 25 +++ tests/bugs/modalg_7/bug30940_6 | 25 +++ tests/bugs/modalg_7/bug31030 | 23 +++ 33 files changed, 586 insertions(+), 319 deletions(-) rename src/{BRepOffset/BRepOffset_Type.hxx => ChFiDS/ChFiDS_TypeOfConcavity.hxx} (75%) create mode 100644 tests/bugs/modalg_7/bug30940_1 create mode 100644 tests/bugs/modalg_7/bug30940_2 create mode 100644 tests/bugs/modalg_7/bug30940_3 create mode 100644 tests/bugs/modalg_7/bug30940_4 create mode 100644 tests/bugs/modalg_7/bug30940_5 create mode 100644 tests/bugs/modalg_7/bug30940_6 create mode 100644 tests/bugs/modalg_7/bug31030 diff --git a/dox/dev_guides/upgrade/upgrade.md b/dox/dev_guides/upgrade/upgrade.md index 82cef60224..bbb5eb1ec4 100644 --- a/dox/dev_guides/upgrade/upgrade.md +++ b/dox/dev_guides/upgrade/upgrade.md @@ -1857,3 +1857,9 @@ The following API changes have been made: @subsection upgrade_740_stdnamespace Standard_Stream.hxx no more has "using std::" statements *Standard_Stream.hxx* header, commonly included by other OCCT header files, does no more add entities from *std namespace* related to streams (like *std::cout*, *std::istream* and others) into global namespace. The application code relying on this matter should be updated to either specify std namespace explicitly (like std::cout) or add "using std::" statements locally. + +@section upgrade_occt750 Upgrade to OCCT 7.5.0 + +@subsection upgrade_750_rename Renaming of types + +Enumeration BRepOffset_Type is renamed to ChFiDS_TypeOfConcavity. diff --git a/src/BRepFill/BRepFill_Evolved.cxx b/src/BRepFill/BRepFill_Evolved.cxx index dadd060d34..914b8b94fe 100644 --- a/src/BRepFill/BRepFill_Evolved.cxx +++ b/src/BRepFill/BRepFill_Evolved.cxx @@ -149,9 +149,6 @@ static void TrimEdge (const TopoDS_Edge& Edge, TColStd_SequenceOfReal& ThePar, TopTools_SequenceOfShape& S); -static TopAbs_Orientation OriEdgeInFace (const TopoDS_Edge& E, - const TopoDS_Face& F); - static Standard_Integer PosOnFace (Standard_Real d1, Standard_Real d2, Standard_Real d3); @@ -986,8 +983,8 @@ void BRepFill_Evolved::ElementaryPerform (const TopoDS_Face& Sp, // skin => same orientation E[0] , inverted orientation E[2] // if contreskin it is inverted. //-------------------------------------------------------------- - E[0].Orientation(OriEdgeInFace(E[0],F[0])); - E[2].Orientation(OriEdgeInFace(E[2],F[1])); + E[0].Orientation(BRepTools::OriEdgeInFace(E[0],F[0])); + E[2].Orientation(BRepTools::OriEdgeInFace(E[2],F[1])); if (DistanceToOZ(VF) < DistanceToOZ(VL) ) { // Skin @@ -1199,14 +1196,14 @@ void BRepFill_Evolved::ElementaryPerform (const TopoDS_Face& Sp, TopTools_ListIteratorOfListOfShape itl; const TopTools_ListOfShape& LF = myMap(CurrentSpine)(VCF); - TopAbs_Orientation Ori = OriEdgeInFace(TopoDS::Edge(LF.First()), + TopAbs_Orientation Ori = BRepTools::OriEdgeInFace(TopoDS::Edge(LF.First()), CurrentFace); for (itl.Initialize(LF), itl.Next(); itl.More(); itl.Next()) { TopoDS_Edge RE = TopoDS::Edge(itl.Value()); MapBis(CurrentFace).Append(RE.Oriented(Ori)); } const TopTools_ListOfShape& LL = myMap(CurrentSpine)(VCL); - Ori = OriEdgeInFace(TopoDS::Edge(LL.First()),CurrentFace); + Ori = BRepTools::OriEdgeInFace(TopoDS::Edge(LL.First()),CurrentFace); for (itl.Initialize(LL), itl.Next() ; itl.More(); itl.Next()) { TopoDS_Edge RE = TopoDS::Edge(itl.Value()); MapBis(CurrentFace).Append(RE.Oriented(Ori)); @@ -2920,26 +2917,6 @@ static TopAbs_Orientation Relative (const TopoDS_Wire& W1, return TopAbs_REVERSED; } -//======================================================================= -//function : OriEdgeInFace -//purpose : -//======================================================================= - -TopAbs_Orientation OriEdgeInFace (const TopoDS_Edge& E, - const TopoDS_Face& F ) - -{ - TopExp_Explorer Exp(F.Oriented(TopAbs_FORWARD),TopAbs_EDGE); - - for (; Exp.More() ;Exp.Next()) { - if (Exp.Current().IsSame(E)) { - return Exp.Current().Orientation(); - } - } - throw Standard_ConstructionError("BRepFill_Evolved::OriEdgeInFace"); -} - - //======================================================================= //function : IsOnFace diff --git a/src/BRepOffset/BRepOffset_Analyse.cxx b/src/BRepOffset/BRepOffset_Analyse.cxx index 4e99763291..79d968d694 100644 --- a/src/BRepOffset/BRepOffset_Analyse.cxx +++ b/src/BRepOffset/BRepOffset_Analyse.cxx @@ -44,16 +44,8 @@ #include #include #include +#include -// -static void Correct2dPoint(const TopoDS_Face& theF, gp_Pnt2d& theP2d); -// -static BRepOffset_Type DefineConnectType(const TopoDS_Edge& E, - const TopoDS_Face& F1, - const TopoDS_Face& F2, - const Standard_Real SinTol, - const Standard_Boolean CorrectPoint); -// static void CorrectOrientationOfTangent(gp_Vec& TangVec, const TopoDS_Vertex& aVertex, const TopoDS_Edge& anEdge) @@ -105,16 +97,17 @@ static void EdgeAnalyse(const TopoDS_Edge& E, // Tangent if the regularity is at least G1. if (BRep_Tool::HasContinuity(E,F1,F2)) { if (BRep_Tool::Continuity(E,F1,F2) > GeomAbs_C0) { - I.Type(BRepOffset_Tangent); + I.Type(ChFiDS_Tangential); LI.Append(I); return; } } // - BRepOffset_Type aType = DefineConnectType(E, F1, F2, SinTol, Standard_False); - if(aType != BRepOffset_Tangent) + ChFiDS_TypeOfConcavity aType = ChFi3d::DefineConnectType(E, F1, F2, + SinTol, Standard_False); + if(aType != ChFiDS_Tangential) { - aType = DefineConnectType(E, F1, F2, SinTol, Standard_True); + aType = ChFi3d::DefineConnectType(E, F1, F2, SinTol, Standard_True); } I.Type(aType); LI.Append(I); @@ -181,10 +174,10 @@ void BRepOffset_Analyse::Perform (const TopoDS_Shape& S, Standard_Real U1,U2; const TopoDS_Face& F = TopoDS::Face(L.First()); BRep_Tool::Range(E,F,U1,U2); - BRepOffset_Interval Inter(U1,U2,BRepOffset_Other); + BRepOffset_Interval Inter(U1,U2,ChFiDS_Other); if (! BRepTools::IsReallyClosed(E,F)) { - Inter.Type(BRepOffset_FreeBoundary); + Inter.Type(ChFiDS_FreeBound); } mapEdgeType(E).Append(Inter); } @@ -233,7 +226,7 @@ const //======================================================================= void BRepOffset_Analyse::Edges(const TopoDS_Vertex& V, - const BRepOffset_Type T, + const ChFiDS_TypeOfConcavity T, TopTools_ListOfShape& LE) const { @@ -263,7 +256,7 @@ const //======================================================================= void BRepOffset_Analyse::Edges(const TopoDS_Face& F, - const BRepOffset_Type T, + const ChFiDS_TypeOfConcavity T, TopTools_ListOfShape& LE) const { @@ -350,8 +343,8 @@ const TopTools_ListOfShape& BRepOffset_Analyse::Ancestors //purpose : //======================================================================= -void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List, - const BRepOffset_Type T ) const +void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List, + const ChFiDS_TypeOfConcavity T ) const { List.Clear(); BRep_Builder B; @@ -377,9 +370,9 @@ void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List, //purpose : //======================================================================= -void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List, - const BRepOffset_Type T1, - const BRepOffset_Type T2) const +void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List, + const ChFiDS_TypeOfConcavity T1, + const ChFiDS_TypeOfConcavity T2) const { List.Clear(); BRep_Builder B; @@ -409,7 +402,7 @@ void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List, void BRepOffset_Analyse::AddFaces (const TopoDS_Face& Face, TopoDS_Compound& Co, TopTools_MapOfShape& Map, - const BRepOffset_Type T) const + const ChFiDS_TypeOfConcavity T) const { BRep_Builder B; TopExp_Explorer exp(Face,TopAbs_EDGE); @@ -439,8 +432,8 @@ void BRepOffset_Analyse::AddFaces (const TopoDS_Face& Face, void BRepOffset_Analyse::AddFaces (const TopoDS_Face& Face, TopoDS_Compound& Co, TopTools_MapOfShape& Map, - const BRepOffset_Type T1, - const BRepOffset_Type T2) const + const ChFiDS_TypeOfConcavity T1, + const ChFiDS_TypeOfConcavity T2) const { BRep_Builder B; TopExp_Explorer exp(Face,TopAbs_EDGE); @@ -464,135 +457,3 @@ void BRepOffset_Analyse::AddFaces (const TopoDS_Face& Face, } } -//======================================================================= -//function : Correct2dPoint -//purpose : -//======================================================================= -void Correct2dPoint(const TopoDS_Face& theF, gp_Pnt2d& theP2d) -{ - BRepAdaptor_Surface aBAS(theF, Standard_False); - if (aBAS.GetType() < GeomAbs_BezierSurface) { - return; - } - // - const Standard_Real coeff = 0.01; - Standard_Real eps; - Standard_Real u1, u2, v1, v2; - // - aBAS.Initialize(theF, Standard_True); - u1 = aBAS.FirstUParameter(); - u2 = aBAS.LastUParameter(); - v1 = aBAS.FirstVParameter(); - v2 = aBAS.LastVParameter(); - if (!(Precision::IsInfinite(u1) || Precision::IsInfinite(u2))) - { - eps = Max(coeff*(u2 - u1), Precision::PConfusion()); - if (Abs(theP2d.X() - u1) < eps) - { - theP2d.SetX(u1 + eps); - } - if (Abs(theP2d.X() - u2) < eps) - { - theP2d.SetX(u2 - eps); - } - } - if (!(Precision::IsInfinite(v1) || Precision::IsInfinite(v2))) - { - eps = Max(coeff*(v2 - v1), Precision::PConfusion()); - if (Abs(theP2d.Y() - v1) < eps) - { - theP2d.SetY(v1 + eps); - } - if (Abs(theP2d.Y() - v2) < eps) - { - theP2d.SetY(v2 - eps); - } - } -} - -//======================================================================= -//function : DefineConnectType -//purpose : -//======================================================================= -BRepOffset_Type DefineConnectType(const TopoDS_Edge& E, - const TopoDS_Face& F1, - const TopoDS_Face& F2, - const Standard_Real SinTol, - const Standard_Boolean CorrectPoint) -{ - TopLoc_Location L; - Standard_Real f,l; - - const Handle(Geom_Surface)& S1 = BRep_Tool::Surface(F1); - const Handle(Geom_Surface)& S2 = BRep_Tool::Surface(F2); - // - Handle (Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E,F1,f,l); - Handle (Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E,F2,f,l); - - BRepAdaptor_Curve C(E); - f = C.FirstParameter(); - l = C.LastParameter(); -// - Standard_Real ParOnC = 0.5*(f+l); - gp_Vec T1 = C.DN(ParOnC,1).Transformed(L.Transformation()); - if (T1.SquareMagnitude() > gp::Resolution()) { - T1.Normalize(); - } - - if (BRepOffset_Tool::OriEdgeInFace(E,F1) == TopAbs_REVERSED) { - T1.Reverse(); - } - if (F1.Orientation() == TopAbs_REVERSED) T1.Reverse(); - - gp_Pnt2d P = C1->Value(ParOnC); - gp_Pnt P3; - gp_Vec D1U,D1V; - - if(CorrectPoint) - Correct2dPoint(F1, P); - // - S1->D1(P.X(),P.Y(),P3,D1U,D1V); - gp_Vec DN1(D1U^D1V); - if (F1.Orientation() == TopAbs_REVERSED) DN1.Reverse(); - - P = C2->Value(ParOnC); - if(CorrectPoint) - Correct2dPoint(F2, P); - S2->D1(P.X(),P.Y(),P3,D1U,D1V); - gp_Vec DN2(D1U^D1V); - if (F2.Orientation() == TopAbs_REVERSED) DN2.Reverse(); - - DN1.Normalize(); - DN2.Normalize(); - - gp_Vec ProVec = DN1^DN2; - Standard_Real NormProVec = ProVec.Magnitude(); - - if (Abs(NormProVec) < SinTol) { - // plane - if (DN1.Dot(DN2) > 0) { - //Tangent - return BRepOffset_Tangent; - } - else { - //Mixed not finished! -#ifdef OCCT_DEBUG - std::cout <<" faces locally mixed"< gp::Resolution()) - ProVec.Normalize(); - Standard_Real Prod = T1.Dot(DN1^DN2); - if (Prod > 0.) { - // - return BRepOffset_Convex; - } - else { - //reenters - return BRepOffset_Concave; - } - } -} diff --git a/src/BRepOffset/BRepOffset_Analyse.hxx b/src/BRepOffset/BRepOffset_Analyse.hxx index b050ef62aa..1ab69dcf9f 100644 --- a/src/BRepOffset/BRepOffset_Analyse.hxx +++ b/src/BRepOffset/BRepOffset_Analyse.hxx @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include class TopoDS_Shape; @@ -60,15 +60,21 @@ public: //! Stores in all the edges of Type //! on the vertex . - Standard_EXPORT void Edges (const TopoDS_Vertex& V, const BRepOffset_Type T, TopTools_ListOfShape& L) const; + Standard_EXPORT void Edges (const TopoDS_Vertex& V, + const ChFiDS_TypeOfConcavity T, + TopTools_ListOfShape& L) const; //! Stores in all the edges of Type //! on the face . - Standard_EXPORT void Edges (const TopoDS_Face& F, const BRepOffset_Type T, TopTools_ListOfShape& L) const; + Standard_EXPORT void Edges (const TopoDS_Face& F, + const ChFiDS_TypeOfConcavity T, + TopTools_ListOfShape& L) const; //! set in all the Edges of which are //! tangent to at the vertex . - Standard_EXPORT void TangentEdges (const TopoDS_Edge& Edge, const TopoDS_Vertex& Vertex, TopTools_ListOfShape& Edges) const; + Standard_EXPORT void TangentEdges (const TopoDS_Edge& Edge, + const TopoDS_Vertex& Vertex, + TopTools_ListOfShape& Edges) const; Standard_EXPORT Standard_Boolean HasAncestor (const TopoDS_Shape& S) const; @@ -76,19 +82,29 @@ public: //! Explode in compounds of faces where //! all the connex edges are of type - Standard_EXPORT void Explode (TopTools_ListOfShape& L, const BRepOffset_Type Type) const; + Standard_EXPORT void Explode (TopTools_ListOfShape& L, + const ChFiDS_TypeOfConcavity Type) const; //! Explode in compounds of faces where //! all the connex edges are of type or - Standard_EXPORT void Explode (TopTools_ListOfShape& L, const BRepOffset_Type Type1, const BRepOffset_Type Type2) const; + Standard_EXPORT void Explode (TopTools_ListOfShape& L, + const ChFiDS_TypeOfConcavity Type1, + const ChFiDS_TypeOfConcavity Type2) const; //! Add in the faces of the shell containing //! where all the connex edges are of type . - Standard_EXPORT void AddFaces (const TopoDS_Face& Face, TopoDS_Compound& Co, TopTools_MapOfShape& Map, const BRepOffset_Type Type) const; + Standard_EXPORT void AddFaces (const TopoDS_Face& Face, + TopoDS_Compound& Co, + TopTools_MapOfShape& Map, + const ChFiDS_TypeOfConcavity Type) const; //! Add in the faces of the shell containing //! where all the connex edges are of type or . - Standard_EXPORT void AddFaces (const TopoDS_Face& Face, TopoDS_Compound& Co, TopTools_MapOfShape& Map, const BRepOffset_Type Type1, const BRepOffset_Type Type2) const; + Standard_EXPORT void AddFaces (const TopoDS_Face& Face, + TopoDS_Compound& Co, + TopTools_MapOfShape& Map, + const ChFiDS_TypeOfConcavity Type1, + const ChFiDS_TypeOfConcavity Type2) const; diff --git a/src/BRepOffset/BRepOffset_Inter3d.cxx b/src/BRepOffset/BRepOffset_Inter3d.cxx index 0019a4f013..2441b581ad 100644 --- a/src/BRepOffset/BRepOffset_Inter3d.cxx +++ b/src/BRepOffset/BRepOffset_Inter3d.cxx @@ -253,8 +253,8 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces const BRepOffset_Analyse& Analyse, const BRepAlgo_Image& InitOffsetFace) { - BRepOffset_Type OT = BRepOffset_Concave; - if (mySide == TopAbs_OUT) OT = BRepOffset_Convex; + ChFiDS_TypeOfConcavity OT = ChFiDS_Concave; + if (mySide == TopAbs_OUT) OT = ChFiDS_Convex; TopExp_Explorer Exp(ShapeInit,TopAbs_EDGE); TopTools_ListOfShape LInt1,LInt2; TopoDS_Face F1,F2; @@ -349,7 +349,7 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces // to the tube or if E2 is not a tangent edge. //------------------------------------------------------- const BRepOffset_ListOfInterval& L = Analyse.Type(E2); - if (!L.IsEmpty() && L.First().Type() == BRepOffset_Tangent) { + if (!L.IsEmpty() && L.First().Type() == ChFiDS_Tangential) { continue; } const TopTools_ListOfShape& AncE2 = Analyse.Ancestors(E2); @@ -511,13 +511,13 @@ void BRepOffset_Inter3d::ConnexIntByInt continue; } // - BRepOffset_Type OT = L.First().Type(); - if (OT != BRepOffset_Convex && OT != BRepOffset_Concave) { + ChFiDS_TypeOfConcavity OT = L.First().Type(); + if (OT != ChFiDS_Convex && OT != ChFiDS_Concave) { continue; } // - if (OT == BRepOffset_Concave) CurSide = TopAbs_IN; - else CurSide = TopAbs_OUT; + if (OT == ChFiDS_Concave) CurSide = TopAbs_IN; + else CurSide = TopAbs_OUT; //----------------------------------------------------------- // edge is of the proper type, return adjacent faces. //----------------------------------------------------------- diff --git a/src/BRepOffset/BRepOffset_Interval.cxx b/src/BRepOffset/BRepOffset_Interval.cxx index ae909a4715..2f31b72c7a 100644 --- a/src/BRepOffset/BRepOffset_Interval.cxx +++ b/src/BRepOffset/BRepOffset_Interval.cxx @@ -33,7 +33,7 @@ BRepOffset_Interval::BRepOffset_Interval() BRepOffset_Interval::BRepOffset_Interval(const Standard_Real U1, const Standard_Real U2, - const BRepOffset_Type Type): + const ChFiDS_TypeOfConcavity Type): f(U1), l(U2), type(Type) diff --git a/src/BRepOffset/BRepOffset_Interval.hxx b/src/BRepOffset/BRepOffset_Interval.hxx index d2d41f1c2e..47c781d132 100644 --- a/src/BRepOffset/BRepOffset_Interval.hxx +++ b/src/BRepOffset/BRepOffset_Interval.hxx @@ -22,7 +22,7 @@ #include #include -#include +#include @@ -35,19 +35,21 @@ public: Standard_EXPORT BRepOffset_Interval(); - Standard_EXPORT BRepOffset_Interval(const Standard_Real U1, const Standard_Real U2, const BRepOffset_Type Type); + Standard_EXPORT BRepOffset_Interval(const Standard_Real U1, + const Standard_Real U2, + const ChFiDS_TypeOfConcavity Type); void First (const Standard_Real U); void Last (const Standard_Real U); - void Type (const BRepOffset_Type T); + void Type (const ChFiDS_TypeOfConcavity T); Standard_Real First() const; Standard_Real Last() const; - BRepOffset_Type Type() const; + ChFiDS_TypeOfConcavity Type() const; @@ -64,7 +66,7 @@ private: Standard_Real f; Standard_Real l; - BRepOffset_Type type; + ChFiDS_TypeOfConcavity type; }; diff --git a/src/BRepOffset/BRepOffset_Interval.lxx b/src/BRepOffset/BRepOffset_Interval.lxx index 150a35f43a..28770cb084 100644 --- a/src/BRepOffset/BRepOffset_Interval.lxx +++ b/src/BRepOffset/BRepOffset_Interval.lxx @@ -41,7 +41,7 @@ inline void BRepOffset_Interval::Last(const Standard_Real U) //purpose : //======================================================================= -inline void BRepOffset_Interval::Type(const BRepOffset_Type T) +inline void BRepOffset_Interval::Type(const ChFiDS_TypeOfConcavity T) { type = T; } @@ -74,7 +74,7 @@ inline Standard_Real BRepOffset_Interval::Last() const //purpose : //======================================================================= -inline BRepOffset_Type BRepOffset_Interval::Type() const +inline ChFiDS_TypeOfConcavity BRepOffset_Interval::Type() const { return type; } diff --git a/src/BRepOffset/BRepOffset_MakeOffset.cxx b/src/BRepOffset/BRepOffset_MakeOffset.cxx index 834e6352ba..59204cfe49 100644 --- a/src/BRepOffset/BRepOffset_MakeOffset.cxx +++ b/src/BRepOffset/BRepOffset_MakeOffset.cxx @@ -509,26 +509,26 @@ static void FillContours(const TopoDS_Shape& aShape, BRepTools_WireExplorer Wexp; for (; Explo.More(); Explo.Next()) + { + TopoDS_Face aFace = TopoDS::Face(Explo.Current()); + TopoDS_Iterator itf(aFace); + for (; itf.More(); itf.Next()) { - TopoDS_Face aFace = TopoDS::Face(Explo.Current()); - TopoDS_Iterator itf(aFace); - for (; itf.More(); itf.Next()) + TopoDS_Wire aWire = TopoDS::Wire(itf.Value()); + for (Wexp.Init(aWire, aFace); Wexp.More(); Wexp.Next()) + { + TopoDS_Edge anEdge = Wexp.Current(); + if (BRep_Tool::Degenerated(anEdge)) + continue; + const BRepOffset_ListOfInterval& Lint = Analyser.Type(anEdge); + if (!Lint.IsEmpty() && Lint.First().Type() == ChFiDS_FreeBound) { - TopoDS_Wire aWire = TopoDS::Wire(itf.Value()); - for (Wexp.Init(aWire, aFace); Wexp.More(); Wexp.Next()) - { - TopoDS_Edge anEdge = Wexp.Current(); - if (BRep_Tool::Degenerated(anEdge)) - continue; - const BRepOffset_ListOfInterval& Lint = Analyser.Type(anEdge); - if (!Lint.IsEmpty() && Lint.First().Type() == BRepOffset_FreeBoundary) - { - MapEF.Bind(anEdge, aFace); - Edges.Append(anEdge); - } - } + MapEF.Bind(anEdge, aFace); + Edges.Append(anEdge); } + } } + } TopTools_ListIteratorOfListOfShape itl; while (!Edges.IsEmpty()) @@ -1050,7 +1050,7 @@ void BRepOffset_MakeOffset::MakeOffsetFaces(BRepOffset_DataMapOfShapeOffset& the aCurOffset = myFaceOffset.IsBound(aF) ? myFaceOffset(aF) : myOffset; BRepOffset_Offset OF(aF, aCurOffset, ShapeTgt, OffsetOutside, myJoin); TopTools_ListOfShape Let; - myAnalyse.Edges(aF,BRepOffset_Tangent,Let); + myAnalyse.Edges(aF,ChFiDS_Tangential,Let); TopTools_ListIteratorOfListOfShape itl(Let); for (; itl.More(); itl.Next()) { const TopoDS_Edge& Cur = TopoDS::Edge(itl.Value()); @@ -1063,14 +1063,14 @@ void BRepOffset_MakeOffset::MakeOffsetFaces(BRepOffset_DataMapOfShapeOffset& the TopExp::Vertices (OTE,OV1,OV2); TopTools_ListOfShape LE; if (!ShapeTgt.IsBound(V1)) { - myAnalyse.Edges(V1,BRepOffset_Tangent,LE); + myAnalyse.Edges(V1,ChFiDS_Tangential,LE); const TopTools_ListOfShape& LA =myAnalyse.Ancestors(V1); if (LE.Extent() == LA.Extent()) ShapeTgt.Bind(V1,OV1); } if (!ShapeTgt.IsBound(V2)) { LE.Clear(); - myAnalyse.Edges(V2,BRepOffset_Tangent,LE); + myAnalyse.Edges(V2,ChFiDS_Tangential,LE); const TopTools_ListOfShape& LA =myAnalyse.Ancestors(V2); if (LE.Extent() == LA.Extent()) ShapeTgt.Bind(V2,OV2); @@ -1463,8 +1463,8 @@ void BRepOffset_MakeOffset::BuildOffsetByArc() //-------------------------------------------------------- // Construction of tubes on edge. //-------------------------------------------------------- - BRepOffset_Type OT = BRepOffset_Convex; - if (myOffset < 0.) OT = BRepOffset_Concave; + ChFiDS_TypeOfConcavity OT = ChFiDS_Convex; + if (myOffset < 0.) OT = ChFiDS_Concave; for (Exp.Init(myShape,TopAbs_EDGE); Exp.More(); Exp.Next()) { const TopoDS_Edge& E = TopoDS::Edge(Exp.Current()); @@ -1566,7 +1566,7 @@ void BRepOffset_MakeOffset::BuildOffsetByArc() // Particular processing if V is at least a free border. //------------------------------------------------------------- TopTools_ListOfShape LBF; - myAnalyse.Edges(V,BRepOffset_FreeBoundary,LBF); + myAnalyse.Edges(V,ChFiDS_FreeBound,LBF); if (!LBF.IsEmpty()) { Standard_Boolean First = Standard_True; for (it.Initialize(LE) ; it.More(); it.Next()) { @@ -1592,8 +1592,8 @@ void BRepOffset_MakeOffset::BuildOffsetByArc() //------------------------------------------------------ // MAJ SD. //------------------------------------------------------ - BRepOffset_Type RT = BRepOffset_Concave; - if (myOffset < 0.) RT = BRepOffset_Convex; + ChFiDS_TypeOfConcavity RT = ChFiDS_Concave; + if (myOffset < 0.) RT = ChFiDS_Convex; BRepOffset_DataMapIteratorOfDataMapOfShapeOffset It(MapSF); for ( ; It.More(); It.Next()) { const TopoDS_Shape& SI = It.Key(); @@ -1737,8 +1737,8 @@ void BRepOffset_MakeOffset::ToContext (BRepOffset_DataMapOfShapeOffset& MapSF) // Reconstruction of faces. //--------------------------- TopoDS_Face F,NF; - BRepOffset_Type RT = BRepOffset_Concave; - if (myOffset < 0.) RT = BRepOffset_Convex; + ChFiDS_TypeOfConcavity RT = ChFiDS_Concave; + if (myOffset < 0.) RT = ChFiDS_Convex; TopoDS_Shape OE,NE; TopAbs_Orientation Or; @@ -1825,8 +1825,8 @@ void BRepOffset_MakeOffset::UpdateFaceOffset() CopiedMap.Assign(myFaceOffset); TopTools_DataMapIteratorOfDataMapOfShapeReal it(CopiedMap); - BRepOffset_Type RT = BRepOffset_Convex; - if (myOffset < 0.) RT = BRepOffset_Concave; + ChFiDS_TypeOfConcavity RT = ChFiDS_Convex; + if (myOffset < 0.) RT = ChFiDS_Concave; for ( ; it.More(); it.Next()) { const TopoDS_Face& F = TopoDS::Face(it.Key()); @@ -1838,9 +1838,9 @@ void BRepOffset_MakeOffset::UpdateFaceOffset() TopTools_MapOfShape Dummy; Build.Add(Co,F); if (myJoin == GeomAbs_Arc) - myAnalyse.AddFaces(F,Co,Dummy,BRepOffset_Tangent,RT); + myAnalyse.AddFaces(F,Co,Dummy,ChFiDS_Tangential,RT); else - myAnalyse.AddFaces(F,Co,Dummy,BRepOffset_Tangent); + myAnalyse.AddFaces(F,Co,Dummy,ChFiDS_Tangential); TopExp_Explorer exp(Co,TopAbs_FACE); for (; exp.More(); exp.Next()) { @@ -3133,7 +3133,7 @@ void BRepOffset_MakeOffset::SelectShells () const TopoDS_Edge& E = TopoDS::Edge(exp.Current()); const TopTools_ListOfShape& LA = myAnalyse.Ancestors(E); if (LA.Extent() < 2) { - if (myAnalyse.Type(E).First().Type() == BRepOffset_FreeBoundary) { + if (myAnalyse.Type(E).First().Type() == ChFiDS_FreeBound) { FreeEdges.Add(E); } } @@ -3334,7 +3334,7 @@ void BRepOffset_MakeOffset::EncodeRegularity () if ( myAnalyse.HasAncestor(Ed)) { const BRepOffset_ListOfInterval& LI = myAnalyse.Type(Ed); if (LI.Extent() == 1 && - LI.First().Type() == BRepOffset_Tangent) { + LI.First().Type() == ChFiDS_Tangential) { B.Continuity(OE,F1,F2,GeomAbs_G1); } } diff --git a/src/BRepOffset/BRepOffset_Tool.cxx b/src/BRepOffset/BRepOffset_Tool.cxx index b04f5fb6a3..a57a0c2a58 100644 --- a/src/BRepOffset/BRepOffset_Tool.cxx +++ b/src/BRepOffset/BRepOffset_Tool.cxx @@ -180,26 +180,6 @@ void BRepOffset_Tool::EdgeVertices (const TopoDS_Edge& E, } } -//======================================================================= -//function : OriEdgeInFace -//purpose : -//======================================================================= - -TopAbs_Orientation BRepOffset_Tool::OriEdgeInFace (const TopoDS_Edge& E, - const TopoDS_Face& F ) - -{ - TopExp_Explorer Exp; - Exp.Init(F.Oriented(TopAbs_FORWARD),TopAbs_EDGE); - - for (; Exp.More() ;Exp.Next()) { - if (Exp.Current().IsSame(E)) { - return Exp.Current().Orientation(); - } - } - throw Standard_ConstructionError("BRepOffset_Tool::OriEdgeInFace"); -} - //======================================================================= //function : FindPeriod //purpose : @@ -3008,8 +2988,8 @@ void BRepOffset_Tool::CheckBounds(const TopoDS_Face& F, const BRepOffset_ListOfInterval& L = Analyse.Type(anEdge); if (!L.IsEmpty() || BRep_Tool::Degenerated(anEdge)) { - BRepOffset_Type OT = L.First().Type(); - if (OT == BRepOffset_Tangent || BRep_Tool::Degenerated(anEdge)) + ChFiDS_TypeOfConcavity OT = L.First().Type(); + if (OT == ChFiDS_Tangential || BRep_Tool::Degenerated(anEdge)) { Standard_Real fpar, lpar; Handle(Geom2d_Curve) aCurve = BRep_Tool::CurveOnSurface(anEdge, F, fpar, lpar); diff --git a/src/BRepOffset/BRepOffset_Tool.hxx b/src/BRepOffset/BRepOffset_Tool.hxx index 82c4ba3a33..f49b10ec6c 100644 --- a/src/BRepOffset/BRepOffset_Tool.hxx +++ b/src/BRepOffset/BRepOffset_Tool.hxx @@ -53,10 +53,6 @@ public: //! taking account the orientation of Edge. Standard_EXPORT static void EdgeVertices (const TopoDS_Edge& E, TopoDS_Vertex& V1, TopoDS_Vertex& V2); - //! returns the cumul of the orientation of - //! and thc containing wire in - Standard_EXPORT static TopAbs_Orientation OriEdgeInFace (const TopoDS_Edge& E, const TopoDS_Face& F); - //! is a section between and . Computes //! the orientation of in influenced by . //! idem for . diff --git a/src/BRepOffset/FILES b/src/BRepOffset/FILES index 0f650d4566..6a70be1cc8 100644 --- a/src/BRepOffset/FILES +++ b/src/BRepOffset/FILES @@ -34,4 +34,3 @@ BRepOffset_Offset.lxx BRepOffset_Status.hxx BRepOffset_Tool.cxx BRepOffset_Tool.hxx -BRepOffset_Type.hxx diff --git a/src/BRepTest/BRepTest_CheckCommands.cxx b/src/BRepTest/BRepTest_CheckCommands.cxx index 0f8e448801..0f34565aa2 100644 --- a/src/BRepTest/BRepTest_CheckCommands.cxx +++ b/src/BRepTest/BRepTest_CheckCommands.cxx @@ -1082,11 +1082,16 @@ static Standard_Integer shapeG1continuity (Draw_Interpretor& di, Standard_Intege face1=TopoDS::Face(It.Value()); It.Next(); face2=TopoDS::Face(It.Value()); + + Standard_Boolean IsSeam = face1.IsEqual(face2); // calcul des deux pcurves const Handle(Geom2d_Curve) c1 = BRep_Tool::CurveOnSurface (TopoDS::Edge(edge),face1,f1,l1); if (c1.IsNull()) return 1; + + if (IsSeam) + edge.Reverse(); const Handle(Geom2d_Curve) c2 = BRep_Tool::CurveOnSurface (TopoDS::Edge(edge),face2,f2,l2); if (c2.IsNull()) return 1; @@ -1212,10 +1217,15 @@ static Standard_Integer shapeG0continuity (Draw_Interpretor& di, Standard_Intege It.Next(); face2=TopoDS::Face(It.Value()); + Standard_Boolean IsSeam = face1.IsEqual(face2); + // calcul des deux pcurves const Handle(Geom2d_Curve) c1 = BRep_Tool::CurveOnSurface (TopoDS::Edge(edge),face1,f1,l1); if (c1.IsNull()) return 1; + + if (IsSeam) + edge.Reverse(); const Handle(Geom2d_Curve) c2 = BRep_Tool::CurveOnSurface (TopoDS::Edge(edge),face2,f2,l2); if (c2.IsNull()) return 1; @@ -1335,10 +1345,16 @@ static Standard_Integer shapeG2continuity (Draw_Interpretor& di, Standard_Intege face1=TopoDS::Face(It.Value()); It.Next(); face2=TopoDS::Face(It.Value()); + + Standard_Boolean IsSeam = face1.IsEqual(face2); + // calcul des deux pcurves const Handle(Geom2d_Curve) c1 = BRep_Tool::CurveOnSurface (TopoDS::Edge(edge),face1,f1,l1); if (c1.IsNull()) return 1; + + if (IsSeam) + edge.Reverse(); const Handle(Geom2d_Curve) c2 = BRep_Tool::CurveOnSurface (TopoDS::Edge(edge),face2,f2,l2); if (c2.IsNull()) return 1; diff --git a/src/BRepTools/BRepTools.cxx b/src/BRepTools/BRepTools.cxx index 6cf6f978d3..f626673fff 100644 --- a/src/BRepTools/BRepTools.cxx +++ b/src/BRepTools/BRepTools.cxx @@ -1068,4 +1068,21 @@ Standard_Real BRepTools::EvalAndUpdateTol(const TopoDS_Edge& theE, } +//======================================================================= +//function : OriEdgeInFace +//purpose : +//======================================================================= +TopAbs_Orientation BRepTools::OriEdgeInFace (const TopoDS_Edge& E, + const TopoDS_Face& F ) + +{ + TopExp_Explorer Exp(F.Oriented(TopAbs_FORWARD),TopAbs_EDGE); + + for (; Exp.More() ;Exp.Next()) { + if (Exp.Current().IsSame(E)) { + return Exp.Current().Orientation(); + } + } + throw Standard_ConstructionError("BRepTools::OriEdgeInFace"); +} diff --git a/src/BRepTools/BRepTools.hxx b/src/BRepTools/BRepTools.hxx index e6bc4b5db6..e1b180128b 100644 --- a/src/BRepTools/BRepTools.hxx +++ b/src/BRepTools/BRepTools.hxx @@ -223,6 +223,10 @@ public: const Standard_Real theF, const Standard_Real theL); + //! returns the cumul of the orientation of + //! and thc containing wire in + Standard_EXPORT static TopAbs_Orientation OriEdgeInFace(const TopoDS_Edge& theEdge, + const TopoDS_Face& theFace); protected: diff --git a/src/BiTgte/BiTgte_Blend.cxx b/src/BiTgte/BiTgte_Blend.cxx index 6bbb10245b..86b75e8c98 100644 --- a/src/BiTgte/BiTgte_Blend.cxx +++ b/src/BiTgte/BiTgte_Blend.cxx @@ -1573,7 +1573,7 @@ void BiTgte_Blend::ComputeCenters() // ------------------------------------ TopTools_ListOfShape Let; if ( AS.ShapeType() == TopAbs_FACE) { - myAnalyse.Edges(TopoDS::Face(AS),BRepOffset_Tangent,Let); + myAnalyse.Edges(TopoDS::Face(AS),ChFiDS_Tangential,Let); } TopTools_ListIteratorOfListOfShape itlet(Let); @@ -1589,14 +1589,14 @@ void BiTgte_Blend::ComputeCenters() TopExp::Vertices (OTE,OV1,OV2); TopTools_ListOfShape LE; if (!EdgeTgt.IsBound(V1)) { - myAnalyse.Edges(V1,BRepOffset_Tangent,LE); + myAnalyse.Edges(V1,ChFiDS_Tangential,LE); const TopTools_ListOfShape& LA = myAnalyse.Ancestors(V1); if (LE.Extent() == LA.Extent()) EdgeTgt.Bind(V1,OV1); } if (!EdgeTgt.IsBound(V2)) { LE.Clear(); - myAnalyse.Edges(V2,BRepOffset_Tangent,LE); + myAnalyse.Edges(V2,ChFiDS_Tangential,LE); const TopTools_ListOfShape& LA = myAnalyse.Ancestors(V2); if (LE.Extent() == LA.Extent()) EdgeTgt.Bind(V2,OV2); @@ -1637,8 +1637,8 @@ void BiTgte_Blend::ComputeCenters() //-------------------------------------------------------- // Construction of tubes on edge. //-------------------------------------------------------- - BRepOffset_Type OT = BRepOffset_Convex; - if (myRadius < 0.) OT = BRepOffset_Concave; + ChFiDS_TypeOfConcavity OT = ChFiDS_Convex; + if (myRadius < 0.) OT = ChFiDS_Concave; TopTools_IndexedDataMapOfShapeListOfShape Map; TopExp::MapShapesAndAncestors(Co,TopAbs_EDGE,TopAbs_FACE,Map); @@ -1724,8 +1724,8 @@ void BiTgte_Blend::ComputeCenters() // Proceed with MakeLoops TopTools_IndexedDataMapOfShapeListOfShape aDMVV; - BRepOffset_Type OT = BRepOffset_Concave; - if (myRadius < 0.) OT = BRepOffset_Convex; + ChFiDS_TypeOfConcavity OT = ChFiDS_Concave; + if (myRadius < 0.) OT = ChFiDS_Convex; TopTools_ListOfShape LOF; //it.Initialize(myFaces); diff --git a/src/ChFi3d/ChFi3d.cxx b/src/ChFi3d/ChFi3d.cxx index 72d172831e..9f0440cc20 100644 --- a/src/ChFi3d/ChFi3d.cxx +++ b/src/ChFi3d/ChFi3d.cxx @@ -29,6 +29,105 @@ #include #include #include +#include +#include + +static void Correct2dPoint(const TopoDS_Face& theF, gp_Pnt2d& theP2d); +// + +//======================================================================= +//function : DefineConnectType +//purpose : +//======================================================================= +ChFiDS_TypeOfConcavity ChFi3d::DefineConnectType(const TopoDS_Edge& E, + const TopoDS_Face& F1, + const TopoDS_Face& F2, + const Standard_Real SinTol, + const Standard_Boolean CorrectPoint) +{ + const Handle(Geom_Surface)& S1 = BRep_Tool::Surface(F1); + const Handle(Geom_Surface)& S2 = BRep_Tool::Surface(F2); + // + Standard_Real f,l; + Handle (Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E,F1,f,l); + //For the case of seam edge + TopoDS_Edge EE = E; + if (F1.IsSame(F2)) + EE.Reverse(); + Handle (Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(EE,F2,f,l); + + BRepAdaptor_Curve C(E); + f = C.FirstParameter(); + l = C.LastParameter(); +// + Standard_Real ParOnC = 0.5*(f+l); + gp_Vec T1 = C.DN(ParOnC,1); + if (T1.SquareMagnitude() <= gp::Resolution()) + { + ParOnC = IntTools_Tools::IntermediatePoint(f,l); + T1 = C.DN(ParOnC,1); + } + if (T1.SquareMagnitude() > gp::Resolution()) { + T1.Normalize(); + } + + if (BRepTools::OriEdgeInFace(E,F1) == TopAbs_REVERSED) { + T1.Reverse(); + } + if (F1.Orientation() == TopAbs_REVERSED) T1.Reverse(); + + gp_Pnt2d P = C1->Value(ParOnC); + gp_Pnt P3; + gp_Vec D1U,D1V; + + if(CorrectPoint) + Correct2dPoint(F1, P); + // + S1->D1(P.X(),P.Y(),P3,D1U,D1V); + gp_Vec DN1(D1U^D1V); + if (F1.Orientation() == TopAbs_REVERSED) DN1.Reverse(); + + P = C2->Value(ParOnC); + if(CorrectPoint) + Correct2dPoint(F2, P); + S2->D1(P.X(),P.Y(),P3,D1U,D1V); + gp_Vec DN2(D1U^D1V); + if (F2.Orientation() == TopAbs_REVERSED) DN2.Reverse(); + + DN1.Normalize(); + DN2.Normalize(); + + gp_Vec ProVec = DN1^DN2; + Standard_Real NormProVec = ProVec.Magnitude(); + + if (NormProVec < SinTol) { + // plane + if (DN1.Dot(DN2) > 0) { + //Tangent + return ChFiDS_Tangential; + } + else { + //Mixed not finished! +#ifdef OCCT_DEBUG + std::cout <<" faces locally mixed"< gp::Resolution()) + ProVec /= NormProVec; + Standard_Real Prod = T1.Dot(ProVec); + if (Prod > 0.) { + // + return ChFiDS_Convex; + } + else { + //reenters + return ChFiDS_Concave; + } + } +} //======================================================================= //function : ConcaveSide @@ -290,3 +389,49 @@ Standard_Boolean ChFi3d::SameSide(const TopAbs_Orientation Or, } return (o1 == o2); } + +//======================================================================= +//function : Correct2dPoint +//purpose : +//======================================================================= +void Correct2dPoint(const TopoDS_Face& theF, gp_Pnt2d& theP2d) +{ + BRepAdaptor_Surface aBAS(theF, Standard_False); + if (aBAS.GetType() < GeomAbs_BezierSurface) { + return; + } + // + const Standard_Real coeff = 0.01; + Standard_Real eps; + Standard_Real u1, u2, v1, v2; + // + aBAS.Initialize(theF, Standard_True); + u1 = aBAS.FirstUParameter(); + u2 = aBAS.LastUParameter(); + v1 = aBAS.FirstVParameter(); + v2 = aBAS.LastVParameter(); + if (!(Precision::IsInfinite(u1) || Precision::IsInfinite(u2))) + { + eps = Max(coeff*(u2 - u1), Precision::PConfusion()); + if (Abs(theP2d.X() - u1) < eps) + { + theP2d.SetX(u1 + eps); + } + if (Abs(theP2d.X() - u2) < eps) + { + theP2d.SetX(u2 - eps); + } + } + if (!(Precision::IsInfinite(v1) || Precision::IsInfinite(v2))) + { + eps = Max(coeff*(v2 - v1), Precision::PConfusion()); + if (Abs(theP2d.Y() - v1) < eps) + { + theP2d.SetY(v1 + eps); + } + if (Abs(theP2d.Y() - v2) < eps) + { + theP2d.SetY(v2 - eps); + } + } +} diff --git a/src/ChFi3d/ChFi3d.hxx b/src/ChFi3d/ChFi3d.hxx index 3623dd47d4..4bf70d650a 100644 --- a/src/ChFi3d/ChFi3d.hxx +++ b/src/ChFi3d/ChFi3d.hxx @@ -24,8 +24,10 @@ #include #include #include +#include class BRepAdaptor_Surface; class TopoDS_Edge; +class TopoDS_Face; class ChFi3d_Builder; class ChFi3d_ChBuilder; class ChFi3d_FilBuilder; @@ -39,6 +41,12 @@ public: DEFINE_STANDARD_ALLOC + //! Defines the type of concavity in the edge of connection of two faces + Standard_EXPORT static ChFiDS_TypeOfConcavity DefineConnectType (const TopoDS_Edge& E, + const TopoDS_Face& F1, + const TopoDS_Face& F2, + const Standard_Real SinTol, + const Standard_Boolean CorrectPoint); //! Returns Reversed in Or1 and(or) Or2 if //! the concave edge defined by the interior of faces F1 and F2, diff --git a/src/ChFi3d/ChFi3d_Builder_0.cxx b/src/ChFi3d/ChFi3d_Builder_0.cxx index 5885154d61..d03784b98d 100644 --- a/src/ChFi3d/ChFi3d_Builder_0.cxx +++ b/src/ChFi3d/ChFi3d_Builder_0.cxx @@ -4611,8 +4611,12 @@ Standard_Boolean ChFi3d_isTangentFaces(const TopoDS_Edge &theEdge, // Obtaining of pcurves of edge on two faces. const Handle(Geom2d_Curve) aC2d1 = BRep_Tool::CurveOnSurface (theEdge, theFace1, aFirst, aLast); + //For the case of seam edge + TopoDS_Edge EE = theEdge; + if (theFace1.IsSame(theFace2)) + EE.Reverse(); const Handle(Geom2d_Curve) aC2d2 = BRep_Tool::CurveOnSurface - (theEdge, theFace2, aFirst, aLast); + (EE, theFace2, aFirst, aLast); if (aC2d1.IsNull() || aC2d2.IsNull()) return Standard_False; diff --git a/src/ChFi3d/ChFi3d_Builder_1.cxx b/src/ChFi3d/ChFi3d_Builder_1.cxx index 0966ed6949..45c19ee18f 100644 --- a/src/ChFi3d/ChFi3d_Builder_1.cxx +++ b/src/ChFi3d/ChFi3d_Builder_1.cxx @@ -680,7 +680,7 @@ void ChFi3d_Builder::PerformExtremity (const Handle(ChFiDS_Spine)& Spine) Standard_Integer NbG1Connections = 0; for(Standard_Integer ii = 1; ii <= 2; ii++){ - TopoDS_Edge E[3],Ec; + TopoDS_Edge E[3]; TopoDS_Vertex V; ChFiDS_State sst; Standard_Integer iedge; @@ -705,44 +705,61 @@ void ChFi3d_Builder::PerformExtremity (const Handle(ChFiDS_Spine)& Spine) if(sst == ChFiDS_BreakPoint){ TopTools_ListIteratorOfListOfShape It;//,Jt; - Standard_Integer i = 0; Standard_Boolean sommetpourri = Standard_False; - TopTools_IndexedMapOfShape EdgesOfV; - //to avoid repeating of edges + TopTools_IndexedMapOfOrientedShape EdgesOfV; + TopTools_MapOfShape Edges; + Edges.Add(E[0]); + EdgesOfV.Add(E[0]); + Standard_Integer IndOfE = 0; for (It.Initialize(myVEMap(V)); It.More(); It.Next()) - EdgesOfV.Add(It.Value()); - for (Standard_Integer ind = 1; ind <= EdgesOfV.Extent(); ind++) { - Ec = TopoDS::Edge(EdgesOfV(ind)); - Standard_Boolean bonedge = !BRep_Tool::Degenerated(Ec); - if (bonedge) + { + TopoDS_Edge anEdge = TopoDS::Edge(It.Value()); + if (BRep_Tool::Degenerated(anEdge)) + continue; + TopoDS_Face F1, F2; + ChFi3d_conexfaces(anEdge, F1, F2, myEFMap); + if (!F2.IsNull() && ChFi3d_isTangentFaces(anEdge, F1, F2, GeomAbs_G2)) //smooth edge { - TopoDS_Face F1, F2; - ChFi3d_conexfaces(Ec, F1, F2, myEFMap); - if (!F2.IsNull() && ChFi3d_isTangentFaces(Ec, F1, F2, GeomAbs_G2)) + if (!F1.IsSame(F2)) + NbG1Connections++; + continue; + } + + if (Edges.Add(anEdge)) + { + EdgesOfV.Add(anEdge); + if (IndOfE < 2) { - bonedge = Standard_False; - if (!F1.IsSame(F2)) - NbG1Connections++; + IndOfE++; + E[IndOfE] = anEdge; } } - if(bonedge){ - if (!Ec.IsSame(E[0])) + else + { + TopoDS_Vertex V1, V2; + TopExp::Vertices(anEdge, V1, V2); + if (V1.IsSame(V2)) //edge is closed - two ends of the edge in the vertex { - if( i < 2 ){ - i++; - E[i] = Ec; - } - else{ -#ifdef OCCT_DEBUG - std::cout<<"top has more than 3 edges"<SetTypeOfConcavity(TypeOfConcavity); + Standard_Boolean ToRestrict = (Offset > 0)? Standard_True : Standard_False; BRepAdaptor_Surface Sb1(ff1, ToRestrict); BRepAdaptor_Surface Sb2(ff2, ToRestrict); @@ -852,8 +875,11 @@ Standard_Boolean ChFi3d_Builder::PerformElement(const Handle(ChFiDS_Spine)& Spin CEc.D1(Wl,P2,V1); Wl = BRep_Tool::Parameter(LVEc,Ec); CEc.D1(Wl,P2,V2); - if (V1.IsParallel(V2,ta)) { - if (FaceTangency(Ec,Ec,VStart)) { + Standard_Boolean IsFaceTangency = FaceTangency(Ec,Ec,VStart); + if (V1.IsParallel(V2,ta) || + IsFaceTangency) + { + if (IsFaceTangency) { CurSt = ChFiDS_Closed; } else { diff --git a/src/ChFi3d/ChFi3d_FilBuilder.cxx b/src/ChFi3d/ChFi3d_FilBuilder.cxx index f1011d62cf..c3020493be 100644 --- a/src/ChFi3d/ChFi3d_FilBuilder.cxx +++ b/src/ChFi3d/ChFi3d_FilBuilder.cxx @@ -1942,13 +1942,21 @@ void ChFi3d_FilBuilder::ExtentThreeCorner(const TopoDS_Vertex& V, Handle(ChFiDS_Spine) Spine = Stripe->Spine(); if (Spine->IsTangencyExtremity((Sens == 1))) return; //No extension on queue Standard_Real dU = Spine->LastParameter(Spine->NbEdges()); - if (Sens == 1){ - Spine->SetFirstParameter(-dU*Coeff); - Spine->SetFirstTgt(0.); + if (Sens == 1){ + if (!(Spine->GetTypeOfConcavity() == ChFiDS_Convex && + Spine->FirstStatus() == ChFiDS_OnSame)) + { + Spine->SetFirstParameter(-dU*Coeff); + Spine->SetFirstTgt(0.); + } } else{ - Spine->SetLastParameter(dU*(1.+Coeff)); - Spine->SetLastTgt(dU); + if (!(Spine->GetTypeOfConcavity() == ChFiDS_Convex && + Spine->LastStatus() == ChFiDS_OnSame)) + { + Spine->SetLastParameter(dU*(1.+Coeff)); + Spine->SetLastTgt(dU); + } } check.Append(Stripe); } diff --git a/src/ChFiDS/ChFiDS_Spine.hxx b/src/ChFiDS/ChFiDS_Spine.hxx index 7f37ed56d9..0e2a41388e 100644 --- a/src/ChFiDS/ChFiDS_Spine.hxx +++ b/src/ChFiDS/ChFiDS_Spine.hxx @@ -34,6 +34,7 @@ #include #include #include +#include class TopoDS_Edge; class ChFiDS_HElSpine; class gp_Lin; @@ -201,8 +202,14 @@ public: ChFiDS_State Status (const Standard_Boolean IsFirst) const; + //! returns the type of concavity in the connection + ChFiDS_TypeOfConcavity GetTypeOfConcavity() const; + void SetStatus (const ChFiDS_State S, const Standard_Boolean IsFirst); + //! sets the type of concavity in the connection + void SetTypeOfConcavity (const ChFiDS_TypeOfConcavity theType); + //! returns if the set of edges starts (or end) on //! Tangency point. Standard_Boolean IsTangencyExtremity (const Standard_Boolean IsFirst) const; @@ -264,6 +271,7 @@ private: BRepAdaptor_Curve myCurve; BRepAdaptor_Curve myOffsetCurve; Standard_Integer indexofcurve; + ChFiDS_TypeOfConcavity myTypeOfConcavity; ChFiDS_State firstState; ChFiDS_State lastState; TopTools_SequenceOfShape spine; diff --git a/src/ChFiDS/ChFiDS_Spine.lxx b/src/ChFiDS/ChFiDS_Spine.lxx index 3bc082e634..fef5d0db42 100644 --- a/src/ChFiDS/ChFiDS_Spine.lxx +++ b/src/ChFiDS/ChFiDS_Spine.lxx @@ -16,6 +16,16 @@ #include +//======================================================================= +//function : SetTypeOfConcavity +//purpose : +//======================================================================= + +inline void ChFiDS_Spine::SetTypeOfConcavity(const ChFiDS_TypeOfConcavity theType) +{ + myTypeOfConcavity = theType; +} + //======================================================================= //function : SetFirstStatus //purpose : @@ -36,6 +46,17 @@ inline void ChFiDS_Spine::SetLastStatus(const ChFiDS_State S) { lastState = S; } + +//======================================================================= +//function : GetTypeOfConcavity +//purpose : +//======================================================================= + +inline ChFiDS_TypeOfConcavity ChFiDS_Spine::GetTypeOfConcavity()const +{ + return myTypeOfConcavity; +} + //======================================================================= //function : FirstStatus //purpose : diff --git a/src/BRepOffset/BRepOffset_Type.hxx b/src/ChFiDS/ChFiDS_TypeOfConcavity.hxx similarity index 75% rename from src/BRepOffset/BRepOffset_Type.hxx rename to src/ChFiDS/ChFiDS_TypeOfConcavity.hxx index f95c1618b3..8c18553432 100644 --- a/src/BRepOffset/BRepOffset_Type.hxx +++ b/src/ChFiDS/ChFiDS_TypeOfConcavity.hxx @@ -14,17 +14,17 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#ifndef _BRepOffset_Type_HeaderFile -#define _BRepOffset_Type_HeaderFile +#ifndef _ChFiDS_TypeOfConcavity_HeaderFile +#define _ChFiDS_TypeOfConcavity_HeaderFile -enum BRepOffset_Type +enum ChFiDS_TypeOfConcavity { -BRepOffset_Concave, -BRepOffset_Convex, -BRepOffset_Tangent, -BRepOffset_FreeBoundary, -BRepOffset_Other +ChFiDS_Concave, +ChFiDS_Convex, +ChFiDS_Tangential, +ChFiDS_FreeBound, +ChFiDS_Other }; -#endif // _BRepOffset_Type_HeaderFile +#endif // _ChFiDS_TypeOfConcavity_HeaderFile diff --git a/src/ChFiDS/FILES b/src/ChFiDS/FILES index a5cbc1b5ed..cee9b7aba5 100644 --- a/src/ChFiDS/FILES +++ b/src/ChFiDS/FILES @@ -46,3 +46,4 @@ ChFiDS_StripeMap.lxx ChFiDS_SurfData.cxx ChFiDS_SurfData.hxx ChFiDS_SurfData.lxx +ChFiDS_TypeOfConcavity.hxx \ No newline at end of file diff --git a/src/TKFillet/EXTERNLIB b/src/TKFillet/EXTERNLIB index 576994dd3c..453e304464 100755 --- a/src/TKFillet/EXTERNLIB +++ b/src/TKFillet/EXTERNLIB @@ -8,3 +8,4 @@ TKTopAlgo TKG3d TKBool TKShHealing +TKBO diff --git a/tests/bugs/modalg_7/bug30940_1 b/tests/bugs/modalg_7/bug30940_1 new file mode 100644 index 0000000000..764c194407 --- /dev/null +++ b/tests/bugs/modalg_7/bug30940_1 @@ -0,0 +1,23 @@ +puts "==================================================================" +puts "OCC30940: BRepFilletAPI_MakeFillet algorithm fails on closed shell" +puts "==================================================================" +puts "" + +brestore [locate_data_file bug30940_compfaces.brep] b + +sewing a 0.0001 b +explode a e + +blend result a 0.1 a_1 0.1 a_2 0.1 a_3 0.1 a_4 0.1 a_5 0.1 a_6 0.1 a_7 0.1 a_8 0.1 a_9 0.1 a_10 0.1 a_11 0.1 a_12 + +checkshape result + +checknbshapes result -shell 1 -face 26 -wire 26 -edge 56 -vertex 30 + +set tolres [checkmaxtol result] + +if { ${tolres} > 0.001} { + puts "Error: bad tolerance of result" +} + +checkprops result -v 276.831 diff --git a/tests/bugs/modalg_7/bug30940_2 b/tests/bugs/modalg_7/bug30940_2 new file mode 100644 index 0000000000..147e8b8df4 --- /dev/null +++ b/tests/bugs/modalg_7/bug30940_2 @@ -0,0 +1,25 @@ +puts "==================================================================" +puts "OCC30940: BRepFilletAPI_MakeFillet algorithm fails on closed shell" +puts "==================================================================" +puts "" + +beziercurve q 4 0 0 0 10 0 0 0 10 0 0 0 0 +mkedge q q +wire q q +mkplane q q +prism q q 0 0 10 +explode q e + +blend result q 0.5 q_3 + +checkshape result + +checknbshapes result -face 4 -edge 5 -vertex 3 + +set tolres [checkmaxtol result] + +if { ${tolres} > 1.e-4} { + puts "Error: bad tolerance of result" +} + +checkprops result -v 149.268 -deps 1.e-5 diff --git a/tests/bugs/modalg_7/bug30940_3 b/tests/bugs/modalg_7/bug30940_3 new file mode 100644 index 0000000000..8f910f057c --- /dev/null +++ b/tests/bugs/modalg_7/bug30940_3 @@ -0,0 +1,25 @@ +puts "==================================================================" +puts "OCC30940: BRepFilletAPI_MakeFillet algorithm fails on closed shell" +puts "==================================================================" +puts "" + +beziercurve q 4 0 0 0 10 0 0 0 10 0 0 0 0 +mkedge q q +wire q q +mkplane q q +prism q q 0 0 10 +explode q e + +blend result q 0.5 q_1 + +checkshape result + +checknbshapes result -face 4 -edge 6 -vertex 4 + +set tolres [checkmaxtol result] + +if { ${tolres} > 1.01e-7} { + puts "Error: bad tolerance of result" +} + +checkprops result -v 149.398 -deps 1.e-5 diff --git a/tests/bugs/modalg_7/bug30940_4 b/tests/bugs/modalg_7/bug30940_4 new file mode 100644 index 0000000000..0c851a88d4 --- /dev/null +++ b/tests/bugs/modalg_7/bug30940_4 @@ -0,0 +1,25 @@ +puts "==================================================================" +puts "OCC30940: BRepFilletAPI_MakeFillet algorithm fails on closed shell" +puts "==================================================================" +puts "" + +beziercurve q 4 0 0 0 10 0 0 0 10 0 0 0 0 +mkedge q q +wire q q +mkplane q q +prism q q 0 0 10 +explode q e + +blend result q 0.5 q_1 0.5 q_2 0.5 q_3 + +checkshape result + +checknbshapes result -face 8 -edge 14 -vertex 6 + +set tolres [checkmaxtol result] + +if { ${tolres} > 1.e-4} { + puts "Error: bad tolerance of result" +} + +checkprops result -v 147.953 -deps 1.e-5 diff --git a/tests/bugs/modalg_7/bug30940_5 b/tests/bugs/modalg_7/bug30940_5 new file mode 100644 index 0000000000..5422146d1d --- /dev/null +++ b/tests/bugs/modalg_7/bug30940_5 @@ -0,0 +1,25 @@ +puts "==================================================================" +puts "OCC30940: BRepFilletAPI_MakeFillet algorithm fails on closed shell" +puts "==================================================================" +puts "" + +beziercurve q 5 0 0 0 0 -10 0 50 50 0 -10 0 0 0 0 0 +mkedge q q +wire q q +mkplane q q +prism q q 0 0 10 +explode q e + +blend result q 0.1 q_3 + +checkshape result + +checknbshapes result -face 4 -edge 5 -vertex 3 + +set tolres [checkmaxtol result] + +if { ${tolres} > 1.e-4} { + puts "Error: bad tolerance of result" +} + +checkprops result -v 1028.46 -deps 1.e-5 diff --git a/tests/bugs/modalg_7/bug30940_6 b/tests/bugs/modalg_7/bug30940_6 new file mode 100644 index 0000000000..7fc39b94d9 --- /dev/null +++ b/tests/bugs/modalg_7/bug30940_6 @@ -0,0 +1,25 @@ +puts "==================================================================" +puts "OCC30940: BRepFilletAPI_MakeFillet algorithm fails on closed shell" +puts "==================================================================" +puts "" + +beziercurve q 5 0 0 0 0 -10 0 50 50 0 -10 0 0 0 0 0 +mkedge q q +wire q q +mkplane q q +prism q q 0 0 10 +explode q e + +blend result q 0.1 q_1 0.1 q_2 0.1 q_3 + +checkshape result + +checknbshapes result -face 8 -edge 14 -vertex 8 + +set tolres [checkmaxtol result] + +if { ${tolres} > 1.e-4} { + puts "Error: bad tolerance of result" +} + +checkprops result -v 1028.37 -deps 1.e-5 diff --git a/tests/bugs/modalg_7/bug31030 b/tests/bugs/modalg_7/bug31030 new file mode 100644 index 0000000000..832efa099e --- /dev/null +++ b/tests/bugs/modalg_7/bug31030 @@ -0,0 +1,23 @@ +puts "========================================================================" +puts "OCC31030: BRepFilletAPI_MakeFillet algorithm fails on almost smooth edge" +puts "========================================================================" +puts "" + +brestore [locate_data_file bug31030_compfaces.brep] b + +sewing a 0.0001 b +explode a e + +blend result a 0.1 a_3 + +checkshape result + +checknbshapes result -shell 1 -face 4 -wire 4 -edge 5 -vertex 3 + +set tolres [checkmaxtol result] + +if { ${tolres} > 0.0003} { + puts "Error: bad tolerance of result" +} + +checkprops result -v 1850.13