14#include <yarp/math/Math.h> 
   18using namespace yarp::os;
 
   19using namespace yarp::sig;
 
   20using namespace yarp::math;
 
   36                Data_t(
const vector<Vector> &points_,
 
   37                       const double epsilon_,
 
   38                       const size_t minpts_) :
 
 
 
   58                shared_ptr<Node_t> node(
new Node_t());
 
 
   65            void append(
const size_t index, shared_ptr<Epsilon_neighbours_t> en)
 
   68                if (en->head==
nullptr)
 
   75                    en->tail.lock()->next=node;
 
 
   83                                                                    shared_ptr<Data_t> augData)
 
   86                for (
size_t i=0; i<augData->points.size(); i++)
 
   89                    for (
size_t j=0; j<augData->points[index].length(); j++)
 
   91                        d+=pow(augData->points[index][j]-augData->points[i][j],2.0);
 
   93                    if ((i!=index) && (sqrt(d)<=augData->epsilon))
 
 
  102            void spread(
const size_t index, shared_ptr<Epsilon_neighbours_t> seeds,
 
  103                        const size_t id, shared_ptr<Data_t> augData)
 
  106                if (
spread->num_members>=augData->minpts)
 
  108                    for (shared_ptr<Node_t> node=
spread->head; node!=
nullptr; node=node->next)
 
  115                                append(node->index,seeds);
 
  117                            augData->ids[node->index]=(int)
id;
 
 
  124            bool expand(
const size_t index, 
const size_t id, shared_ptr<Data_t> augData)
 
  127                if (seeds->num_members<augData->minpts)
 
  134                    augData->ids[index]=(int)
id;
 
  135                    for (shared_ptr<Node_t> 
h=seeds->head; 
h!=
nullptr; 
h=
h->next)
 
  137                        augData->ids[
h->index]=(int)
id;
 
  139                    for (shared_ptr<Node_t> 
h=seeds->head; 
h!=
nullptr; 
h=
h->next)
 
  141                        spread(
h->index,seeds,
id,augData);
 
 
 
  153                                        const Property &options)
 
  155    double epsilon=options.check(
"epsilon",Value(1.0)).asFloat64();
 
  156    size_t minpts=(size_t)options.check(
"minpts",Value(2)).asInt32();
 
  160    for (
size_t i=0; i<augData->points.size(); i++)
 
  171    map<size_t,set<size_t>> clusters;
 
  172    for (
size_t i=0; i<augData->points.size(); i++)
 
  176            clusters[augData->ids[i]].insert(i);
 
 
std::map< size_t, std::set< size_t > > cluster(const std::vector< yarp::sig::Vector > &data, const yarp::os::Property &options) override
Cluster the provided data.
 
shared_ptr< Epsilon_neighbours_t > get_epsilon_neighbours(const size_t index, shared_ptr< Data_t > augData)
 
void append(const size_t index, shared_ptr< Epsilon_neighbours_t > en)
 
bool expand(const size_t index, const size_t id, shared_ptr< Data_t > augData)
 
void spread(const size_t index, shared_ptr< Epsilon_neighbours_t > seeds, const size_t id, shared_ptr< Data_t > augData)
 
shared_ptr< Node_t > create_node(const size_t index)
 
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.
 
const vector< Vector > & points
 
Data_t(const vector< Vector > &points_, const double epsilon_, const size_t minpts_)
 
shared_ptr< Node_t > head
 
shared_ptr< Node_t > next