From d5e4971b173d2a74f4a3d878bf69b1a6df9a8aea Mon Sep 17 00:00:00 2001 From: vro Date: Thu, 22 Mar 2012 16:22:26 +0400 Subject: [PATCH] 0023032: A crash of a draw-command voxeloctboolds on MMGT_OPT=0, MMGT_REENTRANT=1 --- src/Voxel/Voxel_OctBoolDS.cxx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Voxel/Voxel_OctBoolDS.cxx b/src/Voxel/Voxel_OctBoolDS.cxx index 50776ebb2b..b57259f892 100755 --- a/src/Voxel/Voxel_OctBoolDS.cxx +++ b/src/Voxel/Voxel_OctBoolDS.cxx @@ -23,6 +23,9 @@ #include +#include +#include + static Standard_Byte gbits[8] = {1, 2, 4, 8, 16, 32, 64, 128}; static Standard_Byte gnbits[8] = {255-1, 255-2, 255-4, 255-8, 255-16, 255-32, 255-64, 255-128}; static iXYZ xyz; @@ -270,6 +273,7 @@ void Voxel_OctBoolDS::OptimizeMemory() return; Standard_Byte value; + TColStd_ListOfInteger ixs, iys, izs, values; iXYZBool::Iterator itr(*((iXYZBool*)mySubVoxels)); for (; itr.More(); itr.Next()) { @@ -277,11 +281,25 @@ void Voxel_OctBoolDS::OptimizeMemory() if (value == 0 || value == 255) { xyz = itr.Key(); - Set(xyz.ix, xyz.iy, xyz.iz, value ? Standard_True : Standard_False); - UnSplit(xyz.ix, xyz.iy, xyz.iz); + ixs.Append(xyz.ix); + iys.Append(xyz.iy); + izs.Append(xyz.iz); + values.Append((Standard_Integer)value); } } + TColStd_ListIteratorOfListOfInteger itrix(ixs), itriy(iys), itriz(izs), itrvalues(values); + for (; itrix.More(); itrix.Next(), itriy.Next(), itriz.Next(), itrvalues.Next()) + { + const Standard_Integer ix = itrix.Value(); + const Standard_Integer iy = itriy.Value(); + const Standard_Integer iz = itriz.Value(); + const Standard_Integer value = itrvalues.Value(); + + Set(ix, iy, iz, (value ? Standard_True : Standard_False)); + UnSplit(ix, iy, iz); + } + // If the map is empty, release it. if (((iXYZBool*)mySubVoxels)->IsEmpty()) { -- 2.20.1