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 <string>
0012 #include <vector>
0013 
0014 #include "actsvg/core/style.hpp"
0015 #include "actsvg/proto/grid.hpp"
0016 #include "actsvg/proto/portal.hpp"
0017 #include "actsvg/proto/surface.hpp"
0018 #include "actsvg/styles/defaults.hpp"
0019 
0020 namespace actsvg {
0021 
0022 namespace proto {
0023 
0024 /** A proto volume class as a simple translation layer
0025  * from a volume description
0026  *
0027  * @tparam point3_container a vertex description of surfaces
0028  **/
0029 
0030 template <typename point3_container>
0031 struct volume {
0032 
0033     using surface_type = surface<point3_container>;
0034 
0035     using portal_type = portal<point3_container>;
0036 
0037     /// Type enumeration
0038     enum type { e_cylinder = 0, e_cuboid = 1, e_other = 2 };
0039 
0040     // The index of the volume
0041     unsigned int _index = 0u;
0042 
0043     // The depth level of the volume
0044     unsigned int _depth_level = 0u;
0045 
0046     /// Name of the volume
0047     std::string _name = "unnamed";
0048 
0049     // The type of the volume & its parameters
0050     type _type = e_cylinder;
0051     std::vector<scalar> _bound_values;
0052     point3_container _vertices = {};
0053 
0054     // Style parameters
0055     style::fill _fill;
0056     style::stroke _stroke = defaults::__nn_stroke;
0057     style::transform _transform;
0058 
0059     /// Auxiliary information
0060     std::vector<std::string> _info = {};
0061 
0062     /// The contained surfaces as batches
0063     std::vector<std::vector<surface<point3_container>>> _surfaces = {};
0064 
0065     /// The portals
0066     std::vector<portal<point3_container>> _portals = {};
0067 
0068     /// The associated surface grid
0069     grid _surface_grid;
0070 
0071     /** These are the grid associations, when iterating through
0072      * the associataions are also grouped by batch in order to
0073      * split the association view if necessary
0074      *
0075      *  for (auto : batch){
0076      *    size_t i = 0;
0077      *    for (auto: _edges_1){
0078      *      for (auto: _edges_0){
0079      *        auto assoc = _grid_associations[i++];
0080      *        }
0081      *     }
0082      *   }
0083      *
0084      * The entries of the association point to the index in the surface
0085      * container of the volume
0086      **/
0087     std::vector<std::vector<std::vector<size_t>>> _grid_associations = {};
0088 
0089     /// Colorize method
0090     ///
0091     /// @param colors_ are the indexed colors
0092     ///
0093     void colorize(std::vector<style::color>& colors_) {
0094         if (_index < colors_.size()) {
0095             _fill._fc = colors_[_index];
0096         }
0097         for (auto& p : _portals) {
0098             /// @todo set portal color if unique
0099             for (auto& vl : p._volume_links) {
0100                 if (vl._link_index < colors_.size()) {
0101                     vl._stroke._sc = colors_[vl._link_index];
0102                     vl._stroke._sc._opacity = 1.;
0103                     vl._end_marker._fill._fc = colors_[vl._link_index];
0104                     vl._end_marker._fill._fc._opacity = 1.;
0105                     vl._end_marker._stroke = vl._stroke;
0106                 }
0107             }
0108         }
0109     }
0110 };
0111 
0112 }  // namespace proto
0113 
0114 }  // namespace actsvg