Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:32

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2019 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/tools/output_test_stream.hpp>
0010 #include <boost/test/unit_test.hpp>
0011 
0012 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0013 #include "Acts/Utilities/Frustum.hpp"
0014 #include "Acts/Visualization/PlyVisualization3D.hpp"
0015 
0016 #include <algorithm>
0017 #include <array>
0018 #include <cmath>
0019 #include <utility>
0020 #include <vector>
0021 
0022 using boost::test_tools::output_test_stream;
0023 
0024 namespace Acts {
0025 namespace Test {
0026 
0027 BOOST_AUTO_TEST_SUITE(Utilities)
0028 BOOST_AUTO_TEST_CASE(frustum_construction) {
0029   output_test_stream output;
0030 
0031   using Vector2F = Eigen::Matrix<float, 2, 1>;
0032 
0033   using Frustum2f2 = Frustum<float, 2, 2>;
0034   Frustum2f2 fr({1, 0}, {0, 2}, M_PI / 2.);
0035 
0036   BOOST_CHECK_EQUAL(fr.origin(), Vector2F(1, 0));
0037   CHECK_CLOSE_ABS(fr.dir(), Vector2F(0, 1), 1e-6);
0038 
0039   const auto& normals = fr.normals();
0040   BOOST_CHECK_EQUAL(normals.size(), 3u);
0041 
0042   fr.svg(output, 200, 200);
0043   BOOST_CHECK(!output.is_empty(true));
0044 
0045   using Vector3F = Eigen::Matrix<float, 3, 1>;
0046 
0047   using Frustum3f3 = Frustum<float, 3, 3>;
0048   Frustum3f3 fr33({1, 0, 0}, {0, 2, 1}, M_PI / 2.);
0049 
0050   BOOST_CHECK_EQUAL(fr33.origin(), Vector3F(1, 0, 0));
0051   CHECK_CLOSE_ABS(fr33.dir(), Vector3F(0, 2, 1).normalized(), 1e-6);
0052 
0053   const auto& normals33 = fr33.normals();
0054   BOOST_CHECK_EQUAL(normals33.size(), 4u);
0055 
0056   PlyVisualization3D<float> hlp;
0057   // compile call to draw, does not actually test anything
0058   // fr33.draw(hlp);
0059 
0060   using Frustum3f4 = Frustum<float, 3, 4>;
0061   Frustum3f4 fr34({1, 0, 0}, {0, 2, 1}, M_PI / 2.);
0062 
0063   BOOST_CHECK_EQUAL(fr34.origin(), Vector3F(1, 0, 0));
0064   CHECK_CLOSE_ABS(fr34.dir(), Vector3F(0, 2, 1).normalized(), 1e-6);
0065 
0066   const auto& normals34 = fr34.normals();
0067   BOOST_CHECK_EQUAL(normals34.size(), 5u);
0068 
0069   // fr34.draw(hlp);
0070 }
0071 BOOST_AUTO_TEST_SUITE_END()
0072 
0073 }  // namespace Test
0074 }  // namespace Acts