diff --git a/corsika/detail/framework/geometry/CoordinateSystem.inl b/corsika/detail/framework/geometry/CoordinateSystem.inl index faa759aa769f9cd3382d06bca45377bb5488c3ee..12e914ba9d4131209d4be8fa7eec066e9961a97a 100644 --- a/corsika/detail/framework/geometry/CoordinateSystem.inl +++ b/corsika/detail/framework/geometry/CoordinateSystem.inl @@ -75,7 +75,7 @@ namespace corsika { inline CoordinateSystemPtr make_translation(CoordinateSystemPtr const& cs, QuantityVector<length_d> const& vector) { EigenTransform const translation{EigenTranslation(vector.getEigenVector())}; - return std::make_shared<CoordinateSystem const>(CoordinateSystem(cs, translation)); + return CoordinateSystemPtr{new CoordinateSystem(cs, translation)}; } template <typename TDim> @@ -105,8 +105,7 @@ namespace corsika { 0, 0, (a1 * a1 + a2 * a2) * c; // . } - return std::make_shared<CoordinateSystem const>( - CoordinateSystem(cs, EigenTransform(A + B))); + return CoordinateSystemPtr{new CoordinateSystem{cs, EigenTransform{A + B}}}; } template <typename TDim> @@ -120,7 +119,7 @@ namespace corsika { EigenTransform const rotation{ Eigen::AngleAxisd(angle, axis.getEigenVector().normalized())}; - return std::make_shared<CoordinateSystem const>(CoordinateSystem(cs, rotation)); + return CoordinateSystemPtr{new CoordinateSystem{cs, rotation}}; } template <typename TDim> @@ -135,7 +134,7 @@ namespace corsika { Eigen::AngleAxisd(angle, axis.getEigenVector().normalized()) * EigenTranslation(translation.getEigenVector())}; - return std::make_shared<CoordinateSystem const>(CoordinateSystem(cs, transf)); + return CoordinateSystemPtr{new CoordinateSystem{cs, transf}}; } } // namespace corsika diff --git a/corsika/detail/framework/geometry/Point.inl b/corsika/detail/framework/geometry/Point.inl index fe6e8b162383352523f7ba2399ef8685b0b5a2cb..156723dd149102ecec8ee88ab773dafa5cfec84d 100644 --- a/corsika/detail/framework/geometry/Point.inl +++ b/corsika/detail/framework/geometry/Point.inl @@ -24,46 +24,22 @@ namespace corsika { } inline LengthType Point::getX(CoordinateSystemPtr const& pCS) const { - CoordinateSystemPtr const& cs = BaseVector<length_d>::getCoordinateSystem(); - if (*pCS == *cs) { - return BaseVector<length_d>::getQuantityVector().getX(); - } else { - return QuantityVector<length_d>( - get_transformation(*cs.get(), *pCS.get()) * - BaseVector<length_d>::getQuantityVector().eigenVector_) - .getX(); - } + return getCoordinates(pCS).getX(); } inline LengthType Point::getY(CoordinateSystemPtr const& pCS) const { - CoordinateSystemPtr const& cs = BaseVector<length_d>::getCoordinateSystem(); - if (*pCS == *cs) { - return BaseVector<length_d>::getQuantityVector().getY(); - } else { - return QuantityVector<length_d>( - get_transformation(*cs.get(), *pCS.get()) * - BaseVector<length_d>::getQuantityVector().eigenVector_) - .getY(); - } + return getCoordinates(pCS).getY(); } inline LengthType Point::getZ(CoordinateSystemPtr const& pCS) const { - CoordinateSystemPtr const& cs = BaseVector<length_d>::getCoordinateSystem(); - if (*pCS == *cs) { - return BaseVector<length_d>::getQuantityVector().getZ(); - } else { - return QuantityVector<length_d>( - get_transformation(*cs.get(), *pCS.get()) * - BaseVector<length_d>::getQuantityVector().eigenVector_) - .getZ(); - } + return getCoordinates(pCS).getZ(); } /// this always returns a QuantityVector as triple inline QuantityVector<length_d> Point::getCoordinates( CoordinateSystemPtr const& pCS) const { CoordinateSystemPtr const& cs = BaseVector<length_d>::getCoordinateSystem(); - if (*pCS == *cs) { + if (pCS == cs) { return BaseVector<length_d>::getQuantityVector(); } else { return QuantityVector<length_d>( @@ -74,7 +50,7 @@ namespace corsika { /// this always returns a QuantityVector as triple inline QuantityVector<length_d>& Point::getCoordinates(CoordinateSystemPtr const& pCS) { - if (*pCS != *BaseVector<length_d>::getCoordinateSystem()) { rebase(pCS); } + if (pCS != BaseVector<length_d>::getCoordinateSystem()) { rebase(pCS); } return BaseVector<length_d>::getQuantityVector(); } @@ -106,4 +82,4 @@ namespace corsika { return (p1 - p2).getNorm(); } -} // namespace corsika \ No newline at end of file +} // namespace corsika diff --git a/corsika/detail/framework/geometry/Vector.inl b/corsika/detail/framework/geometry/Vector.inl index 0e2cfdd6104bd4062d3bf752c43e7ffc858fe70a..687b93eebd91346fc7c46da7492cfabeb8d2a73e 100644 --- a/corsika/detail/framework/geometry/Vector.inl +++ b/corsika/detail/framework/geometry/Vector.inl @@ -27,7 +27,7 @@ namespace corsika { template <typename TDimension> inline QuantityVector<TDimension> Vector<TDimension>::getComponents( CoordinateSystemPtr const& pCS) const { - if (*pCS == *BaseVector<TDimension>::getCoordinateSystem()) { + if (pCS == BaseVector<TDimension>::getCoordinateSystem()) { return BaseVector<TDimension>::getQuantityVector(); } else { return QuantityVector<TDimension>( diff --git a/corsika/framework/geometry/CoordinateSystem.hpp b/corsika/framework/geometry/CoordinateSystem.hpp index f15b89e994d6399600322b479a287d1a726e1abd..fb3a7040818a02fa3dd0f64263845ed02b07d599 100644 --- a/corsika/framework/geometry/CoordinateSystem.hpp +++ b/corsika/framework/geometry/CoordinateSystem.hpp @@ -35,7 +35,7 @@ namespace corsika { using CoordinateSystemPtr = std::shared_ptr<CoordinateSystem const>; /// this is the only way to create ONE unique root CS - static CoordinateSystemPtr& get_root_CoordinateSystem(); + CoordinateSystemPtr const& get_root_CoordinateSystem(); /** * Creates new CoordinateSystemPtr by translation along \a vector @@ -109,8 +109,8 @@ namespace corsika { public: // default resource allocation - CoordinateSystem(CoordinateSystem const&) = default; - CoordinateSystem(CoordinateSystem&&) = default; + CoordinateSystem(CoordinateSystem const&) = delete; + CoordinateSystem(CoordinateSystem&&) = delete; CoordinateSystem& operator=(CoordinateSystem const& pCS) = delete; // avoid making copies ~CoordinateSystem() = default; @@ -128,15 +128,13 @@ namespace corsika { bool operator!=(CoordinateSystem const&) const; protected: - static CoordinateSystem createCS() { return CoordinateSystem(); } - /** * \name Friends * Manipulation and creation functions. * \{ **/ - friend CoordinateSystemPtr& get_root_CoordinateSystem(); + friend CoordinateSystemPtr const& get_root_CoordinateSystem(); friend CoordinateSystemPtr make_translation(CoordinateSystemPtr const& cs, QuantityVector<length_d> const& vector); diff --git a/corsika/framework/geometry/RootCoordinateSystem.hpp b/corsika/framework/geometry/RootCoordinateSystem.hpp index 41d2654d5973efedf63ca1ab1b0b640acd3e89b2..3585bf35c7fd0c2db2ccf3d8bed67824d83c1e7c 100644 --- a/corsika/framework/geometry/RootCoordinateSystem.hpp +++ b/corsika/framework/geometry/RootCoordinateSystem.hpp @@ -27,8 +27,8 @@ namespace corsika { * RootCoordinateSystem */ - static inline CoordinateSystemPtr& get_root_CoordinateSystem() { - static CoordinateSystemPtr rootCS(new CoordinateSystem); // THIS IS IT + inline CoordinateSystemPtr const& get_root_CoordinateSystem() { + static CoordinateSystemPtr const rootCS(new CoordinateSystem); // THIS IS IT return rootCS; }