37 #include <gtest/gtest.h>
39 #include "fcl/config.h"
49 using S =
typename BV::S;
57 std::vector<Vector3<S>> points(8);
58 points[0] << 0.5 * a, -0.5 * b, 0.5 * c;
59 points[1] << 0.5 * a, 0.5 * b, 0.5 * c;
60 points[2] << -0.5 * a, 0.5 * b, 0.5 * c;
61 points[3] << -0.5 * a, -0.5 * b, 0.5 * c;
62 points[4] << 0.5 * a, -0.5 * b, -0.5 * c;
63 points[5] << 0.5 * a, 0.5 * b, -0.5 * c;
64 points[6] << -0.5 * a, 0.5 * b, -0.5 * c;
65 points[7] << -0.5 * a, -0.5 * b, -0.5 * c;
69 result = model->beginModel();
72 for (std::size_t i = 0; i < points.size(); ++i)
74 result = model->addVertex(points[i]);
78 result = model->endModel();
81 model->computeLocalAABB();
91 using S =
typename BV::S;
99 std::vector<Vector3<S>> points(8);
100 std::vector<Triangle> tri_indices(12);
101 points[0] << 0.5 * a, -0.5 * b, 0.5 * c;
102 points[1] << 0.5 * a, 0.5 * b, 0.5 * c;
103 points[2] << -0.5 * a, 0.5 * b, 0.5 * c;
104 points[3] << -0.5 * a, -0.5 * b, 0.5 * c;
105 points[4] << 0.5 * a, -0.5 * b, -0.5 * c;
106 points[5] << 0.5 * a, 0.5 * b, -0.5 * c;
107 points[6] << -0.5 * a, 0.5 * b, -0.5 * c;
108 points[7] << -0.5 * a, -0.5 * b, -0.5 * c;
110 tri_indices[0].set(0, 4, 1);
111 tri_indices[1].set(1, 4, 5);
112 tri_indices[2].set(2, 6, 3);
113 tri_indices[3].set(3, 6, 7);
114 tri_indices[4].set(3, 0, 2);
115 tri_indices[5].set(2, 0, 1);
116 tri_indices[6].set(6, 5, 7);
117 tri_indices[7].set(7, 5, 4);
118 tri_indices[8].set(1, 5, 2);
119 tri_indices[9].set(2, 5, 6);
120 tri_indices[10].set(3, 7, 0);
121 tri_indices[11].set(0, 7, 4);
125 result = model->beginModel();
128 for (std::size_t i = 0; i < tri_indices.size(); ++i)
130 result = model->addTriangle(points[tri_indices[i][0]], points[tri_indices[i][1]], points[tri_indices[i][2]]);
134 result = model->endModel();
137 model->computeLocalAABB();
144 template<
typename BV>
147 using S =
typename BV::S;
152 auto a = box.
side[0];
153 auto b = box.
side[1];
154 auto c = box.
side[2];
155 std::vector<Vector3<S>> points(8);
156 std::vector<Triangle> tri_indices(12);
157 points[0] << 0.5 * a, -0.5 * b, 0.5 * c;
158 points[1] << 0.5 * a, 0.5 * b, 0.5 * c;
159 points[2] << -0.5 * a, 0.5 * b, 0.5 * c;
160 points[3] << -0.5 * a, -0.5 * b, 0.5 * c;
161 points[4] << 0.5 * a, -0.5 * b, -0.5 * c;
162 points[5] << 0.5 * a, 0.5 * b, -0.5 * c;
163 points[6] << -0.5 * a, 0.5 * b, -0.5 * c;
164 points[7] << -0.5 * a, -0.5 * b, -0.5 * c;
166 tri_indices[0].set(0, 4, 1);
167 tri_indices[1].set(1, 4, 5);
168 tri_indices[2].set(2, 6, 3);
169 tri_indices[3].set(3, 6, 7);
170 tri_indices[4].set(3, 0, 2);
171 tri_indices[5].set(2, 0, 1);
172 tri_indices[6].set(6, 5, 7);
173 tri_indices[7].set(7, 5, 4);
174 tri_indices[8].set(1, 5, 2);
175 tri_indices[9].set(2, 5, 6);
176 tri_indices[10].set(3, 7, 0);
177 tri_indices[11].set(0, 7, 4);
181 result = model->beginModel();
184 result = model->addSubModel(points, tri_indices);
187 result = model->endModel();
190 model->computeLocalAABB();
197 template<
typename BV>
200 testBVHModelTriangles<BV>();
201 testBVHModelPointCloud<BV>();
202 testBVHModelSubModel<BV>();
216 testBVHModel<AABB<double>>();
217 testBVHModel<OBB<double>>();
218 testBVHModel<RSS<double>>();
219 testBVHModel<kIOS<double>>();
220 testBVHModel<OBBRSS<double>>();
221 testBVHModel<KDOP<double, 16> >();
222 testBVHModel<KDOP<double, 18> >();
223 testBVHModel<KDOP<double, 24> >();
227 int main(
int argc,
char* argv[])
229 ::testing::InitGoogleTest(&argc, argv);
230 return RUN_ALL_TESTS();