GCC Code Coverage Report


Directory: ./
File: libs/__/data/image_series.cpp
Date: 2024-05-31 17:23:24
Exec Total Coverage
Lines: 57 57 100.0%
Branches: 41 172 23.8%

Line Branch Exec Source
1 /************************************************************************
2 *
3 * Copyright (C) 2009-2023 IRCAD France
4 * Copyright (C) 2012-2020 IHU Strasbourg
5 *
6 * This file is part of Sight.
7 *
8 * Sight is free software: you can redistribute it and/or modify it under
9 * the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Sight is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Sight. If not, see <https://www.gnu.org/licenses/>.
20 *
21 ***********************************************************************/
22
23 #include "data/image_series.hpp"
24
25 #include "data/detail/series_impl.hxx"
26
27 #include <data/exception.hpp>
28 #include <data/image.hpp>
29 #include <data/registry/macros.hpp>
30
31 SIGHT_REGISTER_DATA(sight::data::image_series)
32
33 namespace sight::data
34 {
35
36 674 image_series::image_series() :
37
4/8
✓ Branch 2 taken 337 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 337 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 337 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 337 times.
✗ Branch 12 not taken.
674 has_fiducials(m_signals)
38 {
39 }
40
41 //------------------------------------------------------------------------------
42
43 2 void image_series::shallow_copy(const object::csptr& _source)
44 {
45 2 const auto& other = std::dynamic_pointer_cast<const image_series>(_source);
46
47
1/52
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
2 SIGHT_THROW_EXCEPTION_IF(
48 exception(
49 "Unable to copy " + (_source ? _source->get_classname() : std::string("<NULL>"))
50 + " to " + get_classname()
51 ),
52 !bool(other)
53 );
54
55 2 m_dicom_reference = other->m_dicom_reference;
56 2 m_fiducials_series = other->m_fiducials_series;
57
58
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 series::shallow_copy(other);
59
60
2/6
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 base_class_t::shallow_copy(other);
61 2 }
62
63 //------------------------------------------------------------------------------
64
65 24 void image_series::deep_copy(const object::csptr& _source, const std::unique_ptr<deep_copy_cache_t>& _cache)
66 {
67 24 const auto& other = std::dynamic_pointer_cast<const image_series>(_source);
68
69
1/52
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
24 SIGHT_THROW_EXCEPTION_IF(
70 exception(
71 "Unable to copy " + (_source ? _source->get_classname() : std::string("<NULL>"))
72 + " to " + get_classname()
73 ),
74 !bool(other)
75 );
76
77
3/6
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
24 m_dicom_reference = data::object::copy(other->m_dicom_reference);
78
79
2/4
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
24 m_fiducials_series = std::make_shared<fiducials_series>();
80
1/2
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 m_fiducials_series->deep_copy(other->m_fiducials_series, _cache);
81
82
1/2
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 series::deep_copy(other, _cache);
83
84
2/6
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
48 base_class_t::deep_copy(other, _cache);
85 24 }
86
87 //------------------------------------------------------------------------------
88
89 181 bool image_series::operator==(const image_series& _other) const noexcept
90 {
91
10/10
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 110 times.
✓ Branch 2 taken 73 times.
✓ Branch 3 taken 108 times.
✓ Branch 5 taken 73 times.
✓ Branch 6 taken 108 times.
✓ Branch 7 taken 71 times.
✓ Branch 8 taken 110 times.
✓ Branch 9 taken 179 times.
✓ Branch 10 taken 2 times.
469 if(!core::tools::is_equal(m_dicom_reference, _other.m_dicom_reference))
92 {
93 return false;
94 }
95
96 // Super class last
97
3/4
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 83 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 96 times.
179 return series::operator==(_other) && base_class_t::operator==(_other);
98 }
99
100 //------------------------------------------------------------------------------
101
102 87 bool image_series::operator!=(const image_series& _other) const noexcept
103 {
104 87 return !(*this == _other);
105 }
106
107 //------------------------------------------------------------------------------
108
109 42 std::vector<double> image_series::window_center() const noexcept
110 {
111 42 return series::window_center();
112 }
113
114 //------------------------------------------------------------------------------
115
116 53 void image_series::set_window_center(const std::vector<double>& _window_centers)
117 {
118 53 series::set_window_center(_window_centers);
119 53 image::set_window_center(_window_centers);
120 53 }
121
122 //------------------------------------------------------------------------------
123
124 53 void image_series::set_window_width(const std::vector<double>& _window_widths)
125 {
126 53 series::set_window_width(_window_widths);
127 53 image::set_window_width(_window_widths);
128 53 }
129
130 //------------------------------------------------------------------------------
131
132 42 std::vector<double> image_series::window_width() const noexcept
133 {
134 42 return series::window_width();
135 }
136
137 //------------------------------------------------------------------------------
138
139 3 void image_series::set_rows(const std::optional<std::uint16_t>& _rows)
140 {
141 3 series::set_rows(_rows);
142
143 // Resize the image (if possible and needed...)
144
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(const auto pixel_format = this->pixel_format(); pixel_format != sight::data::image::pixel_format::undefined)
145 {
146
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 const auto rows_value = _rows.value_or(1);
147
148
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(const auto& original_size = size(); original_size[0] != rows_value)
149 {
150 2 resize({std::size_t(rows_value), original_size[1], original_size[2]}, type(), pixel_format);
151 }
152 }
153 3 }
154
155 //------------------------------------------------------------------------------
156
157 3 void image_series::set_columns(const std::optional<std::uint16_t>& _columns)
158 {
159 3 series::set_columns(_columns);
160
161 // Resize the image (if possible and needed...)
162
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(const auto pixel_format = this->pixel_format(); pixel_format != sight::data::image::pixel_format::undefined)
163 {
164
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 const auto columns_value = _columns.value_or(1);
165
166
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(const auto& original_size = size(); original_size[1] != columns_value)
167 {
168 2 resize({original_size[0], std::size_t(columns_value), original_size[2]}, type(), pixel_format);
169 }
170 }
171 3 }
172
173 //------------------------------------------------------------------------------
174
175 127 std::size_t image_series::resize(const image::size_t& _size, const core::type& _type, enum pixel_format _format)
176 {
177 127 series::shrink_frames(_size[2]);
178 127 return image::resize(_size, _type, _format);
179 }
180
181 //------------------------------------------------------------------------------
182
183 175 fiducials_series::csptr image_series::get_fiducials() const
184 {
185
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 return m_fiducials_series;
186 }
187
188 //------------------------------------------------------------------------------
189
190 170 fiducials_series::sptr image_series::get_fiducials()
191 {
192
1/2
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
170 return m_fiducials_series;
193 }
194
195 } // namespace sight::data
196