From 147feea35d9a40c45428ffb6e07046acc9f7b213 Mon Sep 17 00:00:00 2001 From: Fabian Peller <fabian.peller-konrad@kit.edu> Date: Wed, 19 Apr 2023 08:35:18 +0200 Subject: [PATCH] fix bug if pc is shared-ptr --- .../codewriter/cpp/generator/ndarray/Matrix.cpp | 1 + .../codewriter/cpp/generator/ndarray/PointCloud.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/Matrix.cpp b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/Matrix.cpp index 569d5be67..d0bf18091 100644 --- a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/Matrix.cpp +++ b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/Matrix.cpp @@ -31,6 +31,7 @@ namespace armarx::aron::codegenerator::cpp::generator { const std::map<type::matrix::ElementType, std::tuple<std::string, int, std::string>> ElementType2Cpp = { + // TODO: rename to float32 etc. but keep backward compability {type::matrix::INT16, {"short", 2, "::armarx::aron::type::matrix::INT16"}}, {type::matrix::INT32, {"int", 4, "::armarx::aron::type::matrix::INT32"}}, {type::matrix::INT64, {"long", 8, "::armarx::aron::type::matrix::INT64"}}, diff --git a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/PointCloud.cpp b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/PointCloud.cpp index 78e42fe08..66bfab7ae 100644 --- a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/PointCloud.cpp +++ b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/PointCloud.cpp @@ -102,7 +102,11 @@ namespace armarx::aron::codegenerator::cpp::generator block_if_data->addLine("std::vector<int> " + dims + ";"); block_if_data->addLine("std::vector<unsigned char> " + data + ";"); block_if_data->addLine("" + ARON_READER_ACCESSOR + ".readNDArray("+variantAccessor+", "+dims+", "+type+", "+data+"); // of " + cppAccessor); - block_if_data->addLine(cppAccessor + " = " + getInstantiatedCppTypename() + "(" + dims + "[0], " + dims + "[1]);"); + + block_if_data->addLine("ARMARX_CHECK_AND_THROW(" + dims + ".size() == 3, ::armarx::aron::error::AronException(__PRETTY_FUNCTION__, \"Received wrong dimensions for member '"+cppAccessor+"'.\"));"); + block_if_data->addLine("ARMARX_CHECK_AND_THROW(" + type + " == \"" + std::get<0>(VoxelType2Cpp.at(this->type.getVoxelType())) + "\", ::armarx::aron::error::AronException(__PRETTY_FUNCTION__, \"Received wrong type for member '"+cppAccessor+"'.\"));"); + + block_if_data->addLine(cppAccessor + nextEl() + "assign(" + dims + "[0], " + dims + "[1], " + std::get<0>(VoxelType2Cpp.at(this->type.getVoxelType())) + "());"); block_if_data->addLine("std::memcpy(reinterpret_cast<unsigned char*>(" + cppAccessor + nextEl() + "points.data()), "+data+".data(), "+data+".size());"); return resolveMaybeReadBlock(block_if_data, cppAccessor, variantAccessor); } -- GitLab