Developer documentation
Version 3.0.3-105-gd3941f44
mapper.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_connectome_mapper_h__
18#define __dwi_tractography_connectome_mapper_h__
19
24
25
26namespace MR {
27namespace DWI {
28namespace Tractography {
29namespace Connectome {
30
31
32
33
34class Mapper
35{ MEMALIGN(Mapper)
36
37 public:
38 Mapper (const Tck2nodes_base& a, const Metric& b) :
39 tck2nodes (a),
40 metric (b) { }
41
42 Mapper (const Mapper& that) :
43 tck2nodes (that.tck2nodes),
44 metric (that.metric) { }
45
46
47 bool operator() (const Tractography::Streamline<float>& in, Mapped_track_nodepair& out)
48 {
49 assert (tck2nodes.provides_pair());
50 out.set_track_index (in.get_index());
51 out.set_nodes (tck2nodes (in));
52 out.set_factor (metric (in, out.get_nodes()));
53 out.set_weight (in.weight);
54 return true;
55 }
56
57 bool operator() (const Tractography::Streamline<float>& in, Mapped_track_nodelist& out)
58 {
59 assert (!tck2nodes.provides_pair());
60 out.set_track_index (in.get_index());
61 vector<node_t> nodes;
62 tck2nodes (in, nodes);
63 out.set_nodes (std::move (nodes));
64 out.set_factor (metric (in, out.get_nodes()));
65 out.set_weight (in.weight);
66 return true;
67 }
68
69
70 private:
71 const Tck2nodes_base& tck2nodes;
72 const Metric& metric;
73
74};
75
76
77
78
79}
80}
81}
82}
83
84
85#endif
86
Definition: base.h:24