diff --git a/.gitmodules b/.gitmodules index 947d17a65b38f58c913658c33350111aa34da782..dec1e6771685a85a3ec6da47267566c698e35ea7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,10 @@ [submodule "googletest"] path = googletest url = https://github.com/abseil/googletest.git - branch = release-1.8.1 \ No newline at end of file + branch = release-1.8.1 +[submodule "json"] + path = json + url = https://github.com/nlohmann/json.git +[submodule "eigen"] + path = eigen + url = https://gitlab.com/libeigen/eigen.git diff --git a/CMakeLists.txt b/CMakeLists.txt index ef9f7c64303dfda8a36841001b15e55132d68e57..7afb739613e075d98c57fa7bc349563ac5a609e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,11 +14,26 @@ include(GNUInstallDirs) set(CMAKE_CXX_STANDARD 11) -set(ALE_BUILD_LOAD ON CACHE BOOL "If the C++ Python load interface should be built.") +option(ALE_BUILD_LOAD "If the C++ Python load interface should be built." ON) +option(ALE_USE_EXTERNAL_JSON "If an external nlohmann JSON library should be used" OFF) +option(ALE_USE_EXTERNAL_EIGEN "If an external EIGEN library should be used" OFF) # Third Party Dependencies -find_package(Eigen3 3.3 REQUIRED NO_MODULE) -find_package(nlohmann_json REQUIRED) +if(ALE_USE_EXTERNAL_JSON) + find_package(nlohmann_json REQUIRED) +else() + set(JSON_BuildTests OFF CACHE INTERNAL "") + add_subdirectory(json) +endif() + +if(ALE_USE_EXTERNAL_EIGEN) + find_package(Eigen3 3.3 REQUIRED NO_MODULE) +else() + add_library (eigen INTERFACE) + add_library (Eigen3::Eigen ALIAS eigen) + target_include_directories (eigen INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/eigen) +endif() if(ALE_BUILD_LOAD) # If there is an Anaconda environment activated, search that for Python first @@ -31,7 +46,7 @@ if(ALE_BUILD_LOAD) endif() # Library setup -set(ALE_BUILD_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/") +set(ALE_BUILD_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/ale") set(ALE_INSTALL_INCLUDE_DIR "include/ale") set(ALE_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/InterpUtils.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Rotation.cpp @@ -62,8 +77,9 @@ set_target_properties(ale PROPERTIES # Use generator expressions so that downstream projects can use this target target_include_directories(ale PUBLIC - $<BUILD_INTERFACE:${ALE_BUILD_INCLUDE_DIR}> - $<INSTALL_INTERFACE:include>) + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<INSTALL_INTERFACE:include> + PRIVATE) target_link_libraries(ale PRIVATE ${ALE_PRIVATE_LINKS} PUBLIC ${ALE_PUBLIC_LINKS}) diff --git a/eigen b/eigen new file mode 160000 index 0000000000000000000000000000000000000000..39142904cc2301628931481e8b331cc2d567e22f --- /dev/null +++ b/eigen @@ -0,0 +1 @@ +Subproject commit 39142904cc2301628931481e8b331cc2d567e22f diff --git a/include/Distortion.h b/include/ale/Distortion.h similarity index 100% rename from include/Distortion.h rename to include/ale/Distortion.h diff --git a/include/InterpUtils.h b/include/ale/InterpUtils.h similarity index 99% rename from include/InterpUtils.h rename to include/ale/InterpUtils.h index b7a2bed2956ac06ba18d2f789be5a6ab4dce7399..3bb0e84b372b61c94a784093fe89e6cdf3104435 100644 --- a/include/InterpUtils.h +++ b/include/ale/InterpUtils.h @@ -3,7 +3,7 @@ #include <vector> -#include "Vectors.h" +#include "ale/Vectors.h" namespace ale { diff --git a/include/Isd.h b/include/ale/Isd.h similarity index 92% rename from include/Isd.h rename to include/ale/Isd.h index d4ce223db3c7219ca1f748f042865da0b8f6e512..d1126e7b0ea6ca18601bb278faa714364dbb0a75 100644 --- a/include/Isd.h +++ b/include/ale/Isd.h @@ -7,11 +7,10 @@ #include <nlohmann/json.hpp> -#include "Distortion.h" - -#include "Rotation.h" -#include "States.h" -#include "Orientations.h" +#include "ale/Distortion.h" +#include "ale/Rotation.h" +#include "ale/States.h" +#include "ale/Orientations.h" namespace ale { diff --git a/include/Load.h b/include/ale/Load.h similarity index 100% rename from include/Load.h rename to include/ale/Load.h diff --git a/include/Orientations.h b/include/ale/Orientations.h similarity index 86% rename from include/Orientations.h rename to include/ale/Orientations.h index cf193dec727e43662be61df88127a952fd97e663..5f437db87d8e5002bcf8fa3aee0efd0af60deedb 100644 --- a/include/Orientations.h +++ b/include/ale/Orientations.h @@ -3,7 +3,7 @@ #include <vector> -#include "Rotation.h" +#include "ale/Rotation.h" namespace ale { class Orientations { @@ -12,7 +12,7 @@ namespace ale { * Construct a default empty orientation object */ Orientations() {}; - + /** * Construct an orientation object give a set of rotations * and optionally angular velocities at specific times. @@ -21,10 +21,10 @@ namespace ale { const std::vector<Rotation> &rotations, const std::vector<double> ×, const std::vector<Vec3d> &avs = std::vector<ale::Vec3d>(), - const int refFrame = 1, + const int refFrame = 1, const Rotation &constRot = Rotation(1, 0, 0, 0), - const std::vector<int> const_frames = std::vector<int>(), - const std::vector<int> time_dependent_frames = std::vector<int>() + const std::vector<int> const_frames = std::vector<int>(), + const std::vector<int> time_dependent_frames = std::vector<int>() ); /** @@ -38,10 +38,10 @@ namespace ale { std::vector<Rotation> getRotations() const; std::vector<ale::Vec3d> getAngularVelocities() const; std::vector<double> getTimes() const; - std::vector<int> getConstantFrames() const; + std::vector<int> getConstantFrames() const; std::vector<int> getTimeDependentFrames() const; int getReferenceFrame() const; - Rotation getConstantRotation() const; + Rotation getConstantRotation() const; /** * Get the interpolated rotation at a specific time. @@ -50,7 +50,7 @@ namespace ale { double time, RotationInterpolation interpType=SLERP ) const; - + /** * Get the interpolated angular velocity at a specific time */ @@ -86,10 +86,10 @@ namespace ale { std::vector<Rotation> m_rotations; std::vector<ale::Vec3d> m_avs; std::vector<double> m_times; - std::vector<int> m_timeDepFrames; - std::vector<int> m_constFrames; + std::vector<int> m_timeDepFrames; + std::vector<int> m_constFrames; Rotation m_constRotation; - int m_refFrame; + int m_refFrame; }; } diff --git a/include/Rotation.h b/include/ale/Rotation.h similarity index 98% rename from include/Rotation.h rename to include/ale/Rotation.h index f3f056c21cb9209b0c296760c4f81d9ae0e15197..3e64cc04a018164375b35c60495f4605808347f6 100644 --- a/include/Rotation.h +++ b/include/ale/Rotation.h @@ -4,8 +4,8 @@ #include <memory> #include <vector> -#include "States.h" -#include "Vectors.h" +#include "ale/States.h" +#include "ale/Vectors.h" namespace ale { diff --git a/include/States.h b/include/ale/States.h similarity index 98% rename from include/States.h rename to include/ale/States.h index 37de4e4fe8c1f2706495c96ffa1a60492eecd76c..c4e5e818ba154a570c5aceae7b675949c1fd72e8 100644 --- a/include/States.h +++ b/include/ale/States.h @@ -5,8 +5,8 @@ #include <stdexcept> -#include "Vectors.h" -#include "InterpUtils.h" +#include "ale/Vectors.h" +#include "ale/InterpUtils.h" namespace ale { /** A state vector with position and velocity*/ diff --git a/include/Util.h b/include/ale/Util.h similarity index 94% rename from include/Util.h rename to include/ale/Util.h index 7150a37b2dc7eee54e55c16179a37a3bf2cb71e1..d27244f30a791cae14ecbcb6ab79fb51347f5d66 100644 --- a/include/Util.h +++ b/include/ale/Util.h @@ -4,11 +4,11 @@ #include <string> #include <nlohmann/json.hpp> -#include "InterpUtils.h" -#include "Distortion.h" -#include "States.h" -#include "Orientations.h" -#include "Vectors.h" +#include "ale/InterpUtils.h" +#include "ale/Distortion.h" +#include "ale/States.h" +#include "ale/Orientations.h" +#include "ale/Vectors.h" namespace ale { diff --git a/include/Vectors.h b/include/ale/Vectors.h similarity index 100% rename from include/Vectors.h rename to include/ale/Vectors.h diff --git a/json b/json new file mode 160000 index 0000000000000000000000000000000000000000..c6b298799aca23f2b35fc52c1df393afede20c15 --- /dev/null +++ b/json @@ -0,0 +1 @@ +Subproject commit c6b298799aca23f2b35fc52c1df393afede20c15 diff --git a/src/InterpUtils.cpp b/src/InterpUtils.cpp index 75fbe156f437dcf15f93bc61fe9535c95184b732..741a70997c3344ecd7cc42d48498323336afec46 100644 --- a/src/InterpUtils.cpp +++ b/src/InterpUtils.cpp @@ -1,4 +1,4 @@ -#include "InterpUtils.h" +#include "ale/InterpUtils.h" #include <exception> #include <stdexcept> diff --git a/src/Isd.cpp b/src/Isd.cpp index 8cb674b849146ec3820378fb146d6022c2dd6edb..e3b2876596dedb8a2bf48c8f596149149d7e4524 100644 --- a/src/Isd.cpp +++ b/src/Isd.cpp @@ -1,6 +1,6 @@ -#include "Isd.h" -#include "Util.h" +#include "ale/Isd.h" +#include "ale/Util.h" using json = nlohmann::json; diff --git a/src/Load.cpp b/src/Load.cpp index 676dd6d351175790fac506bd08edb356895559ac..ed15a014210c35bdd84cb5bb2625974e88bf4fd3 100644 --- a/src/Load.cpp +++ b/src/Load.cpp @@ -1,4 +1,4 @@ -#include "Load.h" +#include "ale/Load.h" #include <nlohmann/json.hpp> diff --git a/src/Orientations.cpp b/src/Orientations.cpp index 811d100790a71dae65a6f0b7af6e5c3dae2a8c4a..c2d0200f52b3af36cb003f628bcde8f5707b92e3 100644 --- a/src/Orientations.cpp +++ b/src/Orientations.cpp @@ -1,6 +1,6 @@ -#include "Orientations.h" +#include "ale/Orientations.h" -#include "InterpUtils.h" +#include "ale/InterpUtils.h" namespace ale { @@ -8,9 +8,9 @@ namespace ale { const std::vector<Rotation> &rotations, const std::vector<double> ×, const std::vector<Vec3d> &avs, - const int refFrame, - const Rotation &const_rot, - const std::vector<int> const_frames, + const int refFrame, + const Rotation &const_rot, + const std::vector<int> const_frames, const std::vector<int> time_dependent_frames ) : m_rotations(rotations), m_avs(avs), m_times(times), m_refFrame(refFrame), m_timeDepFrames(time_dependent_frames), m_constFrames(const_frames), m_constRotation(const_rot) { @@ -39,21 +39,21 @@ namespace ale { std::vector<double> Orientations::getTimes() const { return m_times; } - + std::vector<int> Orientations::getTimeDependentFrames() const { - return m_timeDepFrames; + return m_timeDepFrames; } std::vector<int> Orientations::getConstantFrames() const { - return m_constFrames; + return m_constFrames; } - + int Orientations::getReferenceFrame() const { - return m_refFrame; + return m_refFrame; } Rotation Orientations::getConstantRotation() const { - return m_constRotation; + return m_constRotation; } Rotation Orientations::interpolate( diff --git a/src/Rotation.cpp b/src/Rotation.cpp index 3778a03f7b3e822e44071290f651c90608b3f6c8..031726c21a6b797ffced6593491bdc8f919662b5 100644 --- a/src/Rotation.cpp +++ b/src/Rotation.cpp @@ -1,10 +1,10 @@ -#include "Rotation.h" +#include "ale/Rotation.h" #include <exception> #include <Eigen/Geometry> -#include "InterpUtils.h" +#include "ale/InterpUtils.h" namespace ale { diff --git a/src/States.cpp b/src/States.cpp index ad38d10d17b3cb6c000471e6b28416f3e23ca0b2..a059780f995c052e55ab978f828b1536b34471cb 100644 --- a/src/States.cpp +++ b/src/States.cpp @@ -1,4 +1,4 @@ -#include "States.h" +#include "ale/States.h" #include <iostream> #include <algorithm> diff --git a/src/Util.cpp b/src/Util.cpp index 103ecee900916d82122cf44cabdbe6b312eddc77..15776d4a63962a83a3b385de8c29b4bf1fbcfc06 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -2,7 +2,7 @@ #include <algorithm> #include <iostream> -#include "Util.h" +#include "ale/Util.h" using json = nlohmann::json; diff --git a/tests/ctests/IsdTests.cpp b/tests/ctests/IsdTests.cpp index 242e97ddfae4d116505f54740fef71d9b74c2585..b0dee7be06265e4d8641e147ec0bc42ec67d5a0f 100644 --- a/tests/ctests/IsdTests.cpp +++ b/tests/ctests/IsdTests.cpp @@ -4,9 +4,9 @@ #include "gtest/gtest.h" -#include "Isd.h" -#include "Util.h" -#include "Vectors.h" +#include "ale/Isd.h" +#include "ale/Util.h" +#include "ale/Vectors.h" void ASSERT_DOUBLE_VECTOR_EQ(std::vector<double> v1, std::vector<double> v2) { ASSERT_EQ(v1.size(), v2.size()) << "The two input vectors are different in size"; diff --git a/tests/ctests/LoadTests.cpp b/tests/ctests/LoadTests.cpp index 78c4383ef69c5a69e3f33d5d1b3395357afd13c9..a5f0c69b877c59698c74ad5a848d7f11f081b1b0 100644 --- a/tests/ctests/LoadTests.cpp +++ b/tests/ctests/LoadTests.cpp @@ -1,6 +1,6 @@ #include "gtest/gtest.h" -#include "Load.h" +#include "ale/Load.h" #include <stdexcept> diff --git a/tests/ctests/OrientationsTests.cpp b/tests/ctests/OrientationsTests.cpp index 3c392526c041abacd327bca278b4a6e0ebec8c92..6eb56fc64d4d5c678de90906008c637f451628d3 100644 --- a/tests/ctests/OrientationsTests.cpp +++ b/tests/ctests/OrientationsTests.cpp @@ -1,6 +1,6 @@ #include "gtest/gtest.h" -#include "Orientations.h" +#include "ale/Orientations.h" #include <cmath> #include <exception> diff --git a/tests/ctests/RotationTests.cpp b/tests/ctests/RotationTests.cpp index 37636fdd620a881da3797c6fec1da35f9212fa4c..f143070f17b8f8bda47f483f11a909337ba44311 100644 --- a/tests/ctests/RotationTests.cpp +++ b/tests/ctests/RotationTests.cpp @@ -1,6 +1,6 @@ #include "gtest/gtest.h" -#include "Rotation.h" +#include "ale/Rotation.h" #include <cmath> #include <exception> diff --git a/tests/ctests/StatesTests.cpp b/tests/ctests/StatesTests.cpp index d4ccdf3eb47fdf6365e15e4788c58f556f059407..25ca53981fb13093ca99a3809935ad3578dced56 100644 --- a/tests/ctests/StatesTests.cpp +++ b/tests/ctests/StatesTests.cpp @@ -3,8 +3,8 @@ #include <cmath> #include <exception> -#include "States.h" -#include "Vectors.h" +#include "ale/States.h" +#include "ale/Vectors.h" using namespace std; using namespace ale; diff --git a/tests/ctests/TestInterpUtils.cpp b/tests/ctests/TestInterpUtils.cpp index c1f84530587324c19698bb86a2eac28464e4cb5b..457a70c75a8f648c8531ed3ffcdb5a96c089f87f 100644 --- a/tests/ctests/TestInterpUtils.cpp +++ b/tests/ctests/TestInterpUtils.cpp @@ -1,6 +1,6 @@ #include "gmock/gmock.h" -#include "InterpUtils.h" +#include "ale/InterpUtils.h" #include <cmath> #include <exception>