GCC Code Coverage Report


Directory: ./
File: modules/geometry/__/concatenate_matrices.hpp
Date: 2024-05-15 12:26:39
Exec Total Coverage
Lines: 2 3 66.7%
Branches: 0 9 0.0%

Line Branch Exec Source
1 /************************************************************************
2 *
3 * Copyright (C) 2014-2024 IRCAD France
4 * Copyright (C) 2014-2019 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 #pragma once
24
25 #include <core/base.hpp>
26
27 #include <data/matrix4.hpp>
28
29 #include <service/controller.hpp>
30
31 namespace sight::module::geometry
32 {
33
34 /**
35 * @brief This service concatenates N matrices together.
36 *
37 * The computation of the concatenation is triggered when updating the service.
38 * Auto-connections to the matrices can also be used to force the service to recompute the output matrix.
39 *
40 * @section XML XML Configuration
41 *
42 * @code{.xml}
43 <service uid="..." type="sight::module::geometry::concatenate_matrices">
44 <in group="matrix">
45 <key uid="..." />
46 <key uid="..." inverse="true"/>
47 <key uid="..." auto_connect="true"/>
48 </in>
49 <inout key="output" uid="..." />
50 </service>
51 @endcode
52 * @subsection Input Input:
53 * - \b matrix [sight::data::matrix4]: List of matrix keys to concatenate. For each input matrix, it is
54 * possible to invert it before multiplying with it by specifying \b inverse="true".
55 * The auto_connect is connected to the update slot, thus is will trigger a new concatenation.
56 * @subsection In-Out In-Out:
57 * - \b output [sight::data::matrix4]: Output matrix.
58 */
59
60 class concatenate_matrices : public service::controller
61 {
62 public:
63
64 SIGHT_DECLARE_SERVICE(concatenate_matrices, sight::service::controller);
65
66 6 concatenate_matrices() noexcept = default;
67 12 ~concatenate_matrices() noexcept override = default;
68
69 protected:
70
71 /// This method is used to configure the service.
72 void configuring() override;
73
74 /// Does nothing.
75 void starting() override;
76
77 /// Does nothing.
78 void stopping() override;
79
80 /// Concatenates the matrices
81 void updating() override;
82
83 /**
84 * @brief Returns proposals to connect service slots to associated object signals,
85 * this method is used for obj/srv auto connection
86 *
87 * Connect Matrix4::MODIFIED_SIG to this::service::slots::UPDATE
88 */
89 connections_t auto_connections() const override;
90
91 private:
92
93 using invert_vector_t = std::vector<bool>;
94
95 /// Vector to specify if matrix must be inverted.
96 invert_vector_t m_invert_vector;
97
98 static constexpr std::string_view MATRIX_GROUP_INPUT = "matrix";
99 data::ptr_vector<data::matrix4, sight::data::access::in> m_matrices {this, MATRIX_GROUP_INPUT, true};
100
101 static constexpr std::string_view OUTPUT = "output";
102 data::ptr<data::matrix4, sight::data::access::inout> m_output {this, OUTPUT};
103 };
104
105 } //namespace sight::module::geometry
106