EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ObjVisualization3D.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ObjVisualization3D.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
14 
15 #include <array>
16 #include <fstream>
17 #include <iomanip>
18 #include <map>
19 #include <sstream>
20 #include <string>
21 #include <vector>
22 
23 namespace Acts {
24 
28 template <typename T = double>
30  public:
31  static_assert(std::is_same_v<T, double> || std::is_same_v<T, float>,
32  "Use either double or float");
33 
35  using ValueType = T;
36 
39 
41  using LineType = std::pair<size_t, size_t>;
42 
46  ObjVisualization3D(unsigned int prec = 4, double scale = 1.)
47  : m_outputPrecision(prec), m_outputScalor(scale) {}
48 
50  void vertex(const Vector3D& vtx, ColorRGB color = {0, 0, 0}) final;
51 
53  void line(const Vector3D& a, const Vector3D& b,
54  ColorRGB color = {0, 0, 0}) final;
55 
57  void face(const std::vector<Vector3D>& vtxs,
58  ColorRGB color = {0, 0, 0}) final;
59 
61  void faces(const std::vector<Vector3D>& vtxs,
62  const std::vector<FaceType>& faces,
63  ColorRGB color = {0, 0, 0}) final;
64 
66  void write(const std::string& path) const final;
67 
69  void write(std::ostream& os) const final;
70 
74  void write(std::ostream& os, std::ostream& mos) const;
75 
77  void clear() final;
78 
79  private:
81  unsigned int m_outputPrecision = 4;
82  double m_outputScalor = 1.;
88  std::map<size_t, ColorRGB> m_lineColors;
89  std::map<size_t, ColorRGB> m_vertexColors;
90  std::map<size_t, ColorRGB> m_faceColors;
91 };
92 
93 #include "detail/ObjVisualization3D.ipp"
94 
95 } // namespace Acts