]> OCCT Git - occt-copy.git/commitdiff
0030020: Incorrect bspline visualization
authormsv <msv@opencascade.com>
Tue, 7 Aug 2018 08:47:59 +0000 (11:47 +0300)
committermsv <msv@opencascade.com>
Fri, 5 Oct 2018 17:04:30 +0000 (20:04 +0300)
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.

src/GCPnts/GCPnts_TangentialDeflection.pxx
src/GeometryTest/GeometryTest_CurveCommands.cxx
tests/bugs/modalg_7/bug30020 [new file with mode: 0644]
tests/bugs/moddata_3/bug25489
tests/bugs/moddata_3/bug25737_2
tests/bugs/moddata_3/bug27108

index b4838d3b3afb0f8982ac237266be39ca55d2d049..11f44bbb664d96ad355bab3e73c91c4a72b99eea 100644 (file)
@@ -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
index 5e6ad444c7ec77e2c831f4b8f02e9a91c363f3d8..56dd525679073ae65322007da50d62c5b304f455 100644 (file)
@@ -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 (file)
index 0000000..f096ce2
--- /dev/null
@@ -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
index 656351c08716374cf75a5afdbedff249f06243c8..359fcda445ed83dd76e26c85547603d0e53f916a 100755 (executable)
@@ -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\]+)"
index 3d4e981d74c22bab282678abebea9caf863d9ec3..e0d6db6f853e479245aee75e3158c92110e8e9b5 100755 (executable)
@@ -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"
index 49df9911437761731940c5446395b9a5fb762f7a..0cb03ccb97b11317b4c974fabf6bce0cad02e6a6 100644 (file)
@@ -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