diff --git a/src/ChFi3d/ChFi3d_Builder_0.cxx b/src/ChFi3d/ChFi3d_Builder_0.cxx index f7ed9a7452..c5178140da 100755 --- a/src/ChFi3d/ChFi3d_Builder_0.cxx +++ b/src/ChFi3d/ChFi3d_Builder_0.cxx @@ -146,18 +146,6 @@ #include -//#define DRAW -#ifdef DRAW -#include -#include -#include -#include -#include -#include -static Standard_Integer NbSp = 1; -static Standard_Integer NbelFa = 1; -#endif - #ifdef DEB #include extern Standard_Boolean ChFi3d_GetcontextFORCEBLEND(); @@ -176,6 +164,10 @@ extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time); #include #include +//======================================================================= +//function : ChFi3d_InPeriod +//purpose : +//======================================================================= Standard_Real ChFi3d_InPeriod(const Standard_Real U, const Standard_Real UFirst, const Standard_Real ULast, @@ -188,12 +180,10 @@ Standard_Real ChFi3d_InPeriod(const Standard_Real U, if ( u < UFirst) u = UFirst; return u; } - //======================================================================= //function : Box //purpose : Calculation of min/max uv of the fillet to intersect. //======================================================================= - void ChFi3d_Boite(const gp_Pnt2d& p1,const gp_Pnt2d& p2, Standard_Real& mu,Standard_Real& Mu, Standard_Real& mv,Standard_Real& Mv) @@ -201,12 +191,10 @@ void ChFi3d_Boite(const gp_Pnt2d& p1,const gp_Pnt2d& p2, mu = Min(p1.X(),p2.X()); Mu = Max(p1.X(),p2.X()); mv = Min(p1.Y(),p2.Y()); Mv = Max(p1.Y(),p2.Y()); } - //======================================================================= //function : Box //purpose : Calculation of min/max uv of the fillet to intersect. //======================================================================= - void ChFi3d_Boite(const gp_Pnt2d& p1,const gp_Pnt2d& p2, const gp_Pnt2d& p3,const gp_Pnt2d& p4, Standard_Real& Du,Standard_Real& Dv, @@ -221,12 +209,10 @@ void ChFi3d_Boite(const gp_Pnt2d& p1,const gp_Pnt2d& p2, Du = Mu - mu; Dv = Mv - mv; } - //======================================================================= //function : EnlargeBox and its friends. //purpose : //======================================================================= - static Handle(Adaptor3d_HSurface) Geometry(TopOpeBRepDS_DataStructure& DStr, const Standard_Integer ind) { @@ -244,7 +230,10 @@ static Handle(Adaptor3d_HSurface) Geometry(TopOpeBRepDS_DataStructure& DStr, return new GeomAdaptor_HSurface(S); } } - +//======================================================================= +//function : ChFi3d_SetPointTolerance +//purpose : +//======================================================================= void ChFi3d_SetPointTolerance(TopOpeBRepDS_DataStructure& DStr, const Bnd_Box& box, const Standard_Integer IP) @@ -253,10 +242,13 @@ void ChFi3d_SetPointTolerance(TopOpeBRepDS_DataStructure& DStr, box.Get(a,b,c,d,e,f); d-=a; e-=b; f-=c; d*=d; e*=e; f*=f; - vtol = sqrt(d + e + f) * 1.5; + vtol = sqrt(d + e + f) * 1.5;// on prend un petit rab. DStr.ChangePoint(IP).Tolerance(vtol); } - +//======================================================================= +//function : ChFi3d_EnlargeBox +//purpose : +//======================================================================= void ChFi3d_EnlargeBox(const Handle(Geom_Curve)& C, const Standard_Real wd, const Standard_Real wf, @@ -266,7 +258,10 @@ void ChFi3d_EnlargeBox(const Handle(Geom_Curve)& C, box1.Add(C->Value(wd)); box2.Add(C->Value(wf)); } - +//======================================================================= +//function : ChFi3d_EnlargeBox +//purpose : +//======================================================================= void ChFi3d_EnlargeBox(const Handle(Adaptor3d_HSurface)& S, const Handle(Geom2d_Curve)& PC, const Standard_Real wd, @@ -280,7 +275,10 @@ void ChFi3d_EnlargeBox(const Handle(Adaptor3d_HSurface)& S, PC->Value(wf).Coord(u,v); box2.Add(S->Value(u,v)); } - +//======================================================================= +//function : ChFi3d_EnlargeBox +//purpose : +//======================================================================= void ChFi3d_EnlargeBox(const TopoDS_Edge& E, const TopTools_ListOfShape& LF, const Standard_Real w, @@ -298,7 +296,10 @@ void ChFi3d_EnlargeBox(const TopoDS_Edge& E, } } } - +//======================================================================= +//function : ChFi3d_EnlargeBox +//purpose : +//======================================================================= void ChFi3d_EnlargeBox(TopOpeBRepDS_DataStructure& DStr, const Handle(ChFiDS_Stripe)& st, const Handle(ChFiDS_SurfData)& sd, @@ -363,12 +364,10 @@ void ChFi3d_EnlargeBox(TopOpeBRepDS_DataStructure& DStr, } } } - //======================================================================= //function : conexfaces //purpose : //======================================================================= - void ChFi3d_conexfaces(const TopoDS_Edge& E, TopoDS_Face& F1, TopoDS_Face& F2, @@ -390,12 +389,10 @@ void ChFi3d_conexfaces(const TopoDS_Edge& E, } } } - //======================================================================= //function : EdgeState //purpose : check concavities for the tops with 3 edges. //======================================================================= - ChFiDS_State ChFi3d_EdgeState(TopoDS_Edge* E, const ChFiDS_Map& EFMap) { @@ -443,13 +440,11 @@ ChFiDS_State ChFi3d_EdgeState(TopoDS_Edge* E, } return sst; } - //======================================================================= //function : evalconti //purpose : Method very fast to code regularities CN. It is necessary to // refine the processing. //======================================================================= - GeomAbs_Shape ChFi3d_evalconti(const TopoDS_Edge& /*E*/, const TopoDS_Face& F1, const TopoDS_Face& F2) @@ -465,153 +460,86 @@ GeomAbs_Shape ChFi3d_evalconti(const TopoDS_Edge& /*E*/, typ != GeomAbs_Torus) return cont; return GeomAbs_CN; } - +//modified by NIZNHY-PKV Wed Dec 15 11:22:35 2010f //======================================================================= //function : KParticular //purpose : //======================================================================= - -Standard_Boolean ChFi3d_KParticular -(const Handle(ChFiDS_Spine)& Spine, - const Standard_Integer IE, - const BRepAdaptor_Surface& S1, - const BRepAdaptor_Surface& S2) +Standard_Boolean ChFi3d_KParticular (const Handle(ChFiDS_Spine)& Spine, + const Standard_Integer IE, + const BRepAdaptor_Surface& S1, + const BRepAdaptor_Surface& S2) { -#ifdef DEB - if(ChFi3d_GetcontextFORCEBLEND()) return Standard_False; -#endif + Standard_Boolean bRet; + // + bRet=Standard_True; + // Handle(ChFiDS_FilSpine) fs = Handle(ChFiDS_FilSpine)::DownCast(Spine); - if(!fs.IsNull() && !fs->IsConstant(IE)) return Standard_False; - const BRepAdaptor_Curve& bc = Spine->CurrentElementarySpine(IE); - GeomAbs_CurveType ctyp = bc.GetType(); - - switch (S1.GetType()) { - - case GeomAbs_Plane : - - switch(S2.GetType()) { - - case GeomAbs_Plane : - - if (ctyp == GeomAbs_Line) return Standard_True; - else return Standard_False; - - case GeomAbs_Cylinder : - - if (ctyp == GeomAbs_Line && - (S1.Plane().Axis().Direction(). - IsNormal(S2.Cylinder().Axis().Direction(), - Precision::Angular()))) - return Standard_True; - else if (ctyp == GeomAbs_Circle && - (S1.Plane().Axis().Direction(). - IsParallel(S2.Cylinder().Axis().Direction(), - Precision::Angular()))) - return Standard_True; - else return Standard_False; - - case GeomAbs_Cone : - - if (ctyp != GeomAbs_Circle) return Standard_False; - else if (S1.Plane().Axis().Direction(). - IsParallel(S2.Cone().Axis().Direction(), - Precision::Angular())) - return Standard_True; - else return Standard_False; - - case GeomAbs_Sphere : - /* - if (!Constant) return Standard_False; - else if (S1.Plane().Axis().Direction(). - IsParallel(S2.Sphere().Position().Axis().Direction(), - Precision::Angular())) - return Standard_True; - else return Standard_False; - */ - return Standard_False; - case GeomAbs_Torus : - /* - if (!Constant) return Standard_False; - else if (S1.Plane().Axis().Direction(). - IsParallel(S2.Torus().Axis().Direction(), - Precision::Angular())) - return Standard_True; - else return Standard_False;; - */ - return Standard_False;; - default: - - return Standard_False; - } - case GeomAbs_Cylinder : - - if (S2.GetType() == GeomAbs_Plane) { - if (ctyp == GeomAbs_Line && - (S2.Plane().Axis().Direction(). - IsNormal(S1.Cylinder().Axis().Direction(), - Precision::Angular()))) - return Standard_True; - else if (ctyp == GeomAbs_Circle && - (S2.Plane().Axis().Direction(). - IsParallel(S1.Cylinder().Axis().Direction(), - Precision::Angular()))) - return Standard_True; - else return Standard_False; - } - else return Standard_False; - - case GeomAbs_Cone : - - if (S2.GetType() == GeomAbs_Plane) { - if (ctyp != GeomAbs_Circle) return Standard_False; - else if (S2.Plane().Axis().Direction(). - IsParallel(S1.Cone().Axis().Direction(), - Precision::Angular())) - return Standard_True; - else return Standard_False; - - } - else return Standard_False; - - case GeomAbs_Sphere : - /* - if (S2.GetType() == GeomAbs_Plane) { - if (!Constant) return Standard_False; - else if (S2.Plane().Axis().Direction(). - IsParallel(S1.Sphere().Position().Axis().Direction(), - Precision::Angular())) - return Standard_True; - else return Standard_False; - } - else return Standard_False; - */ - return Standard_False; - case GeomAbs_Torus : - /* - if (S2.GetType() == GeomAbs_Plane) { - if (!Constant) return Standard_False; - else if (S2.Plane().Axis().Direction(). - IsParallel(S1.Torus().Axis().Direction(), - Precision::Angular())) - return Standard_True; - else return Standard_False; - } - else return Standard_False; - */ - return Standard_False; - default: - return Standard_False; + if(!fs.IsNull() && !fs->IsConstant(IE)) { + return !bRet; } - return Standard_False; + // + Standard_Boolean bIsPlane1, bIsPlane2; + Standard_Real aPA; + GeomAbs_CurveType aCT; + GeomAbs_SurfaceType aST1, aST2; + // + aST1=S1.GetType(); + aST2=S2.GetType(); + bIsPlane1=(aST1==GeomAbs_Plane); + bIsPlane2=(aST2==GeomAbs_Plane); + if (!(bIsPlane1 || bIsPlane2)) { + return !bRet; + } + // + const BRepAdaptor_Surface& aS1=(bIsPlane1)? S1 : S2; + const BRepAdaptor_Surface& aS2=(bIsPlane1)? S2 : S1; + aST1=aS1.GetType(); + aST2=aS2.GetType(); + // + if (!(aST2==GeomAbs_Plane || aST2==GeomAbs_Cylinder || aST2==GeomAbs_Cone)) { + return !bRet; + } + // + const BRepAdaptor_Curve& bc = Spine->CurrentElementarySpine(IE); + aCT = bc.GetType(); + if (!(aCT==GeomAbs_Line || aCT==GeomAbs_Circle)) { + return !bRet; + } + // + aPA=Precision::Angular(); + // + if (aST2==GeomAbs_Plane){ + if (aCT==GeomAbs_Line) { + return bRet; + } + } + else if (aST2==GeomAbs_Cylinder) { + const gp_Dir& aD1=aS1.Plane().Axis().Direction(); + const gp_Dir& aD2=aS2.Cylinder().Axis().Direction(); + // + if (aCT==GeomAbs_Line && aD1.IsNormal(aD2, aPA)) { + return bRet; + } + else if (aCT==GeomAbs_Circle && aD1.IsParallel(aD2, aPA)) { + return bRet; + } + } + else if(aST2==GeomAbs_Cone) { + const gp_Dir& aD1=aS1.Plane().Axis().Direction(); + const gp_Dir& aD2=aS2.Cone().Axis().Direction(); + if (aCT == GeomAbs_Circle && aD1.IsParallel(aD2, aPA)) { + return bRet; + } + } + return !bRet; } - - +//modified by NIZNHY-PKV Wed Dec 15 11:22:43 2010t //======================================================================= //function : BoundFac //purpose : Resize the limits of surface adjacent to the given box // Useful for intersections with known extremities. //======================================================================= - void ChFi3d_BoundFac(BRepAdaptor_Surface& S, const Standard_Real uumin, const Standard_Real uumax, @@ -626,7 +554,6 @@ void ChFi3d_BoundFac(BRepAdaptor_Surface& S, //purpose : Resize the limits of surface adjacent to the given box // Useful for intersections with known extremities. //======================================================================= - void ChFi3d_BoundSrf(GeomAdaptor_Surface& S, const Standard_Real uumin, const Standard_Real uumax, @@ -644,17 +571,9 @@ void ChFi3d_BoundSrf(GeomAdaptor_Surface& S, Standard_Real peru=0, perv=0; if(surface->IsUPeriodic()) { peru = surface->UPeriod(); -// if((umax - umin) > (0.5 * peru)) { -// umin = uumax - peru; -// umax = peru - (uumax - uumin); -// } } if(surface->IsVPeriodic()) { perv = surface->VPeriod(); -// if((vmax - vmin) > (0.5 * perv)) { -// vmin = vvmax - perv; -// vmax = perv - (vvmax - vvmin); -// } } Standard_Real Stepu = umax - umin; Standard_Real Stepv = vmax - vmin; @@ -683,12 +602,10 @@ void ChFi3d_BoundSrf(GeomAdaptor_Surface& S, } S.Load(surface,uu1,uu2,vv1,vv2); } - //======================================================================= //function : ChFi3d_InterPlaneEdge //purpose : //======================================================================= - Standard_Boolean ChFi3d_InterPlaneEdge (Handle(Adaptor3d_HSurface)& Plan, Handle(Adaptor3d_HCurve)& C, Standard_Real& W, @@ -713,8 +630,12 @@ Standard_Boolean ChFi3d_InterPlaneEdge (Handle(Adaptor3d_HSurface)& Plan, isol = iip; W = CW; } else { - if ( Sens && CW < W) {W = CW; isol = iip;} - else if (!Sens && CW > W) {W = CW; isol = iip;} + if ( Sens && CW < W) { + W = CW; isol = iip; + } + else if (!Sens && CW > W) { + W = CW; isol = iip; + } } } } @@ -722,12 +643,10 @@ Standard_Boolean ChFi3d_InterPlaneEdge (Handle(Adaptor3d_HSurface)& Plan, if(isol == 0) return Standard_False; return Standard_True; } - //======================================================================= //function : ExtrSpineCarac //purpose : //======================================================================= - void ChFi3d_ExtrSpineCarac(const TopOpeBRepDS_DataStructure& DStr, const Handle(ChFiDS_Stripe)& cd, const Standard_Integer i, @@ -780,7 +699,6 @@ void ChFi3d_ExtrSpineCarac(const TopOpeBRepDS_DataStructure& DStr, V.Normalize(); if(sens == 1) V.Reverse(); } - //======================================================================= //function : ChFi3d_CircularSpine //purpose : Calculate a cicular guideline for the corner created from @@ -818,21 +736,15 @@ Handle(Geom_Circle) ChFi3d_CircularSpine(Standard_Real& WFirst, WLast = dddeb.Angle(ddfin); return new Geom_Circle(ccc); } -#ifdef DEB - else { - cout <<"Construction de la ligne guide du coin impossible"< 0 ? (first - last) : (last - first)); return ((Abs(pp - ref) < Abs(p - ref))? pp : p); } - +//======================================================================= +//function : ChFi3d_IntTraces +//purpose : +//======================================================================= Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1, const Standard_Real pref1, Standard_Real& p1, @@ -1088,9 +1003,6 @@ Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1, if (!Intersection.IsEmpty()) { nbseg = Intersection.NbSegments(); if ( nbseg > 0 ) { -#ifdef DEB - cout<< "segments of intersection on restrictions"<= 1 ) { @@ -1116,7 +1028,7 @@ Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1, p2 = int2d.ParamOnSecond(); p2d = int2d.Value(); } -// Modified by skv - Mon Jun 16 15:51:21 2003 OCC615 Begin + // Modified by skv - Mon Jun 16 15:51:21 2003 OCC615 Begin else if (Check2dDistance && RefP2d.Distance(int2d.Value()) < RefP2d.Distance(p2d)) { Standard_Real pp2 = int2d.ParamOnSecond(); @@ -1128,7 +1040,7 @@ Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1, p2 = pp2; p2d = int2d.Value(); } -// Modified by skv - Mon Jun 16 15:51:22 2003 OCC615 End + // Modified by skv - Mon Jun 16 15:51:22 2003 OCC615 End } else if(isper2) { Standard_Real pp2 = int2d.ParamOnSecond(); @@ -1138,7 +1050,7 @@ Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1, p1 = int2d.ParamOnFirst(); p2d = int2d.Value(); } -// Modified by skv - Mon Jun 16 15:51:21 2003 OCC615 Begin + // Modified by skv - Mon Jun 16 15:51:21 2003 OCC615 Begin else if (Check2dDistance && RefP2d.Distance(int2d.Value()) < RefP2d.Distance(p2d)) { Standard_Real pp1 = int2d.ParamOnFirst(); @@ -1150,7 +1062,7 @@ Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1, p2 = pp2; p2d = int2d.Value(); } -// Modified by skv - Mon Jun 16 15:51:22 2003 OCC615 End + // Modified by skv - Mon Jun 16 15:51:22 2003 OCC615 End } else if(((int2d.ParamOnFirst() - p1)*sens1 < 0.) && ((int2d.ParamOnSecond() - p2)*sens2 < 0.)) { @@ -1179,7 +1091,6 @@ Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1, } else { return Standard_False; } } - //======================================================================= //function : Coefficient //purpose : @@ -1199,13 +1110,11 @@ void ChFi3d_Coefficient(const gp_Vec& V3d, DU = (DD*CC-EE*BB)/Delta; DV = (AA*EE-BB*DD)/Delta; } - //======================================================================= //function : ReparamPcurv //purpose : Dans le cas ou la pcurve est une BSpline on verifie // ses parametres et on la reparametre eventuellement. //======================================================================= - void ChFi3d_ReparamPcurv(const Standard_Real Uf, const Standard_Real Ul, Handle(Geom2d_Curve)& Pcurv) @@ -1236,13 +1145,11 @@ void ChFi3d_ReparamPcurv(const Standard_Real Uf, } Pcurv = pc; } - //======================================================================= //function : ProjectPCurv //purpose : Calculation of the pcurve corresponding to a line of intersection // 3d. Should be called only in analytic cases. //======================================================================= - void ChFi3d_ProjectPCurv(const Handle(Adaptor3d_HCurve)& HCg, const Handle(Adaptor3d_HSurface)& HSg, Handle(Geom2d_Curve)& Pcurv, @@ -1295,18 +1202,15 @@ void ChFi3d_ProjectPCurv(const Handle(Adaptor3d_HCurve)& HCg, } } } - //======================================================================= //function : CheckSameParameter //purpose : Controls a posteriori that sameparameter worked well //======================================================================= - -Standard_Boolean ChFi3d_CheckSameParameter -(const Handle(Adaptor3d_HCurve)& C3d, - Handle(Geom2d_Curve)& Pcurv, - const Handle(Adaptor3d_HSurface)& S, - const Standard_Real tol3d, - Standard_Real& tolreached) +Standard_Boolean ChFi3d_CheckSameParameter (const Handle(Adaptor3d_HCurve)& C3d, + Handle(Geom2d_Curve)& Pcurv, + const Handle(Adaptor3d_HSurface)& S, + const Standard_Real tol3d, + Standard_Real& tolreached) { tolreached = 0.; Standard_Real f = C3d->FirstParameter(); @@ -1332,12 +1236,10 @@ Standard_Boolean ChFi3d_CheckSameParameter tolreached = Max(tolreached,Precision::Confusion()); return Standard_True; } - //======================================================================= //function : SameParameter //purpose : Encapsulation of Sameparameter //======================================================================= - Standard_Boolean ChFi3d_SameParameter(const Handle(Adaptor3d_HCurve)& C3d, Handle(Geom2d_Curve)& Pcurv, const Handle(Adaptor3d_HSurface)& S, @@ -1348,26 +1250,15 @@ Standard_Boolean ChFi3d_SameParameter(const Handle(Adaptor3d_HCurve)& C3d, Approx_SameParameter sp(C3d,Pcurv,S,tol3d); if(sp.IsDone() && !sp.IsSameParameter()) Pcurv = sp.Curve2d(); else if(!sp.IsDone() && !sp.IsSameParameter()) { -#ifdef DEB - cout<<"echec SameParameter"< 1.1*tol3d) { -#ifdef DEB - cout<<"SameParameter : Tol non atteinte!!!"< 0) ang2=PI-dref.Angle(d2); - else ang2=-PI-dref.Angle(d2); - Standard_Real angmax = 0.5*PI; - if((Abs(ang1)>angmax)||(Abs(ang2)>angmax)) { - //On fait une cubique a la mords moi le noeud - TColgp_Array1OfPnt2d pol(1,4); - pol(1)=p1; - pol(4)=p2; - Standard_Real Lambda1 = Max(Abs(d2.Dot(d1)),Abs(dref.Dot(d1))); - Lambda1 = Max(0.5*mref*Lambda1,1.e-5); - pol(2) = gp_Pnt2d(p1.XY()+Lambda1*d1.XY()); - Standard_Real Lambda2 = Max(Abs(d1.Dot(d2)),Abs(dref.Dot(d2))); - Lambda2 = Max(0.5*mref*Lambda2,1.e-5); - pol(3)=gp_Pnt2d(p2.XY()+Lambda2*d2.XY()); - return new Geom2d_BezierCurve(pol); - } - else{ - //On lance un Batten -#ifdef DEB - OSD_Chronometer ch; - ChFi3d_InitChron(ch);// init performances pour les batten -#endif - FairCurve_Batten Bat(p1,p2,h); - Bat.SetFreeSliding (Standard_True); - Bat.SetAngle1(ang1); - Bat.SetAngle2(ang2); - FairCurve_AnalysisCode Iana; - Standard_Real tol = 1.e-3; - Standard_Integer nbit; - Standard_Boolean ok; -// nbit = 5; -// ok = Bat.Compute(Iana,nbit,tol); - nbit = 25; - ok = Bat.Compute(Iana,nbit,tol); -#ifdef DEB - ChFi3d_ResultChron( ch,t_batten); // result performances pour les batten -#endif - if(!ok) Standard_Failure::Raise("Echec Batten"); - return Bat.Curve(); - } -*/ } - +//======================================================================= +//function : ChFi3d_BuildPCurve +//purpose : +//======================================================================= Handle(Geom2d_Curve) ChFi3d_BuildPCurve(const Handle(Adaptor3d_HSurface)& Surf, const gp_Pnt2d& p1, const gp_Vec2d& v1, @@ -1687,7 +1538,10 @@ Handle(Geom2d_Curve) ChFi3d_BuildPCurve(const Handle(Adaptor3d_HSurface)& Surf, } return pc; } - +//======================================================================= +//function : ChFi3d_BuildPCurve +//purpose : +//======================================================================= Handle(Geom2d_Curve) ChFi3d_BuildPCurve(const Handle(Adaptor3d_HSurface)& Surf, const gp_Pnt2d& p1, const gp_Vec& v1, @@ -1711,7 +1565,6 @@ Handle(Geom2d_Curve) ChFi3d_BuildPCurve(const Handle(Adaptor3d_HSurface)& Surf, } return ChFi3d_BuildPCurve(Surf,p1,vv1,p2,vv2,0); } - //======================================================================= //function : ComputeArete //purpose : @@ -1728,7 +1581,6 @@ Handle(Geom2d_Curve) ChFi3d_BuildPCurve(const Handle(Adaptor3d_HSurface)& Surf, // firstpoint sur S2 -------------edge:courbe3d/pcurves--->lastpoint sur S2 // //======================================================================= - void ChFi3d_ComputeArete(const ChFiDS_CommonPoint& P1, const gp_Pnt2d& UV1, const ChFiDS_CommonPoint& P2, @@ -1870,13 +1722,10 @@ void ChFi3d_ComputeArete(const ChFiDS_CommonPoint& P1, } } } - //======================================================================= //function : FilCurveInDS //purpose : //======================================================================= - - Handle(TopOpeBRepDS_SurfaceCurveInterference) ChFi3d_FilCurveInDS (const Standard_Integer Icurv, const Standard_Integer Isurf, @@ -1890,7 +1739,6 @@ Handle(TopOpeBRepDS_SurfaceCurveInterference) ChFi3d_FilCurveInDS Pcurv); return SC1; } - //======================================================================= //function : TrsfTrans //purpose : @@ -1898,20 +1746,17 @@ Handle(TopOpeBRepDS_SurfaceCurveInterference) ChFi3d_FilCurveInDS //======================================================================= TopAbs_Orientation ChFi3d_TrsfTrans(const IntSurf_TypeTrans T1) { - switch (T1) - { + switch (T1) { case IntSurf_In: return TopAbs_FORWARD; case IntSurf_Out: return TopAbs_REVERSED; } return TopAbs_INTERNAL; } - //======================================================================= //function : FilCommonPoint //purpose : Loading of the common point // management of the case when it happens on already existing vertex. //======================================================================= - Standard_EXPORT void ChFi3d_FilCommonPoint(const BRepBlend_Extremity& SP, const IntSurf_TypeTrans TransLine, const Standard_Boolean Start, @@ -2007,7 +1852,6 @@ Standard_EXPORT void ChFi3d_FilCommonPoint(const BRepBlend_Extremity& SP, //function : SolidIndex //purpose : //======================================================================= - Standard_Integer ChFi3d_SolidIndex(const Handle(ChFiDS_Spine)& sp, TopOpeBRepDS_DataStructure& DStr, ChFiDS_Map& MapESo, @@ -2022,12 +1866,10 @@ Standard_Integer ChFi3d_SolidIndex(const Handle(ChFiDS_Spine)& sp, const Standard_Integer solidindex = DStr.AddShape(shellousolid); return solidindex; } - //======================================================================= //function : IndexPointInDS //purpose : //======================================================================= - Standard_Integer ChFi3d_IndexPointInDS(const ChFiDS_CommonPoint& P1, TopOpeBRepDS_DataStructure& DStr) { @@ -2041,18 +1883,16 @@ Standard_Integer ChFi3d_IndexPointInDS(const ChFiDS_CommonPoint& P1, } return DStr.AddPoint(TopOpeBRepDS_Point(P1.Point(),P1.Tolerance())); } - //======================================================================= //function : FilPointInDS //purpose : //======================================================================= - -Handle(TopOpeBRepDS_CurvePointInterference) ChFi3d_FilPointInDS -(const TopAbs_Orientation Et, - const Standard_Integer Ic, - const Standard_Integer Ip, - const Standard_Real Par, - const Standard_Boolean IsVertex) +Handle(TopOpeBRepDS_CurvePointInterference) + ChFi3d_FilPointInDS(const TopAbs_Orientation Et, + const Standard_Integer Ic, + const Standard_Integer Ip, + const Standard_Real Par, + const Standard_Boolean IsVertex) { Handle(TopOpeBRepDS_CurvePointInterference) CP1; if (IsVertex) @@ -2065,17 +1905,15 @@ Handle(TopOpeBRepDS_CurvePointInterference) ChFi3d_FilPointInDS TopOpeBRepDS_POINT,Ip,Par); return CP1; } - //======================================================================= //function : FilVertexInDS //purpose : //======================================================================= - -Handle(TopOpeBRepDS_CurvePointInterference) ChFi3d_FilVertexInDS -(const TopAbs_Orientation Et, - const Standard_Integer Ic, - const Standard_Integer Ip, - const Standard_Real Par) +Handle(TopOpeBRepDS_CurvePointInterference) + ChFi3d_FilVertexInDS(const TopAbs_Orientation Et, + const Standard_Integer Ic, + const Standard_Integer Ip, + const Standard_Real Par) { Handle(TopOpeBRepDS_CurvePointInterference) CP1 = new @@ -2084,20 +1922,19 @@ Handle(TopOpeBRepDS_CurvePointInterference) ChFi3d_FilVertexInDS TopOpeBRepDS_VERTEX,Ip,Par); return CP1; } - //======================================================================= //function : Orientation //purpose : returns the orientation of the interference (the first found // in the list). //======================================================================= -static Standard_Boolean ChFi3d_Orientation -(const TopOpeBRepDS_ListOfInterference& LI, - const Standard_Integer igros, - const Standard_Integer ipetit, - TopAbs_Orientation& Or, - const Standard_Boolean isvertex = Standard_False, - const Standard_Boolean aprendre = Standard_False) +static Standard_Boolean + ChFi3d_Orientation(const TopOpeBRepDS_ListOfInterference& LI, + const Standard_Integer igros, + const Standard_Integer ipetit, + TopAbs_Orientation& Or, + const Standard_Boolean isvertex = Standard_False, + const Standard_Boolean aprendre = Standard_False) { //In case, when it is necessary to insert a point/vertex, it should be //known if this is a point or a vertex, because their index can be the same. @@ -2130,7 +1967,7 @@ static Standard_Boolean ChFi3d_Orientation return Standard_False; } -//==================================================================== +//======================================================================= //function : Contains //purpose : Check if the interference does not already exist. //==================================================================== @@ -2145,13 +1982,15 @@ static Standard_Boolean ChFi3d_Contains TopAbs_Orientation bidOr; return ChFi3d_Orientation(LI,igros,ipetit,bidOr,isvertex,aprendre); } - -static void QueryAddVertexInEdge -( TopOpeBRepDS_ListOfInterference& LI, - const Standard_Integer IC, - const Standard_Integer IV, - const Standard_Real par, - const TopAbs_Orientation Or) +//======================================================================= +//function : QueryAddVertexInEdge +//purpose : +//======================================================================= +static void QueryAddVertexInEdge(TopOpeBRepDS_ListOfInterference& LI, + const Standard_Integer IC, + const Standard_Integer IV, + const Standard_Real par, + const TopAbs_Orientation Or) { TopOpeBRepDS_ListIteratorOfListOfInterference it(LI); for (; it.More(); it.Next() ) { @@ -2174,10 +2013,14 @@ static void QueryAddVertexInEdge LI.Append(interf); } +//======================================================================= +//function : CutEdge +//purpose : +//======================================================================= static void CutEdge(const TopoDS_Vertex& V, const Handle(ChFiDS_SurfData)& SD, TopOpeBRepDS_DataStructure& DStr, - const Standard_Boolean /*isfirst*/, + const Standard_Boolean , const Standard_Integer ons) { if(!SD->IsOnCurve(ons)) return; @@ -2198,17 +2041,16 @@ static void CutEdge(const TopoDS_Vertex& V, } } } - //======================================================================= //function : findIndexPoint //purpose : returns in index of point bounding a courve interfering // with and coinciding with last common point on face //======================================================================= - -static Standard_Boolean findIndexPoint(const TopOpeBRepDS_DataStructure& DStr, - const Handle(ChFiDS_SurfData)& Fd, - const Standard_Integer OnS, - Standard_Integer& ipoin) +static Standard_Boolean + findIndexPoint(const TopOpeBRepDS_DataStructure& DStr, + const Handle(ChFiDS_SurfData)& Fd, + const Standard_Integer OnS, + Standard_Integer& ipoin) { ipoin = 0; gp_Pnt P = Fd->Vertex(Standard_False,OnS).Point(); @@ -2235,13 +2077,10 @@ static Standard_Boolean findIndexPoint(const TopOpeBRepDS_DataStructure& DStr, } return Standard_False; } -// ******************************************************************* //======================================================================= //function : FilDS //purpose : //======================================================================= -// ******************************************************************* - void ChFi3d_FilDS(const Standard_Integer SolidIndex, const Handle(ChFiDS_Stripe)& CorDat, TopOpeBRepDS_DataStructure& DStr, @@ -2301,9 +2140,7 @@ void ChFi3d_FilDS(const Standard_Integer SolidIndex, if (FiLen > Precision::PConfusion()) continue; TopOpeBRepDS_Curve& cc = DStr.ChangeCurve(IcFil1); cc.ChangeCurve().Nullify(); -#ifdef DEB - cout << "Nullify degenerated FI of SurfData " << j <<" on S" << onS << endl; -#endif + // care of CommonPoint, eap occ354 if (j!=1 && j!=SeqFil.Length()) continue; Standard_Boolean isfirst = (j==1); @@ -2435,10 +2272,9 @@ void ChFi3d_FilDS(const Standard_Integer SolidIndex, Singulier_en_Bout = (V1.Point().IsEqual(V2.Point(), 0)); if (Singulier_en_Bout) { + // Queue de Billard if ((!V1.IsVertex()) || (!V2.IsVertex())) { -#if DEB - cout << "Singularity at end out of vertex " << endl; -#endif + } else { isVertex1 = isVertex2 = Standard_True; //caution... @@ -2447,11 +2283,9 @@ void ChFi3d_FilDS(const Standard_Integer SolidIndex, BoutdeVtx = V1.Vertex(); Standard_Integer IArcspine = DStr.AddShape(Arcspine); Standard_Integer IVtx = CorDat->IndexFirstPointOnS1(); -#ifndef DEB - TopAbs_Orientation OVtx = TopAbs_FORWARD; -#else - TopAbs_Orientation OVtx; -#endif + + TopAbs_Orientation OVtx = TopAbs_FORWARD;; + for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX); ex.More(); ex.Next()) { if(BoutdeVtx.IsSame(ex.Current())) { @@ -2534,11 +2368,7 @@ void ChFi3d_FilDS(const Standard_Integer SolidIndex, TopoDS_Edge Arcspine = spine->Edges(NumEdge); Standard_Integer IArcspine = DStr.AddShape(Arcspine); Standard_Integer IVtx = DStr.AddShape(BoutdeVtx); -#ifndef DEB TopAbs_Orientation OVtx = TopAbs_FORWARD; -#else - TopAbs_Orientation OVtx; -#endif for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX); ex.More(); ex.Next()) { if(BoutdeVtx.IsSame(ex.Current())) { @@ -2644,17 +2474,12 @@ void ChFi3d_FilDS(const Standard_Integer SolidIndex, // eap, Apr 29 2002, occ 293 else if (isInDS2 && findIndexPoint(DStr, Fd, 1, ipoin)) { -#ifdef DEB - cout << "ChFi3d_FilDS: point " << ipoin <<" is found in DS" << endl; -#endif + } else ipoin = ChFi3d_IndexPointInDS(Fd->VertexLastOnS1(),DStr); TopOpeBRepDS_ListOfInterference& Li = DStr.ChangeCurveInterferences(IcFil1); -#ifdef DEB - if (!Li.IsEmpty()) - cout<<"FilDS : Tangency line on several SurfData"<< endl; -#endif + if (!ChFi3d_Contains(Li,IcFil1,Ipoin1)) { Interfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,IcFil1,Ipoin1, @@ -2736,17 +2561,12 @@ void ChFi3d_FilDS(const Standard_Integer SolidIndex, // eap, Apr 29 2002, occ 293 else if (isInDS2 && findIndexPoint(DStr, Fd, 2, ipoin)) { -#ifdef DEB - cout << "ChFi3d_FilDS: point " << ipoin <<" is found in DS" << endl; -#endif + } else ipoin = ChFi3d_IndexPointInDS(Fd->VertexLastOnS2(),DStr); TopOpeBRepDS_ListOfInterference& Li = DStr.ChangeCurveInterferences(IcFil2); -#ifdef DEB - if (!Li.IsEmpty()) - cout<<"FilDS : Tangency line on several SurfData"<< endl; -#endif + if (!ChFi3d_Contains(Li,IcFil2,Ipoin2)) { Interfp2 = ChFi3d_FilPointInDS(TopAbs_FORWARD,IcFil2,Ipoin2, Fi2.FirstParameter(), isVertex2); @@ -2835,23 +2655,16 @@ void ChFi3d_FilDS(const Standard_Integer SolidIndex, // Processing of degenerated case if (Degene) { + // Queue de Billard Standard_Boolean Vertex = (V3.IsVertex()) && (V4.IsVertex()); if (!Vertex) { -#if DEB - if (j == SeqFil.Length()) { - cout << " Singularity at the end is out of vertex " << endl; - } -#endif + } else { // The edge of the spine starting on this vertex is removed. Standard_Boolean Trouve = Standard_False; TopoDS_Edge Arcspine; -#ifndef DEB TopAbs_Orientation OVtx = TopAbs_FORWARD; -#else - TopAbs_Orientation OVtx; -#endif BoutdeVtx = V3.Vertex(); while (NumEdge<= spine->NbEdges() && !Trouve) { @@ -2908,7 +2721,6 @@ void ChFi3d_FilDS(const Standard_Integer SolidIndex, } } } - //======================================================================= //function : StripeEdgeInter //purpose : This function examines two stripes for an intersection @@ -2918,7 +2730,6 @@ void ChFi3d_FilDS(const Standard_Integer SolidIndex, // this function will become useless. //author : akm, 06/02/02. Against bug OCC119. //======================================================================= - void ChFi3d_StripeEdgeInter (const Handle(ChFiDS_Stripe)& theStripe1, const Handle(ChFiDS_Stripe)& theStripe2, TopOpeBRepDS_DataStructure& /*DStr*/, @@ -3008,7 +2819,6 @@ void ChFi3d_StripeEdgeInter (const Handle(ChFiDS_Stripe)& theStripe1, //function : IndexOfSurfData //purpose : //======================================================================= - Standard_Integer ChFi3d_IndexOfSurfData(const TopoDS_Vertex& V1, const Handle(ChFiDS_Stripe)& CD, Standard_Integer& sens) @@ -3032,7 +2842,6 @@ Standard_Integer ChFi3d_IndexOfSurfData(const TopoDS_Vertex& V1, } return Index; } - //======================================================================= //function : EdgeFromV1 //purpose : @@ -3060,49 +2869,9 @@ TopoDS_Edge ChFi3d_EdgeFromV1(const TopoDS_Vertex& V1, } return E; } - -#ifdef DRAW -//======================================================================= -//function : drawline -//purpose : -//======================================================================= - -static void drawline(const Handle(IntSurf_LineOn2S)& lin) -{ - Handle(Draw_Marker3D) p3d; - Handle(Draw_Marker2D) p2d; - Handle(Draw_Marker2D) p2d2; - - for(Standard_Integer i = 1; i <= lin->NbPoints(); i++) { - const IntSurf_PntOn2S& pt = lin->Value(i); - gp_Pnt point = pt.Value(); - Standard_Real u,v,uu,vv; - pt.ParametersOnS1(u,v); - gp_Pnt2d point2d(u,v); - pt.ParametersOnS2(uu,vv); - gp_Pnt2d point2d2(uu,vv); - if(i == 1 || i == lin->NbPoints()) { - p3d = new Draw_Marker3D(point,Draw_Square,Draw_rouge); - p2d = new Draw_Marker2D(point2d,Draw_Square,Draw_rouge); - p2d2 = new Draw_Marker2D(point2d2,Draw_Square,Draw_rouge); - } - else { - p3d = new Draw_Marker3D(point,Draw_Square,Draw_jaune); - p2d = new Draw_Marker2D(point2d,Draw_Square,Draw_jaune); - p2d2 = new Draw_Marker2D(point2d2,Draw_Square,Draw_jaune); - } - dout< means that the resulting curve is restricted by // boundaries of input surfaces (eap 30 May occ354) //======================================================================= - Standard_Boolean ChFi3d_ComputeCurves(Handle(Adaptor3d_HSurface)& S1, Handle(Adaptor3d_HSurface)& S2, const TColStd_Array1OfReal& Pardeb, @@ -3516,9 +3281,6 @@ Standard_Boolean ChFi3d_ComputeCurves(Handle(Adaptor3d_HSurface)& S1, } } } -#ifdef DEB - cout<<"fail intersection surf/surf adjustment at the main is attempted"<Value(i).Value().Distance(pntd); if(dd < ddeb) { ddeb = dd; indd = i;} @@ -3657,12 +3409,8 @@ Standard_Boolean ChFi3d_ComputeCurves(Handle(Adaptor3d_HSurface)& S1, } dfin = 0.; } -#ifdef DRAW - ChFi3d_SettraceDRAWINT(Standard_True); - if(ChFi3d_GettraceDRAWINT()) drawline(L2S); -#endif - Handle(IntPatch_WLine) - WL = new IntPatch_WLine(L2S,Standard_False); + // + Handle(IntPatch_WLine) WL = new IntPatch_WLine(L2S,Standard_False); GeomInt_WLApprox approx; approx.SetParameters(tolap,tol2d,4,8,0,1); @@ -3728,11 +3476,7 @@ Standard_Boolean ChFi3d_IntCS(Handle(Adaptor3d_HSurface)& S, IntCurveSurface_IntersectionPoint pint; Intersection.Perform(C,S); Standard_Boolean keepfirst = (wc < -1.e100), keeplast = (wc > 1.e100); -#ifndef DEB Standard_Real temp = 0.; -#else - Standard_Real temp; -#endif if(keepfirst) temp = 1.e100; if(keeplast) temp = -1.e100; Standard_Real dist = 2.e100; @@ -3792,6 +3536,10 @@ void ChFi3d_ComputesIntPC (const ChFiDS_FaceInterference& Fi1, ChFi3d_ComputesIntPC(Fi1,Fi2,HS1,HS2,UInt1,UInt2,bid); } +//======================================================================= +//function : ChFi3d_ComputesIntPC +//purpose : +//======================================================================= void ChFi3d_ComputesIntPC (const ChFiDS_FaceInterference& Fi1, const ChFiDS_FaceInterference& Fi2, const Handle(GeomAdaptor_HSurface)& HS1, @@ -3843,7 +3591,6 @@ void ChFi3d_ComputesIntPC (const ChFiDS_FaceInterference& Fi1, // SurfData Fd1 and trims it to allow the intersection computation //======================================================================= - Handle(GeomAdaptor_HSurface) ChFi3d_BoundSurf(TopOpeBRepDS_DataStructure& DStr, const Handle(ChFiDS_SurfData)& Fd1, const Standard_Integer& IFaCo1, @@ -3895,9 +3642,6 @@ Handle(GeomAdaptor_HSurface) ChFi3d_BoundSurf(TopOpeBRepDS_DataStructure& DSt } return HS1; } - - - //======================================================================= //function : SearchPivot //purpose : @@ -4048,11 +3792,7 @@ void ChFi3d_TrimCurve(const Handle(Geom_Curve)& gc, const gp_Pnt& LastP, Handle(Geom_TrimmedCurve)& gtc) { -#ifndef DEB Standard_Real uf = 0.,ul = 0.; -#else - Standard_Real uf,ul; -#endif GeomAdaptor_Curve gac(gc); switch ( gac.GetType() ) { case GeomAbs_Line : @@ -4102,11 +3842,12 @@ void ChFi3d_TrimCurve(const Handle(Geom_Curve)& gc, gtc = new Geom_TrimmedCurve(gc,uf,ul); } + + //======================================================================= -//function : PerformElSpine +//function : GoodExt //purpose : //======================================================================= - static Standard_Boolean GoodExt(const Handle(Geom_Curve)& C, const gp_Vec& V, const Standard_Real f, @@ -4123,26 +3864,39 @@ static Standard_Boolean GoodExt(const Handle(Geom_Curve)& C, } return Standard_True; } - -Standard_EXPORT void ChFi3d_PerformElSpine(Handle(ChFiDS_HElSpine)& HES, - Handle(ChFiDS_Spine)& Spine, - const GeomAbs_Shape continuity, - const Standard_Real tol) +//======================================================================= +//function : PerformElSpine +//purpose : +//======================================================================= +Standard_EXPORT + void ChFi3d_PerformElSpine(Handle(ChFiDS_HElSpine)& HES, + Handle(ChFiDS_Spine)& Spine, + const GeomAbs_Shape continuity, + const Standard_Real tol) { + + Standard_Boolean periodic, Bof, checkdeb, cepadur,bIsSmooth; + Standard_Integer IEdge,IF,IL,nbed, iToApproxByC2; + Standard_Real WF, WL, Wrefdeb, Wreffin,nwf,nwl,period,pared,tolpared; + Standard_Real First, Last, epsV, urefdeb, tolrac; + GeomAbs_Shape aContinuity; + gp_Pnt PDeb, PFin, Bout; + gp_Vec VrefDeb, VrefFin; + Handle(Geom_Curve) Cv; + Handle(Geom_BoundedCurve) TC; + Handle(Geom_BSplineCurve) BS, BSpline; + TopoDS_Edge E, Eold; + TopoDS_Vertex V; + // ChFiDS_ElSpine& ES = HES->ChangeCurve(); - - Standard_Real WF = ES.FirstParameter(); - Standard_Real WL = ES.LastParameter(); - Standard_Real Wrefdeb = WF; - Standard_Real Wreffin = WL; - Standard_Integer IF,IL; - Standard_Boolean periodic = Spine->IsPeriodic(); - Standard_Real nwf = WF, nwl = WL,period; - Standard_Integer nbed = Spine->NbEdges(); - Standard_Real pared,tolpared; - Handle(Geom_BSplineCurve) BSpline; - Handle(Geom_BezierCurve) Bezier; - + WF = ES.FirstParameter(); + WL = ES.LastParameter(); + Wrefdeb = WF; + Wreffin = WL; + nwf = WF; + nwl = WL; + nbed = Spine->NbEdges(); + periodic = Spine->IsPeriodic(); if(periodic) { period = Spine->Period(); nwf = ElCLib::InPeriod(WF,-tol,period-tol); @@ -4157,43 +3911,43 @@ Standard_EXPORT void ChFi3d_PerformElSpine(Handle(ChFiDS_HElSpine)& HES, Wrefdeb = Max(Spine->FirstParameter(IF),WF); Wreffin = Min(Spine->LastParameter(IL),WL); } - - gp_Pnt PDeb, PFin, Bout; - gp_Vec VrefDeb, VrefFin; + // Spine->D1(WF,PDeb,VrefDeb); Spine->D1(WL,PFin,VrefFin); VrefDeb.Normalize(); VrefFin.Normalize(); - - Standard_Boolean Bof; - Standard_Integer IEdge; - - Standard_Real First, Last, epsV; + // TColgp_Array1OfPnt ExtrapPole(1, 5); TColgp_Array1OfPnt ExtraCoeffs(1, 5); TColgp_Array1OfXYZ Cont(1,5); - - TopoDS_Edge E, Eold; - TopoDS_Vertex V; - - // Attention, the first and the last edge are segmented - - // Processing of the first edge - E = Spine->Edges(IF); - Bof = BRepLib::BuildCurve3d(E); + // Attention on segmente eventuellement la premiere et la + // derniere arete. + // Traitment de la premiere arete + cepadur = 0; + E=Spine->Edges(IF); + Bof=BRepLib::BuildCurve3d(E); const BRepAdaptor_Curve& edc = Spine->CurrentElementarySpine(IF); tolpared = edc.Resolution(tol); - Handle(Geom_Curve) Cv = BRep_Tool::Curve(E, First, Last); - Standard_Real urefdeb = Spine->FirstParameter(IF); - Standard_Boolean checkdeb = (nwf > urefdeb),cepadur = 0; - if(checkdeb) Spine->Parameter(IF,nwf,pared,0); + Cv = BRep_Tool::Curve(E, First, Last); + urefdeb = Spine->FirstParameter(IF); + checkdeb = (nwf > urefdeb); + if(checkdeb) { + Spine->Parameter(IF,nwf,pared,0); + } + // if(E.Orientation() == TopAbs_REVERSED) { Standard_Real sov = First; First = Cv->ReversedParameter(Last); Last = Cv->ReversedParameter(sov); - if(checkdeb) pared = Cv->ReversedParameter(pared); - else pared = First; - if(First < pared) First = pared; + if(checkdeb) { + pared = Cv->ReversedParameter(pared); + } + else{ + pared = First; + } + if(First < pared) { + First = pared; + } if(IL == IF) { Standard_Real ureffin = Spine->LastParameter(IL); Standard_Boolean checkfin = (nwl < ureffin); @@ -4201,27 +3955,43 @@ Standard_EXPORT void ChFi3d_PerformElSpine(Handle(ChFiDS_HElSpine)& HES, Spine->Parameter(IL,nwl,pared,0); pared = Cv->ReversedParameter(pared); } - else pared = Last; - if(pared < Last) Last = pared; + else { + pared = Last; + } + if(pared < Last) { + Last = pared; + } } Cv = Cv->Reversed(); - } - else{ - if(!checkdeb) pared = First; - if(First < pared) First = pared; + }//if(E.Orientation() == TopAbs_REVERSED) + else {//#1 + if(!checkdeb) { + pared = First; + } + if(First < pared) { + First = pared; + } if(IL == IF) { Standard_Real ureffin = Spine->LastParameter(IL); Standard_Boolean checkfin = (nwl < ureffin); - if(checkfin) Spine->Parameter(IL,nwl,pared,0); - else pared = Last; - if(pared < Last) Last = pared; + if(checkfin) { + Spine->Parameter(IL,nwl,pared,0); + } + else { + pared = Last; + } + if(pared < Last) { + Last = pared; + } } + }// else {//#1 + // + if(Abs(Last-First) < tolpared) { + cepadur = 1; } - - if(Abs(Last-First) < tolpared) cepadur = 1; - - //In case when KPart consumes an edge - //and cannot stop. A line is drawn. + // + //Petite veru pour les cas ou un KPart a bouffe l arete + //sans parvenir a terminer. On tire une droite. if(cepadur) { Handle(Geom_Line) L; gp_Pnt ptemp; gp_Vec vtemp; @@ -4241,109 +4011,132 @@ Standard_EXPORT void ChFi3d_PerformElSpine(Handle(ChFiDS_HElSpine)& HES, L = new Geom_Line(olin,d); ES.SetCurve(L); } -#ifdef DRAW - ChFi3d_SettraceDRAWSPINE(1); - if (ChFi3d_GettraceDRAWSPINE()) { -// POP for NT -// char name[100]; - char* name = new char[100]; - sprintf(name,"elspine_%d",NbSp++); - Handle(Geom_Curve) bid = new Geom_TrimmedCurve(L,WF,WL); - DrawTrSurf::Set(name,bid); - } -#endif - return; + return;// => } - Handle(Geom_BoundedCurve) TC = new (Geom_TrimmedCurve)(Cv, First, Last); - Handle(Geom_BSplineCurve) BS; - BS = GeomConvert::CurveToBSplineCurve(TC); + // + TC = new (Geom_TrimmedCurve)(Cv, First, Last); + BS=GeomConvert::CurveToBSplineCurve(TC); CurveCleaner(BS, Abs(WL-WF)*1.e-4, 0); + // //Smoothing of the curve - if (TC->Continuity() < GeomAbs_C2 && !ChFi3d_IsSmooth( TC )) - { + iToApproxByC2=0; + aContinuity=TC->Continuity(); + bIsSmooth=ChFi3d_IsSmooth(TC); + if (aContinuity < GeomAbs_C2 && !bIsSmooth) { + ++iToApproxByC2; + BS = ChFi3d_ApproxByC2(TC); + TC=BS; + } + // + // Concatenation des aretes suivantes + GeomConvert_CompCurveToBSplineCurve Concat( TC, Convert_QuasiAngular ); + // + Eold = E; + for (IEdge=IF+1; IEdge<=IL; ++IEdge) { + Standard_Integer iloc = IEdge; + if(periodic) { + iloc = (IEdge - 1)%nbed + 1; + } + // + E = Spine->Edges(iloc); + if (BRep_Tool::Degenerated(E)) { + continue; + } + // + epsV = tol; + Bof = TopExp::CommonVertex(Eold, E, V); + if (Bof) { + epsV = BRep_Tool::Tolerance(V); + } + // + Bof = BRepLib::BuildCurve3d(E); + if (!Bof) { + Standard_ConstructionError::Raise("PerformElSpine : BuildCurve3d error"); + } + // + Cv = BRep_Tool::Curve(E, First, Last); + if(IEdge == IL) { + Standard_Real ureffin = Spine->LastParameter(iloc); + Standard_Boolean checkfin = (nwl < ureffin); + if(checkfin) { + Spine->Parameter(iloc,nwl,pared,0); + } + else { + pared = Last; + } + if(E.Orientation() == TopAbs_REVERSED) { + Standard_Real sov = First; + First = Cv->ReversedParameter(Last); + Last = Cv->ReversedParameter(sov); + if(checkfin) { + pared = Cv->ReversedParameter(pared); + } + else{ + pared = Last; + } + Cv = Cv->Reversed(); + } + if(pared < Last) { + Last = pared; + } + } + // + TC = new (Geom_TrimmedCurve)(Cv, First, Last); + BS = GeomConvert::CurveToBSplineCurve(TC); + CurveCleaner(BS, Abs(WL-WF)*1.e-4, 0); + // + //Smoothing of the curve + aContinuity=TC->Continuity(); + bIsSmooth=ChFi3d_IsSmooth(TC); + if (aContinuity < GeomAbs_C2 && !bIsSmooth) { + ++iToApproxByC2; BS = ChFi3d_ApproxByC2( TC ); TC = BS; } - - // Concatenation of following edges - GeomConvert_CompCurveToBSplineCurve Concat( TC, Convert_QuasiAngular ); - Eold = E; - - for (IEdge=IF+1; IEdge<=IL; IEdge++) { - Standard_Integer iloc = IEdge; - if(periodic) iloc = (IEdge - 1)%nbed + 1; - E = Spine->Edges(iloc); - if (! BRep_Tool::Degenerated(E)) { - Bof = TopExp::CommonVertex(Eold, E, V); - if (Bof) {epsV = BRep_Tool::Tolerance(V);} - else {epsV = tol;} - Bof = BRepLib::BuildCurve3d(E); - if (!Bof) {Standard_ConstructionError:: - Raise("PerformElSpine : BuildCurve3d error");} - Cv = BRep_Tool::Curve(E, First, Last); - if(IEdge == IL) { - Standard_Real ureffin = Spine->LastParameter(iloc); - Standard_Boolean checkfin = (nwl < ureffin); - if(checkfin) Spine->Parameter(iloc,nwl,pared,0); - else pared = Last; - if(E.Orientation() == TopAbs_REVERSED) { - Standard_Real sov = First; - First = Cv->ReversedParameter(Last); - Last = Cv->ReversedParameter(sov); - if(checkfin) pared = Cv->ReversedParameter(pared); - else pared = Last; - Cv = Cv->Reversed(); - } - if(pared < Last) Last = pared; - } - TC = new (Geom_TrimmedCurve)(Cv, First, Last); - BS = GeomConvert::CurveToBSplineCurve(TC); - CurveCleaner(BS, Abs(WL-WF)*1.e-4, 0); - //Smoothing of the curve - if (TC->Continuity() < GeomAbs_C2 && !ChFi3d_IsSmooth( TC )) - { - BS = ChFi3d_ApproxByC2( TC ); - TC = BS; - } - Standard_Real tolrac = Min(tol,epsV); - Bof = Concat.Add( TC, 2*tolrac, Standard_True ); - // if the adding does not go well, it is attempted to increase the tolerance + // + tolrac = Min(tol, epsV); + Bof = Concat.Add( TC, 2.*tolrac, Standard_True ); + // si l'ajout ne s'est pas bien passe on essai d'augmenter la tolerance + if (!Bof) { + Bof = Concat.Add( TC, 2.*epsV, Standard_True ); + } + if (!Bof) { + Bof = Concat.Add( TC, 200.*epsV, Standard_True ); if (!Bof) { - Bof = Concat.Add( TC, 2*epsV, Standard_True ); - } - if (!Bof) { - Bof = Concat.Add( TC, 200*epsV, Standard_True ); -#ifdef DEB - cout << "Tolerance of chain is not respected" << endl; -#endif - if (!Bof) {Standard_ConstructionError:: - Raise("PerformElSpine: spine merged error");} - } + Standard_ConstructionError::Raise("PerformElSpine: spine merged error"); + } } Eold = E; - } - - // The portion of elspine is calculated without extension - // on the valid part of edges of the path. + }// for (IEdge=IF+1; IEdge<=IL; ++IEdge) { + // + // On a la portion d elspine calculee sans prolongements sur la partie + // valide des aretes du chemin. BSpline = Concat.BSplineCurve(); // There is a reparametrisation to maximally connect the abscissas of edges. TColStd_Array1OfReal BSNoeuds (1, BSpline->NbKnots()); BSpline->Knots(BSNoeuds); BSplCLib::Reparametrize (Wrefdeb, Wreffin, BSNoeuds); BSpline->SetKnots(BSNoeuds); - - // Processing of Extremities - Standard_Real LocalWL = WL; - Standard_Real LocalWF = WF; + // + // Traitement des Extremites + Standard_Integer caredeb, carefin; + Standard_Real LocalWL, LocalWF, Angle; GeomAdaptor_Curve gacurve; - Standard_Integer caredeb = 0, carefin = 0; Handle(Geom_BSplineCurve) newc; - Standard_Real Angle = PI*0.75; + // + caredeb = 0; + carefin = 0; + Angle = PI*0.75; + LocalWL = WL; + LocalWF = WF; if (!ES.IsPeriodic() && !PDeb.IsEqual(BSpline->Pole(1), tol) ) { - // Extension of C3 at the beginning - // to avoid inflexion points in the useful part of the - // spine the extension is done till the distant point. - if(BSpline->IsRational()) caredeb = 1; + // Prolongement C3 au debut + // afin d'eviter des pts d'inflexions dans la partie utile de la + // spine le prolongement se fait jusqu'a un point eloigne. + if(BSpline->IsRational()) { + caredeb = 1; + } + // Standard_Real rabdist = Wrefdeb - WF; Bout = PDeb.Translated(-20*rabdist * VrefDeb); Standard_Boolean goodext = 0; @@ -4357,14 +4150,18 @@ Standard_EXPORT void ChFi3d_PerformElSpine(Handle(ChFiDS_HElSpine)& HES, goodext = GoodExt(newc,VrefDeb,Wrefdeb,WF,Angle); } } - if(caredeb) caredeb = newc->NbKnots() - BSpline->NbKnots(); + if(caredeb) { + caredeb = newc->NbKnots() - BSpline->NbKnots(); + } BSpline = newc; LocalWF = BSpline->FirstParameter(); } - + // if (!ES.IsPeriodic() && !PFin.IsEqual(BSpline->Pole(BSpline->NbPoles()), tol) ) { - // Extension of C3 at the end - if(BSpline->IsRational()) carefin = 1; + // Prolongement C3 en fin + if(BSpline->IsRational()) { + carefin = 1; + } Standard_Real rabdist = WL - Wreffin; Bout = PFin.Translated(20*rabdist * VrefFin); Standard_Boolean goodext = 0; @@ -4378,46 +4175,69 @@ Standard_EXPORT void ChFi3d_PerformElSpine(Handle(ChFiDS_HElSpine)& HES, goodext = GoodExt(newc, VrefFin, Wreffin,WL,Angle); } } - if(carefin) carefin = newc->NbKnots() - BSpline->NbKnots(); + if(carefin) { + carefin = newc->NbKnots() - BSpline->NbKnots(); + } BSpline = newc; LocalWL = BSpline->LastParameter(); } - - //Reparametrization and segmentation on the domain of the Spine. - if(Abs(BSpline->FirstParameter() - WF)FirstParameter(); - if(Abs(BSpline->LastParameter() - WL)LastParameter(); - if ( (LocalWFWL)) { // to avoid problems with segment! + // + //Reparametrisation et segmentation sur le domaine de la Spine. + if(Abs(BSpline->FirstParameter() - WF)FirstParameter(); + } + if(Abs(BSpline->LastParameter() - WL)LastParameter(); + } + // + if ( (LocalWFWL)) { // pour eviter des pb avec segment! BSpline->Segment(WF, WL); ES.FirstParameter(WF); ES.LastParameter(WL); } + // if (BSpline->IsRational()) { Handle(Geom_BSplineCurve) C1; C1 = Handle(Geom_BSplineCurve)::DownCast(BSpline->Copy()); GeomConvert::C0BSplineToC1BSplineCurve(C1, tol, 0.1); - // It is necessary to make sure that the origin didn't move (cts21158) - if (C1->FirstParameter() == BSpline->FirstParameter()) BSpline = C1; + // Il faut s'assurer que l'origine n'a pas bouge (cts21158) + if (C1->FirstParameter() == BSpline->FirstParameter()) { + BSpline = C1; + } else { -#if DEB - cout << "Attention : Fail of C0BSplineToC1 !" << endl; -#endif + //cout << "Attention : Echec de C0BSplineToC1 !" << endl; } } - - // Deformation eventual to render spine C2 - // or C3 for approx C2 - if((caredeb || carefin) && BSpline->Degree() < 8) BSpline->IncreaseDegree(8); - Standard_Integer fk = 2, lk = BSpline->NbKnots()-1; - if(BSpline->IsPeriodic()) fk = 1; - if(caredeb) fk += caredeb; - if(carefin) lk -= carefin; - Standard_Integer MultMax, ii; + // + Standard_Integer fk, lk, MultMax, ii; + // Deformation eventuelle pour rendre la spine C2. + // ou C3 pour des approx C2 + if((caredeb || carefin) && BSpline->Degree() < 8) { + BSpline->IncreaseDegree(8); + } + // + fk = 2; + lk = BSpline->NbKnots()-1; + if(BSpline->IsPeriodic()) { + fk = 1; + } + if(caredeb) { + fk += caredeb; + } + if(carefin) { + lk -= carefin; + } + // if (continuity == GeomAbs_C3) { - if (BSpline->Degree() < 7) BSpline->IncreaseDegree(7); + if (BSpline->Degree() < 7) { + BSpline->IncreaseDegree(7); + } MultMax = BSpline->Degree() - 3; } else { - if (BSpline->Degree() < 5) BSpline->IncreaseDegree(5); + if (BSpline->Degree() < 5) { + BSpline->IncreaseDegree(5); + } MultMax = BSpline->Degree() - 2; } // correction C2 or C3 (if possible) @@ -4437,7 +4257,12 @@ Standard_EXPORT void ChFi3d_PerformElSpine(Handle(ChFiDS_HElSpine)& HES, if(ES.IsPeriodic()) { if(!BSpline->IsPeriodic()) { BSpline->SetPeriodic(); - Bof = BSpline->RemoveKnot(1, MultMax, Abs(WL-WF)/10); + //modified by NIZNHY-PKV Fri Dec 10 12:20:22 2010ft + if (iToApproxByC2) { + Bof = BSpline->RemoveKnot(1, MultMax, Abs(WL-WF)/10); + } + //Bof = BSpline->RemoveKnot(1, MultMax, Abs(WL-WF)/10); + //modified by NIZNHY-PKV Mon Dec 13 14:12:54 2010t } } else { @@ -4468,25 +4293,13 @@ Standard_EXPORT void ChFi3d_PerformElSpine(Handle(ChFiDS_HElSpine)& HES, // the same at the end adjust = Standard_True; } - if(adjust) GeomLib::AdjustExtremity(BSpline, PDeb, PFin, VrefDeb, VrefFin); + if(adjust) { + GeomLib::AdjustExtremity(BSpline, PDeb, PFin, VrefDeb, VrefFin); + } } - // The result -#if DEB - if (! BSpline->IsCN(2)) cout << "Attention Spine non C2 !" << endl; -#endif - + // Le Resultat ES.SetCurve(BSpline); -#ifdef DRAW - ChFi3d_SettraceDRAWSPINE(1); - if (ChFi3d_GettraceDRAWSPINE()) { - char name[100]; - sprintf(name,"elspine_%d",NbSp++); - char* Temp = name; - DrawTrSurf::Set(Temp,BSpline); -// DrawTrSurf::Set(name,BSpline); - } -#endif } //======================================================================= @@ -4512,7 +4325,6 @@ void ChFi3d_cherche_face1 (const TopTools_ListOfShape & map, //purpose : find edge E of F1 other than E1 and containing vertex V // Vtx is the other vertex of E //======================================================================= - void ChFi3d_cherche_element(const TopoDS_Vertex & V, const TopoDS_Edge & E1, const TopoDS_Face & F1, @@ -4552,7 +4364,6 @@ void ChFi3d_cherche_element(const TopoDS_Vertex & V, //purpose : find edge E of F1 other than the list of edges E1 and // containing vertex V Vtx is the other vertex of E. //======================================================================= - void ChFi3d_cherche_edge(const TopoDS_Vertex & V, const TopTools_Array1OfShape & E1, const TopoDS_Face & F1, @@ -4619,7 +4430,6 @@ Standard_Integer ChFi3d_nbface (const TopTools_ListOfShape & mapVF ) //purpose : determines two faces sharing an edge. // F1 = F2 if there is an edge to parce //======================================================================= - void ChFi3d_edge_common_faces (const TopTools_ListOfShape & mapEF, TopoDS_Face & F1, TopoDS_Face & F2) @@ -4772,9 +4582,10 @@ void ChFi3d_cherche_vertex (const TopoDS_Edge & E1, } } } -//============================================================ -// determines if F has an edge of sewing -//============================================================= +//======================================================================= +//function : ChFi3d_Couture +//purpose : determine si F a une arete de couture +//======================================================================= void ChFi3d_Couture( const TopoDS_Face & F, Standard_Boolean & couture, TopoDS_Edge & edgecouture) @@ -4795,6 +4606,10 @@ void ChFi3d_Couture( const TopoDS_Face & F, } } +//======================================================================= +//function : ChFi3d_CoutureOnVertex +//purpose : +//======================================================================= void ChFi3d_CoutureOnVertex( const TopoDS_Face & F, const TopoDS_Vertex & V, Standard_Boolean & couture, @@ -4821,9 +4636,12 @@ void ChFi3d_CoutureOnVertex( const TopoDS_Face & F, } } } - +//======================================================================= +//function : ChFi3d_IsPseudoSeam +//purpose : +//======================================================================= Standard_Boolean ChFi3d_IsPseudoSeam( const TopoDS_Edge& E, - const TopoDS_Face& F ) + const TopoDS_Face& F ) { if (! BRep_Tool::IsClosed( E, F )) return Standard_False; @@ -4849,6 +4667,10 @@ Standard_Boolean ChFi3d_IsPseudoSeam( const TopoDS_Edge& E, return NeighborSeamFound; } +//======================================================================= +//function : ChFi3d_ApproxByC2 +//purpose : +//======================================================================= Handle(Geom_BSplineCurve) ChFi3d_ApproxByC2( const Handle(Geom_Curve)& C ) { Standard_Real First = C->FirstParameter(), Last = C->LastParameter(); @@ -4864,7 +4686,10 @@ Handle(Geom_BSplineCurve) ChFi3d_ApproxByC2( const Handle(Geom_Curve)& C ) Handle(Geom_BSplineCurve) BS = Approx.Curve(); return BS; } - +//======================================================================= +//function : ChFi3d_IsSmooth +//purpose : +//======================================================================= Standard_Boolean ChFi3d_IsSmooth( const Handle(Geom_Curve)& C ) { GeomAdaptor_Curve GAC( C ); @@ -4878,14 +4703,6 @@ Standard_Boolean ChFi3d_IsSmooth( const Handle(Geom_Curve)& C ) gp_Pnt P1, P2; Standard_Integer Discretisation = 30; -// Standard_Real t = TI(1); -// LProp.SetParameter(t); -// if (!LProp.IsTangentDefined()) -// return Standard_False; -// C->D0(t, P1); -// LProp.CentreOfCurvature(P2); -// gp_Vec PrevVec(P1, P2); - gp_Vec PrevVec; Standard_Boolean prevVecFound = Standard_False; Standard_Integer intrvFound = 0;