diff --git a/src/grid_cluster.cpp b/src/grid_cluster.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6b6336bbfb23e44c85cf36cbe414bfbb9a4ebea9 --- /dev/null +++ b/src/grid_cluster.cpp @@ -0,0 +1,37 @@ +#include "grid_cluster.h" + +namespace laserscanutils +{ + +//init static cluster counter +unsigned int GridCluster::cluster_id_count_ = 0; + +GridCluster::GridCluster() : PointSet() +{ + // +} + +GridCluster::~GridCluster() +{ + // +} + +void GridCluster::print() const +{ + //print cluster params + std::cout + << "\tcluster_id_: " << cluster_id_ << std::endl + << "\tcentroid_x_: " << centroid_(0) << std::endl + << "\tcentroid_y_: " << centroid_(1)<< std::endl; + + //print cluster cell index pairs + std::cout << "\tcells_: "; + for (unsigned int jj = 0; jj < cells_.size(); jj++) + { + std::cout << cells_.at(jj).first << "," << cells_.at(jj).second << " - "; + } + std::cout << std::endl; +} + +}//close namespace + diff --git a/src/grid_cluster.h b/src/grid_cluster.h new file mode 100644 index 0000000000000000000000000000000000000000..2f6eac4fe763ffa0d49a083ba119c956f0dea201 --- /dev/null +++ b/src/grid_cluster.h @@ -0,0 +1,39 @@ +#ifndef GRID_CLUSTER_H_ +#define GRID_CLUSTER_H_ + +//laserscanutils +#include "laser_scan_utils.h" +#include "point_set.h" + +//std +#include <iostream> + +//open namespace +namespace laserscanutils +{ +/** \brief Cluster class + * + * Cluster of connected occupied cells in a grid + * + **/ +class GridCluster : public PointSet +{ + protected: + unsigned int cluster_id_; //Cluster id. + static unsigned int cluster_id_count_; //cluster counter (acts as simple ID factory) + + public: + std::vector<std::pair<unsigned int, unsigned int> > cells_; //i,j index of the grid cells of this cluster + + public: + //constructor + GridCluster(); + + //Destructor + ~GridCluster(); + + //print + virtual void print() const; +}; +}//namespace +#endif