Skip to content
Snippets Groups Projects
Commit 1c4c3d2e authored by Andreas Salzburger's avatar Andreas Salzburger
Browse files

addressing first round of MR comments

parent 3d550dd1
No related branches found
No related tags found
1 merge request!777Promote Polyhedron to Surface base class
Pipeline #1489941 passed
...@@ -8,16 +8,17 @@ ...@@ -8,16 +8,17 @@
#pragma once #pragma once
#include <iostream>
#include <utility>
#include <vector>
#include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/BinningType.hpp"
#include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/Definitions.hpp"
#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Helpers.hpp"
#include <iosfwd>
#include <utility>
#include <vector>
namespace Acts { namespace Acts {
using range_type = std::pair<double, double>; using Range = std::pair<double, double>;
// @brief Extent in space // @brief Extent in space
/// ///
...@@ -29,22 +30,21 @@ struct Extent { ...@@ -29,22 +30,21 @@ struct Extent {
static constexpr double maxval = std::numeric_limits<double>::max(); static constexpr double maxval = std::numeric_limits<double>::max();
/// Start value /// Start value
static constexpr range_type maxrange = {maxval, -maxval}; static constexpr Range maxrange = {maxval, -maxval};
// The different ranges // The different ranges
std::vector<range_type> ranges = std::vector<range_type>(9, maxrange); std::vector<Range> ranges = std::vector<Range>(9, maxrange);
// Constructor // Constructor
Extent() = default; Extent() = default;
/// Merge another extent in - using operator+= /// Extend with another extent
/// @param other is the source Extent /// @param other is the source Extent
Extent& operator+=(const Extent& other) { void extend(const Extent& other) {
for (auto ir = 0; ir < other.ranges.size(); ++ir) { for (auto ir = 0; ir < other.ranges.size(); ++ir) {
ranges[ir].first = std::min(ranges[ir].first, other.ranges[ir].first); ranges[ir].first = std::min(ranges[ir].first, other.ranges[ir].first);
ranges[ir].second = std::max(ranges[ir].second, other.ranges[ir].second); ranges[ir].second = std::max(ranges[ir].second, other.ranges[ir].second);
} }
return (*this);
} }
/// Convert to output stream for screen output /// Convert to output stream for screen output
...@@ -79,9 +79,9 @@ struct Extent { ...@@ -79,9 +79,9 @@ struct Extent {
ranges[bval].first = std::min(value, ranges[bval].first); ranges[bval].first = std::min(value, ranges[bval].first);
ranges[bval].second = std::max(value, ranges[bval].second); ranges[bval].second = std::max(value, ranges[bval].second);
}; };
// Walk through the binnin parameters // Walk through the binning parameters
for (int bval = 0; bval < binValues; ++bval) { for (int bval = 0; bval < binValues; ++bval) {
BinningValue bValue = (BinningValue)bval; BinningValue bValue = static_cast<BinningValue>(bval);
minMax(bValue, VectorHelpers::cast(vtx, bValue)); minMax(bValue, VectorHelpers::cast(vtx, bValue));
} }
} }
......
...@@ -8,13 +8,14 @@ ...@@ -8,13 +8,14 @@
#pragma once #pragma once
#include <limits>
#include <vector>
#include "Acts/Geometry/Extent.hpp" #include "Acts/Geometry/Extent.hpp"
#include "Acts/Surfaces/BoundaryCheck.hpp" #include "Acts/Surfaces/BoundaryCheck.hpp"
#include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/Definitions.hpp"
#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Helpers.hpp"
#include <limits>
#include <vector>
namespace Acts { namespace Acts {
/// @class Polyhedron /// @class Polyhedron
...@@ -27,7 +28,7 @@ namespace Acts { ...@@ -27,7 +28,7 @@ namespace Acts {
/// that need to be connected to form a face. /// that need to be connected to form a face.
/// This allows the @c objString method to produce a ready-to-go obj output. /// This allows the @c objString method to produce a ready-to-go obj output.
struct Polyhedron { struct Polyhedron {
using face_type = std::vector<size_t>; using Face = std::vector<size_t>;
/// Default constructor /// Default constructor
Polyhedron() = default; Polyhedron() = default;
...@@ -39,8 +40,8 @@ struct Polyhedron { ...@@ -39,8 +40,8 @@ struct Polyhedron {
/// @param radialCheck A dedicated check for radial extent done /// @param radialCheck A dedicated check for radial extent done
/// @note This creates copies of the input vectors /// @note This creates copies of the input vectors
Polyhedron(const std::vector<Vector3D>& verticesIn, Polyhedron(const std::vector<Vector3D>& verticesIn,
const std::vector<face_type>& facesIn, const std::vector<Face>& facesIn,
const std::vector<face_type>& triangularMeshIn, const std::vector<Face>& triangularMeshIn,
bool radialCheck = false) bool radialCheck = false)
: vertices(verticesIn), : vertices(verticesIn),
faces(facesIn), faces(facesIn),
...@@ -52,12 +53,12 @@ struct Polyhedron { ...@@ -52,12 +53,12 @@ struct Polyhedron {
/// List of faces connecting the vertices. /// List of faces connecting the vertices.
/// each face is a list of vertices v /// each face is a list of vertices v
/// corresponding to the vertex vector above /// corresponding to the vertex vector above
std::vector<face_type> faces; std::vector<Face> faces;
/// List of faces connecting the vertices. /// List of faces connecting the vertices.
/// each face is a list of vertices v /// each face is a list of vertices v
/// - in this case restricted to a triangular representation /// - in this case restricted to a triangular representation
std::vector<face_type> triangularMesh; std::vector<Face> triangularMesh;
/// Add another Polyhedrons /// Add another Polyhedrons
/// ///
......
...@@ -129,7 +129,7 @@ class AnnulusBounds : public DiscBounds { ...@@ -129,7 +129,7 @@ class AnnulusBounds : public DiscBounds {
std::vector<Vector2D> corners() const; std::vector<Vector2D> corners() const;
/// This method returns the xy coordinates of the four corners of the /// This method returns the xy coordinates of the four corners of the
/// bounds in module coorindates (in X/y) /// bounds in module coorindates (in x/y)
/// Starting from the upper right (max R, pos locX) and proceding clock-wise /// Starting from the upper right (max R, pos locX) and proceding clock-wise
/// i.e. (max R; pos locX), (min R; pos locX), (min R; neg loc X), (max R: neg /// i.e. (max R; pos locX), (min R; pos locX), (min R; neg loc X), (max R: neg
/// locX) /// locX)
......
...@@ -20,7 +20,7 @@ namespace detail { ...@@ -20,7 +20,7 @@ namespace detail {
/// @brief Helper for writing out faces for polyhedron representation /// @brief Helper for writing out faces for polyhedron representation
struct FacesHelper { struct FacesHelper {
using FaceVector = std::vector<Polyhedron::face_type>; using FaceVector = std::vector<Polyhedron::Face>;
/// @brief This method words for all convex type surface setups /// @brief This method words for all convex type surface setups
/// It includes: /// It includes:
......
...@@ -8,12 +8,11 @@ ...@@ -8,12 +8,11 @@
#include "Acts/Geometry/Extent.hpp" #include "Acts/Geometry/Extent.hpp"
// STD/STL #include <ostream>
#include <iostream>
std::ostream& Acts::Extent::toStream(std::ostream& sl) const { std::ostream& Acts::Extent::toStream(std::ostream& sl) const {
sl << "Extent in space : " << std::endl; sl << "Extent in space : " << std::endl;
for (size_t ib = 0; ib < size_t(binValues); ++ib) { for (size_t ib = 0; ib < static_cast<size_t>(binValues); ++ib) {
sl << " - value :" << std::setw(10) << binningValueNames[ib] sl << " - value :" << std::setw(10) << binningValueNames[ib]
<< " | range = [" << ranges[ib].first << ", " << ranges[ib].second << "]" << " | range = [" << ranges[ib].first << ", " << ranges[ib].second << "]"
<< std::endl; << std::endl;
......
...@@ -14,10 +14,10 @@ Acts::Polyhedron& Acts::Polyhedron::operator+=(const Acts::Polyhedron& other) { ...@@ -14,10 +14,10 @@ Acts::Polyhedron& Acts::Polyhedron::operator+=(const Acts::Polyhedron& other) {
size_t cvert = vertices.size(); size_t cvert = vertices.size();
vertices.insert(vertices.end(), other.vertices.begin(), other.vertices.end()); vertices.insert(vertices.end(), other.vertices.begin(), other.vertices.end());
/// Add the new faces with offsets /// Add the new faces with offsets
auto join = [&](std::vector<face_type>& existing, auto join = [&](std::vector<Face>& existing,
const std::vector<face_type>& additional) -> void { const std::vector<Face>& additional) -> void {
for (const auto& aface : additional) { for (const auto& aface : additional) {
face_type nface = aface; Face nface = aface;
std::transform(nface.begin(), nface.end(), nface.begin(), std::transform(nface.begin(), nface.end(), nface.begin(),
[&](size_t x) { return (x + cvert); }); [&](size_t x) { return (x + cvert); });
existing.push_back(nface); existing.push_back(nface);
......
...@@ -198,8 +198,8 @@ Acts::Polyhedron Acts::ConeSurface::polyhedronRepresentation( ...@@ -198,8 +198,8 @@ Acts::Polyhedron Acts::ConeSurface::polyhedronRepresentation(
const GeometryContext& gctx, size_t lseg) const { const GeometryContext& gctx, size_t lseg) const {
// Prepare vertices and faces // Prepare vertices and faces
std::vector<Vector3D> vertices; std::vector<Vector3D> vertices;
std::vector<Polyhedron::face_type> faces; std::vector<Polyhedron::Face> faces;
std::vector<Polyhedron::face_type> triangularMesh; std::vector<Polyhedron::Face> triangularMesh;
if (bounds().minZ() == -std::numeric_limits<double>::infinity() or if (bounds().minZ() == -std::numeric_limits<double>::infinity() or
bounds().maxZ() == std::numeric_limits<double>::infinity()) { bounds().maxZ() == std::numeric_limits<double>::infinity()) {
......
...@@ -189,8 +189,8 @@ Acts::Polyhedron Acts::CylinderSurface::polyhedronRepresentation( ...@@ -189,8 +189,8 @@ Acts::Polyhedron Acts::CylinderSurface::polyhedronRepresentation(
const GeometryContext& gctx, size_t lseg) const { const GeometryContext& gctx, size_t lseg) const {
// Prepare vertices and faces // Prepare vertices and faces
std::vector<Vector3D> vertices; std::vector<Vector3D> vertices;
std::vector<Polyhedron::face_type> faces; std::vector<Polyhedron::Face> faces;
std::vector<Polyhedron::face_type> triangularMesh; std::vector<Polyhedron::Face> triangularMesh;
auto ctrans = transform(gctx); auto ctrans = transform(gctx);
bool fullCylinder = bounds().coversFullAzimuth(); bool fullCylinder = bounds().coversFullAzimuth();
......
...@@ -156,8 +156,8 @@ Acts::Polyhedron Acts::DiscSurface::polyhedronRepresentation( ...@@ -156,8 +156,8 @@ Acts::Polyhedron Acts::DiscSurface::polyhedronRepresentation(
const GeometryContext& gctx, size_t lseg) const { const GeometryContext& gctx, size_t lseg) const {
// Prepare vertices and faces // Prepare vertices and faces
std::vector<Vector3D> vertices; std::vector<Vector3D> vertices;
std::vector<Polyhedron::face_type> faces; std::vector<Polyhedron::Face> faces;
std::vector<Polyhedron::face_type> triangularMesh; std::vector<Polyhedron::Face> triangularMesh;
// Understand the disc // Understand the disc
bool fullDisc = m_bounds->coversFullAzimuth(); bool fullDisc = m_bounds->coversFullAzimuth();
......
...@@ -72,8 +72,8 @@ Acts::Polyhedron Acts::PerigeeSurface::polyhedronRepresentation( ...@@ -72,8 +72,8 @@ Acts::Polyhedron Acts::PerigeeSurface::polyhedronRepresentation(
const GeometryContext& gctx, size_t /*lseg*/) const { const GeometryContext& gctx, size_t /*lseg*/) const {
// Prepare vertices and faces // Prepare vertices and faces
std::vector<Vector3D> vertices; std::vector<Vector3D> vertices;
std::vector<Polyhedron::face_type> faces; std::vector<Polyhedron::Face> faces;
std::vector<Polyhedron::face_type> triangularMesh; std::vector<Polyhedron::Face> triangularMesh;
const Transform3D& ctransform = transform(gctx); const Transform3D& ctransform = transform(gctx);
Vector3D left(0, 0, -100.); Vector3D left(0, 0, -100.);
......
...@@ -122,8 +122,8 @@ Acts::Polyhedron Acts::PlaneSurface::polyhedronRepresentation( ...@@ -122,8 +122,8 @@ Acts::Polyhedron Acts::PlaneSurface::polyhedronRepresentation(
const GeometryContext& gctx, size_t lseg) const { const GeometryContext& gctx, size_t lseg) const {
// Prepare vertices and faces // Prepare vertices and faces
std::vector<Vector3D> vertices; std::vector<Vector3D> vertices;
std::vector<Polyhedron::face_type> faces; std::vector<Polyhedron::Face> faces;
std::vector<Polyhedron::face_type> triangularMesh; std::vector<Polyhedron::Face> triangularMesh;
// If you have bounds you can create a polyhedron representation // If you have bounds you can create a polyhedron representation
if (m_bounds) { if (m_bounds) {
......
...@@ -59,8 +59,8 @@ Acts::Polyhedron Acts::StrawSurface::polyhedronRepresentation( ...@@ -59,8 +59,8 @@ Acts::Polyhedron Acts::StrawSurface::polyhedronRepresentation(
const GeometryContext& gctx, size_t lseg) const { const GeometryContext& gctx, size_t lseg) const {
// Prepare vertices and faces // Prepare vertices and faces
std::vector<Vector3D> vertices; std::vector<Vector3D> vertices;
std::vector<Polyhedron::face_type> faces; std::vector<Polyhedron::Face> faces;
std::vector<Polyhedron::face_type> triangularMesh; std::vector<Polyhedron::Face> triangularMesh;
const Transform3D& ctransform = transform(gctx); const Transform3D& ctransform = transform(gctx);
// Draw the bounds if more than one segment are chosen // Draw the bounds if more than one segment are chosen
......
...@@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE(ExtentTest) { ...@@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE(ExtentTest) {
// Create a second Extent // Create a second Extent
Extent otherExt; Extent otherExt;
otherExt += gExt; otherExt.extend(gExt);
CHECK_CLOSE_ABS(otherExt.min(binX), 15_mm, 1e-6); CHECK_CLOSE_ABS(otherExt.min(binX), 15_mm, 1e-6);
CHECK_CLOSE_ABS(otherExt.max(binX), 18_mm, 1e-6); CHECK_CLOSE_ABS(otherExt.max(binX), 18_mm, 1e-6);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment