PCLConverter.h
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* ArmarX is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* @author Fabian Peller (fabian dot peller at kit dot edu)
17* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
18* GNU General Public License
19*/
20
21#pragma once
22
23#include <numeric>
24#include <string>
25
26#include <pcl/point_cloud.h>
27#include <pcl/point_types.h>
28
30
31#include <RobotAPI/interface/aron.h>
33
35{
36 class AronPCLConverter
37 {
38 AronPCLConverter() = delete;
39
40 public:
41 template <typename T>
42 static pcl::PointCloud<T>
44 {
46
47 if (nav->getShape().size() != 3) // +1 for bytes per pixel
48 {
49 throw error::AronException("AronIVTConverter",
50 "ConvertToCByteImage",
51 "The size of an NDArray does not match.",
52 nav->getPath());
53 }
54 auto dims = nav->getShape();
55
56 pcl::PointCloud<T> ret(dims[0], dims[1]);
57 memcpy(reinterpret_cast<unsigned char*>(ret.points.data()),
58 nav->getData(),
59 std::accumulate(std::begin(dims), std::end(dims), 1, std::multiplies<int>()));
60 return ret;
61 }
62 };
63
64} // namespace armarx::aron::data::converter
65
66// legacy
68{
70}
static pcl::PointCloud< T > ConvertToPointClout(const data::NDArrayPtr &nav)
A base class for aron exceptions.
Definition Exception.h:37
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
::armarx::aron::data::converter::AronPCLConverter AronPCLConverter
std::shared_ptr< NDArray > NDArrayPtr
Definition NDArray.h:46