From c48cb4da97f6da4673c59bc7018f4a26cfb3d698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=CA=B3=20Pierre-=C3=89douard=20Cailliau?= Date: Sun, 23 Jan 2022 00:14:43 +0100 Subject: [PATCH 1/3] The element MLMatrix44 is a list, so values are separed by spaces and carriage return are ignored. --- src/meshlabplugins/io_base/load_project.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/meshlabplugins/io_base/load_project.cpp b/src/meshlabplugins/io_base/load_project.cpp index c07b4e8e9..469dc09c6 100644 --- a/src/meshlabplugins/io_base/load_project.cpp +++ b/src/meshlabplugins/io_base/load_project.cpp @@ -230,20 +230,10 @@ std::vector loadMLP( vcg::Matrix44f trm; if (tr.childNodes().size() == 1) { if (!binary) { - QStringList rows = tr.firstChild().nodeValue().split("\n", QString::SkipEmptyParts); - int i = 0; - for (const QString& row : qAsConst(rows)){ - if (rows.size() > 0) { - QStringList values = row.split(" ", QString::SkipEmptyParts); - int j = 0; - for (const QString& value : qAsConst(values)) { - if (i < 4 && j < 4) { - md.mm()->cm.Tr[i][j] = value.toFloat(); - j++; - } - } - i++; - } + auto const & values = tr.childNodes(); + auto * v = md.mm()->cm.V(); + for (auto index = 0u; index < values.length(); ++index) { + v[index] = values.item(index).nodeName().toFloat(); } } else { From 3cd7e62c0027128bb835c50c007c58608d0ec0a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=CA=B3=20Pierre-=C3=89douard=20Cailliau?= Date: Sun, 23 Jan 2022 00:41:43 +0100 Subject: [PATCH 2/3] Correct mistake. --- src/meshlabplugins/io_base/load_project.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meshlabplugins/io_base/load_project.cpp b/src/meshlabplugins/io_base/load_project.cpp index 469dc09c6..64d866c8f 100644 --- a/src/meshlabplugins/io_base/load_project.cpp +++ b/src/meshlabplugins/io_base/load_project.cpp @@ -231,7 +231,7 @@ std::vector loadMLP( if (tr.childNodes().size() == 1) { if (!binary) { auto const & values = tr.childNodes(); - auto * v = md.mm()->cm.V(); + auto * v = md.mm()->cm.Tr.V(); for (auto index = 0u; index < values.length(); ++index) { v[index] = values.item(index).nodeName().toFloat(); } From 686499790b7e7a836741272b315914b259596266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=CA=B3=20Pierre-=C3=89douard=20Cailliau?= Date: Mon, 24 Jan 2022 23:22:28 +0100 Subject: [PATCH 3/3] Consumes the values one by one. --- src/meshlabplugins/io_base/load_project.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/meshlabplugins/io_base/load_project.cpp b/src/meshlabplugins/io_base/load_project.cpp index 64d866c8f..63a1b48b6 100644 --- a/src/meshlabplugins/io_base/load_project.cpp +++ b/src/meshlabplugins/io_base/load_project.cpp @@ -230,10 +230,17 @@ std::vector loadMLP( vcg::Matrix44f trm; if (tr.childNodes().size() == 1) { if (!binary) { - auto const & values = tr.childNodes(); - auto * v = md.mm()->cm.Tr.V(); - for (auto index = 0u; index < values.length(); ++index) { - v[index] = values.item(index).nodeName().toFloat(); + auto * const v = md.mm()->cm.Tr.V(); + auto const rows = tr.firstChild().nodeValue().split("\n", QString::SkipEmptyParts); + auto i = 0u; + for (auto const & row: rows) { + if (rows.size() > 0u) { + auto const values = row.split(" ", QString::SkipEmptyParts); + for (auto const & value: values) { + if (i >= 16u) break; + v[i++] = value.toFloat(); + } + } } } else {