#include <ChFiDS_Regularities.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_DataMapOfShapeListOfInteger.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <ChFiDS_ErrorStatus.hxx>
#include <math_Vector.hxx>
#include <TopAbs_Orientation.hxx>
+#include <BRepOffset_Type.hxx>
#include <ChFiDS_SequenceOfSurfData.hxx>
#include <TopAbs_State.hxx>
class TopOpeBRepDS_HDataStructure;
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<QualifiedEdge> ChFi3d_ListOfQualifiedEdge;
//! Root class for calculation of surfaces (fillets,
//! chamfers) destined to smooth edges of
ChFiDS_Map myVFMap;
ChFiDS_Map myVEMap;
Handle(TopOpeBRepDS_HDataStructure) myDS;
+ //TopTools_IndexedDataMapOfShapeListOfShape myFaceNewEdges;
+ //NCollection_IndexedDataMap<Standard_Integer, TColStd_ListOfInteger> myFaceNewEdges;
+ NCollection_IndexedDataMap<Standard_Integer, ChFi3d_ListOfQualifiedEdge> myFaceNewEdges;
+ TopTools_IndexedMapOfShape myNewFaces;
+ TopTools_IndexedMapOfShape myNewEdges;
Handle(TopOpeBRepBuild_HBuilder) myCoup;
ChFiDS_ListOfStripe myListStripe;
ChFiDS_StripeMap myVDataMap;
#include <BRepTools.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <BRepLib.hxx>
+#include <BRepLib_MakeVertex.hxx>
#include <BRepLib_MakeEdge.hxx>
#include <BRepLib_MakeWire.hxx>
#include <BRepLib_MakeFace.hxx>
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.
#include <TopOpeBRepDS_Transition.hxx>
#include <TopTools_Array1OfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
+//#include <BOPTools_AlgoTools2D.hxx>
#ifdef OCCT_DEBUG
# ifdef DRAW
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;
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)
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);
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();
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)
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;
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);
}
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);