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, material) {
0034
0035
0036
0037 const auto axes = actsvg::draw::x_y_axes("axes", {-250, 250}, {-250, 250},
0038 actsvg::style::stroke());
0039
0040
0041 const actsvg::views::x_y xy;
0042 const actsvg::views::z_r zr;
0043 const actsvg::views::z_phi zphi;
0044
0045
0046 vecmem::host_memory_resource host_mr;
0047 detray::toy_det_config<detray::test::scalar> toy_cfg{};
0048 toy_cfg.use_material_maps(true).cyl_map_bins(20, 20).disc_map_bins(5, 20);
0049 const auto [det, names] =
0050 detray::build_toy_detector<detray::test::algebra>(host_mr, toy_cfg);
0051
0052
0053 detray::svgtools::illustrator il{det, names};
0054 il.hide_material(false);
0055
0056
0057 std::array indices{0u, 346u, 347u, 578u, 579u, 2992u, 2993u};
0058
0059 auto& portal_mat_style = il.style()
0060 ._detector_style._volume_style._portal_style
0061 ._surface_style._material_style;
0062
0063 portal_mat_style._gradient_color_scale =
0064 detray::svgtools::styling::colors::gradient::viridis_scale;
0065 for (detray::dindex i : indices) {
0066 std::string name = "test_svgtools_material_" + std::to_string(i);
0067
0068 const auto svg_xy = il.draw_surface_material(i, xy);
0069 detray::svgtools::write_svg(name + "_xy", {axes, svg_xy});
0070 const auto svg_zphi = il.draw_surface_material(i, zphi);
0071 detray::svgtools::write_svg(name + "_zphi", {axes, svg_zphi});
0072 }
0073
0074
0075 portal_mat_style._gradient_color_scale =
0076 detray::svgtools::styling::colors::gradient::plasma_scale;
0077
0078 std::vector indices2{578u, 579u, 1034u, 1035u, 1770u, 1771u, 2870u, 2871u};
0079 std::string name = "test_svgtools_cyl_materials";
0080
0081 const auto svg_xy = il.draw_surface_materials(indices2, xy);
0082 detray::svgtools::write_svg(name + "_xy", {axes, svg_xy});
0083 }