ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FrustumTest.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FrustumTest.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/tools/output_test_stream.hpp>
10 #include <boost/test/unit_test.hpp>
11 
15 
16 using boost::test_tools::output_test_stream;
17 
18 namespace Acts {
19 namespace Test {
20 
21 BOOST_AUTO_TEST_SUITE(Utilities)
22 BOOST_AUTO_TEST_CASE(frustum_construction) {
23  output_test_stream output;
24 
25  using Frustum2f2 = Frustum<float, 2, 2>;
26  Frustum2f2 fr({1, 0}, {0, 2}, M_PI / 2.);
27 
28  BOOST_CHECK_EQUAL(fr.origin(), Vector2F(1, 0));
29  CHECK_CLOSE_ABS(fr.dir(), Vector2F(0, 1), 1e-6);
30 
31  const auto& normals = fr.normals();
32  BOOST_CHECK_EQUAL(normals.size(), 3u);
33 
34  fr.svg(output, 200, 200);
35  BOOST_CHECK(!output.is_empty(true));
36 
37  using Frustum3f3 = Frustum<float, 3, 3>;
38  Frustum3f3 fr33({1, 0, 0}, {0, 2, 1}, M_PI / 2.);
39 
40  BOOST_CHECK_EQUAL(fr33.origin(), Vector3F(1, 0, 0));
41  CHECK_CLOSE_ABS(fr33.dir(), Vector3F(0, 2, 1).normalized(), 1e-6);
42 
43  const auto& normals33 = fr33.normals();
44  BOOST_CHECK_EQUAL(normals33.size(), 4u);
45 
47  // compile call to draw, does not actually test anything
48  fr33.draw(hlp);
49 
50  using Frustum3f4 = Frustum<float, 3, 4>;
51  Frustum3f4 fr34({1, 0, 0}, {0, 2, 1}, M_PI / 2.);
52 
53  BOOST_CHECK_EQUAL(fr34.origin(), Vector3F(1, 0, 0));
54  CHECK_CLOSE_ABS(fr34.dir(), Vector3F(0, 2, 1).normalized(), 1e-6);
55 
56  const auto& normals34 = fr34.normals();
57  BOOST_CHECK_EQUAL(normals34.size(), 5u);
58 
59  fr34.draw(hlp);
60 }
61 BOOST_AUTO_TEST_SUITE_END()
62 
63 } // namespace Test
64 } // namespace Acts