From a4738ea3c13a4a74c15f01e9625cf2356e4d4a94 Mon Sep 17 00:00:00 2001
From: Maximilian Reininghaus <maximilian.reininghaus@kit.edu>
Date: Mon, 3 Dec 2018 12:27:00 +0100
Subject: [PATCH] made environment work with Ralf's recent changes

---
 Environment/HomogeneousMedium.h     | 21 ++++++++++++++++-----
 Environment/IMediumModel.h          | 15 +++++++++------
 Environment/VolumeTreeNode.h        | 10 ++++++++++
 Framework/Geometry/BaseTrajectory.h |  2 +-
 Framework/Geometry/Helix.h          |  2 +-
 Framework/Geometry/Line.h           |  2 +-
 Framework/Geometry/Trajectory.h     |  9 +++++----
 Framework/Geometry/testGeometry.cc  | 18 ++++++++++--------
 8 files changed, 53 insertions(+), 26 deletions(-)

diff --git a/Environment/HomogeneousMedium.h b/Environment/HomogeneousMedium.h
index 60800a97..dcb9a464 100644
--- a/Environment/HomogeneousMedium.h
+++ b/Environment/HomogeneousMedium.h
@@ -1,11 +1,22 @@
+/**
+ * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
+ *
+ * See file AUTHORS for a list of contributors.
+ *
+ * This software is distributed under the terms of the GNU General Public
+ * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
+ * the license.
+ */
+
 #ifndef _include_HomogeneousMedium_h_
 #define _include_HomogeneousMedium_h_
 
 #include <corsika/environment/NuclearComposition.h>
-#include <corsika/geometry/BaseTrajectory.h>
-#include <corsika/geometry/Point.h>
 #include <corsika/particles/ParticleProperties.h>
 #include <corsika/units/PhysicalUnits.h>
+#include <corsika/geometry/Trajectory.h>
+#include <corsika/geometry/Line.h>
+#include <corsika/geometry/Point.h>
 
 /**
  * a homogeneous medium
@@ -31,14 +42,14 @@ namespace corsika::environment {
     NuclearComposition const& GetNuclearComposition() const override { return fNuclComp; }
 
     corsika::units::si::GrammageType IntegratedGrammage(
-        corsika::geometry::BaseTrajectory const& pTraj,
+        corsika::geometry::Trajectory<corsika::geometry::Line> const& pTraj,
         corsika::units::si::TimeType pTo) const override {
       using namespace corsika::units::si;
-      return pTraj.DistanceBetween(0_s, pTo) * fDensity;
+      return pTraj.ArcLength(0_s, pTo) * fDensity;
     }
 
     corsika::units::si::TimeType FromGrammage(
-        corsika::geometry::BaseTrajectory const& pTraj,
+        corsika::geometry::Trajectory<corsika::geometry::Line> const& pTraj,
         corsika::units::si::GrammageType pGrammage) const override {
       return pTraj.TimeFromArclength(pGrammage / fDensity);
     }
diff --git a/Environment/IMediumModel.h b/Environment/IMediumModel.h
index 8b4548ae..74fc5161 100644
--- a/Environment/IMediumModel.h
+++ b/Environment/IMediumModel.h
@@ -1,12 +1,10 @@
 #ifndef _include_IMediumModel_h
-#define _include_IMediumModels_h
+#define _include_IMediumModel_h
 
 #include <corsika/environment/NuclearComposition.h>
-#include <corsika/geometry/BaseTrajectory.h>
+#include <corsika/geometry/Trajectory.h>
 #include <corsika/geometry/Point.h>
 #include <corsika/units/PhysicalUnits.h>
-#include <tuple>
-#include <vector>
 
 namespace corsika::environment {
 
@@ -16,11 +14,16 @@ namespace corsika::environment {
 
     virtual corsika::units::si::MassDensityType GetMassDensity(
         corsika::geometry::Point const&) const = 0;
+    
+    // todo: think about the mixin inheritance of the trajectory vs the BaseTrajectory approach
+    // for now, only lines are supported
     virtual corsika::units::si::GrammageType IntegratedGrammage(
-        corsika::geometry::BaseTrajectory const&, corsika::units::si::TimeType) const = 0;
+        corsika::geometry::Trajectory<corsika::geometry::Line> const&, corsika::units::si::TimeType) const = 0;
+    
     virtual corsika::units::si::TimeType FromGrammage(
-        corsika::geometry::BaseTrajectory const&,
+        corsika::geometry::Trajectory<corsika::geometry::Line> const&,
         corsika::units::si::GrammageType) const = 0;
+    
     virtual NuclearComposition const& GetNuclearComposition() const = 0;
   };
 
diff --git a/Environment/VolumeTreeNode.h b/Environment/VolumeTreeNode.h
index a1f70554..7bf7b87d 100644
--- a/Environment/VolumeTreeNode.h
+++ b/Environment/VolumeTreeNode.h
@@ -1,3 +1,13 @@
+/**
+ * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
+ *
+ * See file AUTHORS for a list of contributors.
+ *
+ * This software is distributed under the terms of the GNU General Public
+ * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
+ * the license.
+ */
+
 #ifndef _include_VolumeTreeNode_H
 #define _include_VolumeTreeNode_H
 
