Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:25

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 // Project include(s)
0010 #include "detray/plugins/svgtools/utils/groups.hpp"
0011 
0012 #include "detray/core/detector.hpp"
0013 
0014 // Detray plugin include(s)
0015 #include "detray/plugins/svgtools/illustrator.hpp"
0016 #include "detray/plugins/svgtools/writer.hpp"
0017 
0018 // Detray test include(s)
0019 #include "detray/test/common/build_toy_detector.hpp"
0020 #include "detray/test/framework/types.hpp"
0021 
0022 // Vecmem include(s)
0023 #include <vecmem/memory/host_memory_resource.hpp>
0024 
0025 // Actsvg include(s)
0026 #include <actsvg/core.hpp>
0027 
0028 // GTest include(s).
0029 #include <gtest/gtest.h>
0030 
0031 // System include(s)
0032 #include <array>
0033 #include <string>
0034 
0035 GTEST_TEST(svgtools, groups) {
0036   // Axes.
0037   const auto axes = actsvg::draw::x_y_axes("axes", {-250, 250}, {-250, 250},
0038                                            actsvg::style::stroke());
0039 
0040   // Creating the views.
0041   const actsvg::views::x_y xy;
0042   const actsvg::views::z_r zr;
0043 
0044   // Creating the detector and geomentry context.
0045   vecmem::host_memory_resource host_mr;
0046   const auto [det, names] =
0047       detray::build_toy_detector<detray::test::algebra>(host_mr);
0048 
0049   // Creating the svg generator for the detector.
0050   const detray::svgtools::illustrator il{det, names};
0051 
0052   // Visualisation of a group of surfaces.
0053   const std::array surface_group_indices{1u, 100u, 10u, 200u};
0054 
0055   const auto [svg_surface_group_xy, mat_group_xy] =
0056       il.draw_surfaces(surface_group_indices, xy);
0057   detray::svgtools::write_svg("test_svgtools_surface_group_xy",
0058                               {axes, svg_surface_group_xy});
0059 
0060   const auto [svg_surface_group_zr, mat_group_zr] =
0061       il.draw_surfaces(surface_group_indices, zr);
0062   detray::svgtools::write_svg("test_svgtools_surface_group_zr.svg",
0063                               {axes, svg_surface_group_zr});
0064 
0065   // Visualisation of a group of volumes.
0066   const std::array volume_group_indices{3u, 5u};
0067 
0068   const auto [vol_group_xy, gr1] = il.draw_volumes(volume_group_indices, xy);
0069   detray::svgtools::write_svg("test_svgtools_volume_group_xy",
0070                               {axes, vol_group_xy});
0071 
0072   const auto [vol_group_zr, gr2] = il.draw_volumes(volume_group_indices, zr);
0073   detray::svgtools::write_svg("test_svgtools_volume_group_zr",
0074                               {axes, vol_group_zr});
0075 
0076   // We can also use the svgtools::utils to group actsvg::svg::objects into
0077   // one.
0078   auto svg_combined_group = detray::svgtools::utils::group("combined_group");
0079   svg_combined_group.add_object(svg_surface_group_xy);
0080   svg_combined_group.add_object(vol_group_xy);
0081 
0082   detray::svgtools::write_svg("test_svgtools_combined_group1.svg",
0083                               {axes, svg_combined_group});
0084 
0085   // Alternatively, this is equivalent to:
0086   detray::svgtools::write_svg("test_svgtools_combined_group2.svg",
0087                               {axes, svg_surface_group_xy, vol_group_zr});
0088 
0089   // NOTE: The all svg object's identification must be unique in the
0090   // file!
0091 }