File indexing completed on 2025-01-19 09:23:43
0001
0002
0003
0004
0005
0006
0007
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 <fstream>
0017 #include <iomanip>
0018 #include <map>
0019 #include <sstream>
0020 #include <string>
0021 #include <vector>
0022
0023 namespace Acts {
0024
0025
0026
0027
0028 template <typename T = double>
0029 class ObjVisualization3D : public IVisualization3D {
0030 public:
0031 static_assert(std::is_same_v<T, double> || std::is_same_v<T, float>,
0032 "Use either double or float");
0033
0034
0035 using ValueType = T;
0036
0037
0038 using VertexType = Eigen::Matrix<ValueType, 3, 1>;
0039
0040
0041 using LineType = std::pair<std::size_t, std::size_t>;
0042
0043
0044
0045
0046 ObjVisualization3D(unsigned int prec = 4, double scale = 1.)
0047 : m_outputPrecision(prec), m_outputScalor(scale) {}
0048
0049
0050 void vertex(const Vector3& vtx, ColorRGB color = {0, 0, 0}) final;
0051
0052
0053 void line(const Vector3& a, const Vector3& b,
0054 ColorRGB color = {0, 0, 0}) final;
0055
0056
0057 void face(const std::vector<Vector3>& vtxs, ColorRGB color = {0, 0, 0}) final;
0058
0059
0060 void faces(const std::vector<Vector3>& vtxs,
0061 const std::vector<FaceType>& faces,
0062 ColorRGB color = {0, 0, 0}) final;
0063
0064
0065 void write(const std::string& path) const final;
0066
0067
0068 void write(std::ostream& os) const final;
0069
0070
0071
0072
0073 void write(std::ostream& os, std::ostream& mos) const;
0074
0075
0076 void clear() final;
0077
0078 private:
0079
0080 unsigned int m_outputPrecision = 4;
0081 double m_outputScalor = 1.;
0082
0083 std::vector<VertexType> m_vertices;
0084 std::vector<FaceType> m_faces;
0085 std::vector<LineType> m_lines;
0086
0087 std::map<std::size_t, ColorRGB> m_lineColors;
0088 std::map<std::size_t, ColorRGB> m_vertexColors;
0089 std::map<std::size_t, ColorRGB> m_faceColors;
0090 };
0091
0092 #ifndef DOXYGEN
0093 #include "detail/ObjVisualization3D.ipp"
0094 #endif
0095
0096 }