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/core/detector.hpp"
0011 
0012 // Detray plugin include(s)
0013 #include "detray/plugins/svgtools/illustrator.hpp"
0014 #include "detray/plugins/svgtools/writer.hpp"
0015 
0016 // Detray test include(s)
0017 #include "detray/test/common/build_toy_detector.hpp"
0018 #include "detray/test/framework/types.hpp"
0019 
0020 // Vecmem include(s)
0021 #include <vecmem/memory/host_memory_resource.hpp>
0022 
0023 // GTest include(s).
0024 #include <gtest/gtest.h>
0025 
0026 GTEST_TEST(svgtools, grids) {
0027   // This test creates the visualization using the illustrator class.
0028   // However, for full control over the process, it is also possible to use
0029   // the tools in svgstools::conversion, svgstools::display, and
0030   // actsvg::display by converting the object to a proto object, optionally
0031   // styling it, and then displaying it.
0032 
0033   // Creating the detector and geomentry context.
0034   vecmem::host_memory_resource host_mr;
0035   const auto [det, names] =
0036       detray::build_toy_detector<detray::test::algebra>(host_mr);
0037 
0038   // Creating the view.
0039   const actsvg::views::x_y view;
0040 
0041   // Creating the svg generator for the detector.
0042   detray::svgtools::illustrator il{det, names};
0043 
0044   // In this example we want to draw the grids of the volumes with indices 0,
0045   // 1, ... in the detector.
0046   std::vector<detray::dindex> indices = {3u, 5u, 7u, 9u};
0047 
0048   for (const detray::dindex i : indices) {
0049     // Draw volume i.
0050     il.hide_grids(false);
0051     const auto [volume_svg, grid] = il.draw_volume(i, view);
0052 
0053     // Write volume i and its grid
0054     detray::svgtools::write_svg("test_svgtools_" + volume_svg._id, volume_svg);
0055     detray::svgtools::write_svg("test_svgtools_" + grid._id, grid);
0056   }
0057 }