File indexing completed on 2025-01-18 09:12:37
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Direction.hpp"
0013 #include "Acts/Geometry/CutoutCylinderVolumeBounds.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Surfaces/Surface.hpp"
0016 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0017 #include "Acts/Utilities/BinningType.hpp"
0018 #include "Acts/Utilities/BoundingBox.hpp"
0019
0020 #include <algorithm>
0021 #include <array>
0022 #include <iostream>
0023 #include <memory>
0024 #include <stdexcept>
0025 #include <utility>
0026 #include <vector>
0027
0028 namespace Acts::Test {
0029
0030 BOOST_AUTO_TEST_SUITE(Geometry)
0031
0032 BOOST_AUTO_TEST_CASE(CutoutCylinderVolumeBoundsConstruction) {
0033 CutoutCylinderVolumeBounds ccvb(5, 10, 15, 30, 25);
0034 ccvb.toStream(std::cout);
0035
0036
0037 CutoutCylinderVolumeBounds copied(ccvb);
0038 BOOST_CHECK_EQUAL(ccvb, copied);
0039
0040
0041 CutoutCylinderVolumeBounds assigned = ccvb;
0042 BOOST_CHECK_EQUAL(ccvb, assigned);
0043 }
0044
0045 BOOST_AUTO_TEST_CASE(CutoutCylinderVolumeBoundsRecreation) {
0046 CutoutCylinderVolumeBounds original(5, 10, 15, 30, 25);
0047 std::array<double, CutoutCylinderVolumeBounds::eSize> values{};
0048 std::vector<double> valvector = original.values();
0049 std::copy_n(valvector.begin(), CutoutCylinderVolumeBounds::eSize,
0050 values.begin());
0051 CutoutCylinderVolumeBounds recreated(values);
0052 BOOST_CHECK_EQUAL(original, recreated);
0053 }
0054
0055 BOOST_AUTO_TEST_CASE(CutoutCylinderVolumeBoundsExceptions) {
0056 double rmin{5}, rmed{10}, rmax{15}, hz{30}, hzc{25};
0057
0058
0059 BOOST_CHECK_THROW(CutoutCylinderVolumeBounds(-rmin, rmed, rmax, hz, hzc),
0060 std::logic_error);
0061
0062
0063 BOOST_CHECK_THROW(CutoutCylinderVolumeBounds(rmin, -rmed, rmax, hz, hzc),
0064 std::logic_error);
0065
0066
0067 BOOST_CHECK_THROW(CutoutCylinderVolumeBounds(rmin, rmed, -rmax, hz, hzc),
0068 std::logic_error);
0069
0070
0071 BOOST_CHECK_THROW(CutoutCylinderVolumeBounds(rmed, rmin, rmax, hz, hzc),
0072 std::logic_error);
0073
0074
0075 BOOST_CHECK_THROW(CutoutCylinderVolumeBounds(rmax, rmed, rmin, hz, hzc),
0076 std::logic_error);
0077
0078
0079 BOOST_CHECK_THROW(CutoutCylinderVolumeBounds(rmin, rmax, rmed, hz, hzc),
0080 std::logic_error);
0081
0082
0083 BOOST_CHECK_THROW(CutoutCylinderVolumeBounds(rmin, rmed, rmax, -hz, hzc),
0084 std::logic_error);
0085
0086
0087 BOOST_CHECK_THROW(CutoutCylinderVolumeBounds(rmin, rmed, rmax, hz, -hzc),
0088 std::logic_error);
0089 }
0090
0091 BOOST_AUTO_TEST_CASE(CutoutCylinderVolumeBoundsAccess) {
0092 double rmin{5}, rmed{10}, rmax{15}, hz{30}, hzc{25};
0093 CutoutCylinderVolumeBounds ccvb(rmin, rmed, rmax, hz, hzc);
0094
0095 BOOST_CHECK_EQUAL(ccvb.get(CutoutCylinderVolumeBounds::eMinR), rmin);
0096 BOOST_CHECK_EQUAL(ccvb.get(CutoutCylinderVolumeBounds::eMedR), rmed);
0097 BOOST_CHECK_EQUAL(ccvb.get(CutoutCylinderVolumeBounds::eMaxR), rmax);
0098 BOOST_CHECK_EQUAL(ccvb.get(CutoutCylinderVolumeBounds::eHalfLengthZ), hz);
0099 BOOST_CHECK_EQUAL(ccvb.get(CutoutCylinderVolumeBounds::eHalfLengthZcutout),
0100 hzc);
0101 }
0102
0103 BOOST_AUTO_TEST_CASE(CutoutCylinderVolumeBoundsInside) {
0104 CutoutCylinderVolumeBounds ccvb(5, 10, 15, 30, 25);
0105
0106 BOOST_CHECK(!ccvb.inside({0, 0, 0}));
0107 BOOST_CHECK(!ccvb.inside({0, 3, 0}));
0108 BOOST_CHECK(!ccvb.inside({3, 0, 0}));
0109 BOOST_CHECK(!ccvb.inside({0, 7, 0}));
0110 BOOST_CHECK(!ccvb.inside({7, 0, 0}));
0111 BOOST_CHECK(ccvb.inside({0, 13, 0}));
0112 BOOST_CHECK(ccvb.inside({13, 0, 0}));
0113 BOOST_CHECK(!ccvb.inside({0, 17, 0}));
0114 BOOST_CHECK(!ccvb.inside({17, 0, 0}));
0115
0116
0117 BOOST_CHECK(!ccvb.inside({0, 0, 35}));
0118 BOOST_CHECK(!ccvb.inside({0, 0, -35}));
0119 BOOST_CHECK(!ccvb.inside({0, 3, 35}));
0120 BOOST_CHECK(!ccvb.inside({0, 3, -35}));
0121 BOOST_CHECK(!ccvb.inside({3, 0, 35}));
0122 BOOST_CHECK(!ccvb.inside({3, 0, -35}));
0123 BOOST_CHECK(!ccvb.inside({0, 10, 35}));
0124 BOOST_CHECK(!ccvb.inside({0, 10, -35}));
0125 BOOST_CHECK(!ccvb.inside({10, 0, 35}));
0126 BOOST_CHECK(!ccvb.inside({10, 0, -35}));
0127 BOOST_CHECK(!ccvb.inside({0, 20, 35}));
0128 BOOST_CHECK(!ccvb.inside({0, 20, -35}));
0129 BOOST_CHECK(!ccvb.inside({20, 0, 35}));
0130 BOOST_CHECK(!ccvb.inside({20, 0, -35}));
0131
0132
0133 BOOST_CHECK(!ccvb.inside({0, 0, 27}));
0134 BOOST_CHECK(!ccvb.inside({0, 0, -27}));
0135 BOOST_CHECK(!ccvb.inside({0, 3, 27}));
0136 BOOST_CHECK(!ccvb.inside({0, 3, -27}));
0137 BOOST_CHECK(!ccvb.inside({3, 0, 27}));
0138 BOOST_CHECK(!ccvb.inside({3, 0, -27}));
0139 BOOST_CHECK(ccvb.inside({0, 7, 27}));
0140 BOOST_CHECK(ccvb.inside({0, 7, -27}));
0141 BOOST_CHECK(ccvb.inside({7, 0, 27}));
0142 BOOST_CHECK(ccvb.inside({7, 0, -27}));
0143 BOOST_CHECK(ccvb.inside({0, 13, 27}));
0144 BOOST_CHECK(ccvb.inside({0, 13, -27}));
0145 BOOST_CHECK(ccvb.inside({13, 0, 27}));
0146 BOOST_CHECK(ccvb.inside({13, 0, -27}));
0147 BOOST_CHECK(!ccvb.inside({0, 17, 27}));
0148 BOOST_CHECK(!ccvb.inside({0, 17, -27}));
0149 BOOST_CHECK(!ccvb.inside({17, 0, 27}));
0150 BOOST_CHECK(!ccvb.inside({17, 0, -27}));
0151
0152
0153 BOOST_CHECK(!ccvb.inside({0, 0, 23}));
0154 BOOST_CHECK(!ccvb.inside({0, 0, -23}));
0155 BOOST_CHECK(!ccvb.inside({0, 3, 23}));
0156 BOOST_CHECK(!ccvb.inside({0, 3, -23}));
0157 BOOST_CHECK(!ccvb.inside({3, 0, 23}));
0158 BOOST_CHECK(!ccvb.inside({3, 0, -23}));
0159 BOOST_CHECK(!ccvb.inside({0, 7, 23}));
0160 BOOST_CHECK(!ccvb.inside({0, 7, -23}));
0161 BOOST_CHECK(!ccvb.inside({7, 0, 23}));
0162 BOOST_CHECK(!ccvb.inside({7, 0, -23}));
0163 BOOST_CHECK(ccvb.inside({0, 13, 23}));
0164 BOOST_CHECK(ccvb.inside({0, 13, -23}));
0165 BOOST_CHECK(ccvb.inside({13, 0, 23}));
0166 BOOST_CHECK(ccvb.inside({13, 0, -23}));
0167 BOOST_CHECK(!ccvb.inside({0, 17, 23}));
0168 BOOST_CHECK(!ccvb.inside({0, 17, -23}));
0169 BOOST_CHECK(!ccvb.inside({17, 0, 23}));
0170 BOOST_CHECK(!ccvb.inside({17, 0, -23}));
0171 }
0172
0173 BOOST_AUTO_TEST_CASE(CutoutCylinderVolumeBoundsBoundingBox) {
0174 GeometryContext tgContext = GeometryContext();
0175 CutoutCylinderVolumeBounds ccvb(5, 10, 15, 30, 25);
0176 auto box = ccvb.boundingBox();
0177 CHECK_CLOSE_ABS(box.min(), Vector3(-15, -15, -30), 1e-6);
0178 CHECK_CLOSE_ABS(box.max(), Vector3(15, 15, 30), 1e-6);
0179
0180 auto ccvbSurfaces = ccvb.orientedSurfaces(Transform3::Identity());
0181 }
0182
0183 BOOST_AUTO_TEST_CASE(CutoutCylinderVolumeOrientedBoundaries) {
0184 GeometryContext tgContext = GeometryContext();
0185
0186 CutoutCylinderVolumeBounds ccvb(5, 10, 15, 30, 25);
0187
0188 auto ccvbOrientedSurfaces = ccvb.orientedSurfaces(Transform3::Identity());
0189 BOOST_CHECK_EQUAL(ccvbOrientedSurfaces.size(), 8);
0190
0191 auto geoCtx = GeometryContext();
0192 Vector3 xaxis(1., 0., 0.);
0193 Vector3 yaxis(0., 1., 0.);
0194 Vector3 zaxis(0., 0., 1.);
0195
0196 for (auto& os : ccvbOrientedSurfaces) {
0197 auto onSurface =
0198 os.surface->referencePosition(geoCtx, AxisDirection::AxisR);
0199 auto locPos =
0200 os.surface->globalToLocal(geoCtx, onSurface, Vector3::Zero()).value();
0201 auto osNormal = os.surface->normal(geoCtx, locPos);
0202
0203 Vector3 insideCcvb = onSurface + os.direction * osNormal;
0204 Vector3 outsideCCvb = onSurface - os.direction * osNormal;
0205
0206 BOOST_CHECK(ccvb.inside(insideCcvb));
0207 BOOST_CHECK(!ccvb.inside(outsideCCvb));
0208
0209
0210 auto rot = os.surface->transform(geoCtx).rotation();
0211 BOOST_CHECK(rot.col(0).isApprox(xaxis));
0212 BOOST_CHECK(rot.col(1).isApprox(yaxis));
0213 BOOST_CHECK(rot.col(2).isApprox(zaxis));
0214 }
0215 }
0216
0217 BOOST_AUTO_TEST_SUITE_END()
0218
0219 }