Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-09 09:26:47

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.
0008 
0009 #include "Acts/Visualization/IVisualization3D.hpp"
0010 #include "ActsPython/Utilities/Helpers.hpp"
0011 #include <Acts/Definitions/Algebra.hpp>
0012 #include <Acts/Geometry/GeometryContext.hpp>
0013 #include <Acts/Surfaces/Surface.hpp>
0014 #include <Acts/Visualization/GeometryView3D.hpp>
0015 #include <Acts/Visualization/ObjVisualization3D.hpp>
0016 #include <Acts/Visualization/ViewConfig.hpp>
0017 
0018 #include <memory>
0019 
0020 #include <pybind11/pybind11.h>
0021 #include <pybind11/stl.h>
0022 #include <pybind11/stl/filesystem.h>
0023 
0024 namespace py = pybind11;
0025 using namespace pybind11::literals;
0026 
0027 using namespace Acts;
0028 
0029 namespace ActsPython {
0030 void addObj(py::module& mex) {
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 viewSegments is the number of segments to approximate a quarter of a circle
0038     /// @param fileName is the path to the output file
0039     ///
0040     mex.def("writeSurfacesObj",
0041             [](const std::vector<std::shared_ptr<Surface>>& surfaces,
0042                const GeometryContext& viewContext, const ViewConfig& viewConfig,
0043                const std::string& fileName) {
0044               GeometryView3D view3D;
0045               ObjVisualization3D obj;
0046 
0047               for (const auto& surface : surfaces) {
0048                 view3D.drawSurface(obj, *surface, viewContext,
0049                                    Transform3::Identity(), viewConfig);
0050               }
0051               obj.write(fileName);
0052             });
0053   }
0054 }
0055 }  // namespace ActsPython