diff --git a/src/GCPnts/GCPnts_TangentialDeflection.gxx b/src/GCPnts/GCPnts_TangentialDeflection.gxx index 54c0b3bc90..7e500307c2 100644 --- a/src/GCPnts/GCPnts_TangentialDeflection.gxx +++ b/src/GCPnts/GCPnts_TangentialDeflection.gxx @@ -219,7 +219,8 @@ void GCPnts_TangentialDeflection::PerformCircular (const TheCurve& C) dfR, curvatureDeflection, angularDeflection, myMinLen); const Standard_Real aDiff = lastu - firstu; - Standard_Integer NbPoints = (Standard_Integer)(aDiff / Du); + // Round up number of points to satisfy curvatureDeflection more precisely + Standard_Integer NbPoints = (Standard_Integer)Ceiling(aDiff / Du); NbPoints = Max(NbPoints, minNbPnts - 1); Du = aDiff / NbPoints; diff --git a/tests/bugs/modalg_6/bug27537 b/tests/bugs/modalg_6/bug27537 new file mode 100644 index 0000000000..a7b0a3c4d0 --- /dev/null +++ b/tests/bugs/modalg_6/bug27537 @@ -0,0 +1,55 @@ +puts "============" +puts "OCC27537" +puts "============" +puts "" +###################################################### +# Incorrect number of sample points provided by GCPnts_TangentialDeflection +###################################################### + +restore [locate_data_file bug27537.brep] result +incmesh result 0.2 + +set bndbox [bounding result] +set xMin [lindex $bndbox 0] +set yMin [lindex $bndbox 1] +set zMin [lindex $bndbox 2] +set xMax [lindex $bndbox 3] +set yMax [lindex $bndbox 4] +set zMax [lindex $bndbox 5] + +mkcurve c result +bounds c u1 u2 +set first [dval u1] +set last [dval u2] + +set x 0. +set y 0. +set z 0. +set param 0. +set isOk true + +set nbSamples 100 +set step [expr ($last - $first)/$nbSamples] +for {set i 0} {$i <= $nbSamples} {incr i} { + if {$i < $nbSamples} { + set param [expr $first + $i * $step] + } else { + set param $last + } + + cvalue c $param cx cy cz + set x [dval cx] + set y [dval cy] + set z [dval cz] + if {$x < $xMin || $x > $xMax || $y < $yMin || $y > $yMax || $z < $zMin || $z > $zMax} { + puts "ERROR: point ($x; $y; $z) is out of bounding box" + set isOk false + } +} + +if {$isOk} { + puts "OK: all sample points inside bounding box" +} + +top; fit +checkview -screenshot -2d -path ${imagedir}/${test_image}.png