38 #include <gtest/gtest.h> 43 #include "fcl_resources/config.h" 52 bool refit_bottomup,
bool verbose);
54 template<
typename BV,
typename TraversalNode>
70 std::vector<Vector3<S>> p1, p2;
71 std::vector<Triangle> t1, t2;
78 S
extents[] = {-3000, -3000, 0, 3000, 3000, 3000};
79 S delta_trans[] = {1, 1, 1};
87 test::generateRandomTransforms<S>(
extents, delta_trans, 0.005 * 2 * 3.1415, transforms, transforms2, n);
91 for(std::size_t i = 0; i < transforms.size(); ++i)
98 EXPECT_TRUE(res == res2);
101 EXPECT_TRUE(res == res2);
104 for(std::size_t i = 0; i < transforms.size(); ++i)
111 EXPECT_TRUE(res == res2);
114 EXPECT_TRUE(res == res2);
117 for(std::size_t i = 0; i < transforms.size(); ++i)
128 EXPECT_TRUE(res == res2);
131 for(std::size_t i = 0; i < transforms.size(); ++i)
138 EXPECT_TRUE(res == res2);
141 EXPECT_TRUE(res == res2);
144 for(std::size_t i = 0; i < transforms.size(); ++i)
151 EXPECT_TRUE(res == res2);
154 EXPECT_TRUE(res == res2);
157 for(std::size_t i = 0; i < transforms.size(); ++i)
164 EXPECT_TRUE(res == res2);
167 EXPECT_TRUE(res == res2);
170 for(std::size_t i = 0; i < transforms.size(); ++i)
177 EXPECT_TRUE(res == res2);
180 EXPECT_TRUE(res == res2);
183 for(std::size_t i = 0; i < transforms.size(); ++i)
190 EXPECT_TRUE(res == res2);
193 EXPECT_TRUE(res == res2);
201 test_front_list<double>();
204 template<
typename BV>
209 bool refit_bottomup,
bool verbose)
211 using S =
typename BV::S;
221 std::vector<Vector3<S>> vertices1_new(vertices1.size());
222 for(std::size_t i = 0; i < vertices1_new.size(); ++i)
224 vertices1_new[i] = tf1 * vertices1[i];
241 if(!detail::initialize<BV>(node, m1, pose1, m2, pose2,
243 std::cout <<
"initialize error" << std::endl;
249 if(verbose) std::cout <<
"front list size " << front_list.size() << std::endl;
253 for(std::size_t i = 0; i < vertices1.size(); ++i)
255 vertices1_new[i] = tf2 * vertices1[i];
266 local_result.
clear();
278 template<
typename BV,
typename TraversalNode>
284 using S =
typename BV::S;
309 std::cout <<
"initialize error" << std::endl;
311 node.enable_statistics =
verbose;
315 if(verbose) std::cout <<
"front list size " << front_list.size() << std::endl;
321 std::cout <<
"initialize error" << std::endl;
323 local_result.
clear();
333 template<
typename BV>
338 using S =
typename BV::S;
359 if(!detail::initialize<BV>(node, m1, pose1, m2, pose2,
361 std::cout <<
"initialize error" << std::endl;
375 int main(
int argc,
char* argv[])
377 ::testing::InitGoogleTest(&argc, argv);
378 return RUN_ALL_TESTS();
int beginModel(int num_tris=0, int num_vertices=0)
Begin a new BVH model.
size_t numContacts() const
number of contacts found
std::array< S, 6 > & extents()
bool enable_statistics
Whether stores statistics.
int replaceSubModel(const std::vector< Vector3< S >> &ps)
Replace a set of points in the old BVH model.
Eigen::Transform< S, 3, Eigen::Isometry > Transform3
int beginReplaceModel()
Replace the geometry information of current frame (i.e. should have the same mesh topology with the p...
SplitMethodType
Three types of split algorithms are provided in FCL as default.
bool collide_front_list_Test(const Transform3< typename BV::S > &tf1, const Transform3< typename BV::S > &tf2, const std::vector< Vector3< typename BV::S >> &vertices1, const std::vector< Triangle > &triangles1, const std::vector< Vector3< typename BV::S >> &vertices2, const std::vector< Triangle > &triangles2, detail::SplitMethodType split_method, bool refit_bottomup, bool verbose)
Eigen::Matrix< S, 3, 1 > Vector3
int addSubModel(const std::vector< Vector3< S >> &ps, const std::vector< Triangle > &ts)
Add a set of triangles in the new BVH model.
int main(int argc, char *argv[])
template FCL_EXPORT std::size_t collide(const CollisionObject< double > *o1, const CollisionObject< double > *o2, const CollisionRequest< double > &request, CollisionResult< double > &result)
Parameters for performing collision request.
template bool initialize(MeshCollisionTraversalNodeOBB< double > &node, const BVHModel< OBB< double >> &model1, const Transform3< double > &tf1, const BVHModel< OBB< double >> &model2, const Transform3< double > &tf2, const CollisionRequest< double > &request, CollisionResult< double > &result)
Traversal node for collision between two meshes.
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
GTEST_TEST(FCL_FRONT_LIST, front_list)
A class describing the split rule that splits each BV node.
int endModel()
End BVH model construction, will build the bounding volume hierarchy.
void loadOBJFile(const char *filename, std::vector< Vector3< S >> &points, std::vector< Triangle > &triangles)
Load an obj mesh file.
#define EXPECT_TRUE(args)
int endReplaceModel(bool refit=true, bool bottomup=true)
End BVH model replacement, will also refit or rebuild the bounding volume hierarchy.
std::shared_ptr< detail::BVSplitterBase< BV > > bv_splitter
Split rule to split one BV node into two children.
std::vector< _Tp, Eigen::aligned_allocator< _Tp > > aligned_vector
bool collide_front_list_Test_Oriented(const Transform3< typename BV::S > &tf1, const Transform3< typename BV::S > &tf2, const std::vector< Vector3< typename BV::S >> &vertices1, const std::vector< Triangle > &triangles1, const std::vector< Vector3< typename BV::S >> &vertices2, const std::vector< Triangle > &triangles2, detail::SplitMethodType split_method, bool verbose)
std::list< BVHFrontNode > BVHFrontList
BVH front list is a list of front nodes.
Traversal node for collision between two meshes if their underlying BVH node is oriented node (OBB...
bool collide_Test(const Transform3< typename BV::S > &tf, const std::vector< Vector3< typename BV::S >> &vertices1, const std::vector< Triangle > &triangles1, const std::vector< Vector3< typename BV::S >> &vertices2, const std::vector< Triangle > &triangles2, detail::SplitMethodType split_method, bool verbose)
void clear()
clear the results obtained