ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
mst.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <pcl/io/io.h>
4 
5 #include <vector>
6 
7 namespace mst {
8 struct edge {
10  float distance;
11  friend bool operator<(const edge &e1, const edge &e2) { return (e1.distance < e2.distance); };
12 };
13 
14 struct state {
15  std::vector<edge> edges;
16  std::vector<size_t> groups;
17 };
18 
19 typedef float (*MstMetric)(pcl::PointXYZI const &, pcl::PointXYZI const &, size_t, size_t,
20  pcl::PointCloud<pcl::PointXYZI>::ConstPtr);
21 typedef bool (*MstFilter)(pcl::PointCloud<pcl::PointXYZI>::ConstPtr, edge const &, std::vector<edge> const &,
22  std::vector<size_t> const &);
23 
24 inline float defaultMstMetric(pcl::PointXYZI const &pointA, pcl::PointXYZI const &pointB, size_t indexA, size_t indexB,
25  pcl::PointCloud<pcl::PointXYZI>::ConstPtr cloud)
26 {
27  Eigen::Vector3f diff(pointA.x - pointB.x, pointA.y - pointB.y, pointA.z - pointB.z);
28 
29  return diff.dot(diff);
30 }
31 
32 inline bool defaultMstFilter(pcl::PointCloud<pcl::PointXYZI>::ConstPtr cloud, edge const &edgeV,
33  std::vector<edge> const &selecetedEdges, std::vector<size_t> const &groups)
34 {
35  return true;
36 }
37 
38 std::vector<edge>
39 calculateSquareDistances(pcl::PointCloud<pcl::PointXYZI>::ConstPtr cloud, MstMetric metric = defaultMstMetric);
40 std::vector<state> calculateMinimumSpanningTree(pcl::PointCloud<pcl::PointXYZI>::ConstPtr cloud,
41  MstMetric metric = defaultMstMetric,
42  MstFilter filter = defaultMstFilter);
43 } // namespace mst
mst::state::edges
std::vector< edge > edges
Definition: mst.h:15
mst::defaultMstMetric
float defaultMstMetric(pcl::PointXYZI const &pointA, pcl::PointXYZI const &pointB, size_t indexA, size_t indexB, pcl::PointCloud< pcl::PointXYZI >::ConstPtr cloud)
Definition: mst.h:24
mst::state
Definition: mst.h:14
mst::MstFilter
bool(* MstFilter)(pcl::PointCloud< pcl::PointXYZI >::ConstPtr, edge const &, std::vector< edge > const &, std::vector< size_t > const &)
Definition: mst.h:21
mst::state::groups
std::vector< size_t > groups
Definition: mst.h:16
mst::MstMetric
float(* MstMetric)(pcl::PointXYZI const &, pcl::PointXYZI const &, size_t, size_t, pcl::PointCloud< pcl::PointXYZI >::ConstPtr)
Definition: mst.h:19
mst::edge
Definition: mst.h:8
mst::edge::voxelIndexA
size_t voxelIndexA
Definition: mst.h:9
mst::defaultMstFilter
bool defaultMstFilter(pcl::PointCloud< pcl::PointXYZI >::ConstPtr cloud, edge const &edgeV, std::vector< edge > const &selecetedEdges, std::vector< size_t > const &groups)
Definition: mst.h:32
mst::calculateMinimumSpanningTree
std::vector< state > calculateMinimumSpanningTree(pcl::PointCloud< pcl::PointXYZI >::ConstPtr cloud, MstMetric metric, MstFilter filter)
Definition: mst.cpp:38
mst
Definition: mst.cpp:6
mst::edge::voxelIndexB
size_t voxelIndexB
Definition: mst.h:9
mst::calculateSquareDistances
std::vector< edge > calculateSquareDistances(pcl::PointCloud< pcl::PointXYZI >::ConstPtr cloud, MstMetric metric)
Definition: mst.cpp:7
mst::edge::operator<
friend bool operator<(const edge &e1, const edge &e2)
Definition: mst.h:11
mst::edge::distance
float distance
Definition: mst.h:10