File indexing completed on 2025-01-18 09:13:03
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Surfaces/PlaneSurface.hpp"
0013 #include "Acts/Surfaces/RectangleBounds.hpp"
0014 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0015 #include "Acts/Visualization/EventDataView3D.hpp"
0016 #include "Acts/Visualization/GeometryView3D.hpp"
0017 #include "Acts/Visualization/IVisualization3D.hpp"
0018 #include "Acts/Visualization/ObjVisualization3D.hpp"
0019 #include "Acts/Visualization/PlyVisualization3D.hpp"
0020
0021 #include <fstream>
0022 #include <sstream>
0023 #include <string>
0024
0025 namespace Acts::PrimitivesView3DTest {
0026
0027
0028 auto identity = Transform3::Identity();
0029 auto rectangle = std::make_shared<RectangleBounds>(10., 10.);
0030 auto plane = Surface::makeShared<PlaneSurface>(identity, rectangle);
0031
0032
0033 GeometryContext gctx = GeometryContext();
0034
0035
0036
0037
0038
0039
0040 static inline std::string run(IVisualization3D& helper) {
0041 std::stringstream ss;
0042
0043 ViewConfig lineView{.color = {0, 0, 255}};
0044 lineView.lineThickness = 0.1;
0045
0046
0047 Vector3 start = {1., 1., 1.};
0048 Vector3 end = {4., 4., 4.};
0049 Acts::GeometryView3D::drawSegment(helper, start, end);
0050 helper.write("Primitives_Line");
0051 helper.write(ss);
0052 helper.clear();
0053
0054
0055 start = {1., 0., 0.};
0056 end = {4., 0., 0.};
0057 Acts::GeometryView3D::drawArrowForward(helper, start, end, 3., 2., lineView);
0058
0059 start = {1., 2., 0.};
0060 end = {4., 2., 0.};
0061 Acts::GeometryView3D::drawArrowBackward(helper, start, end, 3., 2., lineView);
0062
0063 start = {1., 4., 0.};
0064 end = {4., 4., 0.};
0065 Acts::GeometryView3D::drawArrowsBoth(helper, start, end, 3., 2., lineView);
0066
0067 helper.write("Primitives_Arrows");
0068 helper.write(ss);
0069 helper.clear();
0070
0071
0072 Acts::GeometryView3D::drawSurface(helper, *plane, gctx);
0073
0074 ViewConfig errorVis{.color = {250, 0, 0}};
0075 errorVis.lineThickness = 0.025;
0076
0077 SquareMatrix2 cov = SquareMatrix2::Identity();
0078 double s0 = 0.75;
0079 double s1 = 1.99;
0080 double r01 = 0.78;
0081 cov << s0 * s0, r01 * s0 * s1, r01 * s0 * s1, s1 * s1;
0082
0083 Vector2 lcentered{0., 0.};
0084 Acts::EventDataView3D::drawCovarianceCartesian(
0085 helper, lcentered, cov, plane->transform(gctx), 1.0, errorVis);
0086
0087 helper.write("Primitives_CartesianError");
0088 helper.write(ss);
0089 helper.clear();
0090
0091
0092 Acts::GeometryView3D::drawSurface(helper, *plane, gctx);
0093 cov = SquareMatrix2::Identity();
0094 s0 = 0.08;
0095 s1 = 0.035;
0096 r01 = 0.3;
0097 cov << s0 * s0, r01 * s0 * s1, r01 * s0 * s1, s1 * s1;
0098
0099 Vector3 origin{0., 0., 0.};
0100 Vector3 direction = Vector3(1., 3., 15.).normalized();
0101
0102 double directionScale = 5.;
0103
0104 Acts::EventDataView3D::drawCovarianceAngular(helper, origin, direction, cov,
0105 directionScale, 10., errorVis);
0106
0107 Acts::GeometryView3D::drawArrowForward(
0108 helper, origin + 0.5 * directionScale * direction,
0109 origin + 1.2 * directionScale * direction, 3., 2., errorVis);
0110
0111 helper.write("Primitives_AngularError");
0112 helper.write(ss);
0113 helper.clear();
0114
0115 return ss.str();
0116 }
0117
0118 }