Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:14

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/IVisualization3D.hpp"
0013 #include "Acts/Visualization/ViewConfig.hpp"
0014 
0015 #include <array>
0016 #include <filesystem>
0017 #include <fstream>
0018 #include <string>
0019 #include <utility>
0020 #include <vector>
0021 
0022 namespace Acts {
0023 
0024 template <typename T = double>
0025 
0026 /// @brief Helper to write out PlyVisualization3D visualization format
0027 class PlyVisualization3D : public IVisualization3D {
0028  public:
0029   static_assert(std::is_same_v<T, double> || std::is_same_v<T, float>,
0030                 "Use either double or float");
0031 
0032   /// Stored value type, should be double or float
0033   using ValueType = T;
0034 
0035   /// Type of a vertex based on the value type
0036   using VertexType = Eigen::Matrix<ValueType, 3, 1>;
0037 
0038   /// @copydoc Acts::IVisualization3D::vertex()
0039   void vertex(const Vector3& vtx, Color color = {120, 120, 120}) final;
0040 
0041   /// @copydoc Acts::IVisualization3D::face()
0042   void face(const std::vector<Vector3>& vtxs,
0043             Color color = {120, 120, 120}) final;
0044 
0045   /// @copydoc Acts::IVisualization3D::faces()
0046   void faces(const std::vector<Vector3>& vtxs,
0047              const std::vector<FaceType>& faces,
0048              Color color = {120, 120, 120}) final;
0049 
0050   /// @copydoc Acts::IVisualization3D::line()
0051   void line(const Vector3& a, const Vector3& b,
0052             Color color = {120, 120, 120}) final;
0053 
0054   /// @copydoc Acts::IVisualization3D::write(const std::filesystem::path&) const
0055   void write(const std::filesystem::path& path) const final;
0056 
0057   /// @copydoc Acts::IVisualization3D::write(std::ostream&) const
0058   void write(std::ostream& os) const final;
0059 
0060   /// @copydoc Acts::IVisualization3D::clear()
0061   void clear() final;
0062 
0063   void object(const std::string& /*name*/) final {
0064     // Unimplemented
0065   }
0066 
0067  private:
0068   std::vector<std::pair<VertexType, Color>> m_vertices;
0069   std::vector<FaceType> m_faces;
0070   std::vector<std::pair<std::pair<std::size_t, std::size_t>, Color>> m_edges;
0071 };
0072 
0073 #ifndef DOXYGEN
0074 #include "detail/PlyVisualization3D.ipp"
0075 #endif
0076 
0077 }  // namespace Acts