Constellation: Connectivity-based Structural Parcellation


connectivities.h
Go to the documentation of this file.
1#ifndef CONSTELLATION_CONNECTIVITIES_H
2#define CONSTELLATION_CONNECTIVITIES_H
3
4#include <vector>
5#include <set>
6#include <map>
7#include <boost/shared_ptr.hpp>
8
9namespace constel
10{
11
12 class Connectivity : public std::map<size_t, double>
13 {
14 public:
15 Connectivity( size_t size ) : _size( size ) {}
16 size_t size() const { return _size; }
17
18 float get( size_t i ) const
19 {
20 const_iterator it = find( i );
21 if( it == end() )
22 return 0.;
23 return it->second;
24 }
25
27 {
28 Connectivity::const_iterator i, e = c.end();
29 iterator j = find( i->first );
30 if( j == end() )
31 (*this)[ i->first ] = i->second;
32 else
33 j->second += i->second;
34 return *this;
35 }
36
37 double dot( const Connectivity & c ) const
38 {
39 double sum = 0.;
40 if( size() > c.size() )
41 {
42 Connectivity::const_iterator i, j, e = c.end(), je = end();
43 for( i=c.begin(); i!=e; ++i )
44 {
45 j = find( i->first );
46 if( j != je )
47 sum += i->second * i->second;
48 }
49 }
50 else
51 {
52 Connectivity::const_iterator i, j, e = end(), je = c.end();
53 for( i=begin(); i!=e; ++i )
54 {
55 j = c.find( i->first );
56 if( j != je )
57 sum += i->second * i->second;
58 }
59 }
60 return sum;
61 }
62
63 private:
64 size_t _size;
65 };
66
67 typedef std::vector<Connectivity> Connectivities;
68 typedef std::vector<std::vector<std::size_t> > CNeighborhoods;
69 typedef std::vector<std::pair<std::size_t, double> > QuickMap;
70 typedef std::map<std::size_t, float> DistMap;
71 typedef std::vector<QuickMap> Connection;
72 typedef std::vector<Connection> BundleConnections;
73 typedef boost::shared_ptr<BundleConnections> BundleConnections_shared_ptr;
74 typedef std::vector<unsigned> ConnectionsLength;
75 typedef std::vector<float> ConnectionsFloatLength;
76 typedef boost::shared_ptr<ConnectionsLength> ConnectionsLength_shared_ptr;
77 typedef std::vector<std::set<unsigned> > PolygonsByVertexIndex;
78 typedef std::vector<PolygonsByVertexIndex> PolygonsByVertexIndex_collection;
79
80}
81#endif
82
Connectivity(size_t size)
Connectivity & operator+=(const Connectivity &c)
float get(size_t i) const
double dot(const Connectivity &c) const
std::vector< std::pair< std::size_t, double > > QuickMap
boost::shared_ptr< ConnectionsLength > ConnectionsLength_shared_ptr
std::vector< Connection > BundleConnections
std::vector< std::set< unsigned > > PolygonsByVertexIndex
std::vector< QuickMap > Connection
std::vector< float > ConnectionsFloatLength
std::map< std::size_t, float > DistMap
std::vector< std::vector< std::size_t > > CNeighborhoods
boost::shared_ptr< BundleConnections > BundleConnections_shared_ptr
std::vector< PolygonsByVertexIndex > PolygonsByVertexIndex_collection
std::vector< unsigned > ConnectionsLength
std::vector< Connectivity > Connectivities