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
lvr2::BaseVector< float >
lvr2::Transformd
Transform< double > Transformd
4x4 double precision transformation matrix
Definition: MatrixTypes.hpp:71
lvr2::PointBufferPtr
std::shared_ptr< PointBuffer > PointBufferPtr
Definition: PointBuffer.hpp:130
lvr2::TransformableBase
Interface for transformable objects.
Definition: Transformable.hpp:13
NULL
#define NULL
Definition: mydefs.hpp:141
lvr2::Normal< float >
lvr2::qttf::transform
PointBufferPtr transform(PointBufferPtr pc_in, const Transformd &T)
Definition: qttf.cpp:32
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::qttf::getTransformation
Transformd getTransformation(QTreeWidgetItem *from, QTreeWidgetItem *to)
Definition: qttf.cpp:9
lvr2::TransformableBase::getTransform
Eigen::Matrix< T, 4, 4 > getTransform()
Definition: Transformable.hpp:17
qttf.hpp


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 Wed Mar 2 2022 00:37:24