From: ifv Date: Thu, 3 Oct 2013 12:13:10 +0000 (+0400) Subject: 0023981: Wrong section curves X-Git-Tag: V6_7_0_beta~98 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=7c4e9501b4845cb293ced0c3bfe3089ae75571ea;p=occt-copy.git 0023981: Wrong section curves Test case for issue CR23981 Small correction of test case for issue CR23981 --- diff --git a/src/Adaptor3d/Adaptor3d_TopolTool.cxx b/src/Adaptor3d/Adaptor3d_TopolTool.cxx index 8d23eed134..8f7b823177 100755 --- a/src/Adaptor3d/Adaptor3d_TopolTool.cxx +++ b/src/Adaptor3d/Adaptor3d_TopolTool.cxx @@ -24,7 +24,7 @@ #include #include -#define myInfinite 1.e15 +#define myInfinite Precision::Infinite() static void GetConeApexParam(const gp_Cone& C, Standard_Real& U, Standard_Real& V) { @@ -282,12 +282,12 @@ TopAbs_State Adaptor3d_TopolTool::Classify(const gp_Pnt2d& P, if (nbRestr == 4) { if ((U < Uinf - Tol) || (U > Usup + Tol) || - (V < Vinf - Tol) || (V > Vsup + Tol)) { - return TopAbs_OUT; + (V < Vinf - Tol) || (V > Vsup + Tol)) { + return TopAbs_OUT; } if ((Abs(U - Uinf) <= Tol) || (Abs(U - Usup) <= Tol) || - (Abs(V - Vinf) <= Tol) || (Abs(V - Vsup) <= Tol)) { - return TopAbs_ON; + (Abs(V - Vinf) <= Tol) || (Abs(V - Vsup) <= Tol)) { + return TopAbs_ON; } return TopAbs_IN; } @@ -297,100 +297,100 @@ TopAbs_State Adaptor3d_TopolTool::Classify(const gp_Pnt2d& P, else { Standard_Boolean dansu,dansv,surumin,surumax,survmin,survmax; if (Precision::IsNegativeInfinite(Uinf) && - Precision::IsPositiveInfinite(Usup)) { + Precision::IsPositiveInfinite(Usup)) { dansu = Standard_True; surumin = surumax = Standard_False; } else if (Precision::IsNegativeInfinite(Uinf)) { surumin = Standard_False; if (U >= Usup+Tol) { - dansu = Standard_False; - surumax = Standard_False; + dansu = Standard_False; + surumax = Standard_False; } else { - dansu = Standard_True; - surumax = Standard_False; - if (Abs(U-Usup)<=Tol) { - surumax = Standard_True; - } + dansu = Standard_True; + surumax = Standard_False; + if (Abs(U-Usup)<=Tol) { + surumax = Standard_True; + } } } else if (Precision::IsPositiveInfinite(Usup)) { surumax = Standard_False; if (U < Uinf-Tol) { - dansu = Standard_False; - surumin = Standard_False; + dansu = Standard_False; + surumin = Standard_False; } else { - dansu = Standard_True; - surumin = Standard_False; - if (Abs(U-Uinf)<=Tol) { - surumin = Standard_True; - } + dansu = Standard_True; + surumin = Standard_False; + if (Abs(U-Uinf)<=Tol) { + surumin = Standard_True; + } } } else { if ((U < Uinf - Tol) || (U > Usup + Tol)) { - surumin = surumax = dansu = Standard_False; + surumin = surumax = dansu = Standard_False; } else { - dansu = Standard_True; - surumin = surumax = Standard_False; - if (Abs(U-Uinf)<=Tol) { - surumin = Standard_True; - } - else if (Abs(U-Usup)<=Tol) { - surumax = Standard_True; - } + dansu = Standard_True; + surumin = surumax = Standard_False; + if (Abs(U-Uinf)<=Tol) { + surumin = Standard_True; + } + else if (Abs(U-Usup)<=Tol) { + surumax = Standard_True; + } } } if (Precision::IsNegativeInfinite(Vinf) && - Precision::IsPositiveInfinite(Vsup)) { + Precision::IsPositiveInfinite(Vsup)) { dansv = Standard_True; survmin = survmax = Standard_False; } else if (Precision::IsNegativeInfinite(Vinf)) { survmin = Standard_False; if (V > Vsup+Tol) { - dansv = Standard_False; - survmax = Standard_False; + dansv = Standard_False; + survmax = Standard_False; } else { - dansv = Standard_True; - survmax = Standard_False; - if (Abs(V-Vsup)<=Tol) { - survmax = Standard_True; - } + dansv = Standard_True; + survmax = Standard_False; + if (Abs(V-Vsup)<=Tol) { + survmax = Standard_True; + } } } else if (Precision::IsPositiveInfinite(Vsup)) { survmax = Standard_False; if (V < Vinf-Tol) { - dansv = Standard_False; - survmin = Standard_False; + dansv = Standard_False; + survmin = Standard_False; } else { - dansv = Standard_True; - survmin = Standard_False; - if (Abs(V-Vinf)<=Tol) { - survmin = Standard_True; - } + dansv = Standard_True; + survmin = Standard_False; + if (Abs(V-Vinf)<=Tol) { + survmin = Standard_True; + } } } else { if ((V < Vinf - Tol) || (V > Vsup + Tol)) { - survmin = survmax = dansv = Standard_False; + survmin = survmax = dansv = Standard_False; } else { - dansv = Standard_True; - survmin = survmax = Standard_False; - if (Abs(V-Vinf)<=Tol) { - survmin = Standard_True; - } - else if (Abs(V-Vsup)<=Tol) { - survmax = Standard_True; - } + dansv = Standard_True; + survmin = survmax = Standard_False; + if (Abs(V-Vinf)<=Tol) { + survmin = Standard_True; + } + else if (Abs(V-Vsup)<=Tol) { + survmax = Standard_True; + } } } @@ -1269,12 +1269,12 @@ void Adaptor3d_TopolTool::BSplSamplePnts(const Standard_Real theDefl, // for(j = 0, i = 1; i <= nbsu; ++i) { if (bFlag) { - myUPars->SetValue(i,anUPars(i)); + myUPars->SetValue(i,anUPars(i)); } else { if(anUFlg(i)) { - ++j; - myUPars->SetValue(j,anUPars(i)); + ++j; + myUPars->SetValue(j,anUPars(i)); } } } @@ -1293,8 +1293,8 @@ void Adaptor3d_TopolTool::BSplSamplePnts(const Standard_Real theDefl, } else { if(aVFlg(i)) { - ++j; - myVPars->SetValue(j,aVPars(i)); + ++j; + myVPars->SetValue(j,aVPars(i)); } } } diff --git a/src/Extrema/Extrema_ExtPElS.cxx b/src/Extrema/Extrema_ExtPElS.cxx index 16d8313e88..83f0383ec7 100755 --- a/src/Extrema/Extrema_ExtPElS.cxx +++ b/src/Extrema/Extrema_ExtPElS.cxx @@ -22,6 +22,7 @@ #include #include #include +static const Standard_Real ExtPElS_MyEps = Epsilon(2. * M_PI); //============================================================================= Extrema_ExtPElS::Extrema_ExtPElS () { myDone = Standard_False; } @@ -70,6 +71,7 @@ void Extrema_ExtPElS::Perform(const gp_Pnt& P, if (OPp.Magnitude() < Tol) { return; } gp_Vec myZ = Pos.XDirection()^Pos.YDirection(); Standard_Real U1 = gp_Vec(Pos.XDirection()).AngleWithRef(OPp,myZ); //-M_PI -ExtPElS_MyEps && U1 < ExtPElS_MyEps) { U1 = 0.; } Standard_Real U2 = U1 + M_PI; if (U1 < 0.) { U1 += 2. * M_PI; } @@ -164,6 +166,7 @@ void Extrema_ExtPElS::Perform(const gp_Pnt& P, Standard_Real B, U1, V1, U2, V2; Standard_Boolean Same = DirZ.Dot(MP) >= 0.0; U1 = gp_Vec(Pos.XDirection()).AngleWithRef(OPp,myZ); //-M_PI -ExtPElS_MyEps && U1 < ExtPElS_MyEps) { U1 = 0.; } B = MP.Angle(DirZ); if (!Same) { U1 += M_PI; } U2 = U1 + M_PI; @@ -257,6 +260,7 @@ void Extrema_ExtPElS::Perform(const gp_Pnt& P, else { gp_Vec myZ = Pos.XDirection()^Pos.YDirection(); U1 = gp_Vec(Pos.XDirection()).AngleWithRef(OPp,myZ); + if (U1 > -ExtPElS_MyEps && U1 < ExtPElS_MyEps) { U1 = 0.; } U2 = U1 + M_PI; if (U1 < 0.) { U1 += 2. * M_PI; } V = OP.Angle(OPp); @@ -321,6 +325,7 @@ void Extrema_ExtPElS::Perform(const gp_Pnt& P, gp_Vec myZ = Pos.XDirection()^Pos.YDirection(); Standard_Real U1 = gp_Vec(Pos.XDirection()).AngleWithRef(OPp,myZ); + if (U1 > -ExtPElS_MyEps && U1 < ExtPElS_MyEps) { U1 = 0.; } Standard_Real U2 = U1 + M_PI; if (U1 < 0.) { U1 += 2. * M_PI; } Standard_Real R = sqrt(R2); @@ -333,7 +338,10 @@ void Extrema_ExtPElS::Perform(const gp_Pnt& P, if(O2.SquareDistance(P) < Tol) { return; } Standard_Real V1 = OO1.AngleWithRef(gp_Vec(O1,P),OO1.Crossed(OZ)); + if (V1 > -ExtPElS_MyEps && V1 < ExtPElS_MyEps) { V1 = 0.; } Standard_Real V2 = OO2.AngleWithRef(gp_Vec(P,O2),OO2.Crossed(OZ)); + if (V2 > -ExtPElS_MyEps && V2 < ExtPElS_MyEps) { V2 = 0.; } + if (V1 < 0.) { V1 += 2. * M_PI; } if (V2 < 0.) { V2 += 2. * M_PI; } diff --git a/src/GeomInt/GeomInt_IntSS_1.cxx b/src/GeomInt/GeomInt_IntSS_1.cxx index 684fb91cfd..f9af783a78 100755 --- a/src/GeomInt/GeomInt_IntSS_1.cxx +++ b/src/GeomInt/GeomInt_IntSS_1.cxx @@ -336,66 +336,66 @@ Standard_Real ProjectPointOnSurf::LowerDistance() const } // if(myApprox2) { - Handle (Geom2d_Curve) C2d; - BuildPCurves(fprm,lprm,Tolpc,myHS2->ChangeSurface().Surface(),newc,C2d); - if(Tolpc>myTolReached2d || myTolReached2d==0.) { - myTolReached2d=Tolpc; - } - // - slineS2.Append(new Geom2d_TrimmedCurve(C2d,fprm,lprm)); - } - else { - slineS2.Append(H1); - } + Handle (Geom2d_Curve) C2d; + BuildPCurves(fprm,lprm,Tolpc,myHS2->ChangeSurface().Surface(),newc,C2d); + if(Tolpc>myTolReached2d || myTolReached2d==0.) { + myTolReached2d=Tolpc; + } + // + slineS2.Append(new Geom2d_TrimmedCurve(C2d,fprm,lprm)); + } + else { + slineS2.Append(H1); + } } // if (!Precision::IsNegativeInfinite(fprm) && !Precision::IsPositiveInfinite(lprm)) else { - GeomAbs_SurfaceType typS1 = myHS1->Surface().GetType(); - GeomAbs_SurfaceType typS2 = myHS2->Surface().GetType(); - if( typS1 == GeomAbs_SurfaceOfExtrusion || - typS1 == GeomAbs_OffsetSurface || - typS1 == GeomAbs_SurfaceOfRevolution || - typS2 == GeomAbs_SurfaceOfExtrusion || - typS2 == GeomAbs_OffsetSurface || - typS2 == GeomAbs_SurfaceOfRevolution) { - sline.Append(newc); - slineS1.Append(H1); - slineS2.Append(H1); - continue; - } - Standard_Boolean bFNIt, bLPIt; - Standard_Real aTestPrm, dT=100.; - Standard_Real u1, v1, u2, v2, TolX; - // - bFNIt=Precision::IsNegativeInfinite(fprm); - bLPIt=Precision::IsPositiveInfinite(lprm); - - aTestPrm=0.; - - if (bFNIt && !bLPIt) { - aTestPrm=lprm-dT; - } - else if (!bFNIt && bLPIt) { - aTestPrm=fprm+dT; - } - // - gp_Pnt ptref(newc->Value(aTestPrm)); - // - TolX = Precision::Confusion(); - Parameters(myHS1, myHS2, ptref, u1, v1, u2, v2); - ok = (dom1->Classify(gp_Pnt2d(u1, v1), TolX) != TopAbs_OUT); - if(ok) { - ok = (dom2->Classify(gp_Pnt2d(u2,v2),TolX) != TopAbs_OUT); - } - if (ok) { - sline.Append(newc); - slineS1.Append(H1); - slineS2.Append(H1); - } + GeomAbs_SurfaceType typS1 = myHS1->Surface().GetType(); + GeomAbs_SurfaceType typS2 = myHS2->Surface().GetType(); + if( typS1 == GeomAbs_SurfaceOfExtrusion || + typS1 == GeomAbs_OffsetSurface || + typS1 == GeomAbs_SurfaceOfRevolution || + typS2 == GeomAbs_SurfaceOfExtrusion || + typS2 == GeomAbs_OffsetSurface || + typS2 == GeomAbs_SurfaceOfRevolution) { + sline.Append(newc); + slineS1.Append(H1); + slineS2.Append(H1); + continue; + } + Standard_Boolean bFNIt, bLPIt; + Standard_Real aTestPrm, dT=100.; + Standard_Real u1, v1, u2, v2, TolX; + // + bFNIt=Precision::IsNegativeInfinite(fprm); + bLPIt=Precision::IsPositiveInfinite(lprm); + + aTestPrm=0.; + + if (bFNIt && !bLPIt) { + aTestPrm=lprm-dT; + } + else if (!bFNIt && bLPIt) { + aTestPrm=fprm+dT; + } + // + gp_Pnt ptref(newc->Value(aTestPrm)); + // + TolX = Precision::Confusion(); + Parameters(myHS1, myHS2, ptref, u1, v1, u2, v2); + ok = (dom1->Classify(gp_Pnt2d(u1, v1), TolX) != TopAbs_OUT); + if(ok) { + ok = (dom2->Classify(gp_Pnt2d(u2,v2),TolX) != TopAbs_OUT); + } + if (ok) { + sline.Append(newc); + slineS1.Append(H1); + slineS2.Append(H1); + } } }// end of for (i=1; i<=myLConstruct.NbParts(); i++) - }// case IntPatch_Lin: case IntPatch_Parabola: case IntPatch_Hyperbola: - break; + }// case IntPatch_Lin: case IntPatch_Parabola: case IntPatch_Hyperbola: + break; //######################################## // Circle and Ellipse @@ -952,7 +952,19 @@ Standard_Real ProjectPointOnSurf::LowerDistance() const mbspc.Degree()); GeomLib_CheckBSplineCurve Check(BS,myTolCheck,myTolAngCheck); Check.FixTangent(Standard_True,Standard_True); - // + // + //Check IsClosed() + Standard_Real aDist = Max(BS->StartPoint().XYZ().SquareModulus(), + BS->EndPoint().XYZ().SquareModulus()); + Standard_Real eps = Epsilon(aDist); + if(BS->StartPoint().SquareDistance(BS->EndPoint()) < 2.*eps && + !BS->IsClosed() && !BS->IsPeriodic()) + { + //force Closed() + gp_Pnt aPm((BS->Pole(1).XYZ() + BS->Pole(BS->NbPoles()).XYZ()) / 2.); + BS->SetPole(1, aPm); + BS->SetPole(BS->NbPoles(), aPm); + } sline.Append(BS); if(myApprox1) { diff --git a/src/IntPatch/IntPatch_RstInt.cxx b/src/IntPatch/IntPatch_RstInt.cxx index 36789e8886..7aac96b2d2 100755 --- a/src/IntPatch/IntPatch_RstInt.cxx +++ b/src/IntPatch/IntPatch_RstInt.cxx @@ -51,6 +51,7 @@ #include #include +#define myInfinite 1.e15 // the same as was in Adaptor3d_TopolTool static void Recadre(GeomAbs_SurfaceType typeS1, GeomAbs_SurfaceType typeS2, @@ -558,11 +559,15 @@ void IntPatch_RstInt::PutVertexOnLine (Handle(IntPatch_Line)& L, Standard_Real VRes = Surf->VResolution(edgeTol); IntPatch_HInterTool::Bounds(arc,PFirst,PLast); - if (Precision::IsNegativeInfinite(PFirst) || - Precision::IsPositiveInfinite(PLast)) { - //-- cout<<" IntPatch_RstInt::PutVertexOnLine ---> Restrictions Infinies :"< Restrictions Infinies :"<U0) { Umin=U0-10.0; } if(Umax(nTolTangency+nTolTangency)) { - EpsX = nTolTangency * 0.1; - } - //-------------------------------------------------- - // - Plant with a edge with 2 Samples - // - Whose ends are solutions (f = 0) - // - And the derivative is zero or - // - Example: a diameter of a sphere segment - if(NbEchant<3) NbEchant = 3; //-- lbr 19.04.95 - //-------------------------------------------------- - - Standard_Real PDeb = Pdeb; - Standard_Real PFin = Pfin; - - ComputeBoundsfromInfinite(Func,PDeb,PFin,NbEchant); - - math_FunctionSample Echant(PDeb,PFin,NbEchant); - math_FunctionAllRoots Sol(Func,Echant,EpsX,TolBoundary,nTolTangency); - - if (!Sol.IsDone()) {Standard_Failure::Raise();} - - Nbp=Sol.NbPoints(); - for (i=1; i<=Nbp; i++) { - Standard_Real para = Sol.GetPoint(i); - Standard_Real dist; - if(Func.Value(para,dist)) { - PointProcess(Func.Valpoint(Sol.GetPointState(i)),Sol.GetPoint(i), - A,Domain,pnt,TolBoundary,range); - } - } - - // For each interval: - // Process the ends as points - // Add range in the list of segments - - Nbi=Sol.NbIntervals(); - - for (i=1; i<=Nbi; i++) { - IntStart_TheSegment newseg; - newseg.SetValue(A); - // Recover start and end points, and parameter. - Sol.GetInterval(i,pardeb,parfin); - Sol.GetIntervalState(i,ideb,ifin); - ptdeb=Func.Valpoint(ideb); - ptfin=Func.Valpoint(ifin); - - PointProcess(ptdeb,pardeb,A,Domain,pnt,TolBoundary,ranged); - newseg.SetLimitPoint(pnt.Value(ranged),Standard_True); - PointProcess(ptfin,parfin,A,Domain,pnt,TolBoundary,rangef); - newseg.SetLimitPoint(pnt.Value(rangef),Standard_False); - seg.Append(newseg); - } - - Arcsol=Standard_False; - if (Nbi==1) { - if (pardeb == Pdeb && parfin == Pfin) { - Arcsol=Standard_True; - } - } -} //======================================================================= //function : PointProcess //purpose : @@ -955,11 +835,10 @@ IntStart_SearchOnBoundaries::IntStart_SearchOnBoundaries () TheSOBTool::Bounds(A,PDeb,PFin); if(Precision::IsNegativeInfinite(PDeb) || Precision::IsPositiveInfinite(PFin)) { - InfiniteArc(A,Domain,PDeb,PFin,Func,spnt,sseg,TolBoundary,TolTangency,Arcsol); - } - else { - BoundedArc(A,Domain,PDeb,PFin,Func,spnt,sseg,TolBoundary,TolTangency,Arcsol,RecheckOnRegularity); + Standard_Integer NbEchant; + ComputeBoundsfromInfinite(Func,PDeb,PFin,NbEchant); } + BoundedArc(A,Domain,PDeb,PFin,Func,spnt,sseg,TolBoundary,TolTangency,Arcsol,RecheckOnRegularity); all = (all && Arcsol); } diff --git a/tests/bugs/modalg_1/buc60899_1 b/tests/bugs/modalg_1/buc60899_1 index 115e9c8a2a..8dcb57d140 100755 --- a/tests/bugs/modalg_1/buc60899_1 +++ b/tests/bugs/modalg_1/buc60899_1 @@ -41,7 +41,7 @@ prism crg w 0 -$y*2 0 inf bsection result crg cyl -set length 15.1392 +set length 110.093 set 2dviewer 0 # checksection res diff --git a/tests/bugs/moddata_3/bug23981 b/tests/bugs/moddata_3/bug23981 new file mode 100755 index 0000000000..d6bfaa1d31 --- /dev/null +++ b/tests/bugs/moddata_3/bug23981 @@ -0,0 +1,69 @@ +puts "=========" +puts "CR23981" +puts "=========" +puts "" +############################### +## Wrong section curves +############################### + +restore [locate_data_file bug23981_s1.draw] s1 +restore [locate_data_file bug23981_s2.draw] s2 + +intersect i s1 s2 + +puts "First test" +dlog reset +dlog on +xdistcs i_1 s1 0 1 100 +set Log1 [dlog get] + +set List1 [split ${Log1} {TD= \t\n}] + +set L1 [llength ${List1}] +set L2 10 +set L3 5 +set N [expr (${L1} - ${L2})/${L3} + 1] +set Tolerance 1.0e-5 +set D_good 0. + +for {set i 1} {${i} <= ${N}} {incr i} { + set j1 [expr ${L2} + (${i}-1)*${L3}] + set j2 [expr ${j1} + 2] + set T [lindex ${List1} ${j1}] + set D [lindex ${List1} ${j2}] + #puts "i=${i} j1=${j1} j2=${j2} T=${T} D=${D}" + if { [expr abs(${D} - ${D_good})] > ${Tolerance} } { + puts "Error: i=${i} T=${T} D=${D}" + } +} + + +puts "Second test" +dlog reset +dlog on +xdistcs i_2 s1 0 1 100 +set Log2 [dlog get] + +set List2 [split ${Log2} {TD= \t\n}] + +set L1 [llength ${List2}] +set L2 10 +set L3 5 +set N [expr (${L1} - ${L2})/${L3} + 1] +set Tolerance 1.0e-5 +set D_good 0. + +for {set i 1} {${i} <= ${N}} {incr i} { + set j1 [expr ${L2} + (${i}-1)*${L3}] + set j2 [expr ${j1} + 2] + set T [lindex ${List2} ${j1}] + set D [lindex ${List2} ${j2}] + #puts "i=${i} j1=${j1} j2=${j2} T=${T} D=${D}" + if { [expr abs(${D} - ${D_good})] > ${Tolerance} } { + puts "Error: i=${i} T=${T} D=${D}" + } +} + +smallview +fit +set only_screen_axo 1