MathConvert.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_MATH_MATHCONVERT_H
17 #define SURGSIM_MATH_MATHCONVERT_H
18 
19 #include <Eigen/Core>
20 #include <Eigen/Geometry>
21 
22 #include <yaml-cpp/yaml.h>
23 
26 #include "SurgSim/Math/OdeSolver.h"
27 
28 namespace SurgSim
29 {
30 namespace Math
31 {
32 class Shape;
33 }
34 }
35 
43 
44 namespace YAML
45 {
46 
49 template <typename Type, int Rows, int Cols, int MOpt>
50 struct convert<typename Eigen::Matrix<Type, Rows, Cols, MOpt>>
51 {
52  static Node encode(const typename Eigen::Matrix<Type, Rows, Cols, MOpt>& rhs);
53  static bool decode(const Node& node, typename Eigen::Matrix<Type, Rows, Cols, MOpt>& rhs); //NOLINT
54 };
55 
58 template <class Type, int QOpt>
59 struct convert<typename Eigen::Quaternion<Type, QOpt>>
60 {
61  static Node encode(const typename Eigen::Quaternion<Type, QOpt>& rhs);
62  static bool decode(const Node& node, typename Eigen::Quaternion<Type, QOpt>& rhs); //NOLINT
63 };
64 
67 template <class Type, int Dim, int TMode, int TOptions>
68 struct convert<typename Eigen::Transform<Type, Dim, TMode, TOptions>>
69 {
70  static Node encode(const typename Eigen::Transform<Type, Dim, TMode, TOptions>& rhs);
71  static bool decode(const Node& node, typename Eigen::Transform<Type, Dim, TMode, TOptions>& rhs); //NOLINT
72 };
73 
76 template <typename Type>
77 struct convert<typename Eigen::AngleAxis<Type>>
78 {
79  static Node encode(const typename Eigen::AngleAxis<Type>& rhs);
80  static bool decode(const Node& node, typename Eigen::AngleAxis<Type>& rhs); //NOLINT
81 };
82 
83 template <>
84 struct convert<std::shared_ptr<SurgSim::Math::Shape>>
85 {
86  static Node encode(const std::shared_ptr<SurgSim::Math::Shape>& rhs);
87  static bool decode(const Node& node, std::shared_ptr<SurgSim::Math::Shape>& rhs); //NOLINT
88 };
89 
90 template <>
92 {
93  static Node encode(const SurgSim::Math::IntegrationScheme& rhs);
94  static bool decode(const Node& node, SurgSim::Math::IntegrationScheme& rhs); //NOLINT
95 };
96 
97 template <>
99 {
100  static Node encode(const SurgSim::Math::LinearSolver& rhs);
101  static bool decode(const Node& node, SurgSim::Math::LinearSolver& rhs); //NOLINT
102 };
103 
104 };
105 
107 
108 #endif // SURGSIM_MATH_MATHCONVERT_H
LinearSparseSolveAndInverse.h
Eigen
Definition: MathUtilities.h:95
Macros.h
SurgSim::Math::IntegrationScheme
IntegrationScheme
The diverse numerical integration scheme supported Each Ode Solver should have its own entry in this ...
Definition: OdeSolver.h:37
YAML
Definition: DataStructuresConvert.h:29
SURGSIM_DOUBLE_SPECIALIZATION
#define SURGSIM_DOUBLE_SPECIALIZATION
Definition: Macros.h:44
SurgSim
Definition: CompoundShapeToGraphics.cpp:30
SurgSim::Math::LinearSolver
LinearSolver
The linear numerical integration scheme supported Each Linear Solver should have its own entry in thi...
Definition: LinearSparseSolveAndInverse.h:42
SurgSim::Framework::convert
SurgSim::Math::Matrix44f convert(boost::any val)
Wrap boost::any_cast to use in std::bind, for some reason it does not work by itself.
Definition: Accessible.cpp:210
MathConvert-inl.h
SurgSim::Math::Matrix
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65
OdeSolver.h