diff --git a/Framework/Geometry/BaseTrajectory.h b/Framework/Geometry/BaseTrajectory.h
index 718ed3f7..feedace2 100644
--- a/Framework/Geometry/BaseTrajectory.h
+++ b/Framework/Geometry/BaseTrajectory.h
@@ -45,7 +45,7 @@ namespace corsika::geometry {
     virtual corsika::units::si::TimeType TimeFromArclength(
         corsika::units::si::LengthType) const = 0;
 
-    virtual LengthType GetDistance(corsika::units::si::TimeType t1,
+    virtual LengthType ArcLength(corsika::units::si::TimeType t1,
                                    corsika::units::si::TimeType t2) const = 0;
 
     virtual corsika::units::si::TimeType GetDuration(
diff --git a/Framework/Geometry/Helix.h b/Framework/Geometry/Helix.h
index e93fb51c..0fa07e64 100644
--- a/Framework/Geometry/Helix.h
+++ b/Framework/Geometry/Helix.h
@@ -58,7 +58,7 @@ namespace corsika::geometry {
 
     auto GetRadius() const { return radius; }
 
-    corsika::units::si::LengthType DistanceBetween(
+    corsika::units::si::LengthType ArcLength(
       corsika::units::si::TimeType t1, corsika::units::si::TimeType t2) const {
       return (vPar + vPerp).norm() * (t2 - t1);
     }
diff --git a/Framework/Geometry/Line.h b/Framework/Geometry/Line.h
index ece78080..80f6c16b 100644
--- a/Framework/Geometry/Line.h
+++ b/Framework/Geometry/Line.h
@@ -32,7 +32,7 @@ namespace corsika::geometry {
 
     Point GetPosition(corsika::units::si::TimeType t) const { return r0 + v0 * t; }
 
-    LengthType DistanceBetween(corsika::units::si::TimeType t1,
+    LengthType ArcLength(corsika::units::si::TimeType t1,
                                corsika::units::si::TimeType t2) const {
       return v0.norm() * (t2 - t1);
     }
diff --git a/Framework/Geometry/Trajectory.h b/Framework/Geometry/Trajectory.h
index 68679975..f3cabbac 100644
--- a/Framework/Geometry/Trajectory.h
+++ b/Framework/Geometry/Trajectory.h
@@ -13,6 +13,7 @@
 #define _include_TRAJECTORY_H
 
 #include <corsika/units/PhysicalUnits.h>
+#include <corsika/geometry/Point.h>
 
 using corsika::units::si::LengthType;
 using corsika::units::si::TimeType;
@@ -25,7 +26,7 @@ namespace corsika::geometry {
     corsika::units::si::TimeType fTimeLength;
 
   public:
-    using T::GetDistanceBetween;
+    using T::ArcLength;
     using T::GetPosition;
 
     Trajectory(T const& theT, corsika::units::si::TimeType timeLength)
@@ -36,14 +37,14 @@ namespace corsika::geometry {
       return fTraj.GetPosition(t + fTStart);
       }*/
 
-    Point GetPosition(const double u) const { return T::GetPosition(fTimeLength * u); }
+    Point GetPosition(double u) const { return T::GetPosition(fTimeLength * u); }
 
     TimeType GetDuration() const { return fTimeLength; }
 
-    LengthType GetDistance(const corsika::units::si::TimeType t) const {
+    LengthType GetDistance(corsika::units::si::TimeType t) const {
       assert(t > fTimeLength);
       assert(t >= 0 * corsika::units::si::second);
-      return T::DistanceBetween(0, t);
+      return T::ArcLength(0, t);
     }
   };
 
diff --git a/Framework/Geometry/testGeometry.cc b/Framework/Geometry/testGeometry.cc
index 9e3be331..63f119fc 100644
--- a/Framework/Geometry/testGeometry.cc
+++ b/Framework/Geometry/testGeometry.cc
@@ -152,11 +152,12 @@ TEST_CASE("Trajectories") {
             .norm()
             .magnitude() == Approx(0).margin(absMargin));
 
-    Trajectory<Line> base(line, 1_s);
-    CHECK(line.GetPosition(2_s).GetCoordinates() ==
-          base.GetPosition(2_s).GetCoordinates());
+    auto const t = 1_s;
+    Trajectory<Line> base(line, t);
+    CHECK(line.GetPosition(t).GetCoordinates() ==
+          base.GetPosition(1.).GetCoordinates());
 
-    CHECK(base.GetDistanceBetween(1_s, 2_s) / 1_m == Approx(1));
+    CHECK(base.ArcLength(1_s, 2_s) / 1_m == Approx(1));
   }
 
   SECTION("Helix") {
@@ -180,10 +181,11 @@ TEST_CASE("Trajectories") {
               .norm()
               .magnitude() == Approx(0).margin(absMargin));
 
-    Trajectory<Helix> const base(helix, 1_s);
-    CHECK(helix.GetPosition(1234_s).GetCoordinates() ==
-          base.GetPosition(1234_s).GetCoordinates());
+    auto const t = 1234_s;
+    Trajectory<Helix> const base(helix, t);
+    CHECK(helix.GetPosition(t).GetCoordinates() ==
+          base.GetPosition(1.).GetCoordinates());
 
-    CHECK(base.GetDistanceBetween(1_s, 2_s) / 1_m == Approx(5));
+    CHECK(base.ArcLength(1_s, 2_s) / 1_m == Approx(5));
   }
 }
-- 
GitLab