Developer documentation
Version 3.0.3-105-gd3941f44
arc.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __dwi_tractography_resampling_arc_h__
18#define __dwi_tractography_resampling_arc_h__
19
20
22
23
24namespace MR {
25 namespace DWI {
26 namespace Tractography {
27 namespace Resampling {
28
29
30
31 // Also handles resampling along a fixed line
32 class Arc : public BaseCRTP<Arc> { MEMALIGN(Arc)
33
34 using value_type = float;
35 using point_type = Eigen::Vector3f;
36
37 enum class state_t { BEFORE_START, AFTER_START, BEFORE_END, AFTER_END };
38
39 private:
40 class Plane { MEMALIGN(Plane)
41 public:
42 Plane (const point_type& pos, const point_type& dir) :
43 n (dir)
44 {
45 n.normalize();
46 d = n.dot (pos);
47 }
48 value_type dist (const point_type& pos) const { return n.dot (pos) - d; }
49 private:
50 point_type n;
51 value_type d;
52 };
53
54 vector<Plane> planes;
55
56 public:
57 Arc (const size_t n, const point_type& s, const point_type& e) :
58 nsamples (n),
59 start (s),
60 mid (0.5*(s+e)),
61 end (e),
62 idx_start (0),
63 idx_end (0)
64 {
65 init_line();
66 }
67
68 Arc (const size_t n, const point_type& s, const point_type& w, const point_type& e) :
69 nsamples (n),
70 start (s),
71 mid (w),
72 end (e),
73 idx_start (0),
74 idx_end (0)
75 {
76 init_arc();
77 }
78
79 bool operator() (const Streamline<>&, Streamline<>&) const override;
80 bool valid() const override { return nsamples; }
81
82 private:
83 const size_t nsamples;
84 const point_type start, mid, end;
85
86 mutable size_t idx_start, idx_end;
87 mutable point_type start_dir, mid_dir, end_dir;
88
89 void init_line();
90 void init_arc();
91
92
93 state_t state (const point_type&) const;
94
95 };
96
97
98
99 }
100 }
101 }
102}
103
104#endif
105
106
107
bool operator()(const Streamline<> &, Streamline<> &) const override
Arc(const size_t n, const point_type &s, const point_type &w, const point_type &e)
Definition: arc.h:68
Arc(const size_t n, const point_type &s, const point_type &e)
Definition: arc.h:57
bool valid() const override
Definition: arc.h:80
constexpr double e
Definition: math.h:39
typename Streamline<>::point_type point_type
Definition: resampling.h:40
Definition: base.h:24
#define MEMALIGN(...)
Definition: types.h:185