ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
pointcloud.h
Go to the documentation of this file.
1 //
2 // pointcloud.h
3 // Classes and functions for 3D points and clouds thereof.
4 //
5 // Author: Jens Wilberg, Lukas Aymans, Christoph Dalitz
6 // Date: 2018-08-30
7 // License: see ../LICENSE
8 //
9 
10 #ifndef POINTCLOUD_H
11 #define POINTCLOUD_H
12 #include <algorithm>
13 #include <cstddef>
14 #include <fstream>
15 #include <set>
16 #include <vector>
17 // 3D point class.
18 class Point {
19 public:
20  double x;
21  double y;
22  double z;
23  int id;
24  std::set<size_t> cluster_ids;
25 
26  Point(){};
27  Point(const std::vector<double> &point);
28  Point(const std::vector<double> &point, const std::set<size_t> &cluster_ids);
29  Point(double x, double y, double z);
30  Point(double x, double y, double z, const std::set<size_t> &cluster_ids);
31 
32  // representation of 3D point as std::vector
33  std::vector<double> as_vector() const;
34  // Euclidean norm
35  double norm() const;
36  // squared norm
37  double squared_norm() const;
38 
39  inline void SetID(int pid) { id = pid; }
40  inline int GetID() const { return id; }
41 
42  friend std::ostream &operator<<(std::ostream &os, const Point &p);
43  bool operator==(const Point &p) const;
44  Point &operator=(const Point &other);
45  // vector addition
46  Point operator+(const Point &p) const;
47  // vector subtraction
48  Point operator-(const Point &p) const;
49  // scalar product
50  double operator*(const Point &p) const;
51  // scalar division
52  Point operator/(double c) const;
53 };
54 
55 // scalar multiplication
56 Point operator*(Point x, double c);
57 Point operator*(double c, Point x);
58 
59 // The Pointcloud is a vector of points
60 class PointCloud : public std::vector<Point> {
61 private:
62  bool points2d;
63 
64 public:
65  bool is2d() const;
66  void set2d(bool is2d);
67  PointCloud();
68 };
69 
70 // Load csv file.
71 void load_csv_file(const char *fname, PointCloud &cloud, const char delimiter, size_t skip = 0);
72 // Smoothing of the PointCloud *cloud*. The result is returned in *result_cloud*
73 void smoothen_cloud(const PointCloud &cloud, PointCloud &result_cloud, double radius);
74 
75 #endif
Point::norm
double norm() const
Definition: pointcloud.cxx:73
Point::operator=
Point & operator=(const Point &other)
Definition: pointcloud.cxx:84
Point::GetID
int GetID() const
Definition: pointcloud.h:40
Point::operator-
Point operator-(const Point &p) const
Definition: pointcloud.cxx:115
smoothen_cloud
void smoothen_cloud(const PointCloud &cloud, PointCloud &result_cloud, double radius)
Definition: pointcloud.cxx:254
Point::Point
Point()
Definition: pointcloud.h:26
PointCloud::is2d
bool is2d() const
Definition: pointcloud.cxx:158
Point::operator+
Point operator+(const Point &p) const
Definition: pointcloud.cxx:105
PointCloud::PointCloud
PointCloud()
Definition: pointcloud.cxx:148
Point::operator==
bool operator==(const Point &p) const
Point::squared_norm
double squared_norm() const
Definition: pointcloud.cxx:79
Point::id
int id
Definition: pointcloud.h:23
operator*
Point operator*(Point x, double c)
Definition: pointcloud.cxx:137
Point::x
float x
Definition: main.cpp:72
Point::z
double z
Definition: pointcloud.h:22
Point
Definition: main.cpp:71
Point::cluster_ids
std::set< size_t > cluster_ids
Definition: pointcloud.h:24
PointCloud
Definition: pointcloud.h:60
Point::operator<<
friend std::ostream & operator<<(std::ostream &os, const Point &p)
Definition: pointcloud.cxx:99
PointCloud::set2d
void set2d(bool is2d)
Definition: pointcloud.cxx:153
Point::y
float y
Definition: main.cpp:73
Point::as_vector
std::vector< double > as_vector() const
Definition: pointcloud.cxx:63
load_csv_file
void load_csv_file(const char *fname, PointCloud &cloud, const char delimiter, size_t skip=0)
Definition: pointcloud.cxx:183
Point::y
double y
Definition: pointcloud.h:21
Point::x
double x
Definition: pointcloud.h:20
Point::operator*
double operator*(const Point &p) const
Definition: pointcloud.cxx:125
Point::SetID
void SetID(int pid)
Definition: pointcloud.h:39
c
constexpr auto c
Definition: AtRadialChargeModel.cxx:20
Point::z
float z
Definition: main.cpp:74
Point::operator/
Point operator/(double c) const
Definition: pointcloud.cxx:131