File indexing completed on 2026-05-27 07:24:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "detray/core/detector.hpp"
0011
0012
0013 #include "detray/plugins/svgtools/illustrator.hpp"
0014 #include "detray/plugins/svgtools/writer.hpp"
0015
0016
0017 #include "detray/test/common/build_toy_detector.hpp"
0018 #include "detray/test/framework/types.hpp"
0019
0020
0021 #include <vecmem/memory/host_memory_resource.hpp>
0022
0023
0024 #include <actsvg/core.hpp>
0025
0026
0027 #include <gtest/gtest.h>
0028
0029
0030 #include <array>
0031 #include <string>
0032
0033 GTEST_TEST(svgtools, volumes) {
0034
0035
0036
0037
0038
0039
0040
0041 const auto axes = actsvg::draw::x_y_axes("axes", {-250, 250}, {-250, 250},
0042 actsvg::style::stroke());
0043
0044
0045 const actsvg::views::x_y xy;
0046 const actsvg::views::z_r zr;
0047
0048
0049 vecmem::host_memory_resource host_mr;
0050 const auto [det, names] =
0051 detray::build_toy_detector<detray::test::algebra>(host_mr);
0052
0053
0054 detray::svgtools::illustrator il{det, names};
0055
0056 il.hide_grids(true);
0057
0058
0059 std::array indices{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u,
0060 10u, 11u, 12u, 13u, 14u, 15u, 16u, 17u, 18u, 19u};
0061
0062 for (detray::dindex i : indices) {
0063
0064 const auto [vol_svg_xy, xy_grid] = il.draw_volume(i, xy);
0065 detray::svgtools::write_svg("test_svgtools_" + vol_svg_xy._id,
0066 {axes, vol_svg_xy});
0067
0068 const auto [vol_svg_zr, zr_grid] = il.draw_volume(i, zr);
0069 detray::svgtools::write_svg("test_svgtools_" + vol_svg_zr._id,
0070 {axes, vol_svg_zr});
0071 }
0072
0073
0074 std::array vol_names{"beampipe_0", "gap_14", "endcap_1", "connector_gap_2",
0075 "barrel_7"};
0076
0077 for (std::string_view name : vol_names) {
0078
0079 const auto [vol_svg_xy, xy_grid] = il.draw_volume(name, xy);
0080 detray::svgtools::write_svg(
0081 "test_svgtools_" + vol_svg_xy._id + "_fetched_by_name",
0082 {axes, vol_svg_xy});
0083
0084 const auto [vol_svg_zr, zr_grid] = il.draw_volume(name, zr);
0085 detray::svgtools::write_svg(
0086 "test_svgtools_" + vol_svg_zr._id + "_fetched_by_name",
0087 {axes, vol_svg_zr});
0088 }
0089 }