Skip to content

Commit

Permalink
Merge branch 'main' into DoNotConsiderOverUnder
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Oct 9, 2024
2 parents aa650b9 + e6400b6 commit 9a3e5b5
Show file tree
Hide file tree
Showing 52 changed files with 1,195 additions and 678 deletions.
32 changes: 30 additions & 2 deletions Core/include/Acts/Geometry/ProtoLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct ProtoLayer {
/// The envelope parameters
ExtentEnvelope envelope = ExtentEnvelope::Zero();

/// The local transform
Transform3 transform = Transform3::Identity();

/// Constructor
///
/// Loops over a provided vector of surface and calculates the various
Expand All @@ -41,8 +44,10 @@ struct ProtoLayer {
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param surfaces The vector of surfaces to consider
/// @param transformIn The local transform to evaluate the sizing in
ProtoLayer(const GeometryContext& gctx,
const std::vector<const Surface*>& surfaces);
const std::vector<const Surface*>& surfaces,
const Transform3& transformIn = Transform3::Identity());

/// Constructor
///
Expand All @@ -52,8 +57,23 @@ struct ProtoLayer {
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param surfaces The vector of surfaces to consider
/// @param transformIn The local transform to evaluate the sizing in
ProtoLayer(const GeometryContext& gctx,
const std::vector<std::shared_ptr<const Surface>>& surfaces);
const std::vector<std::shared_ptr<const Surface>>& surfaces,
const Transform3& transformIn = Transform3::Identity());

/// Constructor
///
/// Loops over a provided vector of surface and calculates the various
/// min/max values in one go. Also takes into account the thickness
/// of an associated DetectorElement, if it exists.
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param surfaces The vector of surfaces to consider
/// @param transformIn The local transform to evaluate the sizing in
ProtoLayer(const GeometryContext& gctx,
const std::vector<std::shared_ptr<Surface>>& surfaces,
const Transform3& transformIn = Transform3::Identity());

ProtoLayer() = default;

Expand Down Expand Up @@ -81,6 +101,14 @@ struct ProtoLayer {
/// @param sl the input ostream
std::ostream& toStream(std::ostream& sl) const;

/// Output stream operator
/// @param sl the input ostream
/// @param pl the ProtoLayer to be printed
/// @return the output ostream
friend std::ostream& operator<<(std::ostream& sl, const ProtoLayer& pl) {
return pl.toStream(sl);
}

/// Give access to the surfaces used/assigned to the ProtoLayer
const std::vector<const Surface*>& surfaces() const;

Expand Down
11 changes: 11 additions & 0 deletions Core/include/Acts/Geometry/TrackingGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ class TrackingGeometry {
const std::unordered_map<GeometryIdentifier, const Surface*>&
geoIdSurfaceMap() const;

/// Visualize a tracking geometry including substructure
/// @param helper The visualization helper that implement the output
/// @param gctx The geometry context
/// @param viewConfig Global view config
/// @param portalViewConfig View config for portals
/// @param sensitiveViewConfig View configuration for sensitive surfaces
void visualize(IVisualization3D& helper, const GeometryContext& gctx,
const ViewConfig& viewConfig = s_viewVolume,
const ViewConfig& portalViewConfig = s_viewPortal,
const ViewConfig& sensitiveViewConfig = s_viewSensitive) const;

private:
// the known world
std::shared_ptr<TrackingVolume> m_world;
Expand Down
12 changes: 12 additions & 0 deletions Core/include/Acts/Geometry/TrackingVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "Acts/Utilities/BinnedArray.hpp"
#include "Acts/Utilities/Logger.hpp"
#include "Acts/Utilities/TransformRange.hpp"
#include "Acts/Visualization/ViewConfig.hpp"

#include <cstddef>
#include <memory>
Expand Down Expand Up @@ -486,6 +487,17 @@ class TrackingVolume : public Volume {
/// - positiveFaceXY
GlueVolumesDescriptor& glueVolumesDescriptor();

/// Produces a 3D visualization of this tracking volume
/// @param helper The visualization helper describing the output format
/// @param gctx The geometry context
/// @param viewConfig The view configuration
/// @param portalViewConfig View configuration for portals
/// @param sensitiveViewConfig View configuration for sensitive surfaces
void visualize(IVisualization3D& helper, const GeometryContext& gctx,
const ViewConfig& viewConfig,
const ViewConfig& portalViewConfig,
const ViewConfig& sensitiveViewConfig) const;

private:
void connectDenseBoundarySurfaces(
MutableTrackingVolumeVector& confinedDenseVolumes);
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Geometry/Volume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class Volume : public GeometryObject {
/// @param gctx The geometry context
/// @param viewConfig The view configuration
void visualize(IVisualization3D& helper, const GeometryContext& gctx,
const ViewConfig& viewConfig = {}) const;
const ViewConfig& viewConfig) const;

protected:
Transform3 m_transform;
Expand Down
10 changes: 10 additions & 0 deletions Core/include/Acts/Material/ISurfaceMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Acts/Material/MaterialSlab.hpp"

#include <memory>
#include <sstream>
#include <vector>

namespace Acts {
Expand Down Expand Up @@ -117,6 +118,15 @@ class ISurfaceMaterial {
/// Output Method for std::ostream, to be overloaded by child classes
virtual std::ostream& toStream(std::ostream& sl) const = 0;

/// @brief output into a string
///
/// @return the string representation
std::string toString() const {
std::stringstream sstrm;
toStream(sstrm);
return sstrm.str();
}

protected:
double m_splitFactor{1.}; //!< the split factor in favour of oppositePre
MappingType m_mappingType{
Expand Down
9 changes: 1 addition & 8 deletions Core/include/Acts/Propagator/EigenStepper.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "Acts/Propagator/ConstrainedStep.hpp"
#include "Acts/Propagator/EigenStepperError.hpp"
#include "Acts/Propagator/detail/CovarianceEngine.hpp"
#include "Acts/Utilities/QuickMath.hpp"

#include <limits>

Expand Down Expand Up @@ -177,17 +176,11 @@ Acts::Result<double> Acts::EigenStepper<E>::step(
// This is given by the order of the Runge-Kutta method
constexpr double exponent = 0.25;

// Whether to use fast power function if available
constexpr bool tryUseFastPow{false};

double x = state.options.stepping.stepTolerance / errorEstimate_;

if constexpr (exponent == 0.25 && !tryUseFastPow) {
if constexpr (exponent == 0.25) {
// This is 3x faster than std::pow
x = std::sqrt(std::sqrt(x));
} else if constexpr (std::numeric_limits<double>::is_iec559 &&
tryUseFastPow) {
x = fastPow(x, exponent);
} else {
x = std::pow(x, exponent);
}
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Surfaces/Surface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ class Surface : public virtual GeometryObject,
const GeometryContext& gctx, const Vector3& position) const = 0;

void visualize(IVisualization3D& helper, const GeometryContext& gctx,
const ViewConfig& viewConfig = {}) const;
const ViewConfig& viewConfig = s_viewSurface) const;

protected:
/// Output Method for std::ostream, to be overloaded by child classes
Expand Down
90 changes: 0 additions & 90 deletions Core/include/Acts/Utilities/QuickMath.hpp

This file was deleted.

6 changes: 0 additions & 6 deletions Core/include/Acts/Visualization/GeometryView3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ class DetectorVolume;
class Portal;
} // namespace Experimental

static const ViewConfig s_viewSensitive;
static const ViewConfig s_viewPassive;
static const ViewConfig s_viewVolume;
static const ViewConfig s_viewGrid;
static const ViewConfig s_viewLine;

struct GeometryView3D {
/// Helper method to draw Polyhedron objects
///
Expand Down
6 changes: 6 additions & 0 deletions Core/include/Acts/Visualization/IVisualization3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ class IVisualization3D {
/// Remove all contents of this helper
///
virtual void clear() = 0;

virtual ~IVisualization3D() = default;

/// Start a new object context
/// @param name The name of the object
virtual void object(const std::string& name) = 0;
};

/// Overload of the << operator to facilitate writing to streams.
Expand Down
44 changes: 23 additions & 21 deletions Core/include/Acts/Visualization/ObjVisualization3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@
#include "Acts/Visualization/IVisualization3D.hpp"
#include "Acts/Visualization/ViewConfig.hpp"

#include <array>
#include <filesystem>
#include <fstream>
#include <iomanip>
#include <map>
#include <sstream>
#include <string>
#include <vector>

Expand All @@ -26,14 +22,10 @@ namespace Acts {
/// This helper produces output in the OBJ format. Note that colors are not
/// supported in this implementation.
///
template <typename T = double>
class ObjVisualization3D : public IVisualization3D {
public:
static_assert(std::is_same_v<T, double> || std::is_same_v<T, float>,
"Use either double or float");

/// Stored value type, should be double or float
using ValueType = T;
using ValueType = double;

/// Type of a vertex based on the value type
using VertexType = Eigen::Matrix<ValueType, 3, 1>;
Expand Down Expand Up @@ -77,22 +69,32 @@ class ObjVisualization3D : public IVisualization3D {
/// @copydoc Acts::IVisualization3D::clear()
void clear() final;

/// Start a new object context with a name
/// @param name The name of the object
void object(const std::string& name) final;

private:
struct Object {
std::string name;
std::vector<VertexType> vertices{};
std::vector<FaceType> faces{};
std::vector<LineType> lines{};

/// The object data to be written
/// Map of colors to be written at given index position
std::map<std::size_t, Color> lineColors{};
std::map<std::size_t, Color> vertexColors{};
std::map<std::size_t, Color> faceColors{};
};

Object& object();
const Object& object() const;

/// The output parameters
unsigned int m_outputPrecision = 4;
double m_outputScalor = 1.;
/// The object data to be written
std::vector<VertexType> m_vertices;
std::vector<FaceType> m_faces;
std::vector<LineType> m_lines;
/// Map of colors to be written at given index position
std::map<std::size_t, Color> m_lineColors;
std::map<std::size_t, Color> m_vertexColors;
std::map<std::size_t, Color> m_faceColors;
};

#ifndef DOXYGEN
#include "detail/ObjVisualization3D.ipp"
#endif
std::vector<Object> m_objects;
};

} // namespace Acts
4 changes: 4 additions & 0 deletions Core/include/Acts/Visualization/PlyVisualization3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class PlyVisualization3D : public IVisualization3D {
/// @copydoc Acts::IVisualization3D::clear()
void clear() final;

void object(const std::string& /*name*/) final {
// Unimplemented
}

private:
std::vector<std::pair<VertexType, Color>> m_vertices;
std::vector<FaceType> m_faces;
Expand Down
Loading

0 comments on commit 9a3e5b5

Please sign in to comment.