12 #define BOOST_TEST_MODULE SimpleGeoTest 18 #include <boost/test/unit_test.hpp> 31 std::array<Point_t::Data_t, 2U> buffer = {{ 1., 2. }};
37 BOOST_TEST(p1.x == 0.);
38 BOOST_TEST(p1.y == 0.);
44 BOOST_TEST(p2.x == 1.);
45 BOOST_TEST(p2.y == 2.);
51 BOOST_TEST(p3.x == 1.);
52 BOOST_TEST(p3.y == 2.);
64 BOOST_TEST(p1 + p2 == p2);
65 BOOST_TEST(p2 + p1 == p2);
66 BOOST_TEST(p1 * 2. == p1);
67 BOOST_TEST(p2 * 2.0 == p4);
68 BOOST_TEST(p2 / 0.5 == p4);
79 std::array<Point_t::Data_t, 3U> buffer = {{ 1., 2., 4. }};
85 BOOST_TEST(p1.x == 0.);
86 BOOST_TEST(p1.y == 0.);
87 BOOST_TEST(p1.z == 0.);
93 BOOST_TEST(p2.x == 1.);
94 BOOST_TEST(p2.y == 2.);
95 BOOST_TEST(p2.z == 4.);
101 BOOST_TEST(p3.x == 1.);
102 BOOST_TEST(p3.y == 2.);
103 BOOST_TEST(p2.z == 4.);
108 BOOST_TEST(p2 == p3);
109 BOOST_TEST(p1 != p2);
115 BOOST_TEST(p1 + p2 == p2);
116 BOOST_TEST(p2 + p1 == p2);
117 BOOST_TEST(p1 * 2. == p1);
118 BOOST_TEST(p2 * 2.0 == p4);
119 BOOST_TEST(p2 / 0.5 == p4);
138 Area_t A2({ 1., 6.}, { 4., 2. });
142 Area_t A3({ 1., 2.}, { 2., 2. });
149 BOOST_TEST(A1.DeltaX() == 0.0);
150 BOOST_TEST(A2.DeltaX() == 3.0);
152 BOOST_TEST(!A1.isNullX());
153 BOOST_TEST(!A2.isNullX());
154 BOOST_TEST(!A3.isNullX());
156 BOOST_TEST( A1.isEmptyX());
157 BOOST_TEST(!A2.isEmptyX());
158 BOOST_TEST(!A3.isEmptyX());
160 BOOST_TEST(A1.nonEmptyDims() == 0U);
161 BOOST_TEST(A2.nonEmptyDims() == 2U);
162 BOOST_TEST(A3.nonEmptyDims() == 1U);
164 BOOST_TEST(!A1.isNull());
165 BOOST_TEST(!A2.isNull());
166 BOOST_TEST(!A3.isNull());
168 BOOST_TEST( A1.isEmpty());
169 BOOST_TEST(!A2.isEmpty());
170 BOOST_TEST(!A3.isEmpty());
172 BOOST_TEST(!A1.isLine());
173 BOOST_TEST(!A2.isLine());
174 BOOST_TEST( A3.isLine());
176 BOOST_TEST(A1.thinnestSize() == 0.0);
177 BOOST_TEST(A2.thinnestSize() == 3.0);
178 BOOST_TEST(A3.thinnestSize() == 0.0);
180 BOOST_TEST(((A1.thinnestSide() == 0) || (A1.thinnestSide() == 1)));
181 BOOST_TEST(A2.thinnestSide() == 0U);
182 BOOST_TEST(A3.thinnestSide() == 1U);
184 BOOST_TEST(A1.DeltaY() == 0.0);
185 BOOST_TEST(A2.DeltaY() == 4.0);
186 BOOST_TEST(A3.DeltaY() == 0.0);
188 BOOST_TEST(!A1.isNullY());
189 BOOST_TEST(!A2.isNullY());
190 BOOST_TEST(!A3.isNullY());
192 BOOST_TEST( A1.isEmptyY());
193 BOOST_TEST(!A2.isEmptyY());
194 BOOST_TEST( A3.isEmptyY());
196 BOOST_TEST(!A1.isPlane());
197 BOOST_TEST( A2.isPlane());
198 BOOST_TEST(!A3.isPlane());
203 BOOST_TEST(A3 == Area_t({ 1.0, 2.0 }, { 2.0, 2.0 }));
204 BOOST_TEST(A3 != A2);
206 BOOST_TEST(A3 == Area_t({ 1.0, 2.0 }, { 2.0, 2.0 }));
208 A3.IncludePoint({ 1.5, 6.0 });
209 BOOST_TEST(A3 == Area_t({ 1.0, 2.0 }, { 2.0, 6.0 }));
210 A3.IncludePoint({ 4.0, 5.0 });
211 BOOST_TEST(A3 == Area_t({ 1.0, 2.0 }, { 4.0, 6.0 }));
212 BOOST_TEST(A3 == A2);
215 BOOST_TEST(A3 == Area_t({ 1.0, 2.0 }, { 4.0, 6.0 }));
217 A3.IncludePoint({ 0.0, 4.0 });
218 BOOST_TEST(A3 == Area_t({ 0.0, 2.0 }, { 4.0, 6.0 }));
220 A3.Include(Area_t({ 1.0, -1.0 }, { 2.0, 7.0 }));
221 BOOST_TEST(A3 == Area_t({ 0.0, -1.0 }, { 4.0, 7.0 }));
223 A3.Include(Area_t({ -1.0, 0.0 }, { 3.0, 1.0 }));
224 BOOST_TEST(A3 == Area_t({ -1.0, -1.0 }, { 4.0, 7.0 }));
228 A3.Intersect(Area_t({ 8.0, 9.0 }, { 8.0, 9.0 })),
229 Area_t::NullIntersection
231 BOOST_TEST(A3.isNull());
251 Volume_t A2({ 1., 6., 4.}, { 4., 2., 8. });
255 Volume_t A3({ 1., 2., 3.}, { 2., 2., 6. });
256 Volume_t A4({ 2., 3., 3.}, { 2., 2., 3. });
264 BOOST_TEST(A1.DeltaX() == 0.0);
265 BOOST_TEST(A2.DeltaX() == 3.0);
266 BOOST_TEST(A3.DeltaX() == 1.0);
267 BOOST_TEST(A4.DeltaX() == 0.0);
269 BOOST_TEST(!A1.isNullX());
270 BOOST_TEST(!A2.isNullX());
271 BOOST_TEST(!A3.isNullX());
272 BOOST_TEST(!A4.isNullX());
274 BOOST_TEST( A1.isEmptyX());
275 BOOST_TEST(!A2.isEmptyX());
276 BOOST_TEST(!A3.isEmptyX());
277 BOOST_TEST( A4.isEmptyX());
279 BOOST_TEST(A1.nonEmptyDims() == 0U);
280 BOOST_TEST(A2.nonEmptyDims() == 3U);
281 BOOST_TEST(A3.nonEmptyDims() == 2U);
282 BOOST_TEST(A4.nonEmptyDims() == 1U);
284 BOOST_TEST(!A1.isNull());
285 BOOST_TEST(!A2.isNull());
286 BOOST_TEST(!A3.isNull());
287 BOOST_TEST(!A4.isNull());
289 BOOST_TEST( A1.isEmpty());
290 BOOST_TEST(!A2.isEmpty());
291 BOOST_TEST(!A3.isEmpty());
292 BOOST_TEST(!A4.isEmpty());
294 BOOST_TEST(!A1.isLine());
295 BOOST_TEST(!A2.isLine());
296 BOOST_TEST(!A3.isLine());
297 BOOST_TEST( A4.isLine());
299 BOOST_TEST(A1.thinnestSize() == 0.0);
300 BOOST_TEST(A2.thinnestSize() == 3.0);
301 BOOST_TEST(A3.thinnestSize() == 0.0);
302 BOOST_TEST(A4.thinnestSize() == 0.0);
305 (A1.thinnestSide() == 0)
306 || (A1.thinnestSide() == 1)
307 || (A1.thinnestSide() == 2)
309 BOOST_TEST(A2.thinnestSide() == 0U);
310 BOOST_TEST(A3.thinnestSide() == 1U);
311 BOOST_TEST(((A4.thinnestSide() == 0) || (A4.thinnestSide() == 2)));
313 BOOST_TEST(A1.DeltaY() == 0.0);
314 BOOST_TEST(A2.DeltaY() == 4.0);
315 BOOST_TEST(A3.DeltaY() == 0.0);
316 BOOST_TEST(A4.DeltaY() == 1.0);
318 BOOST_TEST(!A1.isNullY());
319 BOOST_TEST(!A2.isNullY());
320 BOOST_TEST(!A3.isNullY());
321 BOOST_TEST(!A4.isNullY());
323 BOOST_TEST( A1.isEmptyY());
324 BOOST_TEST(!A2.isEmptyY());
325 BOOST_TEST( A3.isEmptyY());
326 BOOST_TEST(!A4.isEmptyY());
328 BOOST_TEST(!A1.isPlane());
329 BOOST_TEST(!A2.isPlane());
330 BOOST_TEST( A3.isPlane());
331 BOOST_TEST(!A4.isPlane());
333 BOOST_TEST(A1.DeltaZ() == 0.0);
334 BOOST_TEST(A2.DeltaZ() == 4.0);
335 BOOST_TEST(A3.DeltaZ() == 3.0);
336 BOOST_TEST(A4.DeltaZ() == 0.0);
338 BOOST_TEST(!A1.isNullZ());
339 BOOST_TEST(!A2.isNullZ());
340 BOOST_TEST(!A3.isNullZ());
341 BOOST_TEST(!A4.isNullZ());
343 BOOST_TEST( A1.isEmptyZ());
344 BOOST_TEST(!A2.isEmptyZ());
345 BOOST_TEST(!A3.isEmptyZ());
346 BOOST_TEST( A4.isEmptyZ());
348 BOOST_TEST(!A1.isVolume());
349 BOOST_TEST( A2.isVolume());
350 BOOST_TEST(!A3.isVolume());
351 BOOST_TEST(!A4.isVolume());
356 BOOST_TEST(A3 == Volume_t({ 1.0, 2.0, 3.0 }, { 2.0, 2.0, 6.0 }));
357 BOOST_TEST(A2 == Volume_t({ 1.0, 2.0, 4.0 }, { 4.0, 6.0, 8.0 }));
358 BOOST_TEST(A3 != A2);
360 BOOST_TEST(A3 == Volume_t({ 1.0, 2.0, 4.0 }, { 2.0, 2.0, 6.0 }));
362 A3.IncludePoint({ 1.5, 6.0, 4.0 });
363 BOOST_TEST(A3 == Volume_t({ 1.0, 2.0, 4.0 }, { 2.0, 6.0, 6.0 }));
364 A3.IncludePoint({ 4.0, 5.0, 8.0 });
365 BOOST_TEST(A3 == Volume_t({ 1.0, 2.0, 4.0 }, { 4.0, 6.0, 8.0 }));
366 BOOST_TEST(A3 == A2);
369 BOOST_TEST(A3 == Volume_t({ 1.0, 2.0, 4.0 }, { 4.0, 6.0, 8.0 }));
371 A3.IncludePoint({ 0.0, 4.0, 4.0 });
372 BOOST_TEST(A3 == Volume_t({ 0.0, 2.0, 4.0 }, { 4.0, 6.0, 8.0 }));
374 A3.Include(Volume_t({ 1.0, -1.0, 3.0 }, { 2.0, 7.0, 7.0 }));
375 BOOST_TEST(A3 == Volume_t({ 0.0, -1.0, 3.0 }, { 4.0, 7.0, 8.0 }));
377 A3.Include(Volume_t({ -1.0, 0.0, 2.0 }, { 3.0, 1.0, 6.0 }));
378 BOOST_TEST(A3 == Volume_t({ -1.0, -1.0, 2.0 }, { 4.0, 7.0, 8.0 }));
382 A3.Intersect(Volume_t({ 8.0, 9.0, 2.0 }, { 8.0, 9.0, 3.0 })),
383 Volume_t::NullIntersection
385 BOOST_TEST(A3.isNull());
392 BOOST_AUTO_TEST_SUITE(SimpleGeo_test)
406 BOOST_AUTO_TEST_SUITE_END()
2D point (x, y) (by default, with double precision)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >> Point_t
Volume delimited by two points.
3D point (x, y, z) (by default, with double precision)
Area delimited by two points.
Some simple functions to represent geometry entities.
BOOST_AUTO_TEST_CASE(PointTestCase)