highres-cortex 6.0.4
advection.hh
Go to the documentation of this file.
1/*
2Copyright CEA (2014, 2017, 2019).
3Copyright Université Paris XI (2014).
4
5Contributor: Yann Leprince <yann.leprince@ylep.fr>.
6Contributor: Denis Rivière <denis.riviere@cea.fr>.
7
8This file is part of highres-cortex, a collection of software designed
9to process high-resolution magnetic resonance images of the cerebral
10cortex.
11
12This software is governed by the CeCILL licence under French law and
13abiding by the rules of distribution of free software. You can use,
14modify and/or redistribute the software under the terms of the CeCILL
15licence as circulated by CEA, CNRS and INRIA at the following URL:
16<http://www.cecill.info/>.
17
18As a counterpart to the access to the source code and rights to copy,
19modify and redistribute granted by the licence, users are provided only
20with a limited warranty and the software's author, the holder of the
21economic rights, and the successive licensors have only limited
22liability.
23
24In this respect, the user's attention is drawn to the risks associated
25with loading, using, modifying and/or developing or reproducing the
26software by the user in light of its specific status of scientific
27software, that may mean that it is complicated to manipulate, and that
28also therefore means that it is reserved for developers and experienced
29professionals having in-depth computer knowledge. Users are therefore
30encouraged to load and test the software's suitability as regards their
31requirements in conditions enabling the security of their systems and/or
32data to be ensured and, more generally, to use and operate it in the
33same conditions as regards security.
34
35The fact that you are presently reading this means that you have had
36knowledge of the CeCILL licence and that you accept its terms.
37*/
38
39#ifndef YL_ADVECTION_HH_INCLUDED
40#define YL_ADVECTION_HH_INCLUDED
41
42#include "field.hh"
43
44namespace yl
45{
46
49{
50public:
51 explicit Advection(const VectorField3d& advection_field);
52 virtual ~Advection() {};
53
64 template <class TVisitor>
65 bool
66 visitor_advection(TVisitor& visitor,
67 const Point3df& start_point) const;
68
70 class Visitor
71 {
72 public:
73 Visitor() : m_verbosity(0) {};
74 virtual ~Visitor() {};
75
77 virtual void first(const Point3df& point) = 0;
79 virtual void visit(const Point3df& point) = 0;
81 virtual bool move_on(const Point3df& point) const = 0;
83 virtual bool aborted() const = 0;
85 virtual void finished(const Point3df& /*start_point*/) {}
87 virtual void abort() {}
88
89 int verbosity() const { return m_verbosity; }
95 void set_verbose(int verbosity) { m_verbosity = verbosity; }
96
97 private:
98 int m_verbosity;
99 };
100
102 static const unsigned int default_max_iter = 1000;
104 void set_max_iter(unsigned int max_iter)
105 {
106 m_max_iter = max_iter;
107 };
108
116 void set_verbose(const int verbosity)
117 {
118 m_verbose = verbosity;
119 };
120
123 {
124 };
125
126private:
127 virtual void move_one_step(Point3df& point,
128 const Point3df& local_field) const = 0;
129
130 const yl::VectorField3d& m_vector_field;
131 int m_verbose;
132 unsigned int m_max_iter;
133};
134
141{
142public:
143 ConstantStepAdvection(const yl::VectorField3d& advection_field, float step);
145
147 void set_step(float step)
148 {
149 m_step = step;
150 };
151
152private:
153 virtual void move_one_step(Point3df& point,
154 const Point3df& local_field) const;
155
156 float m_step;
157};
158
159} // namespace yl
160
161#endif // !defined(YL_ADVECTION_HH_INCLUDED)
Thrown by move_one_step() to abort the advection.
Definition advection.hh:123
virtual void abort()
Called when the advection cannot finish successfully.
Definition advection.hh:87
virtual bool move_on(const Point3df &point) const =0
Predicate that decides if the advection will continue or stop.
virtual void visit(const Point3df &point)=0
Called for every point on the advection path, including the first.
int verbosity() const
Definition advection.hh:89
virtual void finished(const Point3df &)
Called after the advection is stopped by move_on()
Definition advection.hh:85
virtual void first(const Point3df &point)=0
Called before visit() on the first point of the advection path.
void set_verbose(int verbosity)
Set the verbosity level (output to stderr)
Definition advection.hh:95
virtual bool aborted() const =0
Indicates whether the Visitor encountered an error.
virtual ~Advection()
Definition advection.hh:52
void set_verbose(const int verbosity)
Set the verbosity level (output to stderr)
Definition advection.hh:116
Advection(const VectorField3d &advection_field)
bool visitor_advection(TVisitor &visitor, const Point3df &start_point) const
Advect a visitor along a vector field.
void set_max_iter(unsigned int max_iter)
Set the maximum number of iterations.
Definition advection.hh:104
static const unsigned int default_max_iter
Default iteration limit.
Definition advection.hh:102
void set_step(float step)
Change the step length.
Definition advection.hh:147
ConstantStepAdvection(const yl::VectorField3d &advection_field, float step)
Store a vector field and access it at any coordinates.
Definition field.hh:60
Definition cortex.hh:41