const Standard_Boolean AdjustToEnds) const
{
+
Standard_Real uMin = C3D.FirstParameter();
Standard_Real uMax = C3D.LastParameter();
- Standard_Real distmin;
- if (!Precision::IsInfinite(uMin)||!Precision::IsInfinite(uMax)) {
- Standard_Real prec = ( AdjustToEnds ? preci : Precision::Confusion() ); //:j8 abv 10 Dec 98: tr10_r0501_db.stp #9423: protection against densing of points near one end
- gp_Pnt LowBound = C3D.Value(uMin);
- gp_Pnt HigBound = C3D.Value(uMax);
- distmin = LowBound.Distance(P3D);
- if (distmin <= prec) {
- param = uMin;
- proj = LowBound;
- return distmin;
- }
- distmin = HigBound.Distance(P3D);
- if (distmin <= prec) {
- param = uMax;
- proj = HigBound;
- return distmin;
- }
+
+ if (Precision::IsInfinite(uMin) && Precision::IsInfinite(uMax))
+ return ProjectAct(C3D, P3D, preci, proj, param);
+
+ Standard_Real distmin_L = Precision::Infinite(), distmin_H = Precision::Infinite();
+ Standard_Real prec = ( AdjustToEnds ? preci : Precision::Confusion() ); //:j8 abv 10 Dec 98: tr10_r0501_db.stp #9423: protection against densing of points near one end
+ gp_Pnt LowBound = C3D.Value(uMin);
+ gp_Pnt HigBound = C3D.Value(uMax);
+ distmin_L = LowBound.Distance(P3D);
+ distmin_H = HigBound.Distance(P3D);
+
+ if (distmin_L <= prec) {
+ param = uMin;
+ proj = LowBound;
+ return distmin_L;
}
- return ProjectAct(C3D, P3D, preci, proj, param);
+
+ if (distmin_H <= prec) {
+ param = uMax;
+ proj = HigBound;
+ return distmin_H;
+ }
+
+ Standard_Real distProj = ProjectAct(C3D, P3D, preci, proj, param);
+ if( distProj < distmin_L + Precision::Confusion() && distProj < distmin_H + Precision::Confusion())
+ return distProj;
+
+ if( distmin_L < distmin_H)
+ {
+ param = uMin;
+ proj = LowBound;
+ return distmin_L;
+ }
+ param = uMax;
+ proj = HigBound;
+ return distmin_H;
+
}
//=======================================================================
{
Standard_Boolean OK = Standard_False;
+ param = 0.;
try {
OCC_CATCH_SIGNALS
Extrema_ExtPC myExtPC(P3D,C3D);
Standard_Failure::Caught()->Print(cout); cout << endl;
#endif
}
-
+
//szv#4:S4163:12Mar99 moved
Standard_Real uMin = C3D.FirstParameter(), uMax = C3D.LastParameter();
Standard_Boolean closed = Standard_False; // si on franchit les bornes ...
- Standard_Real distmin = RealLast(), valclosed = 0.;
+ Standard_Real distmin = Precision::Infinite(), valclosed = 0.;
Standard_Real aModParam = param;
Standard_Real aModMin = distmin;
{
Standard_Real uMin = (cf < cl ? cf : cl);
Standard_Real uMax = (cf < cl ? cl : cf);
- Standard_Real distmin;
+ Standard_Real distmin = Precision::Infinite();
if (C3D->IsKind(STANDARD_TYPE(Geom_BoundedCurve))) {
Standard_Real prec = ( AdjustToEnds ? preci : Precision::Confusion() ); //:j8 abv 10 Dec 98: tr10_r0501_db.stp #9423: protection against densing of points near one end
gp_Pnt LowBound = C3D->Value(uMin);
{
myFace = F;
myEdge = E;
+ myFirstParam = myLastParam = 0.;
myFirstDone = myLastDone = Standard_False;
}
Handle(Geom_Surface) theSurface = BRep_Tool::Surface(myFace);
Handle(Geom2d_Curve) theCurve2d = BRep_Tool::CurveOnSurface(myEdge, myFace, cf, cl);
if ( theCurve2d.IsNull() ) return; //:r5 abv 6 Apr 99: ec_turbine-A.stp, #4313
-
+ myFirstParam = cf;
+ myLastParam = cl;
TopoDS_Vertex V1,V2;
TopExp::Vertices(myEdge, V1, V2);
gp_Pnt Pt1,Pt2;
Pt1 = BRep_Tool::Pnt(V1);
Pt2 = BRep_Tool::Pnt(V2);
}
-//:S4136 Standard_Real preci = BRepAPI::Precision();
+ //:S4136 Standard_Real preci = BRepAPI::Precision();
//pdn to manage degenerated case
if (V1.IsSame(V2)) {
Handle(ShapeAnalysis_Surface) stsu = new ShapeAnalysis_Surface (theSurface);
gp_Pnt2d aPt1,aPt2;
Standard_Real firstpar,lastpar;
if (stsu->DegeneratedValues(Pt1,preci,aPt1,aPt2,firstpar,lastpar)){
-
+
if(theCurve2d->IsKind(STANDARD_TYPE(Geom2d_Line))) {
- if (aPt1.IsEqual(theCurve2d->Value(firstpar),preci) &&
- aPt2.IsEqual(theCurve2d->Value(lastpar),preci)){
- myFirstParam = firstpar;
- myLastParam = lastpar;
- myFirstDone = myLastDone = Standard_True;
- return;
- }
+ if (aPt1.IsEqual(theCurve2d->Value(firstpar),preci) &&
+ aPt2.IsEqual(theCurve2d->Value(lastpar),preci)){
+ myFirstParam = firstpar;
+ myLastParam = lastpar;
+ myFirstDone = myLastDone = Standard_True;
+ return;
+ }
}
#ifdef DEBUG
else cout <<"Other type of deg curve"<<endl;
#endif
-
+
}
}
-
+
Standard_Boolean parU = Standard_False, parV = Standard_False;
GeomAdaptor_Surface SA = GeomAdaptor_Surface(theSurface);
Handle(GeomAdaptor_HSurface) myHSur = new GeomAdaptor_HSurface(SA);
-
+
cf = theCurve2d->FirstParameter();
cl = theCurve2d->LastParameter();
//pdn cutting pcurve by suface bounds
Standard_Real uf,ul,vf,vl;
theSurface->Bounds(uf,ul,vf,vl);
if(!Precision::IsInfinite(uf)&&!Precision::IsInfinite(ul)&&
- !Precision::IsInfinite(vf)&&!Precision::IsInfinite(vl)) {
- Standard_Real cfi,cli;
- Handle(Geom2d_Line) lin = Handle(Geom2d_Line)::DownCast(theCurve2d);
- gp_Pnt2d pnt = lin->Location();
- gp_Dir2d dir = lin->Direction();
- if (dir.Y()==0) {
- parU = Standard_True;
- cfi = (uf-pnt.X())/dir.X();
- cli = (ul-pnt.X())/dir.X();
- }
- else if (dir.X()==0) {
- parV = Standard_True;
- cfi = (vf-pnt.Y())/dir.Y();
- cli = (vl-pnt.Y())/dir.Y();
- }
- else {//common case
- Standard_Real xfi, xli, yfi, yli;
- xfi = (uf-pnt.X())/dir.X();
- xli = (ul-pnt.X())/dir.X();
- yfi = (vf-pnt.Y())/dir.Y();
- yli = (vl-pnt.Y())/dir.Y();
- if (dir.X()*dir.Y() > 0) {
- cfi = (Abs(xli-xfi) < Abs(xli-yfi)? xfi : yfi);
- cli = (Abs(xfi-xli) < Abs(xfi-yli)? xli : yli);
- } else {
- cfi = (Abs(xli-xfi) < Abs(xli-yli)? xfi : yli);
- cli = (Abs(yli-xli) < Abs(yli-yfi)? xli : yfi);
- }
- }
- if (cfi < cli) { cf = cfi; cl = cli; }
- else { cf = cli; cl = cfi; }
+ !Precision::IsInfinite(vf)&&!Precision::IsInfinite(vl)) {
+ Standard_Real cfi,cli;
+ Handle(Geom2d_Line) lin = Handle(Geom2d_Line)::DownCast(theCurve2d);
+ gp_Pnt2d pnt = lin->Location();
+ gp_Dir2d dir = lin->Direction();
+ if (dir.Y()==0) {
+ parU = Standard_True;
+ cfi = (uf-pnt.X())/dir.X();
+ cli = (ul-pnt.X())/dir.X();
+ }
+ else if (dir.X()==0) {
+ parV = Standard_True;
+ cfi = (vf-pnt.Y())/dir.Y();
+ cli = (vl-pnt.Y())/dir.Y();
+ }
+ else {//common case
+ Standard_Real xfi, xli, yfi, yli;
+ xfi = (uf-pnt.X())/dir.X();
+ xli = (ul-pnt.X())/dir.X();
+ yfi = (vf-pnt.Y())/dir.Y();
+ yli = (vl-pnt.Y())/dir.Y();
+ if (dir.X()*dir.Y() > 0) {
+ cfi = (Abs(xli-xfi) < Abs(xli-yfi)? xfi : yfi);
+ cli = (Abs(xfi-xli) < Abs(xfi-yli)? xli : yli);
+ } else {
+ cfi = (Abs(xli-xfi) < Abs(xli-yli)? xfi : yli);
+ cli = (Abs(yli-xli) < Abs(yli-yfi)? xli : yfi);
+ }
+ }
+ if (cfi < cli) { cf = cfi; cl = cli; }
+ else { cf = cli; cl = cfi; }
}
else if(!Precision::IsInfinite(uf)&&!Precision::IsInfinite(ul)){
- Handle(Geom2d_Line) lin = Handle(Geom2d_Line)::DownCast(theCurve2d);
- gp_Dir2d dir = lin->Direction();
- if (dir.X()!=0) {
- if (dir.Y()==0) parU = Standard_True;
- gp_Pnt2d pnt = lin->Location(); //szv#4:S4163:12Mar99 moved
- Standard_Real cfi = (uf-pnt.X())/dir.X();
- Standard_Real cli = (ul-pnt.X())/dir.X();
- if (cfi < cli) { cf = cfi; cl = cli; }
- else { cf = cli; cl = cfi; }
- }
- else {
- cf=-10000;
- cl= 10000;
- }
+ Handle(Geom2d_Line) lin = Handle(Geom2d_Line)::DownCast(theCurve2d);
+ gp_Dir2d dir = lin->Direction();
+ if (dir.X()!=0) {
+ if (dir.Y()==0) parU = Standard_True;
+ gp_Pnt2d pnt = lin->Location(); //szv#4:S4163:12Mar99 moved
+ Standard_Real cfi = (uf-pnt.X())/dir.X();
+ Standard_Real cli = (ul-pnt.X())/dir.X();
+ if (cfi < cli) { cf = cfi; cl = cli; }
+ else { cf = cli; cl = cfi; }
+ }
+ else {
+ cf=-10000;
+ cl= 10000;
+ }
}
else {
- cf=-10000;
- cl= 10000;
- //pdn not cutted by bounds
+ cf=-10000;
+ cl= 10000;
+ //pdn not cutted by bounds
#ifdef DEBUG
- cout<<"Infinite Surface"<<endl;
+ cout<<"Infinite Surface"<<endl;
#endif
}
}
#endif
}
}
-
+ myFirstParam = cf;
+ myLastParam = cl;
Geom2dAdaptor_Curve CA = Geom2dAdaptor_Curve(theCurve2d,cf,cl);
Handle(Geom2dAdaptor_HCurve) myHCur = new Geom2dAdaptor_HCurve(CA);
-
+
Adaptor3d_CurveOnSurface COnS = Adaptor3d_CurveOnSurface(myHCur, myHSur);
// ----------------------------------------------
// ----------------------------------------------
Standard_Real Uinf = COnS.FirstParameter();
Standard_Real Usup = COnS.LastParameter();
-
- Standard_Real w1,w2;
+ myFirstDone = myLastDone = Standard_True;
+ Standard_Real w1 = 0., w2 = 0.;
ShapeAnalysis_Curve sac;
gp_Pnt pnt;
Standard_Real dist = sac.Project(COnS,Pt1,preci,pnt,w1,Standard_False);
- if (dist > preci) return;
+ //if distance is infinite then projection is not performed
+ if( Precision::IsInfinite(dist))
+ {
+ myFirstDone = Standard_False;
+ myLastDone = Standard_False;
+ return;
+ }
+
+ if (dist > preci)
+ return;
dist = sac.Project(COnS,Pt2,preci,pnt,w2,Standard_False);
- if (dist > preci) return;
-
+ if( Precision::IsInfinite(dist))
+ {
+ myLastDone = Standard_False;
+ return;
+ }
+ if (dist > preci)
+ return;
+ if(fabs(w1 - w2) < Precision::PConfusion())
+ {
+ if(!theSurface->IsUPeriodic() && !theSurface->IsVPeriodic())
+ return;
+ }
myFirstParam = w1;
myLastParam = w2;
myFirstDone = myLastDone = Standard_True;
if ( COnS.Value(Uinf).Distance ( COnS.Value(Usup) ) < Precision::Confusion() ) {
// 18.11.2002 SKL OCC630 compare values with tolerance Precision::PConfusion() instead of "=="
if ( Abs(myFirstParam-Uinf) < ::Precision::PConfusion() &&
- Abs(myLastParam-Uinf) < ::Precision::PConfusion() )
- myLastParam = w2 = Usup;
+ Abs(myLastParam-Uinf) < ::Precision::PConfusion() )
+ myLastParam = w2 = Usup;
// 18.11.2002 SKL OCC630 compare values with tolerance Precision::PConfusion() instead of "=="
else if ( Abs(myFirstParam-Usup) < ::Precision::PConfusion() &&
- Abs(myLastParam-Usup) < ::Precision::PConfusion() )
- myFirstParam = w1 = Uinf;
+ Abs(myLastParam-Usup) < ::Precision::PConfusion() )
+ myFirstParam = w1 = Uinf;
}
-
+
//pdn adjust parameters in periodic case
if(parU || parV) {
Standard_Real uf,ul,vf,vl;
if(w1>w2) {
if(w2 > wmid) myFirstParam -= period;
else if (w1 > wmid)
- UpdateParam2d(theCurve2d);
+ UpdateParam2d(theCurve2d);
else {
- myLastParam+=period;
+ myLastParam+=period;
#ifdef DEBUG
- cout <<" Added"<<endl;
+ cout <<" Added"<<endl;
#endif
}
}
else {
if(w1 > wmid) {
- myLastParam -=period;
- UpdateParam2d(theCurve2d);
+ myLastParam -=period;
+ UpdateParam2d(theCurve2d);
#ifdef DEBUG
- cout <<" Added & Inverted"<<endl;
+ cout <<" Added & Inverted"<<endl;
#endif
} else if (w2 < wmid) {
- myFirstParam += period;
- UpdateParam2d(theCurve2d);
+ myFirstParam += period;
+ UpdateParam2d(theCurve2d);
}
}
}
Handle(Geom2d_Curve) theCurve2d = BRep_Tool::CurveOnSurface(myEdge, myFace, cf, cl);
if ( theCurve2d.IsNull() ) return; //:r5 abv 6 Apr 99: ec_turbine-A.stp, #4313
TopoDS_Vertex V1,V2;
-
+
V1 = TopExp::FirstVertex(myEdge);
V2 = TopExp::LastVertex(myEdge);
gp_Pnt Pt1 = BRep_Tool::Pnt(V1);