From 0bb1f1133c888ddda46a1be29fcd10f91c268c09 Mon Sep 17 00:00:00 2001 From: akz Date: Thu, 5 Feb 2015 15:22:13 +0300 Subject: [PATCH] 0025740: VrmlData_Scene::WriteArrIndex() writes extra point indices. Reason of bug: at the end of writing indices the "buf" was written double times. Fix: At the end of operation skip one WriteLine. Test case for issue CR25740 --- src/VrmlData/VrmlData_Scene.cxx | 2 ++ tests/bugs/stlvrml/bug25740 | 43 +++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 tests/bugs/stlvrml/bug25740 diff --git a/src/VrmlData/VrmlData_Scene.cxx b/src/VrmlData/VrmlData_Scene.cxx index 5a83eca28c..ff5717732c 100644 --- a/src/VrmlData/VrmlData_Scene.cxx +++ b/src/VrmlData/VrmlData_Scene.cxx @@ -898,6 +898,8 @@ VrmlData_ErrorStatus VrmlData_Scene::WriteArrIndex char * ptr = &buf[0]; for (Standard_Integer i = 0; i < nVal; i++) { Sprintf (ptr, "%d,", arrVal[i]); + if (i == nVal - 1) + break; ptr = strchr (ptr, ',') + 1; if ((ptr - &buf[0]) > (ptrdiff_t)aLineLimit) { WriteLine(buf); diff --git a/tests/bugs/stlvrml/bug25740 b/tests/bugs/stlvrml/bug25740 new file mode 100644 index 0000000000..6a032fac5e --- /dev/null +++ b/tests/bugs/stlvrml/bug25740 @@ -0,0 +1,43 @@ +puts "================" +puts "OCC25740" +puts "================" +puts "" +####################################################################################### +# VrmlData_Scene::WriteArrIndex() writes extra point indices +####################################################################################### + +set BugNumber OCC25740 + +set aFile $imagedir/${test_image}.vrml + +ptorus p 10 8 0 90 120 +incmesh p 0.1 + +explode p e + +storevrml p_3 ${aFile} 1 1 + +set status 1 +if { ![file exists ${aFile}] } { + set status 0 +} + +# Check file size +set filesize [ file size ${aFile} ] +if { ${filesize} == 0 } { + set status 0 +} + +set fd0 [ open ${aFile} r ] +set filecontent [ read ${fd0} ] +close $fd0 + +if { ![regexp {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,\n\s+16,17,18,19,20,21,22,23,24,25,26,27,28, -1} ${filecontent} full] } { + set status 0 +} + +if {$status == 1} { + puts "OK ${BugNumber}" +} else { + puts "Faulty ${BugNumber}" +} -- 2.20.1