Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:08

0001 // This file is part of the actsvg packge.
0002 //
0003 // Copyright (C) 2022 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include <map>
0012 #include <optional>
0013 #include <string>
0014 #include <utility>
0015 #include <vector>
0016 
0017 #include "actsvg/core/style.hpp"
0018 #include "actsvg/styles/defaults.hpp"
0019 #include "grid.hpp"
0020 
0021 namespace actsvg {
0022 
0023 namespace proto {
0024 
0025 /** A proto surface class as a simple translation layer
0026  * from a surface description
0027  *
0028  * @tparam point3_container a vertex description of surfaces
0029  **/
0030 
0031 template <typename point3_container>
0032 struct surface {
0033 
0034     enum type {
0035         e_annulus,
0036         e_cylinder,
0037         e_diamond,
0038         e_disc,
0039         e_polygon,
0040         e_rectangle,
0041         e_trapez
0042     };
0043 
0044     enum boolean { e_clipping, e_union, e_subtraction, e_none };
0045 
0046     /// Name of the surface
0047     std::string _name = "unnamed";
0048 
0049     /// Auxiliary information as container map
0050     std::map<std::string, std::vector<std::string>> _aux_info = {};
0051 
0052     /// The contained vertices - for polygon surfaces
0053     point3_container _vertices = {};
0054 
0055     /// Dedicated regular disc/cylinder descriptions
0056     /// - if this is not applicable the _vertices view needs to be chosen
0057     std::array<scalar, 2> _radii = {0., 0.};
0058     std::array<scalar, 2> _opening = {-M_PI, M_PI};
0059     std::array<scalar, 2> _zparameters = {0., 0.};
0060 
0061     /// Boolean surfaces
0062     std::vector<surface<point3_container>> _boolean_surface = {};
0063     boolean _boolean_operation = e_none;
0064 
0065     /// Fill and stroke
0066     style::fill _fill = defaults::__s_fill;
0067     style::stroke _stroke = defaults::__s_stroke;
0068     style::transform _transform = defaults::__t_identity;
0069 
0070     /// Type of the surfaces
0071     type _type = e_trapez;
0072 
0073     /// And their measures
0074     std::vector<scalar> _measures = {};
0075 
0076     /// A (potential) template for this surface
0077     svg::object _template_object;
0078 
0079     using point3_type = typename point3_container::value_type;
0080 
0081     /** Static constructor from a templat
0082      * @param t_ the template
0083      * @param o_ the tempalte object
0084      * @param name_ the new name
0085      **/
0086     static surface<point3_container> from_template(
0087         const surface<point3_container>& t_, const svg::object& o_,
0088         const std::string& name_) {
0089         surface<point3_container> s;
0090         s._name = name_;
0091         s._type = t_._type;
0092         s._aux_info = t_._aux_info;
0093         s._vertices = t_._vertices;
0094         s._measures = t_._measures;
0095         s._radii = t_._radii;
0096         s._opening = t_._opening;
0097         s._fill = t_._fill;
0098         s._stroke = t_._stroke;
0099         s._transform = t_._transform;
0100         s._template_object = o_;
0101         return s;
0102     }
0103 };
0104 
0105 }  // namespace proto
0106 
0107 }  // namespace actsvg