PointCloud.h
Go to the documentation of this file.
1 #ifndef _POINTCLOUD_H
2 #define _POINTCLOUD_H
3 #include <cstdio>
4 #ifndef _USE_MATH_DEFINES
5 #define _USE_MATH_DEFINES
6 #endif
7 #include <cmath>
8 #include <MiscLib/Vector.h>
9 #include <limits>
10 #include <GfxTL/VectorXD.h>
11 #include "basic.h"
12 #include <MiscLib/Vector.h>
14 #undef min
15 #undef max
16 
17 #ifndef DLL_LINKAGE
18 #define DLL_LINKAGE
19 #endif
20 
22 {
23  enum { Dim = 3 };
24  typedef float ScalarType;
25  typedef float value_type;
28 #ifdef POINTSWITHINDEX
29  size_t index;
30 #endif
31  //unsigned int meshFaceIndex;
32  Point() {}
33  Point(const Vec3f& Pos)
34  {
35  /*index = -1;*/ pos = Pos;
36  normal = Vec3f(0, 0, 0);
37  }
38  Point(const Vec3f& Pos, const Vec3f& Normal)
39  {
40  pos = Pos;
41  normal = Normal;
42  }
43  const float operator[](unsigned int i) const
44  {
45  return pos[i];
46  }
47  float& operator[](unsigned int i)
48  {
49  return pos[i];
50  }
51  operator const Vec3f& () const
52  {
53  return pos;
54  }
55  operator Vec3f& ()
56  {
57  return pos;
58  }
60  {
61  return *reinterpret_cast< GfxTL::Vector3Df* >(&pos);
62  }
63  operator const GfxTL::VectorXD< 3, float >& () const
64  {
65  return *reinterpret_cast< const GfxTL::Vector3Df* >(&pos);
66  }
67 };
68 
70  : public MiscLib::Vector< Point >
71 {
72 public:
73  PointCloud();
74  PointCloud(Point* points, unsigned int size);
76  {
77  size_t oldSize = size();
78  resize(oldSize + other.size());
79  std::copy(other.begin(), other.end(), begin() + oldSize);
80  m_min = Vec3f(std::min(m_min[0], other.m_min[0]),
81  std::min(m_min[1], other.m_min[1]),
82  std::min(m_min[2], other.m_min[2]));
83  m_max = Vec3f(std::max(m_max[0], other.m_max[0]),
84  std::max(m_max[1], other.m_max[1]),
85  std::max(m_max[2], other.m_max[2]));
86  return *this;
87  }
88  void swapPoints(unsigned int i, unsigned int j)
89  {
90  std::swap(at(i), at(j));
91  }
92  void calcNormals(float radius, unsigned int kNN = 20, unsigned int maxTries = 100);
93  void reset(size_t s = 0);
94  void setBBox(Vec3f bbl, float size)
95  {
96  m_min = bbl;
97  m_max = m_min + Vec3f(size, size, size);
98  }
100  {
101  m_min = min;
102  m_max = max;
103  }
104  void widenBBox(float delta)
105  {
106  Vec3f d(delta, delta, delta);
107  m_min -= d;
108  m_max += d;
109  }
110  float getScale() const
111  {
112  Vec3f diff = m_max - m_min;
113  return std::max(std::max(diff[0], diff[1]), diff[2]);
114  }
115  const Vec3f& getOffset() const
116  {
117  return m_min;
118  }
119  float* getBbox() const;
120  // returns a transfromed bbox if m_transformed is true
121  void GetCurrentBBox(Vec3f* min, Vec3f* max) const;
122  const Vec3f& GetBBoxMin() const
123  {
124  return m_min;
125  }
126  const Vec3f& GetBBoxMax() const
127  {
128  return m_max;
129  }
131  {
132  return m_min;
133  }
135  {
136  return m_max;
137  }
138  void Translate(const Vec3f& trans);
139 
140 private:
141  Vec3f m_min, m_max;
142 };
143 
144 #endif
PointCloud::GetBBoxMax
Vec3f & GetBBoxMax()
Definition: PointCloud.h:134
PointCloud::getOffset
const Vec3f & getOffset() const
Definition: PointCloud.h:115
Point::operator[]
float & operator[](unsigned int i)
Definition: PointCloud.h:47
GfxTL::VectorXD
Definition: MatrixXX.h:21
MiscLib::Vector::begin
T * begin()
Definition: Vector.h:460
Vector.h
PointCloud::setBBox
void setBBox(Vec3f bbl, float size)
Definition: PointCloud.h:94
Vec3f
Definition: basic.h:16
PointCloud::operator+=
PointCloud & operator+=(const PointCloud &other)
Definition: PointCloud.h:75
index
uint8_t index
Definition: EtherCATFrame.h:59
MiscLib::Vector::resize
void resize(size_type s, const value_type &v)
Definition: Vector.h:222
PointCloud::GetBBoxMax
const Vec3f & GetBBoxMax() const
Definition: PointCloud.h:126
PointCloud::widenBBox
void widenBBox(float delta)
Definition: PointCloud.h:104
Point::normal
Vec3f normal
Definition: PointCloud.h:27
Point::ScalarType
float ScalarType
Definition: PointCloud.h:24
MiscLib::Vector
Definition: Vector.h:19
VectorXD.h
armarx::armem::client::util::swap
void swap(SubscriptionHandle &first, SubscriptionHandle &second)
Definition: SubscriptionHandle.cpp:66
MiscLib::Vector::size
size_type size() const
Definition: Vector.h:212
copy
Use of this software is granted under one of the following two to be chosen freely by the user Boost Software License Version Marcin Kalicinski Permission is hereby free of to any person or organization obtaining a copy of the software and accompanying documentation covered by this and transmit the and to prepare derivative works of the and to permit third parties to whom the Software is furnished to do all subject to the including the above license this restriction and the following must be included in all copies of the in whole or in and all derivative works of the unless such copies or derivative works are solely in the form of machine executable object code generated by a source language processor THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR TITLE AND NON INFRINGEMENT IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN TORT OR ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE The MIT Marcin Kalicinski Permission is hereby free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to copy
Definition: license.txt:39
Point
Definition: PointCloud.h:21
MiscLib::Vector::end
T * end()
Definition: Vector.h:470
max
T max(T t1, T t2)
Definition: gdiam.h:48
Point::pos
Vec3f pos
Definition: PointCloud.h:26
MiscLib::Vector::at
T & at(size_type i)
Definition: Vector.h:308
visionx::PointCloud
pcl::PointCloud< Point > PointCloud
Definition: RCPointCloudProvider.cpp:54
PointCloud
Definition: PointCloud.h:69
basic.h
Point::Point
Point(const Vec3f &Pos, const Vec3f &Normal)
Definition: PointCloud.h:38
Point::operator[]
const float operator[](unsigned int i) const
Definition: PointCloud.h:43
DLL_LINKAGE
#define DLL_LINKAGE
Definition: basic.h:11
PointCloud::setBBox
void setBBox(Vec3f min, Vec3f max)
Definition: PointCloud.h:99
Point::Point
Point()
Definition: PointCloud.h:32
GfxTL::Vec3f
VectorXD< 3, float > Vec3f
Definition: VectorXD.h:691
PointCloud::GetBBoxMin
const Vec3f & GetBBoxMin() const
Definition: PointCloud.h:122
min
T min(T t1, T t2)
Definition: gdiam.h:42
PointCloud::getScale
float getScale() const
Definition: PointCloud.h:110
PointCloud::GetBBoxMin
Vec3f & GetBBoxMin()
Definition: PointCloud.h:130
Point::Point
Point(const Vec3f &Pos)
Definition: PointCloud.h:33
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
AlignedAllocator.h
Point::value_type
float value_type
Definition: PointCloud.h:25
PointCloud::swapPoints
void swapPoints(unsigned int i, unsigned int j)
Definition: PointCloud.h:88