|
||||
File indexing completed on 2025-01-19 09:23:43
0001 // This file is part of the Acts project. 0002 // 0003 // Copyright (C) 2019 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 "Acts/Definitions/Algebra.hpp" 0012 #include "Acts/Visualization/ViewConfig.hpp" 0013 0014 #include <array> 0015 #include <cstddef> 0016 #include <fstream> 0017 #include <string> 0018 #include <vector> 0019 0020 namespace Acts { 0021 0022 /// Partially abstract base class which provides an interface to visualization 0023 /// helper classes. It provides a number of methods that all the helpers need to 0024 /// conform to. 0025 class IVisualization3D { 0026 public: 0027 using FaceType = std::vector<std::size_t>; 0028 0029 /// Draw a vertex at a given location and a color. 0030 /// @param vtx The vertex position 0031 /// @param color The color 0032 /// 0033 virtual void vertex(const Vector3& vtx, ColorRGB color = {120, 120, 120}) = 0; 0034 0035 /// Draw a face that connects a list of vertices. 0036 /// @note Depending on the helper implementation, out of plane vertices might 0037 /// be handled differently. 0038 /// @param vtxs The vertices that make up the face 0039 /// @param color The color of the face 0040 /// 0041 virtual void face(const std::vector<Vector3>& vtxs, 0042 ColorRGB color = {120, 120, 120}) = 0; 0043 0044 /// Draw a faces that connects a list of vertices - expert only 0045 /// 0046 /// @note Depending on the helper implementation, out of plane vertices might 0047 /// be handled differently. 0048 /// @param vtxs The vertices that make up the faceS 0049 /// @param faces The face presections (i.e. connecting vertices) 0050 /// @param color The color of the face 0051 /// 0052 virtual void faces(const std::vector<Vector3>& vtxs, 0053 const std::vector<FaceType>& faces, 0054 ColorRGB color = {120, 120, 120}) = 0; 0055 0056 /// Draw a line from a vertex to another 0057 /// @param a The start vertex 0058 /// @param b The end vertex 0059 /// @param color The color of the line 0060 /// 0061 virtual void line(const Vector3& a, const Vector3& b, 0062 ColorRGB color = {120, 120, 120}) = 0; 0063 0064 /// Write the content of the helper to an outstream. 0065 /// @param os The output stream for file 0066 virtual void write(std::ostream& os) const = 0; 0067 0068 /// Write the content of the helper to an outstream. 0069 /// @param path is the file system path for writing the file 0070 /// @note will change to std::filesystem::path once gcc9 is standard 0071 virtual void write(const std::string& path) const = 0; 0072 0073 /// Remove all contents of this helper 0074 /// 0075 virtual void clear() = 0; 0076 0077 protected: 0078 /// Helper: check for extension 0079 /// 0080 /// @note this is a placeholder for std::filesystem::has_extension 0081 /// which needs special linking until gcc9 0082 /// @param path the path to be checked 0083 bool hasExtension(const std::string& path) const; 0084 0085 /// Helper: replace the extension 0086 /// 0087 /// @note this is a placeholder for std::filesystem::replace_extension 0088 /// which needs special linking until gcc9 0089 /// @param path [in,out] the path to be changed 0090 /// @param suffix the extension to be added 0091 void replaceExtension(std::string& path, const std::string& suffix) const; 0092 }; 0093 0094 /// Overload of the << operator to facilitate writing to streams. 0095 /// @param os The output stream 0096 /// @param hlp The helper instance 0097 inline std::ostream& operator<<(std::ostream& os, const IVisualization3D& hlp) { 0098 hlp.write(os); 0099 return os; 0100 } 0101 } // namespace Acts
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |