File indexing completed on 2025-01-18 09:11:14
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 <filesystem>
0016 #include <map>
0017 #include <string>
0018 #include <vector>
0019
0020 namespace Acts {
0021
0022
0023
0024
0025 class ObjVisualization3D : public IVisualization3D {
0026 public:
0027
0028 using ValueType = double;
0029
0030
0031 using VertexType = Eigen::Matrix<ValueType, 3, 1>;
0032
0033
0034 using LineType = std::pair<std::size_t, std::size_t>;
0035
0036
0037
0038
0039 ObjVisualization3D(unsigned int prec = 4, double scale = 1.)
0040 : m_outputPrecision(prec), m_outputScalor(scale) {}
0041
0042
0043 void vertex(const Vector3& vtx, Color color = s_defaultColor) final;
0044
0045
0046 void line(const Vector3& a, const Vector3& b,
0047 Color color = s_defaultColor) final;
0048
0049
0050 void face(const std::vector<Vector3>& vtxs,
0051 Color color = s_defaultColor) final;
0052
0053
0054 void faces(const std::vector<Vector3>& vtxs,
0055 const std::vector<FaceType>& faces,
0056 Color color = s_defaultColor) final;
0057
0058
0059 void write(const std::filesystem::path& path) const final;
0060
0061
0062 void write(std::ostream& os) const final;
0063
0064
0065
0066
0067 void write(std::ostream& os, std::ostream& mos) const;
0068
0069
0070 void clear() final;
0071
0072
0073
0074 void object(const std::string& name) final;
0075
0076 private:
0077 struct Object {
0078 std::string name;
0079 std::vector<VertexType> vertices{};
0080 std::vector<FaceType> faces{};
0081 std::vector<LineType> lines{};
0082
0083
0084
0085 std::map<std::size_t, Color> lineColors{};
0086 std::map<std::size_t, Color> vertexColors{};
0087 std::map<std::size_t, Color> faceColors{};
0088 };
0089
0090 Object& object();
0091 const Object& object() const;
0092
0093
0094 unsigned int m_outputPrecision = 4;
0095 double m_outputScalor = 1.;
0096
0097 std::vector<Object> m_objects;
0098 };
0099
0100 }