highres-cortex 6.0.4
front.hh
Go to the documentation of this file.
1/*
2Copyright Télécom ParisTech (2015).
3
4Contributor: Yann Leprince <yann.leprince@ylep.fr>.
5
6This file is part of highres-cortex, a collection of software designed
7to process high-resolution magnetic resonance images of the cerebral
8cortex.
9
10This software is governed by the CeCILL licence under French law and
11abiding by the rules of distribution of free software. You can use,
12modify and/or redistribute the software under the terms of the CeCILL
13licence as circulated by CEA, CNRS and INRIA at the following URL:
14<http://www.cecill.info/>.
15
16As a counterpart to the access to the source code and rights to copy,
17modify and redistribute granted by the licence, users are provided only
18with a limited warranty and the software's author, the holder of the
19economic rights, and the successive licensors have only limited
20liability.
21
22In this respect, the user's attention is drawn to the risks associated
23with loading, using, modifying and/or developing or reproducing the
24software by the user in light of its specific status of scientific
25software, that may mean that it is complicated to manipulate, and that
26also therefore means that it is reserved for developers and experienced
27professionals having in-depth computer knowledge. Users are therefore
28encouraged to load and test the software's suitability as regards their
29requirements in conditions enabling the security of their systems and/or
30data to be ensured and, more generally, to use and operate it in the
31same conditions as regards security.
32
33The fact that you are presently reading this means that you have had
34knowledge of the CeCILL licence and that you accept its terms.
35*/
36
37#ifndef FRONT_HH_INCLUDED
38#define FRONT_HH_INCLUDED
39
40#include <utility>
41
42#include <boost/functional/hash.hpp>
43#include <boost/heap/priority_queue.hpp>
44
45#include <cartodata/volume/volume.h>
46#include <aims/vector/vector.h>
47
48
49namespace yl
50{
51
53template <class Point>
54struct PointHasher : std::unary_function<Point, std::size_t>
55{
56 std::size_t operator()(const Point& point) const
57 {
58 std::size_t seed = 0;
59 for(int i = 0; i < point.size(); ++i)
60 boost::hash_combine(seed, point[i]);
61 return seed;
62 }
63};
64
65enum {
68};
69
70
72{
73public:
75 int16_t front_label,
76 int16_t done_label);
77
78 const Point3d& get() const
79 {
80 return m_queue.top().second;
81 };
82 Point3d pop();
83
84 void add(const Point3d& /*point*/, float priority);
85
86 bool empty() const
87 {
88 return m_queue.empty();
89 };
90
91 std::size_t size() const
92 {
93 return m_queue.size();
94 };
95
96private:
97 struct VoxelOrdering {
98 bool operator() (const std::pair<float, Point3d>& left,
99 const std::pair<float, Point3d>& right) const
100 {
101 return left.first > right.first;
102 };
103 };
104
105 typedef boost::heap::priority_queue<std::pair<float, Point3d>,
106 boost::heap::compare<VoxelOrdering> >
107 FrontQueue;
108 FrontQueue m_queue;
109
110 carto::VolumeRef<int16_t> m_domain;
111 const int16_t m_front_label;
112 const int16_t m_done_label;
113
114public:
115 static const bool constant_time_size = FrontQueue::constant_time_size;
116};
117
118} // namespace yl
119
120#endif // !defined(FRONT_HH_INCLUDED)
std::size_t size() const
Definition front.hh:91
static const bool constant_time_size
Definition front.hh:115
const Point3d & get() const
Definition front.hh:78
bool empty() const
Definition front.hh:86
void add(const Point3d &, float priority)
SortedFront(carto::VolumeRef< int16_t > &domain, int16_t front_label, int16_t done_label)
Definition cortex.hh:41
@ DEFAULT_FRONT_LABEL
Definition front.hh:66
@ DEFAULT_DONE_LABEL
Definition front.hh:67
Helper class to use Point3d & friends in hash tables.
Definition front.hh:55
std::size_t operator()(const Point &point) const
Definition front.hh:56