All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
25 #include "SurgSim/Math/OdeSolver.h"
26 
27 namespace SurgSim
28 {
29 namespace Math
30 {
31 class Shape;
32 }
33 }
34 
42 
43 namespace YAML
44 {
47  template <typename Type, int Rows, int Cols, int MOpt>
48  struct convert<typename Eigen::Matrix<Type, Rows, Cols, MOpt>>
49  {
50  static Node encode(const typename Eigen::Matrix<Type, Rows, Cols, MOpt>& rhs);
51  static bool decode(const Node& node, typename Eigen::Matrix<Type, Rows, Cols, MOpt>& rhs);
52  };
53 
56  template <class Type, int Rows, int MOpt>
57  struct convert <typename Eigen::Matrix<Type,Rows,1,MOpt>>
58  {
59  static Node encode(const typename Eigen::Matrix<Type, Rows, 1, MOpt>& rhs);
60  static bool decode(const Node& node, typename Eigen::Matrix<Type, Rows, 1, MOpt>& rhs);
61  };
62 
65  template <class Type, int QOpt>
66  struct convert<typename Eigen::Quaternion<Type, QOpt>>
67  {
68  static Node encode(const typename Eigen::Quaternion<Type, QOpt>& rhs);
69  static bool decode(const Node& node, typename Eigen::Quaternion<Type, QOpt>& rhs);
70  };
71 
74  template <class Type, int Dim, int TMode, int TOptions>
75  struct convert<typename Eigen::Transform<Type, Dim, TMode, TOptions>>
76  {
77  static Node encode(const typename Eigen::Transform<Type, Dim, TMode, TOptions>& rhs);
78  static bool decode(const Node& node, typename Eigen::Transform<Type, Dim, TMode, TOptions>& rhs);
79  };
80 
81  template <>
82  struct convert<std::shared_ptr<SurgSim::Math::Shape>>
83  {
84  static Node encode(const std::shared_ptr<SurgSim::Math::Shape>& rhs);
85  static bool decode(const Node& node, std::shared_ptr<SurgSim::Math::Shape>& rhs);
86  };
87 
88  template <>
90  {
91  static Node encode(const SurgSim::Math::IntegrationScheme& rhs);
92  static bool decode(const Node& node, SurgSim::Math::IntegrationScheme& rhs);
93  };
94 };
95 
97 
98 #endif // SURGSIM_MATH_MATHCONVERT_H
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65
SurgSim::Math::Matrix44f convert(boost::any val)
Specialization for convert() to correctly cast Matrix44d to Matrix44f, will throw if the val is no...
Definition: Accessible.cpp:180
IntegrationScheme
The diverse numerical integration scheme supported Each Ode Solver should have its own entry in this ...
Definition: OdeSolver.h:36
#define SURGSIM_DOUBLE_SPECIALIZATION
Definition: Macros.h:44