File indexing completed on 2025-07-05 08:11:59
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Io/Obj/ObjTrackingGeometryWriter.hpp"
0010
0011 #include "Acts/Utilities/Logger.hpp"
0012 #include "ActsExamples/Framework/AlgorithmContext.hpp"
0013 #include <Acts/Geometry/TrackingGeometry.hpp>
0014 #include <Acts/Visualization/GeometryView3D.hpp>
0015 #include <Acts/Visualization/ObjVisualization3D.hpp>
0016
0017 #include <filesystem>
0018
0019 ActsExamples::ObjTrackingGeometryWriter::ObjTrackingGeometryWriter(
0020 const ActsExamples::ObjTrackingGeometryWriter::Config& config,
0021 Acts::Logging::Level level)
0022 : m_logger{Acts::getDefaultLogger(name(), level)}, m_cfg(config) {}
0023
0024 std::string ActsExamples::ObjTrackingGeometryWriter::name() const {
0025 return "ObjTrackingGeometryWriter";
0026 }
0027
0028 ActsExamples::ProcessCode ActsExamples::ObjTrackingGeometryWriter::write(
0029 const AlgorithmContext& context, const Acts::TrackingGeometry& tGeometry) {
0030 ACTS_DEBUG(">>Obj: Writer for TrackingGeometry object called.");
0031
0032 auto world = tGeometry.highestTrackingVolume();
0033 if (world != nullptr) {
0034 write(context, *world,
0035 tGeometry.geometryVersion() ==
0036 Acts::TrackingGeometry::GeometryVersion::Gen3);
0037 }
0038 return ActsExamples::ProcessCode::SUCCESS;
0039 }
0040
0041 void ActsExamples::ObjTrackingGeometryWriter::write(
0042 const AlgorithmContext& context, const Acts::TrackingVolume& tVolume,
0043 bool gen3) {
0044 ACTS_DEBUG(">>Obj: Writer for TrackingVolume object called.");
0045
0046 Acts::ObjVisualization3D objVis(m_cfg.outputPrecision, m_cfg.outputScalor);
0047
0048 if (gen3) {
0049 ACTS_VERBOSE(">>Obj: Gen3 geometry detected, using Gen3 visualization");
0050 tVolume.visualize(objVis, context.geoContext, m_cfg.volumeView,
0051 m_cfg.portalView, m_cfg.sensitiveView);
0052 objVis.write(m_cfg.outputDir / "geometry");
0053 } else {
0054 ACTS_VERBOSE(">>Obj: Gen1 geometry detected, using Gen1 visualization");
0055 Acts::GeometryView3D::drawTrackingVolume(
0056 objVis, tVolume, context.geoContext, m_cfg.containerView,
0057 m_cfg.volumeView, m_cfg.passiveView, m_cfg.sensitiveView,
0058 m_cfg.gridView, true, "", std::filesystem::path(m_cfg.outputDir));
0059 }
0060 }