// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <BOPTools_AlgoTools2D.ixx>
-#include <Standard_NotImplemented.hxx>
-#include <Precision.hxx>
-#include <gp.hxx>
-
-#include <gp_Pnt.hxx>
-#include <gp_Pnt2d.hxx>
-#include <gp_Vec.hxx>
-#include <gp_Vec2d.hxx>
-
-#include <Geom2d_Curve.hxx>
-#include <Geom2d_Line.hxx>
+#include <BOPTools_AlgoTools2D.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_CurveRepresentation.hxx>
+#include <BRep_GCurve.hxx>
+#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
+#include <BRep_TEdge.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepAdaptor_HSurface.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepClass_FaceClassifier.hxx>
+#include <BRepTools.hxx>
+#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_Circle.hxx>
+#include <Geom2d_Curve.hxx>
#include <Geom2d_Ellipse.hxx>
-#include <Geom2d_Parabola.hxx>
#include <Geom2d_Hyperbola.hxx>
+#include <Geom2d_Line.hxx>
+#include <Geom2d_Parabola.hxx>
#include <Geom2d_TrimmedCurve.hxx>
-
#include <Geom2dAdaptor.hxx>
-
#include <Geom_Curve.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <Geom_Surface.hxx>
#include <Geom_Plane.hxx>
-
-#include <GeomAdaptor_Surface.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_TrimmedCurve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <GeomAdaptor_HSurface.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_RectangularTrimmedSurface.hxx>
-
+#include <GeomAdaptor_Surface.hxx>
+#include <GeomInt.hxx>
+#include <GeomLib.hxx>
#include <GeomProjLib.hxx>
-
-#include <TopLoc_Location.hxx>
-#include <TopExp.hxx>
-
-#include <ProjLib_ProjectedCurve.hxx>
-
-#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
-#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
-#include <BRep_TEdge.hxx>
-#include <BRep_CurveRepresentation.hxx>
-#include <BRep_GCurve.hxx>
-
-#include <BRepAdaptor_HSurface.hxx>
-
-#include <BRepAdaptor_Curve.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepClass_FaceClassifier.hxx>
-
-#include <BRepTools.hxx>
-
-#include <BOPCol_IndexedMapOfShape.hxx>
-
-#include <BOPTools.hxx>
-#include <IntTools_Tools.hxx>
+#include <gp.hxx>
#include <gp_Cylinder.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_Vec.hxx>
+#include <gp_Vec2d.hxx>
+#include <IntTools_Context.hxx>
+#include <IntTools_Tools.hxx>
+#include <Precision.hxx>
+#include <ProjLib_ProjectedCurve.hxx>
+#include <ProjLib.hxx>
+#include <Standard_ConstructionError.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
-#include <GeomInt.hxx>
-
-static
- Standard_Boolean CheckEdgeLength (const TopoDS_Edge& );
+#include <TopLoc_Location.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
-static
- Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface(const TopoDS_Edge& ,
- const TopoDS_Face& ,
- Standard_Real& ,
- Standard_Real& ,
- Standard_Boolean& );
-static
- Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface(const TopoDS_Edge& ,
- const Handle(Geom_Surface)& ,
- const TopLoc_Location& ,
- Standard_Real& ,
- Standard_Real& ,
- Standard_Boolean& );
static
Standard_Real MaxToleranceEdge (const TopoDS_Face& );
//purpose :
//=======================================================================
void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE,
- const TopoDS_Face& aF)
+ const TopoDS_Face& aF,
+ const Handle(IntTools_Context)& theContext)
{
BRep_Builder aBB;
Handle(Geom2d_Curve) aC2D;
}
- BOPTools_AlgoTools2D::CurveOnSurface(aE, aF, aC2D, aTolPC);
+ BOPTools_AlgoTools2D::CurveOnSurface(aE, aF, aC2D, aTolPC, theContext);
aTolEdge=BRep_Tool::Tolerance(aE);
if (isdgE) {
return Standard_False;
}
- if (!CheckEdgeLength(anEdge)) {
- return Standard_False;
- }
Handle(Geom_Curve) aC=BRep_Tool::Curve(anEdge, first, last);
gp_Pnt aP;
const TopoDS_Face& aF,
const Standard_Real aParameter,
Standard_Real& U,
- Standard_Real& V)
+ Standard_Real& V,
+ const Handle(IntTools_Context)& theContext)
{
gp_Pnt2d aP2D;
Handle(Geom2d_Curve) aC2D;
Standard_Real aToler, aFirst, aLast;
- BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D,
- aFirst, aLast, aToler);
+ BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, aFirst, aLast, aToler, theContext);
aC2D->D0(aParameter, aP2D);
U=aP2D.X();
V=aP2D.Y();
void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
const TopoDS_Face& aF,
Handle(Geom2d_Curve)& aC2D,
- Standard_Real& aToler)
+ Standard_Real& aToler,
+ const Handle(IntTools_Context)& theContext)
{
Standard_Real aFirst, aLast;
//
- BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D,
- aFirst, aLast, aToler);
+ BOPTools_AlgoTools2D::CurveOnSurface(aE, aF, aC2D, aFirst, aLast, aToler, theContext);
//
return;
}
Handle(Geom2d_Curve)& aC2D,
Standard_Real& aFirst,
Standard_Real& aLast,
- Standard_Real& aToler)
+ Standard_Real& aToler,
+ const Handle(IntTools_Context)& theContext)
{
Standard_Boolean aHasOld;
Handle(Geom2d_Curve) C2D;
return;
}
- BOPTools_AlgoTools2D::Make2D(aE, aF, C2D, aFirst, aLast, aToler);
+ BOPTools_AlgoTools2D::Make2D(aE, aF, C2D, aFirst, aLast, aToler, theContext);
aC2D=C2D;
return;
}
Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface
(const TopoDS_Edge& aE,
const TopoDS_Face& aF)
-
{
Standard_Boolean bHasOld;
Handle(Geom2d_Curve) aC2D;
//function : AdjustPCurveOnFace
//purpose :
//=======================================================================
-void BOPTools_AlgoTools2D::AdjustPCurveOnFace
- (const TopoDS_Face& aF,
- const Handle(Geom_Curve)& aC3D,
- const Handle(Geom2d_Curve)& aC2D,
- Handle(Geom2d_Curve)& aC2DA)
+void BOPTools_AlgoTools2D::AdjustPCurveOnFace
+ (const TopoDS_Face& theF,
+ const Handle(Geom_Curve)& theC3D,
+ const Handle(Geom2d_Curve)& theC2D,
+ Handle(Geom2d_Curve)& theC2DA,
+ const Handle(IntTools_Context)& theContext)
{
- Standard_Real first, last;
-
- first = aC3D -> FirstParameter();
- last = aC3D -> LastParameter();
-
- BOPTools_AlgoTools2D::AdjustPCurveOnFace (aF, first, last, aC2D, aC2DA);
-}
+ Standard_Real aT1 = theC3D->FirstParameter();
+ Standard_Real aT2 = theC3D->LastParameter();
+ //
+ BOPTools_AlgoTools2D::AdjustPCurveOnFace (theF, aT1, aT2, theC2D, theC2DA, theContext);
+}
//=======================================================================
//function : AdjustPCurveOnFace
//purpose :
//=======================================================================
void BOPTools_AlgoTools2D::AdjustPCurveOnFace
- (const TopoDS_Face& aF,
+ (const TopoDS_Face& theF,
+ const Standard_Real theFirst,
+ const Standard_Real theLast,
+ const Handle(Geom2d_Curve)& theC2D,
+ Handle(Geom2d_Curve)& theC2DA,
+ const Handle(IntTools_Context)& theContext)
+{
+ BRepAdaptor_Surface aBASTmp;
+ const BRepAdaptor_Surface* pBAS;
+ if (!theContext.IsNull()) {
+ pBAS = &theContext->SurfaceAdaptor(theF);
+ }
+ else {
+ aBASTmp.Initialize(theF, Standard_True);
+ pBAS = &aBASTmp;
+ }
+ //
+ BOPTools_AlgoTools2D::AdjustPCurveOnSurf(*pBAS, theFirst, theLast, theC2D, theC2DA);
+}
+//=======================================================================
+//function : AdjustPCurveOnFace
+//purpose :
+//=======================================================================
+void BOPTools_AlgoTools2D::AdjustPCurveOnSurf
+ (const BRepAdaptor_Surface& aBAS,
const Standard_Real aFirst,
const Standard_Real aLast,
- const Handle(Geom2d_Curve)& aC2D,
+ const Handle(Geom2d_Curve)& aC2D,
Handle(Geom2d_Curve)& aC2DA)
{
Standard_Boolean mincond, maxcond;
Standard_Real UMin, UMax, VMin, VMax, aT, u2, v2, du, dv, aDelta;
Standard_Real aUPeriod;
//
- aDelta=Precision::PConfusion();
-
- BRepAdaptor_Surface aBAS(aF, Standard_False);
-
- BRepTools::UVBounds(aF, UMin, UMax, VMin, VMax);
+ const TopoDS_Face& aF=aBAS.Face();
+ UMin=aBAS.FirstUParameter();
+ UMax=aBAS.LastUParameter();
+ VMin=aBAS.FirstVParameter();
+ VMax=aBAS.LastVParameter();
+ //
+ aDelta=Precision::PConfusion();
aT =.5*(aFirst+aLast);
du = 0.;
if (aBAS.IsUPeriodic()) {
aUPeriod = aBAS.UPeriod();
+
//
// a. try to clarify u2 using the precision (aDelta)
if (fabs(u2-UMin) < aDelta) {
aT=BOPTools_AlgoTools2D::IntermediatePoint(aT1, aT2);
return aT;
}
-
-//=======================================================================
-//function : BuildPCurveForEdgeOnPlane
-//purpose :
-//=======================================================================
-void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane
- (const TopoDS_Edge& aE,
- const TopoDS_Face& aF)
-{
- Standard_Boolean bToUpdate;
- Standard_Real aTolE, aT1, aT2;
- Handle(Geom2d_Curve) aC2D;
- BRep_Builder aBB;
- //
- aC2D=BRep_Tool_CurveOnSurface(aE, aF, aT1, aT2, bToUpdate);
- if (bToUpdate) {
- aTolE=BRep_Tool::Tolerance(aE);
- aBB.UpdateEdge(aE, aC2D, aF, aTolE);
- }
-}
-//=======================================================================
-// function: BuildPCurveForEdgesOnPlane
-// purpose:
-//=======================================================================
-void BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane
- (const BOPCol_ListOfShape& aLE,
- const TopoDS_Face& aF)
-{
- BOPCol_ListIteratorOfListOfShape aIt;
- //
- aIt.Initialize(aLE);
- for(; aIt.More(); aIt.Next()) {
- const TopoDS_Edge& aE=(*(TopoDS_Edge *)&aIt.Value());
- BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (aE, aF);
- }
-}
//=======================================================================
//function : Make2D
//purpose :
Handle(Geom2d_Curve)& aC2D,
Standard_Real& aFirst,
Standard_Real& aLast,
- Standard_Real& aToler)
+ Standard_Real& aToler,
+ const Handle(IntTools_Context)& theContext)
{
Standard_Boolean aLocIdentity;
Standard_Real f3d, l3d;
//
aToler = BRep_Tool::Tolerance(aE);
- BOPTools_AlgoTools2D::MakePCurveOnFace(aF, C3D2, f3d, l3d, aC2D, aToler);
+ BOPTools_AlgoTools2D::MakePCurveOnFace(aF, C3D2, f3d, l3d, aC2D, aToler, theContext);
//
aFirst = f3d;
aLast = l3d;
void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF,
const Handle(Geom_Curve)& aC3D,
Handle(Geom2d_Curve)& aC2D, //->
- Standard_Real& TolReached2d)
+ Standard_Real& TolReached2d,
+ const Handle(IntTools_Context)& theContext)
{
Standard_Real aFirst, aLast;
//
TolReached2d=0.;
//
- BOPTools_AlgoTools2D::MakePCurveOnFace (aF, aC3D, aFirst,
- aLast, aC2D, TolReached2d);
+ BOPTools_AlgoTools2D::MakePCurveOnFace
+ (aF, aC3D, aFirst, aLast, aC2D, TolReached2d, theContext);
}
//=======================================================================
//function : MakePCurveOnFace
//purpose :
//=======================================================================
-void BOPTools_AlgoTools2D::MakePCurveOnFace
+void BOPTools_AlgoTools2D::MakePCurveOnFace
(const TopoDS_Face& aF,
const Handle(Geom_Curve)& aC3D,
- const Standard_Real aFirst,
- const Standard_Real aLast,
- Handle(Geom2d_Curve)& aC2D,
- Standard_Real& TolReached2d)
+ const Standard_Real aT1,
+ const Standard_Real aT2,
+ Handle(Geom2d_Curve)& aC2D,
+ Standard_Real& TolReached2d,
+ const Handle(IntTools_Context)& theContext)
{
- Standard_Real aTolR;
- Handle(Geom2d_Curve) aC2DA;
+ BRepAdaptor_Surface aBASTmp;
+ const BRepAdaptor_Surface* pBAS;
+ if (!theContext.IsNull()) {
+ pBAS = &theContext->SurfaceAdaptor(aF);
+ }
+ else {
+ aBASTmp.Initialize(aF, Standard_True);
+ pBAS = &aBASTmp;
+ }
//
- Handle(Geom_Surface) aS=BRep_Tool::Surface(aF);
- GeomAdaptor_Surface aGAS(aS);
- Handle(GeomAdaptor_HSurface) aBAHS=
- new GeomAdaptor_HSurface(aGAS);
- Handle(GeomAdaptor_HCurve) aBAHC =
- new GeomAdaptor_HCurve(aC3D, aFirst, aLast);
-
+ Handle(BRepAdaptor_HSurface) aBAHS = new BRepAdaptor_HSurface(*pBAS);
+ Handle(GeomAdaptor_HCurve) aBAHC = new GeomAdaptor_HCurve(aC3D, aT1, aT2);
+ //
+ Standard_Real aTolR;
+ Standard_Real aTR = Precision::Confusion();//1.e-7;
+ Standard_Real aMaxTol = 1.e3 * aTR; //0.0001
+ Standard_Boolean isAnaSurf = ProjLib::IsAnaSurf(aBAHS);
+
//when the type of surface is GeomAbs_SurfaceOfRevolution
- if (aGAS.GetType() == GeomAbs_SurfaceOfRevolution) {
- Standard_Real aTR = 1.e-7;
+ if (pBAS->GetType() == GeomAbs_SurfaceOfRevolution)
+ {
+ if (TolReached2d > aTR) {
+ aTR=TolReached2d;
+ }
+ //
ProjLib_ProjectedCurve aProj1(aBAHS, aBAHC, aTR);
- BOPTools_AlgoTools2D::MakePCurveOfType(aProj1, aC2D);
+ ProjLib::MakePCurveOfType(aProj1, aC2D);
aTolR = aProj1.GetTolerance();
- } else {
- ProjLib_ProjectedCurve aProjCurv(aBAHS, aBAHC);// 1
- BOPTools_AlgoTools2D::MakePCurveOfType(aProjCurv, aC2D);
+ }
+ else
+ {
+ ProjLib_ProjectedCurve aProjCurv(aBAHS);
+ Standard_Integer aDegMin = -1, aDegMax = -1, aMaxSegments = -1;
+ Standard_Real aMaxDist = -1;
+ AppParCurves_Constraint aBndPnt = AppParCurves_TangencyPoint;
+ if ((TolReached2d >= 10. * aTR) && (TolReached2d <= aMaxTol || isAnaSurf))
+ {
+ aTR = Min(aMaxTol, 0.1*TolReached2d);
+ aMaxSegments = 100;
+ aMaxDist = 1.e3*TolReached2d;
+ if(!isAnaSurf || TolReached2d > 1.)
+ {
+ aBndPnt = AppParCurves_PassPoint;
+ }
+ }
+ else if(TolReached2d > aMaxTol)
+ {
+ aTR = Min(TolReached2d, 1.e3 * aMaxTol);
+ aMaxDist = 1.e2 * aTR;
+ aMaxSegments = 100;
+ }
+ aProjCurv.Load(aTR);
+ aProjCurv.SetDegree(aDegMin, aDegMax);
+ aProjCurv.SetMaxSegments(aMaxSegments);
+ aProjCurv.SetBndPnt(aBndPnt);
+ aProjCurv.SetMaxDist(aMaxDist);
+ aProjCurv.Perform(aBAHC);
+ ProjLib::MakePCurveOfType(aProjCurv, aC2D);
aTolR=aProjCurv.GetTolerance();
}
//
- if (aC2D.IsNull()) {
- ProjLib_ProjectedCurve aProjCurvAgain(aBAHS, aBAHC, TolReached2d);// 2
- BOPTools_AlgoTools2D::MakePCurveOfType(aProjCurvAgain, aC2D);
+ if (aC2D.IsNull() && (aTR < aMaxTol || aTR < TolReached2d))
+ {
+ aTR = Max(TolReached2d, aMaxTol);
+ ProjLib_ProjectedCurve aProjCurvAgain(aBAHS, aBAHC, aTR);// 2
+ ProjLib::MakePCurveOfType(aProjCurvAgain, aC2D);
aTolR = aProjCurvAgain.GetTolerance();
- //
- if (aC2D.IsNull()) {
- Standard_Real aTR=0.0001;
- ProjLib_ProjectedCurve aProj3(aBAHS, aBAHC, aTR);// 3
- BOPTools_AlgoTools2D::MakePCurveOfType(aProj3, aC2D);
- aTolR = aProj3.GetTolerance();
- }
- }
- TolReached2d=aTolR;
-
- BOPTools_AlgoTools2D::AdjustPCurveOnFace (aF, aFirst, aLast,
- aC2D, aC2DA);
- aC2D=aC2DA;
-}
-
-//=======================================================================
-//function : MakePCurveOfType
-//purpose :
-//=======================================================================
-void BOPTools_AlgoTools2D::MakePCurveOfType
- (const ProjLib_ProjectedCurve& PC,
- Handle(Geom2d_Curve)& C2D)
-{
-
- switch (PC.GetType()) {
-
- case GeomAbs_Line :
- C2D = new Geom2d_Line(PC.Line());
- break;
- case GeomAbs_Circle :
- C2D = new Geom2d_Circle(PC.Circle());
- break;
- case GeomAbs_Ellipse :
- C2D = new Geom2d_Ellipse(PC.Ellipse());
- break;
- case GeomAbs_Parabola :
- C2D = new Geom2d_Parabola(PC.Parabola());
- break;
- case GeomAbs_Hyperbola :
- C2D = new Geom2d_Hyperbola(PC.Hyperbola());
- break;
- case GeomAbs_BSplineCurve :
- C2D = PC.BSpline();
- break;
- case GeomAbs_BezierCurve :
- case GeomAbs_OtherCurve :
- default :
- Standard_NotImplemented::Raise
- ("BOPTools_AlgoTools2D::MakePCurveOfType");
- break;
- }
-}
-//=======================================================================
-//function : CheckEdgeLength
-//purpose :
-//=======================================================================
-Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E)
-{
- BRepAdaptor_Curve BC(E);
-
- BOPCol_IndexedMapOfShape aM;
- BOPTools::MapShapes(E, TopAbs_VERTEX, aM);
- Standard_Integer i, anExtent, aN=10;
- Standard_Real ln=0., d, t, f, l, dt;
- anExtent=aM.Extent();
-
- if (anExtent!=1)
- return Standard_True;
-
- gp_Pnt p1, p2;
- f = BC.FirstParameter();
- l = BC.LastParameter();
- dt=(l-f)/aN;
-
- BC.D0(f, p1);
- for (i=1; i<=aN; i++) {
- t=f+i*dt;
-
- if (i==aN)
- BC.D0(l, p2);
- else
- BC.D0(t, p2);
-
- d=p1.Distance(p2);
- ln+=d;
- p1=p2;
}
//
- return (ln > Precision::Confusion());
-}
-//=======================================================================
-//function : BRep_Tool_CurveOnSurface
-//purpose :
-//=======================================================================
-Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface(const TopoDS_Edge& E,
- const TopoDS_Face& F,
- Standard_Real& First,
- Standard_Real& Last,
- Standard_Boolean& bToUpdate)
-{
- TopLoc_Location l;
- const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l);
- TopoDS_Edge aLocalEdge = E;
- if (F.Orientation() == TopAbs_REVERSED) {
- aLocalEdge.Reverse();
+ if(aC2D.IsNull())
+ {
+ throw Standard_ConstructionError("BOPTools_AlgoTools2D::MakePCurveOnFace : PCurve is Null");
}
//
- return BRep_Tool_CurveOnSurface(aLocalEdge,S,l,First,Last,bToUpdate);
-}
-//=======================================================================
-//function : BRep_Tool_CurveOnSurface
-//purpose :
-//=======================================================================
-Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface
- (const TopoDS_Edge& E,
- const Handle(Geom_Surface)& S,
- const TopLoc_Location& L,
- Standard_Real& First,
- Standard_Real& Last,
- Standard_Boolean& bToUpdate)
-{
- static const Handle(Geom2d_Curve) nullPCurve;
- bToUpdate=Standard_False;
- TopLoc_Location loc = L.Predivided(E.Location());
- Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
-
- // find the representation
- BRep_ListIteratorOfListOfCurveRepresentation itcr
- ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
-
- while (itcr.More()) {
- const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
- if (cr->IsCurveOnSurface(S,loc)) {
- const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
- GC->Range(First,Last);
- if (GC->IsCurveOnClosedSurface() && Eisreversed)
- return GC->PCurve2();
- else
- return GC->PCurve();
- }
- itcr.Next();
- }
-
- // for planar surface and 3d curve try a projection
- // modif 21-05-97 : for RectangularTrimmedSurface, try a projection
- Handle(Geom_Plane) GP;
- Handle(Geom_RectangularTrimmedSurface) GRTS;
- GRTS = Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
- if(!GRTS.IsNull())
- GP = Handle(Geom_Plane)::DownCast(GRTS->BasisSurface());
- else
- GP = Handle(Geom_Plane)::DownCast(S);
- //fin modif du 21-05-97
-
- if (!GP.IsNull()) {
-
- Handle(GeomAdaptor_HCurve) HC;
- Handle(GeomAdaptor_HSurface) HS;
-
- HC = new GeomAdaptor_HCurve();
- HS = new GeomAdaptor_HSurface();
-
- TopLoc_Location LC;
-
- Standard_Real f, l;// for those who call with (u,u).
- Handle(Geom_Curve) C3d =
- BRep_Tool::Curve(E,/*LC,*/f,l); // transforming plane instead of curve
- // we can loose scale factor of Curve transformation (eap 13 May 2002)
-
- LC = L/*.Predivided(LC)*/;
-
- if (C3d.IsNull()) return nullPCurve;
+ TolReached2d=aTolR;
- Handle(Geom_Plane) Plane = GP;
- if (!LC.IsIdentity()) {
- const gp_Trsf& T = LC.Transformation();
- Handle(Geom_Geometry) GPT = GP->Transformed(T);
- Plane = *((Handle(Geom_Plane)*)&GPT);
- }
- GeomAdaptor_Surface& GAS = HS->ChangeSurface();
- GAS.Load(Plane);
-
- Handle(Geom_Curve) ProjOnPlane =
- GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,f,l),
- Plane,
- Plane->Position().Direction(),
- Standard_True);
-
- GeomAdaptor_Curve& GAC = HC->ChangeCurve();
- GAC.Load(ProjOnPlane);
+ // Adjust curve for periodic surface
+ Handle(Geom2d_Curve) aC2DA;
+ BOPTools_AlgoTools2D::AdjustPCurveOnSurf (*pBAS, aT1, aT2, aC2D, aC2DA);
+ aC2D = aC2DA;
+
+ // Make sure that the range of the 2D curve is sufficient for representation of the 3D curve.
+ Standard_Real aTCFirst = aC2D->FirstParameter();
+ Standard_Real aTCLast = aC2D->LastParameter();
+ if ((aTCFirst - aT1) > Precision::PConfusion() ||
+ (aT2 - aTCLast ) > Precision::PConfusion())
+ {
+ if (aTCFirst < aT1) aTCFirst = aT1;
+ if (aTCLast > aT2) aTCLast = aT2;
- ProjLib_ProjectedCurve Proj(HS,HC);
- Handle(Geom2d_Curve) pc = Geom2dAdaptor::MakeCurve(Proj);
+ GeomLib::SameRange(Precision::PConfusion(), aC2D,
+ aTCFirst, aTCLast, aT1, aT2, aC2D);
+ }
- if (pc->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
- Handle(Geom2d_TrimmedCurve) TC =
- (*((Handle(Geom2d_TrimmedCurve)*)&pc));
- pc = TC->BasisCurve();
+ // compute the appropriate tolerance for the edge
+ Handle(Geom_Surface) aS = pBAS->Surface().Surface();
+ aS = Handle(Geom_Surface)::DownCast(aS->Transformed(pBAS->Trsf()));
+ //
+ Standard_Real aT;
+ if (IntTools_Tools::ComputeTolerance
+ (aC3D, aC2D, aS, aT1, aT2, aTolR, aT)) {
+ if (aTolR > TolReached2d) {
+ TolReached2d = aTolR;
}
- First = f; Last = l;
- //
- bToUpdate=Standard_True;
- //
- return pc;
}
-
- return nullPCurve;
}
+
//=======================================================================
//function : MaxToleranceEdge
//purpose :
}
return aTolMax;
}
+
+//=======================================================================
+//function : IsEdgeIsoline
+//purpose :
+//=======================================================================
+void BOPTools_AlgoTools2D::IsEdgeIsoline( const TopoDS_Edge& theE,
+ const TopoDS_Face& theF,
+ Standard_Boolean& isTheUIso,
+ Standard_Boolean& isTheVIso)
+{
+ isTheUIso = isTheVIso = Standard_False;
+
+ gp_Vec2d aT;
+ gp_Pnt2d aP;
+ Standard_Real aFirst = 0.0, aLast = 0.0;
+ const Handle(Geom2d_Curve) aPC = BRep_Tool::CurveOnSurface(theE, theF, aFirst, aLast);
+
+ aPC->D1(0.5*(aFirst+aLast), aP, aT);
+
+ const Standard_Real aSqMagn = aT.SquareMagnitude();
+ if(aSqMagn <= gp::Resolution())
+ return;
+
+ //Normalyze aT
+ aT /= sqrt(aSqMagn);
+
+ //sin(da) ~ da, when da->0.
+ const Standard_Real aTol = Precision::Angular();
+ const gp_Vec2d aRefVDir(0.0, 1.0), aRefUDir(1.0, 0.0);
+
+ const Standard_Real aDPv = aT.CrossMagnitude(aRefVDir),
+ aDPu = aT.CrossMagnitude(aRefUDir);
+
+ isTheUIso = (aDPv <= aTol);
+ isTheVIso = (aDPu <= aTol);
+}