Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-01 07:55:23

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Geometry/GeometryContext.hpp"
0012 #include "Acts/Geometry/GeometryHierarchyMap.hpp"
0013 #include "Acts/Geometry/TrackingGeometry.hpp"
0014 #include "ActsPlugins/ActSVG/LayerSvgConverter.hpp"
0015 #include "ActsPlugins/ActSVG/SvgUtils.hpp"
0016 #include "ActsPlugins/ActSVG/TrackingGeometrySvgConverter.hpp"
0017 #include "ActsTests/CommonHelpers/CylindricalTrackingGeometry.hpp"
0018 #include "ActsTests/CommonHelpers/TemporaryDirectory.hpp"
0019 
0020 #include <format>
0021 #include <fstream>
0022 #include <memory>
0023 #include <vector>
0024 
0025 using namespace Acts;
0026 using namespace ActsPlugins;
0027 
0028 namespace ActsTests {
0029 
0030 GeometryContext tgContext;
0031 
0032 BOOST_AUTO_TEST_SUITE(ActSvgSuite)
0033 
0034 BOOST_AUTO_TEST_CASE(CylindricalTrackingGeometrySvg) {
0035   Svg::Style cylinderLayerStyle;
0036   cylinderLayerStyle.fillColor = {51, 153, 255};
0037   cylinderLayerStyle.fillOpacity = 0.75;
0038   cylinderLayerStyle.highlightColor = {255, 153, 51};
0039   cylinderLayerStyle.highlights = {"mouseover", "mouseout"};
0040   cylinderLayerStyle.strokeColor = {25, 25, 25};
0041   cylinderLayerStyle.strokeWidth = 0.5;
0042   cylinderLayerStyle.quarterSegments = 72u;
0043 
0044   GeometryIdentifier geoID{0};
0045 
0046   CylindricalTrackingGeometry cGeometry(tgContext);
0047   auto tGeometry = cGeometry();
0048 
0049   Svg::LayerConverter::Options lOptions;
0050   lOptions.name = "cylinder_layer_";
0051   lOptions.surfaceStyles =
0052       GeometryHierarchyMap<Svg::Style>({{geoID, cylinderLayerStyle}});
0053 
0054   Svg::TrackingGeometryConverter::Options tgOptions;
0055   tgOptions.prefix = "utest_geometry_";
0056   tgOptions.layerOptions =
0057       GeometryHierarchyMap<Svg::LayerConverter::Options>({{geoID, lOptions}});
0058 
0059   auto geometrySheets =
0060       Svg::TrackingGeometryConverter::convert(tgContext, *tGeometry, tgOptions);
0061 
0062   for (const auto& s : geometrySheets) {
0063     Svg::toFile({s}, s._id + ".svg");
0064   }
0065 }
0066 
0067 BOOST_AUTO_TEST_CASE(CylindricalTrackingGeometrySvgGen3) {
0068   CylindricalTrackingGeometry cGeometry(tgContext, true);
0069   TemporaryDirectory tmp{};
0070 
0071   auto tGeometry = cGeometry();
0072 
0073   auto objects =
0074       Svg::drawTrackingGeometry(tgContext, *tGeometry, actsvg::views::x_y{});
0075 
0076   Svg::toFile(objects, tmp.path() / "utest_geometry_gen3_xy.svg");
0077 
0078   objects = Svg::drawTrackingGeometry(tgContext, *tGeometry,
0079                                       actsvg::views::z_r{}, true, true);
0080   Svg::toFile(objects, tmp.path() / "utest_geometry_gen3_zr.svg");
0081 
0082   objects = Svg::drawSurfaceArrays(tgContext, *tGeometry);
0083 
0084   for (const auto& obj : objects) {
0085     Svg::toFile(
0086         {obj},
0087         tmp.path() /
0088             std::format("utest_geometry_gen3_surface_arrays_{}.svg", obj._id));
0089   }
0090 }
0091 
0092 BOOST_AUTO_TEST_SUITE_END()
0093 
0094 }  // namespace ActsTests