35 #define BOOST_TEST_MODULE FCL_SERIALIZATION
37 #include <boost/test/included/unit_test.hpp>
53 #include "fcl_resources/config.h"
55 #include <boost/archive/tmpdir.hpp>
56 #include <boost/archive/text_iarchive.hpp>
57 #include <boost/archive/text_oarchive.hpp>
58 #include <boost/archive/xml_iarchive.hpp>
59 #include <boost/archive/xml_oarchive.hpp>
60 #include <boost/archive/binary_iarchive.hpp>
61 #include <boost/archive/binary_oarchive.hpp>
62 #include <boost/filesystem.hpp>
64 #include <boost/asio/streambuf.hpp>
66 namespace utf = boost::unit_test::framework;
71 void saveToBinary(
const T&
object, boost::asio::streambuf& buffer) {
72 boost::archive::binary_oarchive oa(buffer);
78 boost::archive::binary_iarchive ia(buffer);
83 bool check(
const T& value,
const T& other) {
84 return value == other;
101 std::ofstream ofs(txt_filename.c_str());
103 boost::archive::text_oarchive oa(ofs);
109 std::ifstream ifs(txt_filename.c_str());
110 boost::archive::text_iarchive ia(ifs);
120 std::ofstream ofs(bin_filename.c_str(), std::ios::binary);
121 boost::archive::binary_oarchive oa(ofs);
127 std::ifstream ifs(bin_filename.c_str(), std::ios::binary);
128 boost::archive::binary_iarchive ia(ifs);
137 boost::asio::streambuf buffer;
146 template <
typename T>
154 AABB aabb(-Vec3f::Ones(), Vec3f::Ones());
159 Contact contact(NULL, NULL, 1, 2, Vec3f::Ones(), Vec3f::Zero(), -10.);
175 distance_result.
normal.setOnes();
182 std::vector<Vec3f>
p1, p2;
183 std::vector<Triangle> t1, t2;
194 BOOST_CHECK(m1 == m1);
199 BOOST_CHECK(m2 == m2);
200 BOOST_CHECK(m1 != m2);
213 #ifdef HPP_FCL_HAS_QHULL
215 std::vector<Vec3f>
p1;
216 std::vector<Triangle> t1;
241 const FCL_REAL x_dim = 1., y_dim = 2.;
242 const Eigen::DenseIndex nx = 100, ny = 200;
243 const MatrixXf heights = MatrixXf::Random(ny, nx);
261 TriangleP triangle_copy(Vec3f::Random(), Vec3f::Random(), Vec3f::Random());
276 Ellipsoid ellipsoid(1., 2., 3.), ellipsoid_copy(0., 0., 0.);
281 Capsule capsule(1., 2.), capsule_copy(10., 10.);
286 Cone cone(1., 2.), cone_copy(10., 10.);
291 Cylinder cylinder(1., 2.), cylinder_copy(10., 10.);
296 Halfspace hs(Vec3f::Random(), 1.), hs_copy(Vec3f::Zero(), 0.);
301 Plane plane(Vec3f::Random(), 1.), plane_copy(Vec3f::Zero(), 0.);
310 std::vector<Vec3f>
p1;
311 std::vector<Triangle> t1;
325 BOOST_CHECK(
static_cast<size_t>(m1.
memUsage(
false)) ==