qttf.cpp
Go to the documentation of this file.
1 #include "qttf.hpp"
2 
3 #include <iostream>
4 
5 namespace lvr2 {
6 
7 namespace qttf {
8 
10  QTreeWidgetItem* from,
11  QTreeWidgetItem* to
12 )
13 {
14  // default identity
15  Transformd ret = Transformd::Identity();
16 
17  QTreeWidgetItem* it = from;
18 
19  while(it != to || it != NULL)
20  {
21  auto transform_obj = dynamic_cast< Transformable* >(it);
22  if(transform_obj)
23  {
24  ret = ret * transform_obj->getTransform();
25  }
26  it = it->parent();
27  }
28 
29  return ret;
30 }
31 
33  PointBufferPtr pc_in,
34  const Transformd& T
35 )
36 {
37  // generate copy
38  PointBufferPtr buffer_ptr = std::make_shared<PointBuffer>(pc_in->clone());
39 
40  Transformd T_trans = T;
41  T_trans.transpose();
42 
43  // 1) transform points
44  const size_t num_points = buffer_ptr->numPoints();
45  BaseVector<float>* points_raw = reinterpret_cast<BaseVector<float>* >(
46  buffer_ptr->getPointArray().get()
47  );
48 
49  for(size_t i=0; i<num_points; i++)
50  {
51  points_raw[i] = T_trans * points_raw[i];
52  }
53 
54  // 2) transform normals
55  if(buffer_ptr->hasNormals())
56  {
57  Normal<float>* normals_raw = reinterpret_cast<Normal<float>* >(
58  buffer_ptr->getNormalArray().get()
59  );
60  for(size_t i=0; i<num_points; i++)
61  {
62  normals_raw[i] = T_trans * normals_raw[i];
63  }
64  }
65 
66 
67  return buffer_ptr;
68 }
69 
71  PointBufferPtr pc_in,
72  QTreeWidgetItem* from,
73  QTreeWidgetItem* to
74 )
75 {
76  return transform(pc_in, getTransformation(from, to));
77 }
78 
79 } // namespace qttf
80 
81 } // namespace lvr2
std::shared_ptr< PointBuffer > PointBufferPtr
Transform< double > Transformd
4x4 double precision transformation matrix
Definition: MatrixTypes.hpp:71
Interface for transformable objects.
Eigen::Matrix< T, 4, 4 > getTransform()
Transformd getTransformation(QTreeWidgetItem *from, QTreeWidgetItem *to)
Definition: qttf.cpp:9
#define NULL
Definition: mydefs.hpp:141
PointBufferPtr transform(PointBufferPtr pc_in, const Transformd &T)
Definition: qttf.cpp:32


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:09