Developer documentation
Version 3.0.3-105-gd3941f44
loader.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_mapping_loader_h__
18#define __dwi_tractography_mapping_loader_h__
19
20
21#include "memory.h"
22#include "progressbar.h"
23#include "thread_queue.h"
26
27
28namespace MR {
29 namespace DWI {
30 namespace Tractography {
31 namespace Mapping {
32
33
34
36 { MEMALIGN(TrackLoader)
37
38 public:
39 TrackLoader (Reader<>& file, const size_t to_load = 0, const std::string& msg = "mapping tracks to image") :
40 reader (file),
41 tracks_to_load (to_load),
42 progress (msg.size() ? new ProgressBar (msg, tracks_to_load) : nullptr) { }
43
44 virtual ~TrackLoader() { }
45 virtual bool operator() (Streamline<>& out)
46 {
47 if (!reader (out)) {
48 progress.reset();
49 return false;
50 }
51 if (tracks_to_load && out.get_index() >= tracks_to_load) {
52 out.clear();
53 progress.reset();
54 return false;
55 }
56 if (progress)
57 ++(*progress);
58 return true;
59 }
60
61 protected:
63 const size_t tracks_to_load;
64 std::unique_ptr<ProgressBar> progress;
65
66 };
67
68
69 }
70 }
71 }
72}
73
74#endif
75
76
77
std::unique_ptr< ProgressBar > progress
Definition: loader.h:64
A class to read streamlines data.
Definition: file.h:63
implements a progress meter to provide feedback to the user
Definition: progressbar.h:58
Definition: base.h:24