From da6b95a0752b92e58c66f4d571a7702ba1bab5ab Mon Sep 17 00:00:00 2001 From: oan Date: Tue, 29 Oct 2019 11:04:53 +0300 Subject: [PATCH] 0031043: GCPnts_TangentialDeflection generates points which number is inconsistent with MinimumOfPoints Parameter Updated crvtpoints command API to reproduce reported problem Generate number of points according to the specified minimum value --- src/GCPnts/GCPnts_TangentialDeflection.pxx | 20 +++---- .../GeometryTest_CurveCommands.cxx | 9 ++-- tests/bugs/modalg_7/bug31043 | 54 +++++++++++++++++++ 3 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 tests/bugs/modalg_7/bug31043 diff --git a/src/GCPnts/GCPnts_TangentialDeflection.pxx b/src/GCPnts/GCPnts_TangentialDeflection.pxx index c32e4a0808..deadfb6309 100644 --- a/src/GCPnts/GCPnts_TangentialDeflection.pxx +++ b/src/GCPnts/GCPnts_TangentialDeflection.pxx @@ -196,10 +196,12 @@ void GCPnts_TangentialDeflection::PerformLinear (const TheCurve& C) { D0 (C, firstu, P); parameters.Append (firstu); points .Append (P); - if (minNbPnts > 2) { + if (minNbPnts > 2) + { Standard_Real Du = (lastu - firstu) / minNbPnts; 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); @@ -571,14 +573,14 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C) //-- On rajoute des points aux milieux des segments si le nombre //-- mini de points n'est pas atteint //-- - Standard_Integer Nbp = points.Length(); - Standard_Integer MinNb= (9*minNbPnts)/10; - //if(MinNb<4) MinNb=4; + Standard_Integer Nbp = points.Length(); - //-- if(Nbp < MinNb) { cout<<"\n*"; } else { cout<<"\n."; } - while(Nbp < MinNb) { - //-- cout<<" \nGCPnts TangentialDeflection : Ajout de Points ("< 3) + if(n > 4) angle = Draw::Atof(a[4]); - GCPnts_TangentialDeflection PntGen(aHCurve->Curve(), angle, defl, 2); + if(n > 5) + aMinPntsNb = Draw::Atoi (a[5]); + + GCPnts_TangentialDeflection PntGen(aHCurve->Curve(), angle, defl, aMinPntsNb); nbp = PntGen.NbPoints(); di << "Nb points : " << nbp << "\n"; diff --git a/tests/bugs/modalg_7/bug31043 b/tests/bugs/modalg_7/bug31043 new file mode 100644 index 0000000000..696a905f1a --- /dev/null +++ b/tests/bugs/modalg_7/bug31043 @@ -0,0 +1,54 @@ +puts "=============" +puts "0031043: GCPnts_TangentialDeflection generates points which number is inconsistent with MinimumOfPoints parameter" +puts "=============" + +restore [locate_data_file bug28500_shape_mesh_artifact.brep] result + +tclean result +explode result f +explode result_7 e + +mkcurve c result_7_1 + +set log [crvtpoints r c 0.01 1.57 1] +regexp {Nb points : ([0-9]+)} $log full pnts + +if { $pnts < 2 } { + puts "Error : Incorrect number of points $pnts" +} + + +set log [crvtpoints r c 0.01 1.57 2] +regexp {Nb points : ([0-9]+)} $log full pnts + +if { $pnts < 2 } { + puts "Error : Incorrect number of points $pnts" +} + +set log [crvtpoints r c 0.01 1.57 3] +regexp {Nb points : ([0-9]+)} $log full pnts + +if { $pnts < 3 } { + puts "Error : Incorrect number of points $pnts" +} + +set log [crvtpoints r c 0.01 1.57 4] +regexp {Nb points : ([0-9]+)} $log full pnts + +if { $pnts < 4 } { + puts "Error : Incorrect number of points $pnts" +} + +set log [crvtpoints r c 0.01 1.57 5] +regexp {Nb points : ([0-9]+)} $log full pnts + +if { $pnts < 5 } { + puts "Error : Incorrect number of points $pnts" +} + +set log [crvtpoints r c 0.01 1.57 6] +regexp {Nb points : ([0-9]+)} $log full pnts + +if { $pnts < 6 } { + puts "Error : Incorrect number of points $pnts" +}