ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
writer.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 CERN for the benefit of the ACTS project
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// Project include(s)
12#include "detray/io/utils/file_handle.hpp"
13
14// Actsvg include(s)
15#include "actsvg/core.hpp"
16
17// System include(s)
18#include <array>
19#include <ios>
20#include <string>
21#include <vector>
22
23namespace detray::svgtools {
24
26template <typename container_t>
27inline void write_svg(const std::string& path, const container_t& svgs,
28 bool replace = true) {
29 actsvg::svg::file file;
30 for (const actsvg::svg::object& obj : svgs) {
31 file.add_object(obj);
32 }
33 std::ios_base::openmode io_mode =
34 replace ? std::ios::out | std::ios::trunc : std::ios::out;
35
36 detray::io::file_handle stream{path, ".svg", io_mode};
37 *stream << file;
38}
39
42inline void write_svg(const std::string& path, const actsvg::svg::object& svg,
43 bool replace = true) {
44 write_svg(path, std::array{svg}, replace);
45}
46
49inline void write_svg(const std::string& path,
50 const std::initializer_list<actsvg::svg::object>& svgs,
51 bool replace = true) {
52 std::vector<actsvg::svg::object> arg = svgs;
53 write_svg(path, arg, replace);
54}
55
56} // namespace detray::svgtools