From: jgv Date: Tue, 25 Apr 2017 13:56:13 +0000 (+0300) Subject: Intermediate version X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=888d6f9df6a58b3faa69c35567cbdbc6ee51a337;p=occt-copy.git Intermediate version --- diff --git a/src/ChFi3d/ChFi3d_Builder.hxx b/src/ChFi3d/ChFi3d_Builder.hxx index 238c0b850d..d94cb96919 100644 --- a/src/ChFi3d/ChFi3d_Builder.hxx +++ b/src/ChFi3d/ChFi3d_Builder.hxx @@ -30,11 +30,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include class TopOpeBRepDS_HDataStructure; @@ -70,6 +72,23 @@ class TopoDS_Face; class AppBlend_Approx; class Geom2d_Curve; +struct QualifiedEdge +{ + Standard_Integer Index; + TopAbs_Orientation Orientation; + BRepOffset_Type Convexity; + + QualifiedEdge(Standard_Integer theIndex, + TopAbs_Orientation theOrientation, + BRepOffset_Type theConvexity) + : Index(theIndex), + Orientation(theOrientation), + Convexity(theConvexity) + { + } +}; + +typedef NCollection_List ChFi3d_ListOfQualifiedEdge; //! Root class for calculation of surfaces (fillets, //! chamfers) destined to smooth edges of @@ -304,6 +323,11 @@ protected: ChFiDS_Map myVFMap; ChFiDS_Map myVEMap; Handle(TopOpeBRepDS_HDataStructure) myDS; + //TopTools_IndexedDataMapOfShapeListOfShape myFaceNewEdges; + //NCollection_IndexedDataMap myFaceNewEdges; + NCollection_IndexedDataMap myFaceNewEdges; + TopTools_IndexedMapOfShape myNewFaces; + TopTools_IndexedMapOfShape myNewEdges; Handle(TopOpeBRepBuild_HBuilder) myCoup; ChFiDS_ListOfStripe myListStripe; ChFiDS_StripeMap myVDataMap; diff --git a/src/ChFi3d/ChFi3d_Builder_0.cxx b/src/ChFi3d/ChFi3d_Builder_0.cxx index fd166d3442..bc48e9bb54 100644 --- a/src/ChFi3d/ChFi3d_Builder_0.cxx +++ b/src/ChFi3d/ChFi3d_Builder_0.cxx @@ -90,6 +90,7 @@ #include #include #include +#include #include #include #include @@ -192,6 +193,211 @@ Standard_Real ChFi3d_InPeriod(const Standard_Real U, if ( u < UFirst) u = UFirst; return u; } + +//======================================================================= +//function : ChFi3d_AdjustSecondPointToFirstPoint +//purpose : +//======================================================================= +void ChFi3d_AdjustSecondPointToFirstPoint(const gp_Pnt2d& theFirstPoint, + gp_Pnt2d& theSecondPoint, + const BRepAdaptor_Surface& theSurf) +{ + if (theSurf.IsUPeriodic()) + { + Standard_Real UPeriod = theSurf.UPeriod(); + Standard_Real NewU = ElCLib::InPeriod(theSecondPoint.X(), + theFirstPoint.X() - UPeriod/2, + theFirstPoint.X() + UPeriod/2); + theSecondPoint.SetX(NewU); + } + if (theSurf.IsVPeriodic()) + { + Standard_Real VPeriod = theSurf.VPeriod(); + Standard_Real NewV = ElCLib::InPeriod(theSecondPoint.Y(), + theFirstPoint.Y() - VPeriod/2, + theFirstPoint.Y() + VPeriod/2); + theSecondPoint.SetY(NewV); + } +} + +//======================================================================= +//function : ChFi3d_SplitAndAdjust +//purpose : +//======================================================================= +void ChFi3d_SplitAndAdjust(const TopTools_ListOfShape& theElist, + TopTools_ListOfShape& theNewElist, + const BRepAdaptor_Surface& theBAsurf) +{ + TopoDS_Face aFace = theBAsurf.Face(); + Handle(Geom_Surface) aSurf, aBasisSurf; + TopLoc_Location aLoc; + aSurf = BRep_Tool::Surface(aFace, aLoc); + aBasisSurf = aSurf; + if (aSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + aBasisSurf = (Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurf))->BasisSurface(); + + if (!aBasisSurf->IsUClosed() && !aBasisSurf->IsVClosed()) + return; + + TColGeom2d_SequenceOfCurve Boundaries; + Standard_Real Ubounds [2], Vbounds [2]; + aSurf->Bounds(Ubounds[0], Ubounds[1], Vbounds[0], Vbounds[1]); + for (Standard_Integer i = 0; i < 2; i++) + if (!Precision::IsInfinite(Ubounds[i])) + { + gp_Pnt2d Origin(Ubounds[i], 0.); + Handle(Geom2d_Curve) aLine = new Geom2d_Line(Origin, gp::DY2d()); + if (!Precision::IsInfinite(Vbounds[0]) || !Precision::IsInfinite(Vbounds[1])) + aLine = new Geom2d_TrimmedCurve(aLine, Vbounds[0], Vbounds[1]); + Boundaries.Append(aLine); + } + for (Standard_Integer i = 0; i < 2; i++) + if (!Precision::IsInfinite(Vbounds[i])) + { + gp_Pnt2d Origin(0., Vbounds[i]); + Handle(Geom2d_Curve) aLine = new Geom2d_Line(Origin, gp::DX2d()); + if (!Precision::IsInfinite(Ubounds[0]) || !Precision::IsInfinite(Ubounds[1])) + aLine = new Geom2d_TrimmedCurve(aLine, Ubounds[0], Ubounds[1]); + Boundaries.Append(aLine); + } + + Geom2dInt_GInter Intersector; + BRep_Builder BB; + TopTools_ListIteratorOfListOfShape itl(theElist); + for (; itl.More(); itl.Next()) + { + TopoDS_Edge anEdge = TopoDS::Edge(itl.Value()); + TopAbs_Orientation anOr = anEdge.Orientation(); + Standard_Real aTol = BRep_Tool::Tolerance(anEdge); + TColStd_SequenceOfReal Params; + Standard_Real fpar, lpar; + Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(anEdge, aFace, fpar, lpar); + Geom2dAdaptor_Curve aGAcurve(aPCurve, fpar, lpar); + Standard_Real LeftTol = Precision::PConfusion(), RightTol = Precision::PConfusion(); + BRepAdaptor_Curve BAcurve(anEdge); + gp_Pnt FirstPnt = BAcurve.Value(fpar); + gp_Pnt LastPnt = BAcurve.Value(lpar); + Standard_Real Offset = 0.01*(lpar - fpar); + gp_Pnt PntOffset = BAcurve.Value(fpar + Offset); + Standard_Real dist3d = FirstPnt.Distance(PntOffset); + if (dist3d > gp::Resolution()) + LeftTol = Offset*aTol/dist3d; + PntOffset = BAcurve.Value(lpar - Offset); + dist3d = LastPnt.Distance(PntOffset); + if (dist3d > gp::Resolution()) + RightTol = Offset*aTol/dist3d; + for (Standard_Integer i = 1; i <= Boundaries.Length(); i++) + { + Geom2dAdaptor_Curve aGAboundary(Boundaries(i)); + Intersector.Perform(aGAcurve, aGAboundary, + Precision::PIntersection(), + Precision::PIntersection()); + if (Intersector.IsDone() && !Intersector.IsEmpty()) + { + for (Standard_Integer j = 1; j <= Intersector.NbPoints(); j++) + { + IntRes2d_IntersectionPoint int2d = Intersector.Point(j); + Standard_Real aParam = int2d.ParamOnFirst(); + if (Abs(aParam - fpar) > LeftTol && + Abs(aParam - lpar) > RightTol) + Params.Append(aParam); + } + for (Standard_Integer j = 1; j <= Intersector.NbSegments(); j++) + { + IntRes2d_IntersectionSegment seg2d = Intersector.Segment(j); + IntRes2d_IntersectionPoint int2d = seg2d.FirstPoint(); + Standard_Real aParam = int2d.ParamOnFirst(); + if (Abs(aParam - fpar) > LeftTol && + Abs(aParam - lpar) > RightTol) + Params.Append(aParam); + int2d = seg2d.LastPoint(); + aParam = int2d.ParamOnFirst(); + if (Abs(aParam - fpar) > LeftTol && + Abs(aParam - lpar) > RightTol) + Params.Append(aParam); + } + } + } //for (Standard_Integer i = 1; i <= Boundaries.Length(); i++) + + //Sort parameters + for (Standard_Integer i = 1; i < Params.Length(); i++) + for (Standard_Integer j = i+1; j <= Params.Length(); j++) + if (Params(i) > Params(j)) + { Standard_Real tmp = Params(i); Params(i) = Params(j); Params(j) = tmp; } + //Delete duplicating parameters + Standard_Real ParamTol = Max(LeftTol, RightTol); + Standard_Integer i = 2; + while (i <= Params.Length()) + if (Params(i) - Params(i-1) > ParamTol) + Params.Remove(i); + else + i++; + + //Split + TopoDS_Vertex FirstVertex = TopExp::FirstVertex(anEdge), LastVertex; + Standard_Real FirstPar = fpar, LastPar; + for (i = 1; i <= Params.Length(); i++) + { + LastPar = Params(i); + TopoDS_Edge aNewEdge = TopoDS::Edge(anEdge.EmptyCopied()); + aNewEdge.Orientation(TopAbs_FORWARD); + BB.Range(aNewEdge, FirstPar, LastPar); + gp_Pnt LastPnt = BAcurve.Value(LastPar); + LastVertex = BRepLib_MakeVertex(LastPnt); + BB.UpdateVertex(LastVertex, ParamTol); + BB.Add(aNewEdge, FirstVertex.Oriented(TopAbs_FORWARD)); + BB.Add(aNewEdge, LastVertex.Oriented(TopAbs_REVERSED)); + aNewEdge.Orientation(anOr); + BB.UpdateEdge(aNewEdge, aTol); + theNewElist.Append(aNewEdge); + FirstVertex = LastVertex; + FirstPar = LastPar; + } + LastPar = lpar; + LastVertex = TopExp::LastVertex(anEdge); + TopoDS_Edge aNewEdge = TopoDS::Edge(anEdge.EmptyCopied()); + aNewEdge.Orientation(TopAbs_FORWARD); + BB.Range(aNewEdge, FirstPar, LastPar); + BB.Add(aNewEdge, FirstVertex.Oriented(TopAbs_FORWARD)); + BB.Add(aNewEdge, LastVertex.Oriented(TopAbs_REVERSED)); + aNewEdge.Orientation(anOr); + BB.UpdateEdge(aNewEdge, aTol); + theNewElist.Append(aNewEdge); + } + + if (theNewElist.IsEmpty()) + theNewElist.Assign(theElist); + + //Adjust + for (itl.Initialize(theNewElist); itl.More(); itl.Next()) + { + TopoDS_Edge anEdge = TopoDS::Edge(itl.Value()); + Standard_Real fpar, lpar; + Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(anEdge, aFace, fpar, lpar); + gp_Pnt2d MidP2d = aPCurve->Value(0.5*(fpar + lpar)); + Standard_Real aU = MidP2d.X(), aV = MidP2d.Y(); + if (aU < Ubounds[0] || aU > Ubounds[1]) + { + Standard_Real Period = Ubounds[1] - Ubounds[0]; + Standard_Real Sign = (aU < Ubounds[0])? 1 : -1; + while (aU < Ubounds[0] || aU > Ubounds[1]) + aU += Sign*Period; + } + if (aV < Vbounds[0] || aV > Vbounds[1]) //??? sphere? cone? + { + Standard_Real Period = Vbounds[1] - Vbounds[0]; + Standard_Real Sign = (aV < Vbounds[0])? 1 : -1; + while (aV < Vbounds[0] || aV > Vbounds[1]) + aV += Sign*Period; + } + if (aU != MidP2d.X() || aV != MidP2d.Y()) + { + gp_Vec2d OffsetVec(aU - MidP2d.X(), aV - MidP2d.Y()); + aPCurve->Translate(OffsetVec); + } + } +} + //======================================================================= //function : Box //purpose : Calculation of min/max uv of the fillet to intersect. diff --git a/src/ChFi3d/ChFi3d_Builder_0.hxx b/src/ChFi3d/ChFi3d_Builder_0.hxx index f6c6af4046..8ec8dede5b 100644 --- a/src/ChFi3d/ChFi3d_Builder_0.hxx +++ b/src/ChFi3d/ChFi3d_Builder_0.hxx @@ -81,6 +81,14 @@ Standard_Real ChFi3d_InPeriod(const Standard_Real U, const Standard_Real ULast, const Standard_Real Eps); +void ChFi3d_AdjustSecondPointToFirstPoint(const gp_Pnt2d& theFirstPoint, + gp_Pnt2d& theSecondPoint, + const BRepAdaptor_Surface& theSurf); + +void ChFi3d_SplitAndAdjust(const TopTools_ListOfShape& theElist, + TopTools_ListOfShape& theNewElist, + const BRepAdaptor_Surface& theBAsurf); + void ChFi3d_Boite(const gp_Pnt2d& p1,const gp_Pnt2d& p2, Standard_Real& mu,Standard_Real& Mu, Standard_Real& mv,Standard_Real& Mv); diff --git a/src/ChFi3d/ChFi3d_Builder_C1.cxx b/src/ChFi3d/ChFi3d_Builder_C1.cxx index b63ad08337..6ef8f18453 100644 --- a/src/ChFi3d/ChFi3d_Builder_C1.cxx +++ b/src/ChFi3d/ChFi3d_Builder_C1.cxx @@ -140,6 +140,7 @@ #include #include #include +//#include #ifdef OCCT_DEBUG # ifdef DRAW @@ -621,6 +622,7 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, BRepAdaptor_Surface& Bs = HBs->ChangeSurface(); BRepAdaptor_Surface& Bad = HBad->ChangeSurface(); BRepAdaptor_Surface& Bop = HBop->ChangeSurface(); + TopoDS_Edge aNewEdge; Handle(Geom_Curve) Cc; Handle(Geom2d_Curve) Pc,Ps; Standard_Real Ubid,Vbid;//,mu,Mu,mv,Mv; @@ -631,6 +633,7 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, Standard_Integer IFadArc = 1, IFopArc = 2; Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc))); TopExp_Explorer ex; + BRep_Builder BB; #ifdef OCCT_DEBUG ChFi3d_InitChron(ch); // init perf condition if (onsame) @@ -731,12 +734,11 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, TopoDS_Face FFv; Standard_Real tol; Standard_Integer prol=0; - BRep_Builder BRE; Handle(Geom_Surface ) Sface; Sface=BRep_Tool::Surface(Fv); ChFi3d_ExtendSurface(Sface,prol); tol=BRep_Tool::Tolerance(Fv); - BRE.MakeFace(FFv,Sface,tol); + BB.MakeFace(FFv,Sface,tol); if (prol) { Bs.Initialize(FFv,Standard_False); DStr.SetNewSurface(Fv,Sface); @@ -857,6 +859,21 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, Pc,tolesp,tol2d,tolreached)) throw Standard_Failure("OneCorner : echec calcul intersection"); + //jgv + aNewEdge = BRepLib_MakeEdge(Cc); + BB.UpdateEdge(aNewEdge, tolreached); + TopLoc_Location aLoc; + BB.UpdateEdge(aNewEdge, Ps, DStr.Surface(Fd->Surf()).Surface(), aLoc, 0.); + /* + Handle(Geom2d_Curve) AdjustedPc; + BOPTools_AlgoTools2D::AdjustPCurveOnSurf(Bs, Cc->FirstParameter(), Cc->LastParameter(), + Pc, AdjustedPc); + Pc = AdjustedPc; + */ + BB.UpdateEdge(aNewEdge, Pc, Bs.Face(), 0.); + myNewEdges.Add(aNewEdge); + ///// + Udeb = Cc->FirstParameter(); Ufin = Cc->LastParameter(); @@ -933,11 +950,20 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, break; } } + } -// - - + Standard_Integer IndFv; + if (!myNewFaces.Contains(Fv)) + myNewFaces.Add(Fv); + IndFv = myNewFaces.FindIndex(Fv); + if (!myFaceNewEdges.Contains(IndFv)) + { + ChFi3d_ListOfQualifiedEdge aList; + myFaceNewEdges.Add(IndFv, aList); } + Standard_Integer IndE = myNewEdges.FindIndex(aNewEdge); + QualifiedEdge aQE(IndE, Et, BRepOffset_Convex); + myFaceNewEdges.ChangeFromKey(IndFv).Append(aQE); #ifdef OCCT_DEBUG ChFi3d_ResultChron(ch ,t_inter); //result perf condition if (inter) @@ -1246,6 +1272,7 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, Hc = BRep_Tool::CurveOnSurface(Arcprol,Fop,Ubid,Ubid); pop1 = Hc->Value(parVtx); pop2 = Fiop.PCurveOnFace()->Value(Fiop.Parameter(isfirst)); + ChFi3d_AdjustSecondPointToFirstPoint(pop1, pop2, Bop); Hc = BRep_Tool::CurveOnSurface(Arcprol,Fv,Ubid,Ubid); pv1 = Hc->Value(parVtx); pv2 = p2dbout; @@ -1268,6 +1295,31 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, zob2dv,tolesp,tol2d,tolreached)) throw Standard_Failure("OneCorner : echec calcul intersection"); + //jgv + TopoDS_Vertex CommonVertexForNewEdgeAndZobEdge = TopExp::FirstVertex(aNewEdge); + TopoDS_Edge aZobEdge = BRepLib_MakeEdge(zob3d, Vtx, CommonVertexForNewEdgeAndZobEdge); + BB.UpdateEdge(aZobEdge, tolreached); + /* + Handle(Geom2d_Curve) AdjustedZob2dop; + BOPTools_AlgoTools2D::AdjustPCurveOnSurf(Bop, zob3d->FirstParameter(), zob3d->LastParameter(), + zob2dop, AdjustedZob2dop); + zob2dop = AdjustedZob2dop; + */ + BB.UpdateEdge(aZobEdge, zob2dop, Bop.Face(), 0.); + /* + Handle(Geom2d_Curve) AdjustedZob2dv; + BOPTools_AlgoTools2D::AdjustPCurveOnSurf(Bs, zob3d->FirstParameter(), zob3d->LastParameter(), + zob2dv, AdjustedZob2dv); + zob2dv = AdjustedZob2dv; + */ + BB.UpdateEdge(aZobEdge, zob2dv, Bs.Face(), 0.); + TopTools_ListOfShape aZobList, aNewZobList; + aZobList.Append(aZobEdge); + ChFi3d_SplitAndAdjust(aZobList, aNewZobList, Bop); + TopTools_ListIteratorOfListOfShape itl(aNewZobList); + for (; itl.More(); itl.Next()) + myNewEdges.Add(itl.Value()); + Udeb = zob3d->FirstParameter(); Ufin = zob3d->LastParameter(); TopOpeBRepDS_Curve Zob(zob3d,tolreached); @@ -1353,6 +1405,11 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, } else { Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolv)); + + Standard_Integer IndZobE = myNewEdges.FindIndex(aZobEdge); + QualifiedEdge aQzobE(IndZobE, Et, BRepOffset_Convex); + myFaceNewEdges.ChangeFromKey(IndFv).Append(aQzobE); + Handle(TopOpeBRepDS_SurfaceCurveInterference) InterFv = ChFi3d_FilCurveInDS(IZob,IShape,zob2dv,Et); DStr.ChangeShapeInterferences(IShape).Append(InterFv);