From: msv Date: Tue, 7 Aug 2018 08:47:59 +0000 (+0300) Subject: 0030020: Incorrect bspline visualization X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=765283765bd96cd817ba4f3665620965a6053672;p=occt-copy.git 0030020: Incorrect bspline visualization Let's we have a spline having fit points located on a direct line (let's number them 1, 2, 3), but they are located in order 1, 3, 2. There was a bug in GCPnts_TangentialDeflection that only first and last points were put in the result. Now more point is put, so that the result polygon made back movement. The command crvtpoints has been made to accept angular value in degrees instead of radians. --- diff --git a/src/GCPnts/GCPnts_TangentialDeflection.pxx b/src/GCPnts/GCPnts_TangentialDeflection.pxx index b4838d3b3a..11f44bbb66 100644 --- a/src/GCPnts/GCPnts_TangentialDeflection.pxx +++ b/src/GCPnts/GCPnts_TangentialDeflection.pxx @@ -195,9 +195,9 @@ void GCPnts_TangentialDeflection::PerformLinear (const TheCurve& C) { parameters.Append (firstu); points .Append (P); if (minNbPnts > 2) { - Standard_Real Du = (lastu - firstu) / minNbPnts; + Standard_Real Du = (lastu - firstu) / (minNbPnts - 1); Standard_Real U = firstu + Du; - for (Standard_Integer i = 2; i <= minNbPnts; i++) { + for (Standard_Integer i = 2; i < minNbPnts; i++) { D0 (C, U, P); parameters.Append (U); points .Append (P); @@ -287,6 +287,7 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C) { //Si c'est une droite on verifie en calculant minNbPoints : Standard_Boolean IsLine = Standard_True; + Standard_Boolean IsSequential = Standard_True; Standard_Integer NbPoints = (minNbPnts > 3) ? minNbPnts : 3; switch (C.GetType()) { case GeomAbs_BSplineCurve: @@ -325,8 +326,8 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C) Intervs(i + 1) = lastu; } - Standard_Real delta = (Intervs(i+1) - Intervs(i))/NbPoints; - for (j = 1; j <= NbPoints && IsLine; ++j) + Standard_Real delta = (Intervs(i+1) - Intervs(i))/(NbPoints-1); + for (j = 1; j < NbPoints && IsLine; ++j) { param = Intervs(i) + j*delta; D0 (C, param, MiddlePoint); @@ -336,6 +337,12 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C) { const Standard_Real aAngle = V2.CrossMagnitude(V1)/(L1*L2); IsLine = (aAngle < ATol); + + // Check if points on line are subsequent + if(IsLine && IsSequential) + { + IsSequential = (L2 <= L1); + } } } } @@ -345,7 +352,18 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C) parameters.Clear(); points .Clear(); + const Standard_Integer oldMinNbPoints = minNbPnts; + if(!IsSequential) + { + minNbPnts = NbPoints; + } + PerformLinear(C); + + if(!IsSequential) + { + minNbPnts = oldMinNbPoints; + } return; } else diff --git a/src/GeometryTest/GeometryTest_CurveCommands.cxx b/src/GeometryTest/GeometryTest_CurveCommands.cxx index 5e6ad444c7..56dd525679 100644 --- a/src/GeometryTest/GeometryTest_CurveCommands.cxx +++ b/src/GeometryTest/GeometryTest_CurveCommands.cxx @@ -1032,7 +1032,7 @@ static Standard_Integer crvtpoints (Draw_Interpretor& di, Standard_Integer n, co defl = Draw::Atof(a[3]); if(n > 3) - angle = Draw::Atof(a[4]); + angle = Draw::Atof(a[4]) * M_PI / 180; GCPnts_TangentialDeflection PntGen(aHCurve->Curve(), angle, defl, 2); diff --git a/tests/bugs/modalg_7/bug30020 b/tests/bugs/modalg_7/bug30020 new file mode 100644 index 0000000000..f096ce28e7 --- /dev/null +++ b/tests/bugs/modalg_7/bug30020 @@ -0,0 +1,19 @@ +puts "========" +puts "0030020: Incorrect bspline visualization" +puts "========\n" + +set F [open pnts w] +puts $F "3 3d" +puts $F "0 0 0" +puts $F "2 0 0" +puts $F "1 0 0" +close $F +interpol c pnts +file delete pnts + +set out [crvtpoints r c 0.1 1] +if {[lindex $out 3] != 3} { + puts "Error: number of points is not equal to 3" +} + +checklength r -l 3 diff --git a/tests/bugs/moddata_3/bug25489 b/tests/bugs/moddata_3/bug25489 index 656351c087..359fcda445 100755 --- a/tests/bugs/moddata_3/bug25489 +++ b/tests/bugs/moddata_3/bug25489 @@ -12,7 +12,7 @@ subshape a e 8 mkcurve c a_8 set deflection 0.001 -set info [crvtpoints r c ${deflection} pi/6] +set info [crvtpoints r c ${deflection} 30] set str1 "Nb points +: +(\[-0-9.+eE\]+)\n" set str2 "Max defl: +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+)" diff --git a/tests/bugs/moddata_3/bug25737_2 b/tests/bugs/moddata_3/bug25737_2 index 3d4e981d74..e0d6db6f85 100755 --- a/tests/bugs/moddata_3/bug25737_2 +++ b/tests/bugs/moddata_3/bug25737_2 @@ -16,7 +16,7 @@ donly a_1 fit set deflection 1. -set angular_deflection 0.349 +set angular_deflection [dval 0.349/pi*180] set info [crvtpoints r c ${deflection} ${angular_deflection}] set str1 "Nb points +: +(\[-0-9.+eE\]+)\n" diff --git a/tests/bugs/moddata_3/bug27108 b/tests/bugs/moddata_3/bug27108 index 49df991143..0cb03ccb97 100644 --- a/tests/bugs/moddata_3/bug27108 +++ b/tests/bugs/moddata_3/bug27108 @@ -12,7 +12,7 @@ restore [locate_data_file bug27108_Left.brep] a explode a e mkcurve c a_1 -set bug_info [crvtpoints result c $bug27108_requested_deflection 20*pi/180] +set bug_info [crvtpoints result c $bug27108_requested_deflection 20] smallview donly c result