From f4efc6f20e565147c969bd57b31f5a5e7fc85e99 Mon Sep 17 00:00:00 2001 From: Stephen Nicholas Swatman Date: Thu, 19 Sep 2024 17:57:23 +0200 Subject: [PATCH 1/6] feat: Improvements to multitrajectory iterators (#3619) This small PR adds an post-increment operator to the multitrajectory iterator, as well as `cbegin` and `cend` methods. --- Core/include/Acts/EventData/MultiTrajectory.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Core/include/Acts/EventData/MultiTrajectory.hpp b/Core/include/Acts/EventData/MultiTrajectory.hpp index 4b1add782b1..446348a6ae0 100644 --- a/Core/include/Acts/EventData/MultiTrajectory.hpp +++ b/Core/include/Acts/EventData/MultiTrajectory.hpp @@ -87,6 +87,12 @@ class TrackStateRange { } } + Iterator operator++(int) { + Iterator tmp(*this); + operator++(); + return tmp; + } + bool operator==(const Iterator& other) const { if (!proxy && !other.proxy) { return true; @@ -109,6 +115,9 @@ class TrackStateRange { Iterator begin() { return m_begin; } Iterator end() { return Iterator{std::nullopt}; } + Iterator cbegin() const { return m_begin; } + Iterator cend() const { return Iterator{std::nullopt}; } + private: Iterator m_begin; }; From 971be3af6f4b36fed048dc129031fde1c79bfabc Mon Sep 17 00:00:00 2001 From: Ragansu Chakkappai <66349236+Ragansu@users.noreply.github.com> Date: Thu, 19 Sep 2024 21:49:30 +0200 Subject: [PATCH 2/6] refactor: Modified from_json in AmbiguityConfigJson for easier implementation in Athena (#3628) This PR is to do 2 changes for easier implementation in Athena a) Change factor_hits/holes to goodhits/holes and fakehits/holes this is how config is defined in Athena b) Change ERROR to DEBUG in track state with no surface as Athena has extra trackstates which doesnt have surface. Ragansu --- .../ScoreBasedAmbiguityResolution.ipp | 2 +- .../Json/src/AmbiguityConfigJsonConverter.cpp | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp b/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp index 8041188b5cf..3dcf1a20a01 100644 --- a/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp +++ b/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp @@ -46,7 +46,7 @@ ScoreBasedAmbiguityResolution::computeInitialState( for (const auto& ts : track.trackStatesReversed()) { if (!ts.hasReferenceSurface()) { - ACTS_ERROR("Track state has no reference surface"); + ACTS_DEBUG("Track state has no reference surface"); continue; } auto iVolume = ts.referenceSurface().geometryId().volume(); diff --git a/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp b/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp index 2542a237b52..3a4c0f44a6f 100644 --- a/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp +++ b/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp @@ -35,15 +35,26 @@ void from_json(const nlohmann::json& j, ConfigPair& p) { detectorConfig.sharedHitsFlag = value["sharedHitsFlag"]; - std::vector factorHits = value["factorHits"]; - std::vector factorHoles = value["factorHoles"]; + const std::vector& goodHits = value["goodHits"]; + const std::vector& goodHoles = value["goodHoles"]; - for (auto factor : factorHits) { - detectorConfig.factorHits.push_back(factor); + const std::vector& fakeHits = value["fakeHits"]; + const std::vector& fakeHoles = value["fakeHoles"]; + + if (goodHits.size() != fakeHits.size()) { + throw std::invalid_argument("goodHits and FakeHits size mismatch"); + } + + for (std::size_t i = 0; i < goodHits.size(); i++) { + detectorConfig.factorHits.push_back(goodHits[i] / fakeHits[i]); + } + + if (goodHoles.size() != fakeHoles.size()) { + throw std::invalid_argument("goodHoles and FakeHoles size mismatch"); } - for (auto factor : factorHoles) { - detectorConfig.factorHoles.push_back(factor); + for (std::size_t i = 0; i < goodHoles.size(); i++) { + detectorConfig.factorHoles.push_back(goodHoles[i] / fakeHoles[i]); } detectorConfigs.push_back(detectorConfig); From 6291edb63b19d1ef85c2f34455e899046d12b931 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Fri, 20 Sep 2024 12:15:04 +0200 Subject: [PATCH 3/6] chore: synchronize versions (#3631) This PR synchronises the versions between `_acts__version` and the `cmake/ActsExternalSources.cmake` file, they have diverged at many places. --- CMakeLists.txt | 10 +++++----- cmake/ActsExternSources.cmake | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f13ea348110..2444a405ab6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,8 +221,7 @@ endif() # minimal dependency versions. they are defined here in a single place so # they can be easily upgraded, although they might not be used if the # dependency is included via `add_subdirectory(...)`. -set(_acts_actsvg_version 0.4.40) -set(_acts_autodiff_version 0.6) +set(_acts_actsvg_version 0.4.47) set(_acts_boost_version 1.71.0) set(_acts_dd4hep_version 1.21) set(_acts_edm4hep_version 0.7) @@ -232,13 +231,14 @@ set(_acts_podio_version 1.0.1) # will try this first set(_acts_podio_fallback_version 0.16) # if not found, will try this one set(_acts_doxygen_version 1.9.4) set(_acts_hepmc3_version 3.2.1) -set(_acts_nlohmanjson_version 3.2.0) +set(_acts_nlohmanjson_version 3.10.5) set(_acts_onnxruntime_version 1.12.0) set(_acts_root_version 6.20) set(_acts_tbb_version 2020.1) set(_acts_pythia8_version 8.309) -set(_acts_detray_version 0.72.0) -set(_acts_traccc_version 0.13.0) +set(_acts_pybind11_version 2.13.1) +set(_acts_detray_version 0.72.1) +set(_acts_traccc_version 0.15.0) set(_acts_covfie_version 0.10.0) set(_acts_vecmem_version 1.4.0) set(_acts_algebraplugins_version 0.22.0) diff --git a/cmake/ActsExternSources.cmake b/cmake/ActsExternSources.cmake index 2a0cb12d33c..c5b332e7316 100644 --- a/cmake/ActsExternSources.cmake +++ b/cmake/ActsExternSources.cmake @@ -1,40 +1,40 @@ set(ACTS_ACTSVG_SOURCE - "URL;https://github.com/acts-project/actsvg/archive/refs/tags/v0.4.47.tar.gz;URL_HASH;SHA256=aeb3927f8db1c7c9b8afa76adaa720013aa03a01032c8d5f457f623e2b04a172" + "URL;https://github.com/acts-project/actsvg/archive/refs/tags/v${_acts_actsvg_version}.tar.gz;URL_HASH;SHA256=aeb3927f8db1c7c9b8afa76adaa720013aa03a01032c8d5f457f623e2b04a172" CACHE STRING "Source to take ACTSVG from" ) mark_as_advanced(ACTS_ACTSVG_SOURCE) set(ACTS_VECMEM_SOURCE - "URL;https://github.com/acts-project/vecmem/archive/refs/tags/v1.4.0.tar.gz;URL_HASH;SHA256=545dfb4de4f9f3d773eef6a0e3297ebf981bb81950930d0991ad739e31ab16af" + "URL;https://github.com/acts-project/vecmem/archive/refs/tags/v${_acts_vecmem_version}.tar.gz;URL_HASH;SHA256=545dfb4de4f9f3d773eef6a0e3297ebf981bb81950930d0991ad739e31ab16af" CACHE STRING "Source to take VECMEM from" ) mark_as_advanced(ACTS_VECMEM_SOURCE) set(ACTS_ALGEBRAPLUGINS_SOURCE - "URL;https://github.com/acts-project/algebra-plugins/archive/refs/tags/v0.22.0.tar.gz;URL_HASH;SHA256=6fde02181c1b856c0a17a1925f0969798eecd5e3d6f2a87ea2eb365b6c948cc1" + "URL;https://github.com/acts-project/algebra-plugins/archive/refs/tags/v${_acts_algebraplugins_version}.tar.gz;URL_HASH;SHA256=6fde02181c1b856c0a17a1925f0969798eecd5e3d6f2a87ea2eb365b6c948cc1" CACHE STRING "Source to take ALGEBRAPLUGINS from" ) mark_as_advanced(ACTS_ALGEBRAPLUGINS_SOURCE) set(ACTS_COVFIE_SOURCE - "URL;https://github.com/acts-project/covfie/archive/refs/tags/v0.10.0.tar.gz;URL_HASH;SHA256=d44142b302ffc193ad2229f1d2cc6d8d720dd9da8c37989ada4f23018f86c964" + "URL;https://github.com/acts-project/covfie/archive/refs/tags/v${_acts_covfie_version}.tar.gz;URL_HASH;SHA256=d44142b302ffc193ad2229f1d2cc6d8d720dd9da8c37989ada4f23018f86c964" CACHE STRING "Source to take COVFIE from" ) mark_as_advanced(ACTS_COVFIE_SOURCE) set(ACTS_DETRAY_SOURCE - "URL;https://github.com/acts-project/detray/archive/refs/tags/v0.72.1.tar.gz;URL_HASH;SHA256=6cc8d34bc0d801338e9ab142c4a9884d19d9c02555dbb56972fab86b98d0f75b" + "URL;https://github.com/acts-project/detray/archive/refs/tags/v${_acts_detray_version}.tar.gz;URL_HASH;SHA256=6cc8d34bc0d801338e9ab142c4a9884d19d9c02555dbb56972fab86b98d0f75b" CACHE STRING "Source to take DETRAY from" ) mark_as_advanced(ACTS_DETRAY_SOURCE) set(ACTS_TRACCC_SOURCE - "URL;https://github.com/acts-project/traccc/archive/refs/tags/v0.15.0.tar.gz;URL_HASH;SHA256=1a9a1d0d2f6c4a7773eae3119b1e044fb52031ca49dfc88e6dc4ab8a11df167e" + "URL;https://github.com/acts-project/traccc/archive/refs/tags/v${_acts_traccc_version}.tar.gz;URL_HASH;SHA256=1a9a1d0d2f6c4a7773eae3119b1e044fb52031ca49dfc88e6dc4ab8a11df167e" CACHE STRING "Source to take TRACCC from" ) @@ -48,7 +48,7 @@ set(ACTS_FRNN_SOURCE mark_as_advanced(ACTS_FRNN_SOURCE) set(ACTS_NLOHMANNJSON_SOURCE - "URL;https://github.com/nlohmann/json/archive/refs/tags/v3.10.5.tar.gz;URL_HASH;SHA256=5daca6ca216495edf89d167f808d1d03c4a4d929cef7da5e10f135ae1540c7e4" + "URL;https://github.com/nlohmann/json/archive/refs/tags/v${_acts_nlohmanjson_version}.tar.gz;URL_HASH;SHA256=5daca6ca216495edf89d167f808d1d03c4a4d929cef7da5e10f135ae1540c7e4" CACHE STRING "Source to take nlohmann_json from" ) @@ -62,7 +62,7 @@ set(ACTS_EIGEN3_SOURCE mark_as_advanced(ACTS_EIGEN3_SOURCE) set(ACTS_PYBIND11_SOURCE - "GIT_REPOSITORY;https://github.com/pybind/pybind11.git;GIT_TAG;v2.13.1" + "GIT_REPOSITORY;https://github.com/pybind/pybind11.git;GIT_TAG;v${_acts_pybind11_version}" CACHE STRING "Source to take pybind11 from" ) From e58a1f2b46368130b078816a981acefc17b95207 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Fri, 20 Sep 2024 16:52:27 +0200 Subject: [PATCH 4/6] refactor: Visualization3D location and API (#3622) This PR - Moves some of the visualization logic from helper functions into member functions (`Surface`, `Volume`, Polyhedron`) - Updates the `Color` struct used in `ViewConfig` to be more versatile. --- Core/include/Acts/Geometry/Polyhedron.hpp | 6 ++ Core/include/Acts/Geometry/Volume.hpp | 7 ++ Core/include/Acts/Surfaces/Surface.hpp | 4 + Core/include/Acts/Utilities/BoundingBox.hpp | 3 +- Core/include/Acts/Utilities/BoundingBox.ipp | 3 +- .../Acts/Visualization/IVisualization3D.hpp | 13 ++- .../Acts/Visualization/ObjVisualization3D.hpp | 15 +-- .../Acts/Visualization/PlyVisualization3D.hpp | 12 +-- .../include/Acts/Visualization/ViewConfig.hpp | 92 +++++++++++++++++-- .../detail/ObjVisualization3D.ipp | 24 ++--- .../detail/PlyVisualization3D.ipp | 12 +-- Core/src/Geometry/Polyhedron.cpp | 12 +++ Core/src/Geometry/Volume.cpp | 9 ++ Core/src/Surfaces/Surface.cpp | 8 ++ Core/src/Visualization/GeometryView3D.cpp | 25 +---- .../Geant4/src/SensitiveSurfaceMapper.cpp | 2 +- Examples/Io/Csv/src/CsvSeedWriter.cpp | 10 +- Examples/Io/Json/src/JsonSurfacesWriter.cpp | 1 + Examples/Python/src/Obj.cpp | 23 ++--- Examples/Python/src/Output.cpp | 7 ++ .../Core/Geometry/LayerCreatorTests.cpp | 1 + .../Core/Geometry/ProtoLayerHelperTests.cpp | 12 +-- .../Core/Utilities/BoundingBoxTest.cpp | 4 +- .../Visualization/Visualization3DTests.cpp | 25 ++++- .../Geant4DetectorSurfaceFactoryTests.cpp | 6 +- 25 files changed, 231 insertions(+), 105 deletions(-) diff --git a/Core/include/Acts/Geometry/Polyhedron.hpp b/Core/include/Acts/Geometry/Polyhedron.hpp index 69ae109c52d..e8a55d17d93 100644 --- a/Core/include/Acts/Geometry/Polyhedron.hpp +++ b/Core/include/Acts/Geometry/Polyhedron.hpp @@ -10,12 +10,15 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Geometry/Extent.hpp" +#include "Acts/Visualization/ViewConfig.hpp" #include #include namespace Acts { +class IVisualization3D; + /// @class Polyhedron /// /// Struct which contains a cartesian approximation for any surface type. @@ -79,5 +82,8 @@ struct Polyhedron { /// /// @return ranges that describe the space taken by this surface Extent extent(const Transform3& transform = Transform3::Identity()) const; + + void visualize(IVisualization3D& helper, + const ViewConfig& viewConfig = {}) const; }; } // namespace Acts diff --git a/Core/include/Acts/Geometry/Volume.hpp b/Core/include/Acts/Geometry/Volume.hpp index 65e3e8b9219..3a6a592ffb0 100644 --- a/Core/include/Acts/Geometry/Volume.hpp +++ b/Core/include/Acts/Geometry/Volume.hpp @@ -118,6 +118,13 @@ class Volume : public GeometryObject { bool operator==(const Volume& other) const; bool operator!=(const Volume& other) const; + /// Produces a 3D visualization of this volume + /// @param helper The visualization helper describing the output format + /// @param gctx The geometry context + /// @param viewConfig The view configuration + void visualize(IVisualization3D& helper, const GeometryContext& gctx, + const ViewConfig& viewConfig = {}) const; + protected: Transform3 m_transform; Transform3 m_itransform; diff --git a/Core/include/Acts/Surfaces/Surface.hpp b/Core/include/Acts/Surfaces/Surface.hpp index 1ca13d48600..d2f62e0bf31 100644 --- a/Core/include/Acts/Surfaces/Surface.hpp +++ b/Core/include/Acts/Surfaces/Surface.hpp @@ -25,6 +25,7 @@ #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Intersection.hpp" #include "Acts/Utilities/Result.hpp" +#include "Acts/Visualization/ViewConfig.hpp" #include #include @@ -484,6 +485,9 @@ class Surface : public virtual GeometryObject, virtual ActsMatrix<2, 3> localCartesianToBoundLocalDerivative( const GeometryContext& gctx, const Vector3& position) const = 0; + void visualize(IVisualization3D& helper, const GeometryContext& gctx, + const ViewConfig& viewConfig = {}) const; + protected: /// Output Method for std::ostream, to be overloaded by child classes /// diff --git a/Core/include/Acts/Utilities/BoundingBox.hpp b/Core/include/Acts/Utilities/BoundingBox.hpp index 22121fbfb07..aee5ec8d016 100644 --- a/Core/include/Acts/Utilities/BoundingBox.hpp +++ b/Core/include/Acts/Utilities/BoundingBox.hpp @@ -218,8 +218,7 @@ class AxisAlignedBoundingBox { /// @param helper The visualization helper to write to /// @param color The color to use for drawing /// @param trf An optional transform to apply first. - void draw(IVisualization3D& helper, - std::array color = {120, 120, 120}, + void draw(IVisualization3D& helper, Color color = {120, 120, 120}, const transform_type& trf = transform_type::Identity()) const requires(DIM == 3); diff --git a/Core/include/Acts/Utilities/BoundingBox.ipp b/Core/include/Acts/Utilities/BoundingBox.ipp index 8dcb2612b48..bce97e29825 100644 --- a/Core/include/Acts/Utilities/BoundingBox.ipp +++ b/Core/include/Acts/Utilities/BoundingBox.ipp @@ -353,8 +353,7 @@ Acts::AxisAlignedBoundingBox::transformed( template void Acts::AxisAlignedBoundingBox::draw( - IVisualization3D& helper, std::array color, - const transform_type& trf) const + IVisualization3D& helper, Color color, const transform_type& trf) const requires(DIM == 3) { static_assert(DIM == 3, "PLY output only supported in 3D"); diff --git a/Core/include/Acts/Visualization/IVisualization3D.hpp b/Core/include/Acts/Visualization/IVisualization3D.hpp index 96af6328979..b012fb6447c 100644 --- a/Core/include/Acts/Visualization/IVisualization3D.hpp +++ b/Core/include/Acts/Visualization/IVisualization3D.hpp @@ -11,11 +11,8 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Visualization/ViewConfig.hpp" -#include #include #include -#include -#include #include namespace Acts { @@ -27,11 +24,13 @@ class IVisualization3D { public: using FaceType = std::vector; + static constexpr Color s_defaultColor = {120, 120, 120}; + /// Draw a vertex at a given location and a color. /// @param vtx The vertex position /// @param color The color /// - virtual void vertex(const Vector3& vtx, ColorRGB color = {120, 120, 120}) = 0; + virtual void vertex(const Vector3& vtx, Color color = s_defaultColor) = 0; /// Draw a face that connects a list of vertices. /// @note Depending on the helper implementation, out of plane vertices might @@ -40,7 +39,7 @@ class IVisualization3D { /// @param color The color of the face /// virtual void face(const std::vector& vtxs, - ColorRGB color = {120, 120, 120}) = 0; + Color color = s_defaultColor) = 0; /// Draw a faces that connects a list of vertices - expert only /// @@ -52,7 +51,7 @@ class IVisualization3D { /// virtual void faces(const std::vector& vtxs, const std::vector& faces, - ColorRGB color = {120, 120, 120}) = 0; + Color color = s_defaultColor) = 0; /// Draw a line from a vertex to another /// @param a The start vertex @@ -60,7 +59,7 @@ class IVisualization3D { /// @param color The color of the line /// virtual void line(const Vector3& a, const Vector3& b, - ColorRGB color = {120, 120, 120}) = 0; + Color color = s_defaultColor) = 0; /// Write the content of the helper to an outstream. /// @param os The output stream for file diff --git a/Core/include/Acts/Visualization/ObjVisualization3D.hpp b/Core/include/Acts/Visualization/ObjVisualization3D.hpp index 79da56d3e9c..e7a65b62720 100644 --- a/Core/include/Acts/Visualization/ObjVisualization3D.hpp +++ b/Core/include/Acts/Visualization/ObjVisualization3D.hpp @@ -48,19 +48,20 @@ class ObjVisualization3D : public IVisualization3D { : m_outputPrecision(prec), m_outputScalor(scale) {} /// @copydoc Acts::IVisualization3D::vertex() - void vertex(const Vector3& vtx, ColorRGB color = {0, 0, 0}) final; + void vertex(const Vector3& vtx, Color color = s_defaultColor) final; /// @copydoc Acts::IVisualization3D::line() void line(const Vector3& a, const Vector3& b, - ColorRGB color = {0, 0, 0}) final; + Color color = s_defaultColor) final; /// @copydoc Acts::IVisualization3D::face() - void face(const std::vector& vtxs, ColorRGB color = {0, 0, 0}) final; + void face(const std::vector& vtxs, + Color color = s_defaultColor) final; /// @copydoc Acts::IVisualization3D::faces() void faces(const std::vector& vtxs, const std::vector& faces, - ColorRGB color = {0, 0, 0}) final; + Color color = s_defaultColor) final; /// @copydoc Acts::IVisualization3D::write(const std::filesystem::path&) const void write(const std::filesystem::path& path) const final; @@ -85,9 +86,9 @@ class ObjVisualization3D : public IVisualization3D { std::vector m_faces; std::vector m_lines; /// Map of colors to be written at given index position - std::map m_lineColors; - std::map m_vertexColors; - std::map m_faceColors; + std::map m_lineColors; + std::map m_vertexColors; + std::map m_faceColors; }; #ifndef DOXYGEN diff --git a/Core/include/Acts/Visualization/PlyVisualization3D.hpp b/Core/include/Acts/Visualization/PlyVisualization3D.hpp index 95f2fdacd28..f8a5bee466d 100644 --- a/Core/include/Acts/Visualization/PlyVisualization3D.hpp +++ b/Core/include/Acts/Visualization/PlyVisualization3D.hpp @@ -36,20 +36,20 @@ class PlyVisualization3D : public IVisualization3D { using VertexType = Eigen::Matrix; /// @copydoc Acts::IVisualization3D::vertex() - void vertex(const Vector3& vtx, ColorRGB color = {120, 120, 120}) final; + void vertex(const Vector3& vtx, Color color = {120, 120, 120}) final; /// @copydoc Acts::IVisualization3D::face() void face(const std::vector& vtxs, - ColorRGB color = {120, 120, 120}) final; + Color color = {120, 120, 120}) final; /// @copydoc Acts::IVisualization3D::faces() void faces(const std::vector& vtxs, const std::vector& faces, - ColorRGB color = {120, 120, 120}) final; + Color color = {120, 120, 120}) final; /// @copydoc Acts::IVisualization3D::line() void line(const Vector3& a, const Vector3& b, - ColorRGB color = {120, 120, 120}) final; + Color color = {120, 120, 120}) final; /// @copydoc Acts::IVisualization3D::write(const std::filesystem::path&) const void write(const std::filesystem::path& path) const final; @@ -61,9 +61,9 @@ class PlyVisualization3D : public IVisualization3D { void clear() final; private: - std::vector> m_vertices; + std::vector> m_vertices; std::vector m_faces; - std::vector, ColorRGB>> m_edges; + std::vector, Color>> m_edges; }; #ifndef DOXYGEN diff --git a/Core/include/Acts/Visualization/ViewConfig.hpp b/Core/include/Acts/Visualization/ViewConfig.hpp index 06288d368e7..cdda1e027c4 100644 --- a/Core/include/Acts/Visualization/ViewConfig.hpp +++ b/Core/include/Acts/Visualization/ViewConfig.hpp @@ -14,18 +14,98 @@ namespace Acts { -/// The color typedef. It's an array of three numbers [0, 255] -/// representing the RGB color values. -/// -using ColorRGB = std::array; +/// Struct describing a color. Internally, the color is represented using a +/// triplet of integers between 0 and 255 corresponding to red green and blue. +struct Color { + // Copy and move constructors are defaulted + Color() = default; + Color(const Color&) = default; + Color(Color&&) = default; + Color& operator=(const Color&) = default; + Color& operator=(Color&&) = default; + + /// Constructor from raw integer rgb values [0, 255] + /// @param r The red component + /// @param g The green component + /// @param b The blue component + constexpr Color(int r, int g, int b) : rgb{r, g, b} {} + + /// Constructor from array of integer rgb values [0, 255] + /// @param values The rgb values + constexpr explicit Color(std::array values) : rgb(values) {} + + /// Constructor from array of double rgb values [0, 1] + /// @param values The rgb values + constexpr explicit Color(std::array values) { + rgb[0] = static_cast(values[0] * 255); + rgb[1] = static_cast(values[1] * 255); + rgb[2] = static_cast(values[2] * 255); + } + + /// Constructor from raw double dgb values [0, 1] + /// @param r The red component + /// @param g The green component + /// @param b The blue component + constexpr Color(double r, double g, double b) + : Color{std::array{r, g, b}} {} + + /// Constructor from hex string. The expected format is `#RRGGBB` + /// @param hex The hex string + constexpr explicit Color(std::string_view hex) { + auto hexToInt = [](std::string_view hexStr) { + int value = 0; + std::stringstream ss; + ss << std::hex << hexStr; + ss >> value; + return value; + }; + + if (hex[0] == '#' && hex.size() == 7) { + rgb[0] = hexToInt(hex.substr(1, 2)); // Extract R component + rgb[1] = hexToInt(hex.substr(3, 2)); // Extract G component + rgb[2] = hexToInt(hex.substr(5, 2)); // Extract B component + } else { + throw std::invalid_argument{ + "Invalid hex color format. Expected format: #RRGGBB"}; + } + } + + /// Operator to access the color components + /// @param i The index of the component + /// @return The color component + int operator[](unsigned int i) const { return rgb.at(i); } + + /// Operator to access the color components + /// @param i The index of the component + /// @return The color component + int& operator[](unsigned int i) { return rgb.at(i); } + + /// Operator to compare two colors + /// @param lhs The first color + /// @param rhs The second color + /// @return True if the colors are equal + friend bool operator==(const Color& lhs, const Color& rhs) = default; + + /// Output stream operator + /// @param os The output stream + /// @param color The color to be printed + /// @return The output stream + friend std::ostream& operator<<(std::ostream& os, const Color& color) { + os << "[" << color.rgb[0] << ", " << color.rgb[1] << ", " << color.rgb[2] + << "]"; + return os; + } + + std::array rgb{}; +}; /// @brief Struct to concentrate all visualization configurations /// in order to harmonize visualization interfaces struct ViewConfig { /// Visible flag bool visible = true; - /// The RGB color for this object - ColorRGB color = {250, 0, 0}; + /// The color for this object + Color color = {250, 0, 0}; /// Out of plane drawing parameter for objects double offset = 0.1; /// The visual line thickness for this object diff --git a/Core/include/Acts/Visualization/detail/ObjVisualization3D.ipp b/Core/include/Acts/Visualization/detail/ObjVisualization3D.ipp index e43bbb11f19..b959eb9e18c 100644 --- a/Core/include/Acts/Visualization/detail/ObjVisualization3D.ipp +++ b/Core/include/Acts/Visualization/detail/ObjVisualization3D.ipp @@ -7,15 +7,15 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. template -void ObjVisualization3D::vertex(const Vector3& vtx, ColorRGB color) { +void ObjVisualization3D::vertex(const Vector3& vtx, Color color) { m_vertexColors[m_vertices.size()] = color; m_vertices.push_back(vtx.template cast()); } template void ObjVisualization3D::line(const Vector3& a, const Vector3& b, - ColorRGB color) { - if (color != ColorRGB{0, 0, 0}) { + Color color) { + if (color != Color{0, 0, 0}) { m_lineColors[m_lines.size()] = color; } // not implemented @@ -26,8 +26,8 @@ void ObjVisualization3D::line(const Vector3& a, const Vector3& b, template void ObjVisualization3D::face(const std::vector& vtxs, - ColorRGB color) { - if (color != ColorRGB{0, 0, 0}) { + Color color) { + if (color != Color{0, 0, 0}) { m_faceColors[m_faces.size()] = color; } FaceType idxs; @@ -42,16 +42,16 @@ void ObjVisualization3D::face(const std::vector& vtxs, template void ObjVisualization3D::faces(const std::vector& vtxs, const std::vector& faces, - ColorRGB color) { + Color color) { // No faces given - call the face() method if (faces.empty()) { face(vtxs, color); } else { - if (color != ColorRGB{0, 0, 0}) { + if (color != Color{0, 0, 0}) { m_faceColors[m_faces.size()] = color; } auto vtxoffs = m_vertices.size(); - if (color != ColorRGB{0, 0, 0}) { + if (color != Color{0, 0, 0}) { m_vertexColors[m_vertices.size()] = color; } m_vertices.insert(m_vertices.end(), vtxs.begin(), vtxs.end()); @@ -99,7 +99,7 @@ template void ObjVisualization3D::write(std::ostream& os, std::ostream& mos) const { std::map materials; - auto mixColor = [&](const ColorRGB& color) -> std::string { + auto mixColor = [&](const Color& color) -> std::string { std::string materialName; materialName = "material_"; materialName += std::to_string(color[0]) + std::string("_"); @@ -121,7 +121,7 @@ void ObjVisualization3D::write(std::ostream& os, std::ostream& mos) const { }; std::size_t iv = 0; - ColorRGB lastVertexColor = {0, 0, 0}; + Color lastVertexColor = {0, 0, 0}; for (const VertexType& vtx : m_vertices) { if (m_vertexColors.find(iv) != m_vertexColors.end()) { auto color = m_vertexColors.find(iv)->second; @@ -137,7 +137,7 @@ void ObjVisualization3D::write(std::ostream& os, std::ostream& mos) const { ++iv; } std::size_t il = 0; - ColorRGB lastLineColor = {0, 0, 0}; + Color lastLineColor = {0, 0, 0}; for (const LineType& ln : m_lines) { if (m_lineColors.find(il) != m_lineColors.end()) { auto color = m_lineColors.find(il)->second; @@ -150,7 +150,7 @@ void ObjVisualization3D::write(std::ostream& os, std::ostream& mos) const { ++il; } std::size_t is = 0; - ColorRGB lastFaceColor = {0, 0, 0}; + Color lastFaceColor = {0, 0, 0}; for (const FaceType& fc : m_faces) { if (m_faceColors.find(is) != m_faceColors.end()) { auto color = m_faceColors.find(is)->second; diff --git a/Core/include/Acts/Visualization/detail/PlyVisualization3D.ipp b/Core/include/Acts/Visualization/detail/PlyVisualization3D.ipp index c5c12b2dc89..30d69126b0e 100644 --- a/Core/include/Acts/Visualization/detail/PlyVisualization3D.ipp +++ b/Core/include/Acts/Visualization/detail/PlyVisualization3D.ipp @@ -7,13 +7,13 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. template -void PlyVisualization3D::vertex(const Vector3& vtx, ColorRGB color) { +void PlyVisualization3D::vertex(const Vector3& vtx, Color color) { m_vertices.emplace_back(vtx.template cast(), color); } template void PlyVisualization3D::face(const std::vector& vtxs, - ColorRGB color) { + Color color) { FaceType idxs; idxs.reserve(vtxs.size()); for (const auto& vtx : vtxs) { @@ -26,13 +26,13 @@ void PlyVisualization3D::face(const std::vector& vtxs, template void PlyVisualization3D::faces(const std::vector& vtxs, const std::vector& /*faces*/, - ColorRGB color) { + Color color) { face(vtxs, color); } template void PlyVisualization3D::line(const Vector3& a, const Vector3& b, - ColorRGB color) { + Color color) { vertex(a, color); std::size_t idx_a = m_vertices.size() - 1; vertex(b, color); @@ -73,7 +73,7 @@ void PlyVisualization3D::write(std::ostream& os) const { os << "property uchar blue\n"; os << "end_header\n"; - for (const std::pair& vtx : m_vertices) { + for (const std::pair& vtx : m_vertices) { os << vtx.first.x() << " " << vtx.first.y() << " " << vtx.first.z() << " "; os << vtx.second[0] << " " << vtx.second[1] << " " << vtx.second[2] << "\n"; } @@ -86,7 +86,7 @@ void PlyVisualization3D::write(std::ostream& os) const { os << "\n"; } - for (const std::pair, ColorRGB>& edge : + for (const std::pair, Color>& edge : m_edges) { std::pair idxs = edge.first; os << idxs.first << " " << idxs.second << " "; diff --git a/Core/src/Geometry/Polyhedron.cpp b/Core/src/Geometry/Polyhedron.cpp index 6663a49705a..437d8d951cb 100644 --- a/Core/src/Geometry/Polyhedron.cpp +++ b/Core/src/Geometry/Polyhedron.cpp @@ -10,6 +10,7 @@ #include "Acts/Surfaces/detail/VerticesHelper.hpp" #include "Acts/Utilities/BinningType.hpp" +#include "Acts/Visualization/IVisualization3D.hpp" #include #include @@ -96,3 +97,14 @@ Acts::Extent Acts::Polyhedron::extent(const Transform3& transform) const { } return extent; } + +void Acts::Polyhedron::visualize(IVisualization3D& helper, + const ViewConfig& viewConfig) const { + if (viewConfig.visible) { + if (!viewConfig.triangulate) { + helper.faces(vertices, faces, viewConfig.color); + } else { + helper.faces(vertices, triangularMesh, viewConfig.color); + } + } +} diff --git a/Core/src/Geometry/Volume.cpp b/Core/src/Geometry/Volume.cpp index a04cab7b6f7..fd521e11a58 100644 --- a/Core/src/Geometry/Volume.cpp +++ b/Core/src/Geometry/Volume.cpp @@ -130,4 +130,13 @@ bool Volume::operator==(const Volume& other) const { bool Volume::operator!=(const Volume& other) const { return !(*this == other); } + +void Volume::visualize(IVisualization3D& helper, const GeometryContext& gctx, + const ViewConfig& viewConfig) const { + auto bSurfaces = volumeBounds().orientedSurfaces(transform()); + for (const auto& bs : bSurfaces) { + bs.surface->visualize(helper, gctx, viewConfig); + } +} + } // namespace Acts diff --git a/Core/src/Surfaces/Surface.cpp b/Core/src/Surfaces/Surface.cpp index d6442dbaf49..8cb1c8a7b19 100644 --- a/Core/src/Surfaces/Surface.cpp +++ b/Core/src/Surfaces/Surface.cpp @@ -13,6 +13,7 @@ #include "Acts/Surfaces/detail/AlignmentHelper.hpp" #include "Acts/Utilities/JacobianHelpers.hpp" #include "Acts/Utilities/VectorHelpers.hpp" +#include "Acts/Visualization/ViewConfig.hpp" #include #include @@ -358,3 +359,10 @@ void Acts::Surface::assignSurfaceMaterial( void Acts::Surface::associateLayer(const Acts::Layer& lay) { m_associatedLayer = (&lay); } + +void Acts::Surface::visualize(IVisualization3D& helper, + const GeometryContext& gctx, + const ViewConfig& viewConfig) const { + Polyhedron polyhedron = polyhedronRepresentation(gctx, viewConfig.nSegments); + polyhedron.visualize(helper, viewConfig); +} diff --git a/Core/src/Visualization/GeometryView3D.cpp b/Core/src/Visualization/GeometryView3D.cpp index 0080ef6ec74..f6ee3427e38 100644 --- a/Core/src/Visualization/GeometryView3D.cpp +++ b/Core/src/Visualization/GeometryView3D.cpp @@ -51,27 +51,15 @@ ViewConfig s_viewLine = {.color = {0, 0, 220}}; void Acts::GeometryView3D::drawPolyhedron(IVisualization3D& helper, const Polyhedron& polyhedron, const ViewConfig& viewConfig) { - if (viewConfig.visible) { - if (!viewConfig.triangulate) { - helper.faces(polyhedron.vertices, polyhedron.faces, viewConfig.color); - } else { - helper.faces(polyhedron.vertices, polyhedron.triangularMesh, - viewConfig.color); - } - } + polyhedron.visualize(helper, viewConfig); } void Acts::GeometryView3D::drawSurface(IVisualization3D& helper, const Surface& surface, const GeometryContext& gctx, - const Transform3& transform, + const Transform3& /*transform*/, const ViewConfig& viewConfig) { - Polyhedron surfaceHedron = - surface.polyhedronRepresentation(gctx, viewConfig.nSegments); - if (!transform.isApprox(Transform3::Identity())) { - surfaceHedron.move(transform); - } - drawPolyhedron(helper, surfaceHedron, viewConfig); + surface.visualize(helper, gctx, viewConfig); } void Acts::GeometryView3D::drawSurfaceArray( @@ -163,12 +151,9 @@ void Acts::GeometryView3D::drawSurfaceArray( void Acts::GeometryView3D::drawVolume(IVisualization3D& helper, const Volume& volume, const GeometryContext& gctx, - const Transform3& transform, + const Transform3& /*transform*/, const ViewConfig& viewConfig) { - auto bSurfaces = volume.volumeBounds().orientedSurfaces(volume.transform()); - for (const auto& bs : bSurfaces) { - drawSurface(helper, *bs.surface, gctx, transform, viewConfig); - } + volume.visualize(helper, gctx, viewConfig); } void Acts::GeometryView3D::drawPortal(IVisualization3D& helper, diff --git a/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp b/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp index a452c817377..58cd3e6ba3c 100644 --- a/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp +++ b/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp @@ -66,7 +66,7 @@ namespace { void writeG4Polyhedron( Acts::IVisualization3D& visualizer, const G4Polyhedron& polyhedron, const Acts::Transform3& trafo = Acts::Transform3::Identity(), - Acts::ColorRGB color = {0, 0, 0}) { + Acts::Color color = {0, 0, 0}) { constexpr double convertLength = CLHEP::mm / Acts::UnitConstants::mm; for (int i = 1; i <= polyhedron.GetNoFacets(); ++i) { diff --git a/Examples/Io/Csv/src/CsvSeedWriter.cpp b/Examples/Io/Csv/src/CsvSeedWriter.cpp index 2b3be226c48..f406c327913 100644 --- a/Examples/Io/Csv/src/CsvSeedWriter.cpp +++ b/Examples/Io/Csv/src/CsvSeedWriter.cpp @@ -22,6 +22,7 @@ #include "ActsExamples/Utilities/Range.hpp" #include "ActsExamples/Validation/TrackClassification.hpp" +#include #include #include #include @@ -163,13 +164,8 @@ ActsExamples::ProcessCode ActsExamples::CsvSeedWriter::writeT( infoMap[toAdd.seedID] = toAdd; } - mos << "seed_id,particleId," - << "pT,eta,phi," - << "bX,bY,bZ," - << "mX,mY,mZ," - << "tX,tY,tZ," - << "good/duplicate/fake," - << "vertexZ,quality," + mos << "seed_id,particleId," << "pT,eta,phi," << "bX,bY,bZ," << "mX,mY,mZ," + << "tX,tY,tZ," << "good/duplicate/fake," << "vertexZ,quality," << "Hits_ID" << '\n'; for (auto& [id, info] : infoMap) { diff --git a/Examples/Io/Json/src/JsonSurfacesWriter.cpp b/Examples/Io/Json/src/JsonSurfacesWriter.cpp index 99176f742b3..01546a12ebe 100644 --- a/Examples/Io/Json/src/JsonSurfacesWriter.cpp +++ b/Examples/Io/Json/src/JsonSurfacesWriter.cpp @@ -26,6 +26,7 @@ #include "ActsExamples/Utilities/Paths.hpp" #include +#include #include #include #include diff --git a/Examples/Python/src/Obj.cpp b/Examples/Python/src/Obj.cpp index 6fbd8a48682..2a36d06ad09 100644 --- a/Examples/Python/src/Obj.cpp +++ b/Examples/Python/src/Obj.cpp @@ -40,35 +40,29 @@ void addObj(Context& ctx) { /// mex.def("writeSurfacesObj", [](const std::vector>& surfaces, - const GeometryContext& viewContext, - const std::array& viewRgb, unsigned int viewSegements, + const GeometryContext& viewContext, const ViewConfig& viewConfig, const std::string& fileName) { - Acts::ViewConfig sConfig = Acts::ViewConfig{.color = viewRgb}; - sConfig.nSegments = viewSegements; Acts::GeometryView3D view3D; Acts::ObjVisualization3D obj; for (const auto& surface : surfaces) { view3D.drawSurface(obj, *surface, viewContext, - Acts::Transform3::Identity(), sConfig); + Acts::Transform3::Identity(), viewConfig); } obj.write(fileName); }); mex.def("writeVolumesObj", [](const std::vector>& Volumes, - const GeometryContext& viewContext, - const std::array& viewRgb, unsigned int viewSegements, + const GeometryContext& viewContext, const ViewConfig& viewConfig, const std::string& fileName) { - Acts::ViewConfig sConfig = Acts::ViewConfig{.color = viewRgb}; - sConfig.nSegments = viewSegements; Acts::GeometryView3D view3D; Acts::ObjVisualization3D obj; for (const auto& volume : Volumes) { view3D.drawDetectorVolume(obj, *volume, viewContext, Acts::Transform3::Identity(), - sConfig); + viewConfig); } obj.write(fileName); }); @@ -76,22 +70,19 @@ void addObj(Context& ctx) { [](const std::vector>& surfaces, const std::vector>& Volumes, - const GeometryContext& viewContext, - const std::array& viewRgb, unsigned int viewSegements, + const GeometryContext& viewContext, const ViewConfig& viewConfig, const std::string& fileName) { - Acts::ViewConfig sConfig = Acts::ViewConfig{.color = viewRgb}; - sConfig.nSegments = viewSegements; Acts::GeometryView3D view3D; Acts::ObjVisualization3D obj; for (const auto& volume : Volumes) { view3D.drawDetectorVolume(obj, *volume, viewContext, Acts::Transform3::Identity(), - sConfig); + viewConfig); } for (const auto& surface : surfaces) { view3D.drawSurface(obj, *surface, viewContext, - Acts::Transform3::Identity(), sConfig); + Acts::Transform3::Identity(), viewConfig); } obj.write(fileName); }); diff --git a/Examples/Python/src/Output.cpp b/Examples/Python/src/Output.cpp index d12e98294ec..7e78dbcde9b 100644 --- a/Examples/Python/src/Output.cpp +++ b/Examples/Python/src/Output.cpp @@ -125,6 +125,13 @@ void addOutput(Context& ctx) { ACTS_PYTHON_STRUCT_END(); patchKwargsConstructor(c); + + py::class_(m, "Color") + .def(py::init<>()) + .def(py::init()) + .def(py::init()) + .def(py::init()) + .def_readonly("rgb", &Color::rgb); } { diff --git a/Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp b/Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp index fcf862ef126..deb72b97159 100644 --- a/Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp +++ b/Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include diff --git a/Tests/UnitTests/Core/Geometry/ProtoLayerHelperTests.cpp b/Tests/UnitTests/Core/Geometry/ProtoLayerHelperTests.cpp index fd9bd8cd987..d8ba622257e 100644 --- a/Tests/UnitTests/Core/Geometry/ProtoLayerHelperTests.cpp +++ b/Tests/UnitTests/Core/Geometry/ProtoLayerHelperTests.cpp @@ -78,11 +78,11 @@ BOOST_AUTO_TEST_CASE(ProtoLayerHelperTests) { BOOST_CHECK_EQUAL(radialLayers.size(), 4); - std::vector sortedColors = {{102, 204, 255}, - {102, 255, 153}, - {255, 204, 102}, - {204, 102, 0}, - {278, 123, 55}}; + std::vector sortedColors = {{102, 204, 255}, + {102, 255, 153}, + {255, 204, 102}, + {204, 102, 0}, + {278, 123, 55}}; std::size_t il = 0; for (auto& layer : radialLayers) { @@ -184,7 +184,7 @@ BOOST_AUTO_TEST_CASE(ProtoLayerHelperTests) { ProtoLayerHelper::SortingConfig(BinningValue::binR, 1.)); BOOST_CHECK_EQUAL(rSorted.size(), 3); - ColorRGB dColor = {0, 0, 0}; + Color dColor = {0, 0, 0}; int ir = 0; for (auto& rBatch : rSorted) { diff --git a/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp b/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp index 6b6dcd3847d..93d6ae5766e 100644 --- a/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp +++ b/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp @@ -887,7 +887,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { min + i * step, min + j * step, min + k * step); Box bb(&o, pos, size); - std::array color = {255, 0, 0}; + Color color = {255, 0, 0}; if (bb.intersect(fr)) { color = {0, 255, 0}; @@ -1150,7 +1150,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { min + i * step, min + j * step, min + k * step); Box bb(&o, pos, size); - std::array color = {255, 0, 0}; + Color color = {255, 0, 0}; if (bb.intersect(fr)) { color = {0, 255, 0}; diff --git a/Tests/UnitTests/Core/Visualization/Visualization3DTests.cpp b/Tests/UnitTests/Core/Visualization/Visualization3DTests.cpp index 09bade86ae8..e8ae4a82c46 100644 --- a/Tests/UnitTests/Core/Visualization/Visualization3DTests.cpp +++ b/Tests/UnitTests/Core/Visualization/Visualization3DTests.cpp @@ -298,7 +298,8 @@ BOOST_AUTO_TEST_CASE(ObjOutputTest) { output << obj; - std::string exp = R"(v 1 0 0 + std::string exp = R"(usemtl material_120_120_120 +v 1 0 0 )"; BOOST_CHECK(output.is_equal(exp)); @@ -307,15 +308,35 @@ BOOST_AUTO_TEST_CASE(ObjOutputTest) { obj.face({{1, 0, 0}, {1, 1, 0}, {0, 1, 0}}); output << obj; - exp = R"(v 1 0 0 + exp = R"(usemtl material_120_120_120 +v 1 0 0 v 1 1 0 v 0 1 0 +usemtl material_120_120_120 f 1 2 3 )"; BOOST_CHECK(output.is_equal(exp)); } +BOOST_AUTO_TEST_CASE(ColorTests) { + Color red{"#ff0000"}; + BOOST_CHECK_EQUAL(red, Color(255, 0, 0)); + + Color green{"#00ff00"}; + BOOST_CHECK_EQUAL(green, Color(0, 255, 0)); + + Color blue{"#0000ff"}; + BOOST_CHECK_EQUAL(blue, Color(0, 0, 255)); + + Color grey{"#808080"}; + BOOST_CHECK_EQUAL(grey, Color(128, 128, 128)); + BOOST_CHECK_EQUAL(grey, Color(std::array{128, 128, 128})); + BOOST_CHECK_EQUAL(grey, + Color(std::array{128 / 255.0, 128 / 255.0, 128 / 255.0})); + BOOST_CHECK_EQUAL(grey, Color(128 / 255.0, 128 / 255.0, 128 / 255.0)); +} + BOOST_AUTO_TEST_SUITE_END() } // namespace Acts::Test diff --git a/Tests/UnitTests/Plugins/Geant4/Geant4DetectorSurfaceFactoryTests.cpp b/Tests/UnitTests/Plugins/Geant4/Geant4DetectorSurfaceFactoryTests.cpp index 87c9914755f..6fd9606b6a1 100644 --- a/Tests/UnitTests/Plugins/Geant4/Geant4DetectorSurfaceFactoryTests.cpp +++ b/Tests/UnitTests/Plugins/Geant4/Geant4DetectorSurfaceFactoryTests.cpp @@ -174,11 +174,11 @@ BOOST_AUTO_TEST_CASE(Geant4DetecturSurfaceFactory_Transforms) { const auto& [el, surf] = val; Acts::ViewConfig vCfg; if (k == 0) { - vCfg.color = Acts::ColorRGB({0, 255, 0}); + vCfg.color = {0, 255, 0}; } else if (k == 1) { - vCfg.color = Acts::ColorRGB({255, 0, 0}); + vCfg.color = {255, 0, 0}; } else if (k == 2) { - vCfg.color = Acts::ColorRGB({0, 255, 255}); + vCfg.color = {0, 255, 255}; } Acts::GeometryView3D::drawSurface(obj, *surf, gctx, Acts::Transform3::Identity(), vCfg); From 76a8f7915f0ae99845d5cb39f007958ae8e4116c Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Fri, 20 Sep 2024 19:24:14 +0200 Subject: [PATCH 5/6] refactor(geo): Portal(Link)+Surface verbosity reduction (#3636) Reduces the output level for some outputs. Some where erroneously WARNINGs, some were DEBUG where VERBOSE makes more sense. --- Core/src/Geometry/GridPortalLinkMerging.cpp | 4 ++-- Core/src/Geometry/Portal.cpp | 4 ++-- Core/src/Geometry/PortalLinkBase.cpp | 2 +- Core/src/Surfaces/CylinderSurface.cpp | 4 ++-- Core/src/Surfaces/DiscSurface.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Core/src/Geometry/GridPortalLinkMerging.cpp b/Core/src/Geometry/GridPortalLinkMerging.cpp index 51dfd89548b..80ad2b78ca9 100644 --- a/Core/src/Geometry/GridPortalLinkMerging.cpp +++ b/Core/src/Geometry/GridPortalLinkMerging.cpp @@ -213,11 +213,11 @@ std::unique_ptr colinearMerge( auto mergedPortalLink = mergeVariableLocal(); return mergedPortalLink; } else if (aType == AxisType::Equidistant && bType == AxisType::Variable) { - ACTS_WARNING("===> mixed merged"); + ACTS_VERBOSE("===> mixed merged"); auto mergedPortalLink = mergeVariableLocal(); return mergedPortalLink; } else { - ACTS_WARNING("===> mixed merged"); + ACTS_VERBOSE("===> mixed merged"); auto mergedPortalLink = mergeVariableLocal(); return mergedPortalLink; } diff --git a/Core/src/Geometry/Portal.cpp b/Core/src/Geometry/Portal.cpp index 4b1e65356af..fac9041b40f 100644 --- a/Core/src/Geometry/Portal.cpp +++ b/Core/src/Geometry/Portal.cpp @@ -175,7 +175,7 @@ const RegularSurface& Portal::surface() const { Portal Portal::merge(const GeometryContext& gctx, Portal& aPortal, Portal& bPortal, BinningValue direction, const Logger& logger) { - ACTS_DEBUG("Merging to portals along " << direction); + ACTS_VERBOSE("Merging two portals along " << direction); if (&aPortal == &bPortal) { ACTS_ERROR("Cannot merge a portal with itself"); @@ -238,7 +238,7 @@ Portal Portal::merge(const GeometryContext& gctx, Portal& aPortal, Portal Portal::fuse(const GeometryContext& gctx, Portal& aPortal, Portal& bPortal, const Logger& logger) { - ACTS_DEBUG("Fusing two portals"); + ACTS_VERBOSE("Fusing two portals"); if (&aPortal == &bPortal) { ACTS_ERROR("Cannot merge a portal with itself"); throw PortalMergingException{}; diff --git a/Core/src/Geometry/PortalLinkBase.cpp b/Core/src/Geometry/PortalLinkBase.cpp index 9a6be75794c..46d3d25e202 100644 --- a/Core/src/Geometry/PortalLinkBase.cpp +++ b/Core/src/Geometry/PortalLinkBase.cpp @@ -64,7 +64,7 @@ void PortalLinkBase::checkMergePreconditions(const PortalLinkBase& a, std::unique_ptr PortalLinkBase::merge( std::unique_ptr a, std::unique_ptr b, BinningValue direction, const Logger& logger) { - ACTS_DEBUG("Merging two arbitrary portals"); + ACTS_VERBOSE("Merging two arbitrary portals"); ACTS_VERBOSE(" - a: " << *a); ACTS_VERBOSE(" - b: " << *b); diff --git a/Core/src/Surfaces/CylinderSurface.cpp b/Core/src/Surfaces/CylinderSurface.cpp index b53e6bf1b7d..08c614d9879 100644 --- a/Core/src/Surfaces/CylinderSurface.cpp +++ b/Core/src/Surfaces/CylinderSurface.cpp @@ -374,8 +374,8 @@ Acts::CylinderSurface::mergedWith(const CylinderSurface& other, const Logger& logger) const { using namespace Acts::UnitLiterals; - ACTS_DEBUG("Merging cylinder surfaces in " << binningValueName(direction) - << " direction"); + ACTS_VERBOSE("Merging cylinder surfaces in " << binningValueName(direction) + << " direction"); if (m_associatedDetElement != nullptr || other.m_associatedDetElement != nullptr) { diff --git a/Core/src/Surfaces/DiscSurface.cpp b/Core/src/Surfaces/DiscSurface.cpp index 140047a5785..f75b5ce463b 100644 --- a/Core/src/Surfaces/DiscSurface.cpp +++ b/Core/src/Surfaces/DiscSurface.cpp @@ -385,7 +385,7 @@ Acts::DiscSurface::mergedWith(const DiscSurface& other, BinningValue direction, const Logger& logger) const { using namespace Acts::UnitLiterals; - ACTS_DEBUG("Merging disc surfaces in " << direction << " direction"); + ACTS_VERBOSE("Merging disc surfaces in " << direction << " direction"); if (m_associatedDetElement != nullptr || other.m_associatedDetElement != nullptr) { From 4aa7d19be8b20d64d4646df01d613f29bad7ef1e Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Fri, 20 Sep 2024 20:21:36 +0200 Subject: [PATCH 6/6] feat(util): Add GraphViz helper types (#3635) --- Core/include/Acts/Utilities/GraphViz.hpp | 110 +++++++ Core/src/Utilities/CMakeLists.txt | 1 + Core/src/Utilities/GraphViz.cpp | 286 ++++++++++++++++++ Tests/UnitTests/Core/Utilities/CMakeLists.txt | 1 + .../Core/Utilities/GraphVizTests.cpp | 54 ++++ 5 files changed, 452 insertions(+) create mode 100644 Core/include/Acts/Utilities/GraphViz.hpp create mode 100644 Core/src/Utilities/GraphViz.cpp create mode 100644 Tests/UnitTests/Core/Utilities/GraphVizTests.cpp diff --git a/Core/include/Acts/Utilities/GraphViz.hpp b/Core/include/Acts/Utilities/GraphViz.hpp new file mode 100644 index 00000000000..2aeb75dba5f --- /dev/null +++ b/Core/include/Acts/Utilities/GraphViz.hpp @@ -0,0 +1,110 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#pragma once + +#include +#include + +namespace Acts::GraphViz { + +enum class Shape { + Box, + Polygon, + Ellipse, + Oval, + Circle, + Point, + Egg, + Triangle, + Plaintext, + Plain, + Diamond, + Trapezium, + Parallelogram, + House, + Pentagon, + Hexagon, + Septagon, + Octagon, + DoubleCircle, + DoubleOctagon, + TripleOctagon, + InvTriangle, + InvTrapezium, + InvHouse, + Mdiamond, + Msquare, + Mcircle, + Rect, + Rectangle, + Square, + Star, + None, + Underline, + Cylinder, + Note, + Tab, + Folder, + Box3d, + Component, + Promoter, + Cds, + Terminator, + Utr, + PrimerSite, + RestrictionSite, + FivePOverhang, + ThreePOverhang, + NOverhang, + Assembly, + Signature, + Insulator, + Ribosite, + RNAStab, + ProteaseSite, + ProteinStab, + RPromoter, + RArrow, + LArrow, + LPromoter +}; + +std::ostream& operator<<(std::ostream& os, const Shape& shape); + +enum class Style { + Filled, + Invisible, + Diagonals, + Rounded, + Dashed, + Dotted, + Solid, + Bold +}; + +std::ostream& operator<<(std::ostream& os, const Style& style); + +struct Node { + std::string id; + std::string label; + Shape shape = Shape::Ellipse; + std::vector