Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:10:06

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2023 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #include <Acts/Definitions/Algebra.hpp>
0010 #include <Acts/Geometry/GeometryContext.hpp>
0011 #include <Acts/Plugins/Python/Utilities.hpp>
0012 #include <Acts/Surfaces/Surface.hpp>
0013 #include <Acts/Visualization/GeometryView3D.hpp>
0014 #include <Acts/Visualization/ObjVisualization3D.hpp>
0015 #include <Acts/Visualization/ViewConfig.hpp>
0016 
0017 #include <memory>
0018 
0019 #include <pybind11/pybind11.h>
0020 #include <pybind11/stl.h>
0021 
0022 namespace py = pybind11;
0023 using namespace pybind11::literals;
0024 
0025 using namespace Acts;
0026 
0027 namespace Acts::Python {
0028 void addObj(Context& ctx) {
0029   auto [m, mex] = ctx.get("main", "examples");
0030 
0031   {
0032     /// Write a collection of surfaces to an '.obj' file
0033     ///
0034     /// @param surfaces is the collection of surfaces
0035     /// @param viewContext is the geometry context
0036     /// @param viewRgb is the color of the surfaces
0037     /// @param fileName is the path to the output file
0038     ///
0039     mex.def("writeSurfacesObj",
0040             [](const std::vector<std::shared_ptr<Surface>>& surfaces,
0041                const GeometryContext& viewContext,
0042                const std::array<int, 3>& viewRgb, const std::string& fileName) {
0043               Acts::ViewConfig sConfig = Acts::ViewConfig{viewRgb};
0044               Acts::GeometryView3D view3D;
0045               Acts::ObjVisualization3D obj;
0046 
0047               for (const auto& surface : surfaces) {
0048                 view3D.drawSurface(obj, *surface, viewContext,
0049                                    Acts::Transform3::Identity(), sConfig);
0050               }
0051               obj.write(fileName);
0052             });
0053   }
0054 }
0055 }  // namespace Acts::Python