mt
 All Classes Files Functions Enumerations Groups Pages
serialize.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2006 by Adolfo Rodriguez *
3  * adolfo.rodriguez@upc.edu *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
22 
23 // HEADER GUARD
24 #ifndef PMF_COM_MT_SERIALIZE_H
25 #define PMF_COM_MT_SERIALIZE_H
26 
27 // BOOST LIBRARY HEADERS
28 #include <boost/archive/text_oarchive.hpp>
29 #include <boost/archive/text_iarchive.hpp>
30 #include <boost/serialization/base_object.hpp>
31 #include <boost/serialization/variant.hpp>
32 #include <boost/serialization/string.hpp>
33 
34 // MT LIBRARY HEADERS
35 #include <mt/basic_scalar.h>
36 #include <mt/empty.h>
37 #include <mt/vector3.h>
38 #include <mt/unit3.h>
39 #include <mt/interval.h>
40 #include <mt/matrix3x3.h>
41 #include <mt/quaternion.h>
42 #include <mt/rotation.h>
43 #include <mt/transform.h>
44 
45 #include <mt/point3.h>
46 #include <mt/line3.h>
47 #include <mt/plane3.h>
48 #include <mt/sphere3.h>
49 #include <mt/cylinder3.h>
50 #include <mt/circle3.h>
51 #include <mt/ellipse3.h>
52 
53 #include <mt/element.h>
54 #include <mt/object.h>
55 
56 
58 
59 namespace boost
60 {
61 namespace serialization
62 {
63 
65 
77 
78 // BASIC MATH CLASSES
79 
80 template<class Archive, class T> inline
81 void serialize(Archive& ar, mt::BasicScalar<T>& s, const unsigned int version)
82 {
83  ar & s.getRef();
84 }
85 
86 
87 template<class Archive> inline
88 void serialize(Archive& ar, mt::Vector3& v, const unsigned int version)
89 {
90  ar & v[0];
91  ar & v[1];
92  ar & v[2];
93 }
94 
95 
96 template<class Archive> inline
97 void serialize(Archive& ar, mt::Unit3& u, const unsigned int version)
98 {
99  ar & boost::serialization::base_object<mt::Vector3>(u);
100 }
101 
102 
103 template<class Archive> inline
104 void serialize(Archive& ar, mt::Interval& i, const unsigned int version)
105 {
106  ar & i.getLowerBoundRef();
107  ar & i.getUpperBoundRef();
108 }
109 
110 
111 template<class Archive> inline
112 void serialize(Archive& ar, mt::Matrix3x3& M, const unsigned int version)
113 {
114  ar & M[0];
115  ar & M[1];
116  ar & M[2];
117 }
118 
119 
120 template<class Archive> inline
121 void serialize(Archive& ar, mt::Quaternion& q, const unsigned int version)
122 {
123  ar & q[0];
124  ar & q[1];
125  ar & q[2];
126  ar & q[3];
127 }
128 
129 
130 template<class Archive> inline
131 void serialize(Archive& ar, mt::Rotation& r, const unsigned int version)
132 {
133  ar & boost::serialization::base_object<mt::Quaternion>(r);
134 }
135 
136 
137 template<class Archive> inline
138 void serialize(Archive& ar, mt::Transform& t, const unsigned int version)
139 {
140  ar & t.getRotationRef();
141  ar & t.getTranslationRef();
142 }
143 
144 
145 // GEOMETRIC ELEMENTS
146 
147 template<class Archive> inline
148 void serialize(Archive& ar, mt::Empty& e, const unsigned int version) {}
149 
150 
151 template<class Archive> inline
152 void serialize(Archive& ar, mt::Point3& p, const unsigned int version)
153 {
154  ar & boost::serialization::base_object<mt::Vector3>(p);
155 }
156 
157 
158 template<class Archive> inline
159 void serialize(Archive& ar, mt::Line3& L, const unsigned int version)
160 {
161  ar & L.getDirectionRef();
162  ar & L.getSupportRef();
163  ar & L.getDirectionTypeRef();
164 }
165 
166 
167 template<class Archive> inline
168 void serialize(Archive& ar, mt::Plane3& P, const unsigned int version)
169 {
170  ar & P.getNormalRef();
171  ar & P.getDistOrigRef();
172  ar & P.getDirectionTypeRef();
173 }
174 
175 
176 template<class Archive> inline
177 void serialize(Archive& ar, mt::Sphere3& S, const unsigned int version)
178 {
179  ar & S.getCenterRef();
180  ar & S.getRadiusRef();
181 }
182 
183 
184 template<class Archive> inline
185 void serialize(Archive& ar, mt::Cylinder3& C, const unsigned int version)
186 {
187  ar & C.getAxisRef();
188  ar & C.getRadiusRef();
189 }
190 
191 
192 template<class Archive> inline
193 void serialize(Archive& ar, mt::Circle3& C, const unsigned int version)
194 {
195  ar & C.getCenterRef();
196  ar & C.getRadiusRef();
197  ar & C.getNormalRef();
198 }
199 
200 
201 template<class Archive> inline
202 void serialize(Archive& ar, mt::Ellipse3& E, const unsigned int version)
203 {
204  ar & E.getCenterRef();
205  ar & E.getAxisDirRef(1);
206  ar & E.getAxisDirRef(2);
207  ar & E.getAxisLengthRef(1);
208  ar & E.getAxisLengthRef(2);
209 }
210 
211 // MT VARIANT DOES NOT NEED SERIALIZE FUNCTION
212 
213 
214 template<class Archive> inline
215 void serialize(Archive& ar, mt::Element& el, const unsigned int version)
216 {
217  ar & el.getGeometryRef();
218  ar & el.getNameRef();
219 }
220 
221 
222 template<class Archive> inline
223 void serialize(Archive& ar, mt::Object& obj, const unsigned int version)
224 {
225  ar & obj.getOriginRef();
226  ar & obj.getNameRef();
227 }
228 
229 
230 } // serialization
231 } // boost
232 
233 #endif // PMF_COM_MT_SERIALIZE_H