KrisLibrary  1.0.0
PointCloud.h
1 #ifndef MESHING_POINT_CLOUD_H
2 #define MESHING_POINT_CLOUD_H
3 
5 #include <KrisLibrary/math/vector.h>
6 #include <KrisLibrary/utils/PropertyMap.h>
7 #include <vector>
8 #include <iosfwd>
9 #include <string>
10 
11 namespace Meshing {
12 
13 using namespace Math3D;
14 using namespace std;
15 
51 {
52  public:
53  void Clear();
54  bool LoadPCL(const char* fn);
55  bool SavePCL(const char* fn) const;
56  bool LoadPCL(istream& in);
57  bool SavePCL(ostream& out) const;
66  void FromDepthImage(int w,int h,float wfov,float hfov,const std::vector<float>& depths,const std::vector<unsigned int>& rgb,float invalidDepth=0.0);
76  void FromDepthImage(int w,int h,float wfov,float hfov,float depthscale,const std::vector<unsigned short>& depths,const std::vector<unsigned int>& rgb,unsigned short invalidDepth=0);
78  void GetAABB(Vector3& bmin,Vector3& bmax) const;
80  void Transform(const Matrix4& mat);
82  bool IsStructured() const;
83  int GetStructuredWidth() const;
84  int GetStructuredHeight() const;
85  void SetStructured(int w,int h);
86  Vector3 GetOrigin() const;
87  void SetOrigin(const Vector3& origin);
88  RigidTransform GetViewpoint() const;
89  void SetViewpoint(const RigidTransform& T);
90  int PropertyIndex(const string& name) const;
91  bool HasProperty(const string& name) const { return PropertyIndex(name) >= 0; }
98  bool GetProperty(const string& name,vector<Real>& items) const;
105  int SetProperty(const string& name,const vector<Real>& items);
107  void RemoveProperty(const string& name);
109  void GetSubCloud(const Vector3& bmin,const Vector3& bmax,PointCloud3D& subcloud);
111  void GetSubCloud(const string& property,Real value,PointCloud3D& subcloud);
113  void GetSubCloud(const string& property,Real minValue,Real maxValue,PointCloud3D& subcloud);
115  bool HasXYZAsProperties() const;
117  void SetXYZAsProperties(bool);
118  bool HasNormals() const;
119  bool GetNormals(vector<Vector3>& normals) const;
120  void SetNormals(const vector<Vector3>& normals);
123  void ComputeNormals(Real radius=0);
124  bool HasColor() const;
125  bool HasOpacity() const;
126  bool HasRGB() const;
127  bool HasRGBA() const;
129  bool UnpackColorChannels(bool alpha=false);
131  bool PackColorChannels(const char* fmt="rgba");
132  bool GetColors(vector<Real>& r,vector<Real>& g,vector<Real>& b,vector<Real>& a) const;
133  bool GetColors(vector<Vector4>& rgba) const;
134  void SetColors(const vector<Real>& r,const vector<Real>& g,const vector<Real>& b,bool includeAlpha = false);
135  void SetColors(const vector<Real>& r,const vector<Real>& g,const vector<Real>& b,const vector<Real>& a,bool includeAlpha = true);
136  void SetColors(const vector<Vector4>& rgba,bool includeAlpha=true);
137  bool HasUV() const;
138  bool GetUV(vector<Vector2>& uvs) const;
139  void SetUV(const vector<Vector2>& uvs);
140 
141  vector<Vector3> points;
142  vector<string> propertyNames;
143  vector<Vector> properties;
144  PropertyMap settings;
145 };
146 
147 } //namespace Meshing
148 
149 #endif
150 
The namespace for all classes/functions in the Meshing package.
Definition: AnyGeometry.h:11
A 3D vector class.
Definition: math3d/primitives.h:136
A 3D point cloud class.
Definition: PointCloud.h:50
Definition: rayprimitives.h:132
Class declarations for useful 3D math types.
A rigid-body transformation.
Definition: math3d/primitives.h:820
A 4x4 matrix class.
Definition: math3d/primitives.h:626
Contains all the definitions in the Math3D package.
Definition: AnyGeometry.h:13
A simple map from keys to values.
Definition: PropertyMap.h:27