Skip to content

Commit

Permalink
Integrate svg tools into the validation suite. The ray and helix scans
Browse files Browse the repository at this point in the history
will dump the geometry, intersections and trajectory to an xy and
rz view.
  • Loading branch information
niermann999 committed Oct 28, 2023
1 parent db34bc1 commit 4d4be93
Show file tree
Hide file tree
Showing 18 changed files with 484 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,31 @@
#include "detray/intersection/intersection.hpp"
#include "detray/plugins/svgtools/conversion/landmark.hpp"
#include "detray/plugins/svgtools/meta/proto/intersection_record.hpp"
#include "detray/plugins/svgtools/utils/intersection_utils.hpp"

// System include(s)
#include <vector>

namespace detray::svgtools::conversion {

/// @returns The proto intersection record from a list of points
template <typename point3_t, typename container_t>
inline auto intersection_record(const container_t& points) {
using p_intersection_record_t =
svgtools::meta::proto::intersection_record<point3_t>;
p_intersection_record_t p_ir;
for (const auto& point : points) {
const auto p_lm = svgtools::conversion::landmark<point3_t>(point);
p_ir._landmarks.push_back(p_lm);
}
return p_ir;
}
/// @returns The proto intersection of a detray intersection.
template <typename point3_t, typename detector_t, typename intersection_t>
inline auto intersection(
const detector_t& detector, const dvector<intersection_t>& intersections,
const typename detector_t::vector3 dir = {},
const typename detector_t::geometry_context& gctx = {}) {
using p_intersection_t = svgtools::meta::proto::intersection<point3_t>;
p_intersection_t p_ir;

/// @returns The proto intersection record of a detray intersection record.
template <typename point3_t, typename detector_t>
inline auto intersection_record(
const typename detector_t::geometry_context& context,
const detector_t& detector,
const std::vector<
std::pair<detray::dindex,
detray::intersection2D<typename detector_t::surface_type,
typename detector_t::transform3>>>&
intersection_record) {
std::vector<typename detector_t::point3> points;
for (const auto& record : intersection_record) {
const auto point = svgtools::utils::intersection_point(
context, detector, record.second);
points.push_back(point);
std::vector<typename p_intersection_t::landmark_type> landmarks;
for (const auto& intr : intersections) {
const detray::surface surface{detector, intr.sf_desc};
const auto position = surface.local_to_global(gctx, intr.local, dir);
const auto p_lm = svgtools::conversion::landmark<point3_t>(position);
landmarks.push_back(p_lm);
}
return svgtools::conversion::intersection_record<point3_t>(points);

p_ir._landmarks = std::move(landmarks);
return p_ir;
}

} // namespace detray::svgtools::conversion
} // namespace detray::svgtools::conversion
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,16 @@
#include "detray/intersection/intersection.hpp"
#include "detray/plugins/svgtools/conversion/point.hpp"
#include "detray/plugins/svgtools/meta/proto/landmark.hpp"
#include "detray/plugins/svgtools/utils/intersection_utils.hpp"

namespace detray::svgtools::conversion {

/// @returns The proto landmark of a detray intersection.
template <typename point3_t, typename detector_t>
inline auto landmark(
const typename detector_t::geometry_context& context,
const detector_t& detector,
const detray::intersection2D<typename detector_t::surface_type,
typename detector_t::transform3>&
d_intersection) {
const auto position =
svgtools::utils::intersection_point(context, detector, d_intersection);
return svgtools::conversion::landmark<point3_t>(position);
}

/// @returns The proto landmark of a detray point.
template <typename point3_t, typename d_point3_t>
inline auto landmark(d_point3_t& position) {
using p_landmark_t = svgtools::meta::proto::landmark<point3_t>;
p_landmark_t p_lm;
p_lm._position = svgtools::conversion::point<point3_t>(position);

return p_lm;
}

Expand Down
Loading

0 comments on commit 4d4be93

Please sign in to comment.