Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-21 08:02:27

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 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Visualization/ViewConfig.hpp"
0013 
0014 #include <cstddef>
0015 #include <filesystem>
0016 #include <vector>
0017 
0018 namespace Acts {
0019 
0020 /// Partially abstract base class which provides an interface to visualization
0021 /// helper classes. It provides a number of methods that all the helpers need to
0022 /// conform to.
0023 class IVisualization3D {
0024  public:
0025   /// Type alias for face definition as vertex indices
0026   using FaceType = std::vector<std::size_t>;
0027 
0028   /// Default color used for visualization when no color is specified
0029   static constexpr Color s_defaultColor = {120, 120, 120};
0030 
0031   /// Draw a vertex at a given location and a color.
0032   /// @param vtx The vertex position
0033   /// @param color The color
0034   ///
0035   virtual void vertex(const Vector3& vtx, Color color = s_defaultColor) = 0;
0036 
0037   /// Draw a face that connects a list of vertices.
0038   /// @note Depending on the helper implementation, out of plane vertices might
0039   /// be handled differently.
0040   /// @param vtxs The vertices that make up the face
0041   /// @param color The color of the face
0042   ///
0043   virtual void face(const std::vector<Vector3>& vtxs,
0044                     Color color = s_defaultColor) = 0;
0045 
0046   /// Draw a faces that connects a list of vertices - expert only
0047   ///
0048   /// @note Depending on the helper implementation, out of plane vertices might
0049   /// be handled differently.
0050   /// @param vtxs The vertices that make up the faceS
0051   /// @param faces The face presections (i.e. connecting vertices)
0052   /// @param color The color of the face
0053   ///
0054   virtual void faces(const std::vector<Vector3>& vtxs,
0055                      const std::vector<FaceType>& faces,
0056                      Color color = s_defaultColor) = 0;
0057 
0058   /// Draw a line from a vertex to another
0059   /// @param a The start vertex
0060   /// @param b The end vertex
0061   /// @param color The color of the line
0062   ///
0063   virtual void line(const Vector3& a, const Vector3& b,
0064                     Color color = s_defaultColor) = 0;
0065 
0066   /// Write the content of the helper to an outstream.
0067   /// @param os The output stream for file
0068   virtual void write(std::ostream& os) const = 0;
0069 
0070   /// Write the content of the helper to an outstream.
0071   /// @param path is the file system path for writing the file
0072   virtual void write(const std::filesystem::path& path) const = 0;
0073 
0074   /// Remove all contents of this helper
0075   ///
0076   virtual void clear() = 0;
0077 
0078   virtual ~IVisualization3D() = default;
0079 
0080   /// Start a new object context
0081   /// @param name The name of the object
0082   virtual void object(const std::string& name) = 0;
0083 };
0084 
0085 /// Stream operator for IVisualization3D
0086 /// @param os The output stream
0087 /// @param hlp The helper instance
0088 /// @return Reference to output stream
0089 inline std::ostream& operator<<(std::ostream& os, const IVisualization3D& hlp) {
0090   hlp.write(os);
0091   return os;
0092 }
0093 }  // namespace Acts