From f175c5344588c4c5551351c81a7f05d91e2c2f7a Mon Sep 17 00:00:00 2001 From: ifv Date: Tue, 17 Feb 2015 11:03:23 +0300 Subject: [PATCH] Fix regressions (see #25729 for details) --- src/BRepOffset/BRepOffset_Analyse.cxx | 209 ++--- src/BRepOffset/BRepOffset_MakeOffset.cxx | 957 +++++++---------------- 2 files changed, 409 insertions(+), 757 deletions(-) diff --git a/src/BRepOffset/BRepOffset_Analyse.cxx b/src/BRepOffset/BRepOffset_Analyse.cxx index 659d12786a..a78d0b9f41 100644 --- a/src/BRepOffset/BRepOffset_Analyse.cxx +++ b/src/BRepOffset/BRepOffset_Analyse.cxx @@ -5,8 +5,8 @@ // // This file is part of Open CASCADE Technology software library. // -// This library is free software; you can redistribute it and / or modify it -// under the terms of the GNU Lesser General Public version 2.1 as published +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. @@ -49,7 +49,21 @@ #include // static void Correct2dPoint(const Adaptor3d_Surface& theS, 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) +{ + TopoDS_Vertex Vlast = TopExp::LastVertex(anEdge); + if (aVertex.IsSame(Vlast)) + TangVec.Reverse(); +} //======================================================================= //function : BRepOffset_Analyse //purpose : @@ -79,100 +93,32 @@ BRepOffset_Analyse::BRepOffset_Analyse(const TopoDS_Shape& S, //======================================================================= static void EdgeAnalyse(const TopoDS_Edge& E, - const TopoDS_Face& F1, - const TopoDS_Face& F2, - const Standard_Real SinTol, - BRepOffset_ListOfInterval& LI) + const TopoDS_Face& F1, + const TopoDS_Face& F2, + const Standard_Real SinTol, + BRepOffset_ListOfInterval& LI) { - - TopLoc_Location L; Standard_Real f,l; - - BRepAdaptor_Surface S1(F1), S2(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(); - + BRep_Tool::Range(E, F1, f, l); + BRepOffset_Interval I; + I.First(f); I.Last(l); + // // Tangent if the regularity is at least G1. if (BRep_Tool::HasContinuity(E,F1,F2)) { if (BRep_Tool::Continuity(E,F1,F2) > GeomAbs_C0) { - BRepOffset_Interval I; - I.First(f); I.Last(l); I.Type(BRepOffset_Tangent); LI.Append(I); return; } } - // First stage : Type determined by one of ends. - // Calculate normals and tangents on the curves and surface. - // normals are oriented outwards. - - 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; - - Correct2dPoint(S1, 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); - Correct2dPoint(S2, 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(); - - BRepOffset_Interval I; - I.First(f); I.Last(l); - - if (Abs(NormProVec) < SinTol) { - // plane - if (DN1.Dot(DN2) > 0) { - //Tangent - I.Type(BRepOffset_Tangent); - } - else { - //Mixed not finished! -#ifdef DEB - cout <<" faces locally mixed"< gp::Resolution()) - ProVec.Normalize(); - Standard_Real Prod = T1.Dot(DN1^DN2); - if (Prod > 0.) { - // - I.Type(BRepOffset_Convex); - } - else { - //reenters - I.Type(BRepOffset_Concave); - } + // + BRepOffset_Type aType = DefineConnectType(E, F1, F2, SinTol, Standard_False); + if(aType != BRepOffset_Tangent) + { + aType = DefineConnectType(E, F1, F2, SinTol, Standard_True); } + I.Type(aType); LI.Append(I); } @@ -261,7 +207,7 @@ void BRepOffset_Analyse::Perform (const TopoDS_Shape& S, mapEdgeType(E).Append(Inter); } else { -#ifdef DEB +#ifdef OCCT_DEBUG cout <<"edge shared by more than two faces"< 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(S1, 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(S2, 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 + 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_MakeOffset.cxx b/src/BRepOffset/BRepOffset_MakeOffset.cxx index 1919e8a12f..69ca982442 100644 --- a/src/BRepOffset/BRepOffset_MakeOffset.cxx +++ b/src/BRepOffset/BRepOffset_MakeOffset.cxx @@ -5,8 +5,8 @@ // // This file is part of Open CASCADE Technology software library. // -// This library is free software; you can redistribute it and / or modify it -// under the terms of the GNU Lesser General Public version 2.1 as published +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. @@ -121,7 +121,7 @@ #include #endif -#ifdef DEB +#ifdef OCCT_DEBUG #include //#define DEB_VERB Standard_Boolean AffichInt2d = Standard_False; @@ -799,14 +799,14 @@ void BRepOffset_MakeOffset::MakeThickSolid() YaResult = 1; Glue.Add (exp.Current().Reversed()); } -#ifdef DEB +#ifdef OCCT_DEBUG if(YaResult == 0) { cout << "OffsetShape does not contain a FACES." << endl; } #endif } -#ifdef DEB +#ifdef OCCT_DEBUG else { cout << "OffsetShape is null!" << endl; @@ -887,7 +887,7 @@ static void TrimEdge (TopoDS_Edge& NE, Standard_Real aSameParTol = Precision::Confusion(); TopoDS_Vertex V1,V2; - Standard_Real U; + Standard_Real U = 0.; Standard_Real UMin = Precision::Infinite(); Standard_Real UMax = -UMin; @@ -946,7 +946,7 @@ static void TrimEdge (TopoDS_Edge& NE, //======================================================================= void BRepOffset_MakeOffset::BuildOffsetByInter() { -#ifdef DEB +#ifdef OCCT_DEBUG if ( ChronBuild) { cout << " CONSTRUCTION OF OFFSETS :" << endl; Clock.Reset(); @@ -1131,7 +1131,7 @@ void BRepOffset_MakeOffset::BuildOffsetByInter() //------------------------------- myMakeLoops.Build(LFE ,AsDes,IMOE); -#ifdef DEB +#ifdef OCCT_DEBUG TopTools_IndexedMapOfShape COES; #endif //--------------------------- @@ -1367,7 +1367,7 @@ void BRepOffset_MakeOffset::BuildOffsetByInter() } } -#ifdef DEB +#ifdef OCCT_DEBUG DEBVerticesControl (COES,myAsDes); if ( ChronBuild) Clock.Show(); #endif @@ -1380,7 +1380,7 @@ void BRepOffset_MakeOffset::BuildOffsetByInter() //======================================================================= void BRepOffset_MakeOffset::BuildOffsetByArc() { -#ifdef DEB +#ifdef OCCT_DEBUG if ( ChronBuild) { cout << " CONSTRUCTION OF OFFSETS :" << endl; Clock.Reset(); @@ -1616,7 +1616,7 @@ void BRepOffset_MakeOffset::BuildOffsetByArc() } } -#ifdef DEB +#ifdef OCCT_DEBUG if ( ChronBuild) Clock.Show(); #endif } @@ -1630,7 +1630,7 @@ void BRepOffset_MakeOffset::BuildOffsetByArc() void BRepOffset_MakeOffset::SelfInter(TopTools_MapOfShape& /*Modif*/) { -#ifdef DEB +#ifdef OCCT_DEBUG if ( ChronBuild) { cout << " AUTODEBOUCLAGE:" << endl; Clock.Reset(); @@ -1640,7 +1640,7 @@ void BRepOffset_MakeOffset::SelfInter(TopTools_MapOfShape& /*Modif*/) Standard_NotImplemented::Raise(); -#ifdef DEB +#ifdef OCCT_DEBUG if ( ChronBuild) Clock.Show(); #endif } @@ -1848,64 +1848,63 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() Standard_Real TolApex = 1.e-5; Standard_Integer i; - Standard_Boolean isSphericalFaceAdded = Standard_False; TopTools_DataMapOfShapeListOfShape FacesOfCone; //TopTools_DataMapOfShapeShape DegEdges; TopExp_Explorer Explo( myOffsetShape, TopAbs_FACE ); if (myJoin == GeomAbs_Arc) + { + for (; Explo.More(); Explo.Next()) { - for (; Explo.More(); Explo.Next()) - { - TopoDS_Face aFace = TopoDS::Face( Explo.Current() ); - Handle(Geom_Surface) aSurf = BRep_Tool::Surface( aFace ); - //if (aSurf->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface)) - //aSurf = (Handle(Geom_OffsetSurface)::DownCast(aSurf))->BasisSurface(); //??? - - TopTools_IndexedMapOfShape Emap; - TopExp::MapShapes( aFace, TopAbs_EDGE, Emap ); - for (i = 1; i <= Emap.Extent(); i++) - { - TopoDS_Edge anEdge = TopoDS::Edge( Emap(i) ); - //Standard_Real f, l; - //Handle(Geom_Curve) theCurve = BRep_Tool::Curve( anEdge, f, l ); - //Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &anEdge.TShape()); - if (BRep_Tool::Degenerated(anEdge)) - { - //Check if anEdge is a really degenerated edge or not - BRepAdaptor_Curve BACurve(anEdge, aFace); - gp_Pnt Pfirst, Plast, Pmid; - Pfirst = BACurve.Value(BACurve.FirstParameter()); - Plast = BACurve.Value(BACurve.LastParameter()); - Pmid = BACurve.Value((BACurve.FirstParameter()+BACurve.LastParameter())/2.); - if (Pfirst.Distance(Plast) <= TolApex && - Pfirst.Distance(Pmid) <= TolApex) - continue; - //Cones.Append( aFace ); - //Circs.Append( anEdge ); - //TopoDS_Vertex Vdeg = TopExp::FirstVertex( anEdge ); - TopoDS_Edge OrEdge = - TopoDS::Edge( myInitOffsetEdge.Root( anEdge) ); - TopoDS_Vertex VF = TopExp::FirstVertex( OrEdge ); - if ( FacesOfCone.IsBound(VF) ) - { - //add a face to the existing list - TopTools_ListOfShape& aFaces = FacesOfCone.ChangeFind(VF); - aFaces.Append (aFace); - //DegEdges.Bind(aFace, anEdge); - } - else - { - //the vertex is not in the map => create a new key and items - TopTools_ListOfShape aFaces; - aFaces.Append (aFace); - FacesOfCone.Bind(VF, aFaces); - //DegEdges.Bind(aFace, anEdge); - } - } - } //for (i = 1; i <= Emap.Extent(); i++) - } //for (; fexp.More(); fexp.Next()) - } //if (myJoin == GeomAbs_Arc) + TopoDS_Face aFace = TopoDS::Face( Explo.Current() ); + Handle(Geom_Surface) aSurf = BRep_Tool::Surface( aFace ); + //if (aSurf->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface)) + //aSurf = (Handle(Geom_OffsetSurface)::DownCast(aSurf))->BasisSurface(); //??? + + TopTools_IndexedMapOfShape Emap; + TopExp::MapShapes( aFace, TopAbs_EDGE, Emap ); + for (i = 1; i <= Emap.Extent(); i++) + { + TopoDS_Edge anEdge = TopoDS::Edge( Emap(i) ); + //Standard_Real f, l; + //Handle(Geom_Curve) theCurve = BRep_Tool::Curve( anEdge, f, l ); + //Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &anEdge.TShape()); + if (BRep_Tool::Degenerated(anEdge)) + { + //Check if anEdge is a really degenerated edge or not + BRepAdaptor_Curve BACurve(anEdge, aFace); + gp_Pnt Pfirst, Plast, Pmid; + Pfirst = BACurve.Value(BACurve.FirstParameter()); + Plast = BACurve.Value(BACurve.LastParameter()); + Pmid = BACurve.Value((BACurve.FirstParameter()+BACurve.LastParameter())/2.); + if (Pfirst.Distance(Plast) <= TolApex && + Pfirst.Distance(Pmid) <= TolApex) + continue; + //Cones.Append( aFace ); + //Circs.Append( anEdge ); + //TopoDS_Vertex Vdeg = TopExp::FirstVertex( anEdge ); + TopoDS_Edge OrEdge = + TopoDS::Edge( myInitOffsetEdge.Root( anEdge) ); + TopoDS_Vertex VF = TopExp::FirstVertex( OrEdge ); + if ( FacesOfCone.IsBound(VF) ) + { + //add a face to the existing list + TopTools_ListOfShape& aFaces = FacesOfCone.ChangeFind(VF); + aFaces.Append (aFace); + //DegEdges.Bind(aFace, anEdge); + } + else + { + //the vertex is not in the map => create a new key and items + TopTools_ListOfShape aFaces; + aFaces.Append (aFace); + FacesOfCone.Bind(VF, aFaces); + //DegEdges.Bind(aFace, anEdge); + } + } + } //for (i = 1; i <= Emap.Extent(); i++) + } //for (; fexp.More(); fexp.Next()) + } //if (myJoin == GeomAbs_Arc) TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Cone(FacesOfCone); BRep_Builder BB; @@ -1922,218 +1921,218 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() gp_Pnt FirstPoint; TopoDS_Vertex theFirstVertex, CurFirstVertex; for (; itFaces.More(); itFaces.Next()) + { + TopoDS_Face aFace = TopoDS::Face(itFaces.Value()); //TopoDS::Face(Faces.First()); + TopoDS_Edge DegEdge; // = TopoDS::Edge(DegEdges(aFace)); + for (Explo.Init(aFace, TopAbs_EDGE); Explo.More(); Explo.Next()) { - TopoDS_Face aFace = TopoDS::Face(itFaces.Value()); //TopoDS::Face(Faces.First()); - TopoDS_Edge DegEdge; // = TopoDS::Edge(DegEdges(aFace)); - for (Explo.Init(aFace, TopAbs_EDGE); Explo.More(); Explo.Next()) - { - DegEdge = TopoDS::Edge(Explo.Current()); - if (BRep_Tool::Degenerated(DegEdge)) - { - TopoDS_Edge OrEdge = TopoDS::Edge( myInitOffsetEdge.Root( DegEdge) ); - TopoDS_Vertex VF = TopExp::FirstVertex( OrEdge ); - if (VF.IsSame(anApex)) - break; - } - } - TopoDS_Shape aLocalDegShape = DegEdge.Oriented(TopAbs_FORWARD); - TopoDS_Edge CurEdge = TopoDS::Edge(aLocalDegShape); - BB.Degenerated(CurEdge, Standard_False); - BB.SameRange(CurEdge, Standard_False); - BB.SameParameter(CurEdge, Standard_False); - gp_Pnt fPnt, lPnt, mPnt; - GetEdgePoints(CurEdge, aFace, fPnt, mPnt, lPnt); - Standard_Real f, l; - BRep_Tool::Range(CurEdge, f, l); - if (isFirstFace) - { - gp_Vec aVec1(fPnt, mPnt); - gp_Vec aVec2(fPnt, lPnt); - gp_Vec aNorm = aVec1.Crossed(aVec2); - gp_Pnt theApex = BRep_Tool::Pnt(anApex); - gp_Vec ApexToFpnt(theApex, fPnt); - gp_Vec Ydir = aNorm ^ ApexToFpnt; - gp_Vec Xdir = Ydir ^ aNorm; - //Xdir.Rotate(gp_Ax1(theApex, aNorm), -f); - gp_Ax2 anAx2(theApex, gp_Dir(aNorm), gp_Dir(Xdir)); - theSphere.SetRadius(myOffset); - theSphere.SetPosition(gp_Ax3(anAx2) /*gp_Ax3(theApex, gp_Dir(aNorm))*/); - aSphSurf = new Geom_SphericalSurface(theSphere); - FirstPoint = fPnt; - theFirstVertex = BRepLib_MakeVertex(fPnt); - CurFirstVertex = theFirstVertex; - } - - TopoDS_Vertex v1, v2, FirstVert, EndVert; - TopExp::Vertices(CurEdge, v1, v2); - FirstVert = CurFirstVertex; - if (lPnt.Distance(FirstPoint) <= Precision::Confusion()) - EndVert = theFirstVertex; - else - EndVert = BRepLib_MakeVertex(lPnt); - CurEdge.Free( Standard_True ); - BB.Remove(CurEdge, v1); - BB.Remove(CurEdge, v2); - BB.Add(CurEdge, FirstVert.Oriented(TopAbs_FORWARD)); - BB.Add(CurEdge, EndVert.Oriented(TopAbs_REVERSED)); - //take the curve from sphere an put it to the edge - Standard_Real Uf, Vf, Ul, Vl; - ElSLib::Parameters( theSphere, fPnt, Uf, Vf ); - ElSLib::Parameters( theSphere, lPnt, Ul, Vl ); - if (Abs(Ul) <= Precision::Confusion()) - Ul = 2.*M_PI; - Handle(Geom_Curve) aCurv = aSphSurf->VIso(Vf); - /* + DegEdge = TopoDS::Edge(Explo.Current()); + if (BRep_Tool::Degenerated(DegEdge)) + { + TopoDS_Edge OrEdge = TopoDS::Edge( myInitOffsetEdge.Root( DegEdge) ); + TopoDS_Vertex VF = TopExp::FirstVertex( OrEdge ); + if (VF.IsSame(anApex)) + break; + } + } + TopoDS_Shape aLocalDegShape = DegEdge.Oriented(TopAbs_FORWARD); + TopoDS_Edge CurEdge = TopoDS::Edge(aLocalDegShape); + BB.Degenerated(CurEdge, Standard_False); + BB.SameRange(CurEdge, Standard_False); + BB.SameParameter(CurEdge, Standard_False); + gp_Pnt fPnt, lPnt, mPnt; + GetEdgePoints(CurEdge, aFace, fPnt, mPnt, lPnt); + Standard_Real f, l; + BRep_Tool::Range(CurEdge, f, l); + if (isFirstFace) + { + gp_Vec aVec1(fPnt, mPnt); + gp_Vec aVec2(fPnt, lPnt); + gp_Vec aNorm = aVec1.Crossed(aVec2); + gp_Pnt theApex = BRep_Tool::Pnt(anApex); + gp_Vec ApexToFpnt(theApex, fPnt); + gp_Vec Ydir = aNorm ^ ApexToFpnt; + gp_Vec Xdir = Ydir ^ aNorm; + //Xdir.Rotate(gp_Ax1(theApex, aNorm), -f); + gp_Ax2 anAx2(theApex, gp_Dir(aNorm), gp_Dir(Xdir)); + theSphere.SetRadius(myOffset); + theSphere.SetPosition(gp_Ax3(anAx2) /*gp_Ax3(theApex, gp_Dir(aNorm))*/); + aSphSurf = new Geom_SphericalSurface(theSphere); + FirstPoint = fPnt; + theFirstVertex = BRepLib_MakeVertex(fPnt); + CurFirstVertex = theFirstVertex; + } + + TopoDS_Vertex v1, v2, FirstVert, EndVert; + TopExp::Vertices(CurEdge, v1, v2); + FirstVert = CurFirstVertex; + if (lPnt.Distance(FirstPoint) <= Precision::Confusion()) + EndVert = theFirstVertex; + else + EndVert = BRepLib_MakeVertex(lPnt); + CurEdge.Free( Standard_True ); + BB.Remove(CurEdge, v1); + BB.Remove(CurEdge, v2); + BB.Add(CurEdge, FirstVert.Oriented(TopAbs_FORWARD)); + BB.Add(CurEdge, EndVert.Oriented(TopAbs_REVERSED)); + //take the curve from sphere an put it to the edge + Standard_Real Uf, Vf, Ul, Vl; + ElSLib::Parameters( theSphere, fPnt, Uf, Vf ); + ElSLib::Parameters( theSphere, lPnt, Ul, Vl ); + if (Abs(Ul) <= Precision::Confusion()) + Ul = 2.*M_PI; + Handle(Geom_Curve) aCurv = aSphSurf->VIso(Vf); + /* if (!isFirstFace) - { - gp_Circ aCircle = (Handle(Geom_Circle)::DownCast(aCurv))->Circ(); - if (Abs(Uf - f) > Precision::Confusion()) - { - aCircle.Rotate(aCircle.Axis(), f - Uf); - aCurv = new Geom_Circle(aCircle); - } - } - */ - Handle(Geom_TrimmedCurve) aTrimCurv = new Geom_TrimmedCurve(aCurv, Uf, Ul); - BB.UpdateEdge(CurEdge, aTrimCurv, Precision::Confusion()); - BB.Range(CurEdge, Uf, Ul, Standard_True); - Handle(Geom2d_Line) theLin2d = new Geom2d_Line( gp_Pnt2d( 0., Vf ), gp::DX2d() ); - Handle(Geom2d_TrimmedCurve) theTrimLin2d = new Geom2d_TrimmedCurve(theLin2d, Uf, Ul); - BB.UpdateEdge(CurEdge, theTrimLin2d, aSphSurf, L, Precision::Confusion()); - BB.Range(CurEdge, aSphSurf, L, Uf, Ul); - BRepLib::SameParameter(CurEdge); - BB.Add(SphereWire, CurEdge); - //Modifying correspondent edges in aFace: substitute vertices common with CurEdge - BRepAdaptor_Curve2d BAc2d(CurEdge, aFace); - gp_Pnt2d fPnt2d, lPnt2d; - fPnt2d = BAc2d.Value(BAc2d.FirstParameter()); - lPnt2d = BAc2d.Value(BAc2d.LastParameter()); - TopTools_IndexedMapOfShape Emap; - TopExp::MapShapes(aFace, TopAbs_EDGE, Emap); - TopoDS_Edge EE [2]; - Standard_Integer j = 0, k; - for (k = 1; k <= Emap.Extent(); k++) - { - const TopoDS_Edge& anEdge = TopoDS::Edge(Emap(k)); - if (!BRep_Tool::Degenerated(anEdge)) - { - TopoDS_Vertex V1, V2; - TopExp::Vertices(anEdge, V1, V2); - if (V1.IsSame(v1) || V2.IsSame(v1)) - EE[j++] = anEdge; - } - } - for (k = 0; k < j; k++) - { - TopoDS_Shape aLocalShape = EE[k].Oriented(TopAbs_FORWARD); - TopoDS_Edge Eforward = TopoDS::Edge(aLocalShape); - Eforward.Free(Standard_True); - TopoDS_Vertex V1, V2; - TopExp::Vertices( Eforward, V1, V2 ); - BRepAdaptor_Curve2d EEc( Eforward, aFace ); - gp_Pnt2d p2d1, p2d2; - p2d1 = EEc.Value(EEc.FirstParameter()); - p2d2 = EEc.Value(EEc.LastParameter()); - if (V1.IsSame(v1)) - { - TopoDS_Vertex NewV = (p2d1.Distance(fPnt2d) <= Precision::Confusion())? - FirstVert : EndVert; - BB.Remove( Eforward, V1 ); - BB.Add( Eforward, NewV.Oriented(TopAbs_FORWARD) ); - } - else - { - TopoDS_Vertex NewV = (p2d2.Distance(fPnt2d) <= Precision::Confusion())? - FirstVert : EndVert; - BB.Remove( Eforward, V2 ); - BB.Add( Eforward, NewV.Oriented(TopAbs_REVERSED) ); - } - } - - isFirstFace = Standard_False; - CurFirstVertex = EndVert; + { + gp_Circ aCircle = (Handle(Geom_Circle)::DownCast(aCurv))->Circ(); + if (Abs(Uf - f) > Precision::Confusion()) + { + aCircle.Rotate(aCircle.Axis(), f - Uf); + aCurv = new Geom_Circle(aCircle); + } + } + */ + Handle(Geom_TrimmedCurve) aTrimCurv = new Geom_TrimmedCurve(aCurv, Uf, Ul); + BB.UpdateEdge(CurEdge, aTrimCurv, Precision::Confusion()); + BB.Range(CurEdge, Uf, Ul, Standard_True); + Handle(Geom2d_Line) theLin2d = new Geom2d_Line( gp_Pnt2d( 0., Vf ), gp::DX2d() ); + Handle(Geom2d_TrimmedCurve) theTrimLin2d = new Geom2d_TrimmedCurve(theLin2d, Uf, Ul); + BB.UpdateEdge(CurEdge, theTrimLin2d, aSphSurf, L, Precision::Confusion()); + BB.Range(CurEdge, aSphSurf, L, Uf, Ul); + BRepLib::SameParameter(CurEdge); + BB.Add(SphereWire, CurEdge); + //Modifying correspondent edges in aFace: substitute vertices common with CurEdge + BRepAdaptor_Curve2d BAc2d(CurEdge, aFace); + gp_Pnt2d fPnt2d, lPnt2d; + fPnt2d = BAc2d.Value(BAc2d.FirstParameter()); + lPnt2d = BAc2d.Value(BAc2d.LastParameter()); + TopTools_IndexedMapOfShape Emap; + TopExp::MapShapes(aFace, TopAbs_EDGE, Emap); + TopoDS_Edge EE [2]; + Standard_Integer j = 0, k; + for (k = 1; k <= Emap.Extent(); k++) + { + const TopoDS_Edge& anEdge = TopoDS::Edge(Emap(k)); + if (!BRep_Tool::Degenerated(anEdge)) + { + TopoDS_Vertex V1, V2; + TopExp::Vertices(anEdge, V1, V2); + if (V1.IsSame(v1) || V2.IsSame(v1)) + EE[j++] = anEdge; + } } + for (k = 0; k < j; k++) + { + TopoDS_Shape aLocalShape = EE[k].Oriented(TopAbs_FORWARD); + TopoDS_Edge Eforward = TopoDS::Edge(aLocalShape); + Eforward.Free(Standard_True); + TopoDS_Vertex V1, V2; + TopExp::Vertices( Eforward, V1, V2 ); + BRepAdaptor_Curve2d EEc( Eforward, aFace ); + gp_Pnt2d p2d1, p2d2; + p2d1 = EEc.Value(EEc.FirstParameter()); + p2d2 = EEc.Value(EEc.LastParameter()); + if (V1.IsSame(v1)) + { + TopoDS_Vertex NewV = (p2d1.Distance(fPnt2d) <= Precision::Confusion())? + FirstVert : EndVert; + BB.Remove( Eforward, V1 ); + BB.Add( Eforward, NewV.Oriented(TopAbs_FORWARD) ); + } + else + { + TopoDS_Vertex NewV = (p2d2.Distance(fPnt2d) <= Precision::Confusion())? + FirstVert : EndVert; + BB.Remove( Eforward, V2 ); + BB.Add( Eforward, NewV.Oriented(TopAbs_REVERSED) ); + } + } + + isFirstFace = Standard_False; + CurFirstVertex = EndVert; + } //Building new spherical face Standard_Real Ufirst = RealLast(), Ulast = RealFirst(); gp_Pnt2d p2d1, p2d2; TopTools_ListOfShape EdgesOfWire; TopoDS_Iterator itw(SphereWire); for (; itw.More(); itw.Next()) - { - const TopoDS_Edge& anEdge = TopoDS::Edge(itw.Value()); - EdgesOfWire.Append(anEdge); - Standard_Real f, l; - Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(anEdge, aSphSurf, L, f, l); - p2d1 = aC2d->Value(f); - p2d2 = aC2d->Value(l); - if (p2d1.X() < Ufirst) - Ufirst = p2d1.X(); - if (p2d1.X() > Ulast) - Ulast = p2d1.X(); - if (p2d2.X() < Ufirst) - Ufirst = p2d2.X(); - if (p2d2.X() > Ulast) - Ulast = p2d2.X(); - } + { + const TopoDS_Edge& anEdge = TopoDS::Edge(itw.Value()); + EdgesOfWire.Append(anEdge); + Standard_Real f, l; + Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(anEdge, aSphSurf, L, f, l); + p2d1 = aC2d->Value(f); + p2d2 = aC2d->Value(l); + if (p2d1.X() < Ufirst) + Ufirst = p2d1.X(); + if (p2d1.X() > Ulast) + Ulast = p2d1.X(); + if (p2d2.X() < Ufirst) + Ufirst = p2d2.X(); + if (p2d2.X() > Ulast) + Ulast = p2d2.X(); + } TopTools_ListOfShape NewEdges; TopoDS_Edge FirstEdge; TopTools_ListIteratorOfListOfShape itl(EdgesOfWire); for (; itl.More(); itl.Next()) + { + FirstEdge = TopoDS::Edge(itl.Value()); + Standard_Real f, l; + Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(FirstEdge, aSphSurf, L, f, l); + p2d1 = aC2d->Value(f); + p2d2 = aC2d->Value(l); + if (Abs(p2d1.X() - Ufirst) <= Precision::Confusion()) { - FirstEdge = TopoDS::Edge(itl.Value()); - Standard_Real f, l; - Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(FirstEdge, aSphSurf, L, f, l); - p2d1 = aC2d->Value(f); - p2d2 = aC2d->Value(l); - if (Abs(p2d1.X() - Ufirst) <= Precision::Confusion()) - { - EdgesOfWire.Remove(itl); - break; - } + EdgesOfWire.Remove(itl); + break; } + } NewEdges.Append(FirstEdge); TopoDS_Vertex Vf1, CurVertex; TopExp::Vertices(FirstEdge, Vf1, CurVertex); itl.Initialize(EdgesOfWire); while (itl.More()) + { + const TopoDS_Edge& anEdge = TopoDS::Edge(itl.Value()); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anEdge, V1, V2); + if (V1.IsSame(CurVertex) || V2.IsSame(CurVertex)) { - const TopoDS_Edge& anEdge = TopoDS::Edge(itl.Value()); - TopoDS_Vertex V1, V2; - TopExp::Vertices(anEdge, V1, V2); - if (V1.IsSame(CurVertex) || V2.IsSame(CurVertex)) - { - NewEdges.Append(anEdge); - CurVertex = (V1.IsSame(CurVertex))? V2 : V1; - EdgesOfWire.Remove(itl); - } - else - itl.Next(); + NewEdges.Append(anEdge); + CurVertex = (V1.IsSame(CurVertex))? V2 : V1; + EdgesOfWire.Remove(itl); } - + else + itl.Next(); + } + Standard_Real Vfirst, Vlast; if (p2d1.Y() > 0.) - { - Vfirst = p2d1.Y(); Vlast = M_PI/2.; - } + { + Vfirst = p2d1.Y(); Vlast = M_PI/2.; + } else - { - Vfirst = -M_PI/2.; Vlast = p2d1.Y(); - } + { + Vfirst = -M_PI/2.; Vlast = p2d1.Y(); + } TopoDS_Face NewSphericalFace = BRepLib_MakeFace(aSphSurf, Ufirst, Ulast, Vfirst, Vlast, Precision::Confusion()); TopoDS_Edge OldEdge; for (Explo.Init(NewSphericalFace, TopAbs_EDGE); Explo.More(); Explo.Next()) + { + OldEdge = TopoDS::Edge(Explo.Current()); + if (!BRep_Tool::Degenerated(OldEdge)) { - OldEdge = TopoDS::Edge(Explo.Current()); - if (!BRep_Tool::Degenerated(OldEdge)) - { - BRepAdaptor_Curve2d BAc2d(OldEdge, NewSphericalFace); - p2d1 = BAc2d.Value(BAc2d.FirstParameter()); - p2d2 = BAc2d.Value(BAc2d.LastParameter()); - if (Abs(p2d1.X() - Ufirst) <= Precision::Confusion() && - Abs(p2d2.X() - Ulast) <= Precision::Confusion()) - break; - } + BRepAdaptor_Curve2d BAc2d(OldEdge, NewSphericalFace); + p2d1 = BAc2d.Value(BAc2d.FirstParameter()); + p2d2 = BAc2d.Value(BAc2d.LastParameter()); + if (Abs(p2d1.X() - Ufirst) <= Precision::Confusion() && + Abs(p2d2.X() - Ulast) <= Precision::Confusion()) + break; } + } TopoDS_Vertex V1, V2; TopExp::Vertices(OldEdge, V1, V2); TopTools_ListOfShape LV1, LV2; @@ -2146,431 +2145,51 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() theSubstitutor.Substitute(OldEdge, NewEdges); theSubstitutor.Build(NewSphericalFace); if (theSubstitutor.IsCopied(NewSphericalFace)) - { - const TopTools_ListOfShape& listSh = theSubstitutor.Copy(NewSphericalFace); - NewSphericalFace = TopoDS::Face(listSh.First()); - } - + { + const TopTools_ListOfShape& listSh = theSubstitutor.Copy(NewSphericalFace); + NewSphericalFace = TopoDS::Face(listSh.First()); + } + //Adding NewSphericalFace to the shell Explo.Init( myOffsetShape, TopAbs_SHELL ); TopoDS_Shape theShell = Explo.Current(); theShell.Free( Standard_True ); BB.Add( theShell, NewSphericalFace ); - isSphericalFaceAdded = Standard_True; } - if(isSphericalFaceAdded) + if (myShape.ShapeType() == TopAbs_SOLID || myThickening) { Explo.Init( myOffsetShape, TopAbs_SHELL ); - + if (Explo.More()) { TopoDS_Shape theShell = Explo.Current(); theShell.Closed( Standard_True ); } - } - -/* - //Reconstructing - BRep_Builder BB; - for (i = 1; i <= Cones.Length(); i++) - { - TopoDS_Face Cone = TopoDS::Face( Cones(i) ); - TopoDS_Edge Circ = TopoDS::Edge( Circs(i) ); - TopoDS_Edge Seam = TopoDS::Edge( Seams(i) ); - if (Circ.IsNull()) //case 1 with big offset - { - //ExtraFace is absent - - Handle(Geom_Surface) aSurf = BRep_Tool::Surface( Cone ), OffSurf = aSurf; - - if (aSurf->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface)) - aSurf = (Handle(Geom_OffsetSurface)::DownCast(aSurf))->BasisSurface(); - gp_Cone theCone = (Handle(Geom_ConicalSurface)::DownCast(aSurf))->Cone(); - gp_Pnt apex = theCone.Apex(); - Standard_Real Uapex, Vapex; - ElSLib::Parameters( theCone, apex, Uapex, Vapex ); - if (aSurf->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface)) - apex = OffSurf->Value( Uapex, Vapex ); - - //Making new degenerated edge - Handle(Geom2d_Line) theLine = GCE2d_MakeLine( gp_Pnt2d( 0., Vapex ), gp_Pnt2d( 2.*M_PI, Vapex ) ); - TopoDS_Edge NewEdge; - BB.MakeEdge( NewEdge ); - NewEdge.Orientation(TopAbs_FORWARD); - BB.UpdateEdge( NewEdge, theLine, Cone, Precision::Confusion() ); - BB.Range( NewEdge, 0., 2.*M_PI ); - BB.SameParameter( NewEdge, Standard_True ); - BB.SameRange( NewEdge, Standard_True ); - BB.Degenerated( NewEdge, Standard_True ); - TopoDS_Vertex Apex = BRepLib_MakeVertex( apex ); - BB.Add( NewEdge, Apex.Oriented(TopAbs_FORWARD) ); - BB.Add( NewEdge, Apex.Oriented(TopAbs_REVERSED) ); - - //Reconstructing Seam - Standard_Real f, l, par, cpar; - Handle(Geom2d_Curve) theCurve = BRep_Tool::CurveOnSurface( Seam, Cone, f, l ); - gp_Lin2d aLine = (Handle(Geom2d_Line)::DownCast(theCurve))->Lin2d(); - par = ElCLib::Parameter( aLine, gp_Pnt2d( Uapex, Vapex ) ); - TopoDS_Shape aLocalShape = Seam.Oriented(TopAbs_FORWARD); - TopoDS_Vertex cver = TopExp::LastVertex( TopoDS::Edge(aLocalShape) ); - cpar = BRep_Tool::Parameter( cver, Seam, Cone ); - if (Abs(f-cpar) < Abs(l-cpar)) - BB.Range( Seam, par, l ); - else - BB.Range( Seam, f, par ); - Seam.Free( Standard_True ); - TopoDS_Shape cver1; - TopoDS_Iterator iter( Seam ); - for (; iter.More(); iter.Next()) - { - cver1 = iter.Value(); - if (cver1.IsSame(cver)) - break; - } - BB.Remove( Seam, cver1 ); - if (Abs(f-cpar) < Abs(l-cpar)) - BB.Add( Seam, Apex.Oriented( TopAbs::Compose(Seam.Orientation(),TopAbs_FORWARD) ) ); - else - BB.Add( Seam, Apex.Oriented( TopAbs::Compose(Seam.Orientation(),TopAbs_REVERSED) ) ); - - //Adding NewEdge into Cone - TopoDS_Shape theWire; - for (fexp.Init( Cone, TopAbs_WIRE ); fexp.More(); fexp.Next()) - { - theWire = fexp.Current(); - Standard_Boolean found = Standard_False; - for (iter.Initialize( theWire ); iter.More(); iter.Next()) - { - if (Seam.IsSame( iter.Value() )) - { - found = Standard_True; - break; - } - } - if (found) - break; - } - theWire.Free( Standard_True ); - NewEdge.Orientation( TopAbs::Compose(theWire.Orientation(),TopAbs_REVERSED) ); - BB.Add( theWire, NewEdge ); - } //end of case 1 with big offset - else - { - Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &Circ.TShape()); - if (! TE->Degenerated()) //case 1 - { - //Find ExtraFace - TopoDS_Face ExtraFace; - for (fexp.Init( myOffsetShape, TopAbs_FACE ); fexp.More(); fexp.Next()) - { - ExtraFace = TopoDS::Face( fexp.Current() ); - if (ExtraFace.IsSame( Cone )) - continue; - Standard_Boolean found = Standard_False; - TopExp_Explorer eexp( ExtraFace, TopAbs_EDGE ); - for (; eexp.More(); eexp.Next()) - if (Circ.IsSame( eexp.Current() )) - { - found = Standard_True; - break; - } - if (found) - break; - } - - Handle(Geom_Surface) aSurf = BRep_Tool::Surface( Cone ), OffSurf = aSurf; - if (aSurf->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface)) - aSurf = (Handle(Geom_OffsetSurface)::DownCast(aSurf))->BasisSurface(); - gp_Cone theCone = (Handle(Geom_ConicalSurface)::DownCast(aSurf))->Cone(); - gp_Pnt apex = theCone.Apex(); - Standard_Real Uapex, Vapex; - ElSLib::Parameters( theCone, apex, Uapex, Vapex ); - if (aSurf->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface)) - apex = OffSurf->Value( Uapex, Vapex ); - - //Making new degenerated edge - Handle(Geom2d_Line) theLine = GCE2d_MakeLine( gp_Pnt2d( 0., Vapex ), gp_Pnt2d( 2.*M_PI, Vapex ) ); - TopoDS_Edge NewEdge; - BB.MakeEdge( NewEdge ); - NewEdge.Orientation(TopAbs_FORWARD); - BB.UpdateEdge( NewEdge, theLine, Cone, BRep_Tool::Tolerance( Circ ) ); - BB.Range( NewEdge, 0., 2.*M_PI ); - BB.SameParameter( NewEdge, Standard_True ); - BB.SameRange( NewEdge, Standard_True ); - BB.Degenerated( NewEdge, Standard_True ); - TopoDS_Vertex Apex = BRepLib_MakeVertex( apex ); - BB.Add( NewEdge, Apex.Oriented(TopAbs_FORWARD) ); - BB.Add( NewEdge, Apex.Oriented(TopAbs_REVERSED) ); - - TopoDS_Vertex cver = TopExp::FirstVertex( Circ ); - - //Reconstructing Seam - Standard_Real f, l, par, cpar; - Handle(Geom2d_Curve) theCurve = BRep_Tool::CurveOnSurface( Seam, Cone, f, l ); - gp_Lin2d aLine = (Handle(Geom2d_Line)::DownCast(theCurve))->Lin2d(); - par = ElCLib::Parameter( aLine, gp_Pnt2d( Uapex, Vapex ) ); - cpar = BRep_Tool::Parameter( cver, Seam, Cone ); - if (Abs(f-cpar) < Abs(l-cpar)) - BB.Range( Seam, par, l ); - else - BB.Range( Seam, f, par ); - Seam.Free( Standard_True ); - TopoDS_Shape cver1; - TopoDS_Iterator iter( Seam ); - for (; iter.More(); iter.Next()) - { - cver1 = iter.Value(); - if (cver1.IsSame(cver)) - break; - } - BB.Remove( Seam, cver1 ); - if (Abs(f-cpar) < Abs(l-cpar)) - BB.Add( Seam, Apex.Oriented( TopAbs::Compose(Seam.Orientation(),TopAbs_FORWARD) ) ); - else - BB.Add( Seam, Apex.Oriented( TopAbs::Compose(Seam.Orientation(),TopAbs_REVERSED) ) ); - - //Removing ExtraFace from the shell - fexp.Init( myOffsetShape, TopAbs_SHELL ); - TopoDS_Shape theShell = fexp.Current(); - theShell.Free( Standard_True ); - TopoDS_Shape ExtraFace1; - for (iter.Initialize( theShell ); iter.More(); iter.Next()) - { - ExtraFace1 = iter.Value(); - if (ExtraFace1.IsSame(ExtraFace)) - break; - } - BB.Remove( theShell, ExtraFace1 ); - - //Substitute Circ by NewEdge in Cone - TopoDS_Shape theWire; - TopoDS_Shape Circ1; - for (fexp.Init( Cone, TopAbs_WIRE ); fexp.More(); fexp.Next()) - { - theWire = fexp.Current(); - Standard_Boolean found = Standard_False; - for (iter.Initialize( theWire ); iter.More(); iter.Next()) - { - Circ1 = iter.Value(); - if (Circ1.IsSame(Circ)) - { - found = Standard_True; - break; - } - } - if (found) - break; - } - TopAbs_Orientation Or = Circ1.Orientation(); - theWire.Free( Standard_True ); - BB.Remove( theWire, Circ1 ); - BB.Add( theWire, NewEdge.Oriented(Or) ); - } //end of case 1 - else // Circ is degenerated - { - if (myOffset > 0. && myJoin == GeomAbs_Arc) //case 2 - { - TopoDS_Vertex cver = TopExp::FirstVertex( Circ ); - - TopoDS_Face OrCone = TopoDS::Face( myInitOffsetFace.Root( Cone ) ); - Handle(Geom_Surface) aSurf = BRep_Tool::Surface( OrCone ), OffSurf = aSurf; - if (aSurf->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface)) - aSurf = (Handle(Geom_OffsetSurface)::DownCast(aSurf))->BasisSurface(); - gp_Cone theCone = (Handle(Geom_ConicalSurface)::DownCast(aSurf))->Cone(); - gp_Pnt apex = theCone.Apex(); - if (aSurf->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface)) - { - Standard_Real Uapex, Vapex; - ElSLib::Parameters( theCone, apex, Uapex, Vapex ); - apex = OffSurf->Value( Uapex, Vapex ); - } - - Standard_Real f, l; - Handle(Geom_Curve) ccur = BRep_Tool::Curve( Circ, f, l ); - gp_Ax2 Axe2 = (Handle(Geom_Circle)::DownCast(ccur))->Circ().Position(); - gp_Ax3 Axe3( Axe2 ); - Axe3.SetLocation( apex ); - gp_Sphere theSphere( Axe3, myOffset ); - - gp_Pnt OrPnt = BRep_Tool::Pnt(cver); - Standard_Real Uor, Vor; - ElSLib::Parameters( theSphere, OrPnt, Uor, Vor ); - TopoDS_Face NewFace; - if (Vor > 0.) - NewFace = BRepLib_MakeFace( theSphere, 0., 2.*M_PI, Vor, M_PI/2. ); - else - NewFace = BRepLib_MakeFace( theSphere, 0., 2.*M_PI, -M_PI/2., Vor ); - - //Updating the bound of NewFace - TopoDS_Edge Bound; - TopExp_Explorer eexp( NewFace, TopAbs_EDGE ); - for (; eexp.More(); eexp.Next()) - { - Bound = TopoDS::Edge( eexp.Current() ); - Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &Bound.TShape()); - if (!TE->Degenerated() && !BRepTools::IsReallyClosed( Bound, NewFace )) - break; - } - Handle(Geom2d_Curve) pcurve = BRep_Tool::CurveOnSurface( Circ, Cone, f, l ); - BB.UpdateEdge( Bound, pcurve, Cone, BRep_Tool::Tolerance(Circ) ); - TopoDS_Vertex bver = TopExp::FirstVertex( Bound ); - BB.UpdateVertex( bver, BRep_Tool::Tolerance(cver) ); - - //Updating cver in Seam - TopoDS_Vertex cver1; - TopoDS_Iterator iter( Seam ); - for (; iter.More(); iter.Next()) - { - cver1 = TopoDS::Vertex( iter.Value() ); - if (cver1.IsSame(cver)) - break; - } - TopAbs_Orientation Or = cver1.Orientation(); - Seam.Free( Standard_True ); - BB.Remove( Seam, cver1 ); - BB.Add( Seam, bver.Oriented(Or) ); - - //Substitute Circ by Bound in Cone - TopoDS_Shape theWire; - TopoDS_Shape Circ1; - for (fexp.Init( Cone, TopAbs_WIRE ); fexp.More(); fexp.Next()) - { - theWire = fexp.Current(); - Standard_Boolean found = Standard_False; - for (iter.Initialize( theWire ); iter.More(); iter.Next()) - { - Circ1 = iter.Value(); - if (Circ1.IsSame(Circ)) - { - found = Standard_True; - break; - } - } - if (found) - break; - } - Or = Circ1.Orientation(); - theWire.Free( Standard_True ); - BB.Remove( theWire, Circ1 ); - BB.Add( theWire, Bound.Oriented(Or) ); - - //Adding NewFace to the shell - fexp.Init( myOffsetShape, TopAbs_SHELL ); - TopoDS_Shape theShell = fexp.Current(); - theShell.Free( Standard_True ); - BB.Add( theShell, NewFace ); - - theShell.Closed( Standard_True ); - } //end of case 2 - else // if ((myOffset > 0. && myJoin == GeomAbs_Intersection) || myOffset < 0.) //case 3, 4 - { - Handle(Geom_Surface) aSurf = BRep_Tool::Surface( Cone ), OffSurf = aSurf; - if (aSurf->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface)) - aSurf = (Handle(Geom_OffsetSurface)::DownCast(aSurf))->BasisSurface(); - gp_Cone theCone = (Handle(Geom_ConicalSurface)::DownCast(aSurf))->Cone(); - gp_Pnt apex = theCone.Apex(); - Standard_Real Uapex, Vapex; - ElSLib::Parameters( theCone, apex, Uapex, Vapex ); - if (aSurf->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface)) - apex = OffSurf->Value( Uapex, Vapex ); - - //Making new degenerated edge - Handle(Geom2d_Line) theLine = GCE2d_MakeLine( gp_Pnt2d( 0., Vapex ), gp_Pnt2d( 2.*M_PI, Vapex ) ); - TopoDS_Edge NewEdge; - BB.MakeEdge( NewEdge ); - NewEdge.Orientation(TopAbs_FORWARD); - BB.UpdateEdge( NewEdge, theLine, Cone, BRep_Tool::Tolerance( Circ ) ); - BB.Range( NewEdge, 0., 2.*M_PI ); - BB.SameParameter( NewEdge, Standard_True ); - BB.SameRange( NewEdge, Standard_True ); - BB.Degenerated( NewEdge, Standard_True ); - TopoDS_Vertex Apex = BRepLib_MakeVertex( apex ); - BB.Add( NewEdge, Apex.Oriented(TopAbs_FORWARD) ); - BB.Add( NewEdge, Apex.Oriented(TopAbs_REVERSED) ); - - TopoDS_Vertex cver = TopExp::FirstVertex( Circ ); - - //Reconstructing Seam - Standard_Real f, l, par, cpar; - Handle(Geom2d_Curve) theCurve = BRep_Tool::CurveOnSurface( Seam, Cone, f, l ); - gp_Lin2d aLine = (Handle(Geom2d_Line)::DownCast(theCurve))->Lin2d(); - par = ElCLib::Parameter( aLine, gp_Pnt2d( Uapex, Vapex ) ); - cpar = BRep_Tool::Parameter( cver, Seam, Cone ); - if (Abs(f-cpar) < Abs(l-cpar)) - BB.Range( Seam, par, l ); - else - BB.Range( Seam, f, par ); - Seam.Free( Standard_True ); - TopoDS_Shape cver1; - TopoDS_Iterator iter( Seam ); - for (; iter.More(); iter.Next()) - { - cver1 = iter.Value(); - if (cver1.IsSame(cver)) - break; - } - BB.Remove( Seam, cver1 ); - if (Abs(f-cpar) < Abs(l-cpar)) - BB.Add( Seam, Apex.Oriented( TopAbs::Compose(Seam.Orientation(),TopAbs_FORWARD) ) ); - else - BB.Add( Seam, Apex.Oriented( TopAbs::Compose(Seam.Orientation(),TopAbs_REVERSED) ) ); - - //Substitute Circ by NewEdge in Cone - TopoDS_Shape theWire; - TopoDS_Shape Circ1; - for (fexp.Init( Cone, TopAbs_WIRE ); fexp.More(); fexp.Next()) - { - theWire = fexp.Current(); - Standard_Boolean found = Standard_False; - for (iter.Initialize( theWire ); iter.More(); iter.Next()) - { - Circ1 = iter.Value(); - if (Circ1.IsSame(Circ)) - { - found = Standard_True; - break; - } - } - if (found) - break; - } - TopAbs_Orientation Or = Circ1.Orientation(); - theWire.Free( Standard_True ); - BB.Remove( theWire, Circ1 ); - BB.Add( theWire, NewEdge.Oriented(Or) ); - - fexp.Init( myOffsetShape, TopAbs_SHELL ); - TopoDS_Shape theShell = fexp.Current(); - theShell.Closed( Standard_True ); - } //end of case 3, 4 - } - } //else (! Circ.IsNull()) - } -*/ - - Standard_Integer NbShell = 0; - TopoDS_Compound NC; - TopoDS_Shape S1; - BB.MakeCompound (NC); - - for (Explo.Init(myOffsetShape,TopAbs_SHELL); Explo.More(); Explo.Next()) { - const TopoDS_Shell& Sh = TopoDS::Shell(Explo.Current()); - NbShell++; - if (Sh.Closed()) { - TopoDS_Solid Sol; - BB.MakeSolid (Sol); - BB.Add (Sol,Sh); - Sol.Closed(Standard_True); - BB.Add (NC,Sol); - if (NbShell == 1) S1 = Sol; - } - else { - BB.Add (NC,Sh); - if (NbShell == 1) S1 = Sh; + + Standard_Integer NbShell = 0; + TopoDS_Compound NC; + TopoDS_Shape S1; + BB.MakeCompound (NC); + + for (Explo.Init(myOffsetShape,TopAbs_SHELL); Explo.More(); Explo.Next()) { + const TopoDS_Shell& Sh = TopoDS::Shell(Explo.Current()); + NbShell++; + if (Sh.Closed()) { + TopoDS_Solid Sol; + BB.MakeSolid (Sol); + BB.Add (Sol,Sh); + Sol.Closed(Standard_True); + BB.Add (NC,Sol); + if (NbShell == 1) S1 = Sol; + } + else { + BB.Add (NC,Sh); + if (NbShell == 1) S1 = Sh; + } } + if (NbShell == 1) myOffsetShape = S1; + else myOffsetShape = NC; } - if (NbShell == 1) myOffsetShape = S1; - else myOffsetShape = NC; } @@ -2581,7 +2200,7 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() void BRepOffset_MakeOffset::Intersection3D(BRepOffset_Inter3d& Inter) { -#ifdef DEB +#ifdef OCCT_DEBUG if (ChronBuild) { cout << " INTERSECTION 3D:" << endl; Clock.Reset(); @@ -2615,7 +2234,7 @@ void BRepOffset_MakeOffset::Intersection3D(BRepOffset_Inter3d& Inter) //-------------------------------- Inter.ConnexIntByArc(OffsetFaces,myShape,myAnalyse,myInitOffsetFace); } -#ifdef DEB +#ifdef OCCT_DEBUG if ( ChronBuild) Clock.Show(); #endif } @@ -2628,7 +2247,7 @@ void BRepOffset_MakeOffset::Intersection3D(BRepOffset_Inter3d& Inter) void BRepOffset_MakeOffset::Intersection2D(const TopTools_IndexedMapOfShape& Modif, const TopTools_IndexedMapOfShape& NewEdges) { -#ifdef DEB +#ifdef OCCT_DEBUG if (ChronBuild) { cout << " INTERSECTION 2D:" << endl; Clock.Reset(); @@ -2649,7 +2268,7 @@ void BRepOffset_MakeOffset::Intersection2D(const TopTools_IndexedMapOfShape& Mod BRepOffset_Inter2d::Compute(myAsDes,F,NewEdges,myTol); } -#ifdef DEB +#ifdef OCCT_DEBUG if (AffichInt2d) { DEBVerticesControl (NewEdges,myAsDes); } @@ -2665,7 +2284,7 @@ void BRepOffset_MakeOffset::Intersection2D(const TopTools_IndexedMapOfShape& Mod void BRepOffset_MakeOffset::MakeLoops(TopTools_IndexedMapOfShape& Modif) { -#ifdef DEB +#ifdef OCCT_DEBUG if (ChronBuild) { cout << " DEBOUCLAGE 2D:" << endl; Clock.Reset(); @@ -2694,7 +2313,7 @@ void BRepOffset_MakeOffset::MakeLoops(TopTools_IndexedMapOfShape& Modif) if (myOffset > 0 ) InSide = 0; myMakeLoops.BuildOnContext(LC,myAnalyse,myAsDes,myImageOffset,InSide); -#ifdef DEB +#ifdef OCCT_DEBUG if ( ChronBuild) Clock.Show(); #endif } @@ -2707,7 +2326,7 @@ void BRepOffset_MakeOffset::MakeLoops(TopTools_IndexedMapOfShape& Modif) void BRepOffset_MakeOffset::MakeFaces(TopTools_IndexedMapOfShape& /*Modif*/) { -#ifdef DEb +#ifdef OCCT_DEBUG if (ChronBuild) { cout << " RECONSTRUCTION OF FACES:" << endl; Clock.Reset(); @@ -2726,7 +2345,7 @@ void BRepOffset_MakeOffset::MakeFaces(TopTools_IndexedMapOfShape& /*Modif*/) } myMakeLoops.BuildFaces(LOF,myAsDes,myImageOffset); -#ifdef DEB +#ifdef OCCT_DEBUG if ( ChronBuild) Clock.Show(); #endif } @@ -3148,7 +2767,7 @@ void BRepOffset_MakeOffset::MakeMissingWalls () void BRepOffset_MakeOffset::MakeShells () { -#ifdef DEB +#ifdef OCCT_DEBUG if (ChronBuild) { cout << " RECONSTRUCTION OF SHELLS:" << endl; Clock.Reset(); @@ -3307,7 +2926,7 @@ const TopTools_IndexedMapOfShape& BRepOffset_MakeOffset::ClosingFaces () const void BRepOffset_MakeOffset::EncodeRegularity () { -#ifdef DEB +#ifdef OCCT_DEBUG if (ChronBuild) { cout << " CODING OF REGULARITIES:" << endl; Clock.Reset(); @@ -3335,7 +2954,7 @@ void BRepOffset_MakeOffset::EncodeRegularity () const TopTools_ListOfShape& LofOF = myAsDes->Ascendant(ROE); if (LofOF.Extent() != 2) { -#ifdef DEB_VERB +#ifdef OCCT_DEBUG_VERB cout << " Edge shared by " << LofOF.Extent() << " Faces" << endl; #endif continue; @@ -3478,7 +3097,7 @@ void BRepOffset_MakeOffset::EncodeRegularity () } } -#ifdef DEB +#ifdef OCCT_DEBUG if ( ChronBuild) Clock.Show(); #endif } -- 2.39.5