File indexing completed on 2025-01-18 09:12:51
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/tools/output_test_stream.hpp>
0010 #include <boost/test/unit_test.hpp>
0011
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0014 #include "Acts/Surfaces/DiamondBounds.hpp"
0015 #include "Acts/Surfaces/RectangleBounds.hpp"
0016 #include "Acts/Surfaces/SurfaceBounds.hpp"
0017
0018 #include <iostream>
0019 #include <stdexcept>
0020 #include <vector>
0021
0022 namespace Acts::Test {
0023
0024 BOOST_AUTO_TEST_SUITE(Surfaces)
0025
0026 BOOST_AUTO_TEST_CASE(DiamondBoundsConstruction) {
0027
0028
0029
0030 const double minHalfX = 10.;
0031 const double midHalfX = 20.;
0032 const double maxHalfX = 15.;
0033 const double halfY1 = 5.;
0034 const double halfY2 = 7.;
0035
0036
0037 BOOST_CHECK_EQUAL(
0038 DiamondBounds(minHalfX, midHalfX, maxHalfX, halfY1, halfY2).type(),
0039 SurfaceBounds::eDiamond);
0040
0041
0042 DiamondBounds original(minHalfX, midHalfX, maxHalfX, halfY1, halfY2);
0043 DiamondBounds copied(original);
0044 BOOST_CHECK_EQUAL(copied.type(), SurfaceBounds::eDiamond);
0045
0046
0047 BOOST_CHECK_THROW(
0048 DiamondBounds db(midHalfX, minHalfX, maxHalfX, halfY1, halfY2),
0049 std::logic_error);
0050 BOOST_CHECK_THROW(
0051 DiamondBounds db(minHalfX, maxHalfX, midHalfX, halfY1, halfY2),
0052 std::logic_error);
0053 }
0054
0055
0056 BOOST_AUTO_TEST_CASE(DiamondBoundsProperties) {
0057 const double minHalfX = 10.;
0058 const double midHalfX = 50.;
0059 const double maxHalfX = 30.;
0060 const double halfY1 = 10.;
0061 const double halfY2 = 20.;
0062
0063
0064 DiamondBounds diamondBoundsObject(minHalfX, midHalfX, maxHalfX, halfY1,
0065 halfY2);
0066
0067
0068 BOOST_CHECK_EQUAL(diamondBoundsObject.type(), SurfaceBounds::eDiamond);
0069
0070
0071 BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthXnegY),
0072 minHalfX);
0073
0074
0075 BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthXzeroY),
0076 midHalfX);
0077
0078
0079 BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthXposY),
0080 maxHalfX);
0081
0082
0083 BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthYneg),
0084 halfY1);
0085
0086
0087 BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthYpos),
0088 halfY2);
0089
0090
0091 BOOST_CHECK_EQUAL(diamondBoundsObject.boundingBox(),
0092 RectangleBounds(Vector2{-50., -10.}, Vector2{50., 20.}));
0093
0094
0095 Vector2 origin(0., 0.);
0096 Vector2 outsideBy10(0., 30.);
0097 Vector2 inRectangle(15., 0.);
0098
0099
0100 diamondBoundsObject.toStream(std::cout);
0101 boost::test_tools::output_test_stream dumpOutput;
0102 diamondBoundsObject.toStream(dumpOutput);
0103 BOOST_CHECK(
0104 dumpOutput.is_equal("Acts::DiamondBounds: (halfXatYneg, halfXatYzero, "
0105 "halfXatYpos, halfYneg, halfYpos) = (10.0000000, "
0106 "50.0000000, 30.0000000, 10.0000000, 20.0000000)"));
0107
0108
0109 BOOST_CHECK(diamondBoundsObject.inside(origin, BoundaryTolerance::None()));
0110
0111 BOOST_CHECK(
0112 !diamondBoundsObject.inside(outsideBy10, BoundaryTolerance::None()));
0113
0114
0115
0116 std::vector<Vector2> referenceVertices{
0117 {-minHalfX, -halfY1}, {minHalfX, -halfY1}, {midHalfX, 0.},
0118 {maxHalfX, halfY2}, {-maxHalfX, halfY2}, {-midHalfX, 0.}};
0119 const auto& actualVertices = diamondBoundsObject.vertices();
0120 BOOST_CHECK_EQUAL_COLLECTIONS(actualVertices.cbegin(), actualVertices.cend(),
0121 referenceVertices.cbegin(),
0122 referenceVertices.cend());
0123 }
0124
0125
0126 BOOST_AUTO_TEST_CASE(DiamondBoundsAssignment) {
0127 const double minHalfX = 10.;
0128 const double midHalfX = 20.;
0129 const double maxHalfX = 15.;
0130 const double halfY1 = 5.;
0131 const double halfY2 = 7.;
0132
0133 DiamondBounds diamondBoundsObject(minHalfX, midHalfX, maxHalfX, halfY1,
0134 halfY2);
0135 DiamondBounds similarlyConstructeDiamondBoundsObject(
0136 minHalfX, midHalfX, maxHalfX, halfY1, halfY2);
0137
0138
0139 BOOST_CHECK_EQUAL(diamondBoundsObject,
0140 similarlyConstructeDiamondBoundsObject);
0141
0142
0143 DiamondBounds assignedDiamondBoundsObject(
0144 2 * minHalfX, 2 * midHalfX, 2 * maxHalfX, 2 * halfY1, 2 * halfY2);
0145
0146
0147 assignedDiamondBoundsObject = diamondBoundsObject;
0148 BOOST_CHECK_EQUAL(assignedDiamondBoundsObject, diamondBoundsObject);
0149 }
0150
0151 BOOST_AUTO_TEST_SUITE_END()
0152
0153 }