From 7a7003ad880ad5083b172c9b54ce487a0c0479c9 Mon Sep 17 00:00:00 2001 From: Jeroen Claessens Date: Fri, 27 Sep 2024 09:05:55 +0200 Subject: [PATCH 1/2] fix: sizeSum calculation --- modules/pcd/src/lib/parse-pcd.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/pcd/src/lib/parse-pcd.ts b/modules/pcd/src/lib/parse-pcd.ts index 24cfe7457b..1ca1abf9bb 100644 --- a/modules/pcd/src/lib/parse-pcd.ts +++ b/modules/pcd/src/lib/parse-pcd.ts @@ -240,20 +240,17 @@ function parsePCDHeader(data: string): PCDHeader { pcdHeader.offset = {}; let sizeSum = 0; - if (pcdHeader.fields !== null && pcdHeader.size !== null) { - for (let i = 0; i < pcdHeader.fields.length; i++) { - if (pcdHeader.data === 'ascii') { - pcdHeader.offset[pcdHeader.fields[i]] = i; - } else { - pcdHeader.offset[pcdHeader.fields[i]] = sizeSum; - sizeSum += pcdHeader.size[i]; - } + for (let i = 0, l = pcdHeader.fields.length; i < l; i++) { + if (pcdHeader.data === 'ascii') { + pcdHeader.offset[pcdHeader.fields[i]] = i; + } else { + pcdHeader.offset[pcdHeader.fields[i]] = sizeSum; + sizeSum += pcdHeader.size[i] * pcdHeader.count[i]; } } // for binary only pcdHeader.rowSize = sizeSum; - return pcdHeader; } From 0703ec481b1d2cad7b8dbffd2c803cbe31d9d4b6 Mon Sep 17 00:00:00 2001 From: Jeroen Claessens Date: Fri, 27 Sep 2024 09:59:33 +0200 Subject: [PATCH 2/2] fix: rgb parsing --- modules/pcd/src/lib/parse-pcd.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/pcd/src/lib/parse-pcd.ts b/modules/pcd/src/lib/parse-pcd.ts index 1ca1abf9bb..e2d1daa115 100644 --- a/modules/pcd/src/lib/parse-pcd.ts +++ b/modules/pcd/src/lib/parse-pcd.ts @@ -333,9 +333,9 @@ function parsePCDBinary(pcdHeader: PCDHeader, data: ArrayBufferLike): HeaderAttr } if (offset.rgb !== undefined) { - color.push(dataview.getUint8(row + offset.rgb + 0)); - color.push(dataview.getUint8(row + offset.rgb + 1)); - color.push(dataview.getUint8(row + offset.rgb + 2)); + color.push(dataview.getUint8(row + offset.rgb + 2) / 255.0); + color.push(dataview.getUint8(row + offset.rgb + 1) / 255.0); + color.push(dataview.getUint8(row + offset.rgb + 0) / 255.0); } if (offset.normal_x !== undefined) { @@ -397,13 +397,13 @@ function parsePCDBinaryCompressed(pcdHeader: PCDHeader, data: ArrayBufferLike): if (offset.rgb !== undefined) { color.push( - dataview.getUint8(pcdHeader.points * offset.rgb + pcdHeader.size[3] * i + 0) / 255.0 + dataview.getUint8(pcdHeader.points * offset.rgb + pcdHeader.size[3] * i + 2) / 255.0 ); color.push( dataview.getUint8(pcdHeader.points * offset.rgb + pcdHeader.size[3] * i + 1) / 255.0 ); color.push( - dataview.getUint8(pcdHeader.points * offset.rgb + pcdHeader.size[3] * i + 2) / 255.0 + dataview.getUint8(pcdHeader.points * offset.rgb + pcdHeader.size[3] * i + 0) / 255.0 ); }