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);
106 BOOST_CHECK(
check(value, value));
109 std::ifstream ifs(txt_filename.c_str());
110 boost::archive::text_iarchive ia(ifs);
114 BOOST_CHECK(
check(value, other_value));
120 std::ofstream ofs(bin_filename.c_str(), std::ios::binary);
121 boost::archive::binary_oarchive oa(ofs);
124 BOOST_CHECK(
check(value, value));
127 std::ifstream ifs(bin_filename.c_str(), std::ios::binary);
128 boost::archive::binary_iarchive ia(ifs);
132 BOOST_CHECK(
check(value, other_value));
137 boost::asio::streambuf buffer;
139 BOOST_CHECK(
check(value, value));
142 BOOST_CHECK(
check(value, other_value));
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;
186 loadOBJFile((path /
"env.obj").
string().c_str(), p1, t1);
187 loadOBJFile((path /
"rob.obj").
string().c_str(), p2, 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;
219 loadOBJFile((path /
"env.obj").
string().c_str(), p1, 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;
314 loadOBJFile((path /
"env.obj").
string().c_str(), p1, t1);
325 BOOST_CHECK(static_cast<size_t>(m1.
memUsage(
false)) ==
shared_ptr< ConvexBase > convex
Convex<Triangle> representation of this object.
void test_serialization(const T &value, T &other_value, const int mode=TXT|XML|BIN|STREAM)
size_t computeMemoryFootprint(const T &object)
Returns the memory footpring of the input object. For POD objects, this function returns the result o...
request to the distance computation
Eigen::Matrix< FCL_REAL, Eigen::Dynamic, Eigen::Dynamic > MatrixXf
Ellipsoid centered at point zero.
bool check(const T &value, const T &other)
Cylinder along Z axis. The cylinder is defined at its centroid.
void loadOBJFile(const char *filename, std::vector< Vec3f > &points, std::vector< Triangle > &triangles)
Load an obj mesh file.
Vec3f nearest_points[2]
nearest points
int addSubModel(const std::vector< Vec3f > &ps, const std::vector< Triangle > &ts)
Add a set of triangles in the new BVH model.
Half Space: this is equivalent to the Plane in ODE. The separation plane is defined as n * x = d; Poi...
void addContact(const Contact &c)
add one contact into result structure
FCL_REAL distance_lower_bound
Data structure depicting a height field given by the base grid dimensions and the elevation along the...
bool buildConvexHull(bool keepTriangle, const char *qhullCommand=NULL)
Build a convex hull and store it in attribute convex.
void loadFromBinary(T &object, boost::asio::streambuf &buffer)
request to the collision algorithm
int beginModel(unsigned int num_tris=0, unsigned int num_vertices=0)
Begin a new BVH model.
Center at zero point, axis aligned box.
Vec3f normal
In case both objects are in collision, store the normal.
Triangle stores the points instead of only indices of points.
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
Cone The base of the cone is at and the top is at .
A class describing the AABB collision structure, which is a box in 3D space determined by two diagona...
Center at zero point sphere.
Capsule It is where is the distance between the point x and the capsule segment AB...
int memUsage(const bool msg) const
Check the number of memory used.
BOOST_AUTO_TEST_CASE(test_aabb)
int endModel()
End BVH model construction, will build the bounding volume hierarchy.
void saveToBinary(const T &object, boost::asio::streambuf &buffer)