Remove external dependency on fmtlib in favor of std::format. Begin transition of model::Part into an interface
This commit is contained in:
parent
6a015d9797
commit
e5c068ddf7
@ -17,10 +17,10 @@ endif()
|
|||||||
FetchContent_MakeAvailable(googletest)
|
FetchContent_MakeAvailable(googletest)
|
||||||
|
|
||||||
# fmtlib dependency
|
# fmtlib dependency
|
||||||
FetchContent_Declare(fmt
|
#FetchContent_Declare(fmt
|
||||||
GIT_REPOSITORY https://github.com/fmtlib/fmt
|
# GIT_REPOSITORY https://github.com/fmtlib/fmt
|
||||||
GIT_TAG 9.1.0)
|
# GIT_TAG 9.1.0)
|
||||||
FetchContent_MakeAvailable(fmt)
|
#FetchContent_MakeAvailable(fmt)
|
||||||
|
|
||||||
# jsoncpp dependency
|
# jsoncpp dependency
|
||||||
FetchContent_Declare(jsoncpp
|
FetchContent_Declare(jsoncpp
|
||||||
|
@ -7,12 +7,7 @@ namespace model
|
|||||||
Part::Part(const std::string& n,
|
Part::Part(const std::string& n,
|
||||||
const Matrix3& I,
|
const Matrix3& I,
|
||||||
double m,
|
double m,
|
||||||
const Vector3& centerMass,
|
const Vector3& centerMass)
|
||||||
double l,
|
|
||||||
double inRadTop,
|
|
||||||
double outRadTop,
|
|
||||||
double inRadBottom,
|
|
||||||
double outRadBottom)
|
|
||||||
: parent(nullptr),
|
: parent(nullptr),
|
||||||
name(n),
|
name(n),
|
||||||
inertiaTensor(I),
|
inertiaTensor(I),
|
||||||
@ -20,11 +15,6 @@ Part::Part(const std::string& n,
|
|||||||
mass(m),
|
mass(m),
|
||||||
compositeMass(m),
|
compositeMass(m),
|
||||||
cm(centerMass),
|
cm(centerMass),
|
||||||
length(l),
|
|
||||||
innerRadiusTop(inRadTop),
|
|
||||||
outerRadiusTop(outRadTop),
|
|
||||||
innerRadiusBottom(inRadBottom),
|
|
||||||
outerRadiusBottom(outRadBottom),
|
|
||||||
needsRecomputing(false),
|
needsRecomputing(false),
|
||||||
childParts()
|
childParts()
|
||||||
{ }
|
{ }
|
||||||
@ -40,11 +30,6 @@ Part::Part(const Part& orig)
|
|||||||
mass(orig.mass),
|
mass(orig.mass),
|
||||||
compositeMass(orig.compositeMass),
|
compositeMass(orig.compositeMass),
|
||||||
cm(orig.cm),
|
cm(orig.cm),
|
||||||
length(orig.length),
|
|
||||||
innerRadiusTop(orig.innerRadiusTop),
|
|
||||||
outerRadiusTop(orig.outerRadiusTop),
|
|
||||||
innerRadiusBottom(orig.innerRadiusBottom),
|
|
||||||
outerRadiusBottom(orig.outerRadiusBottom),
|
|
||||||
needsRecomputing(orig.needsRecomputing),
|
needsRecomputing(orig.needsRecomputing),
|
||||||
childParts()
|
childParts()
|
||||||
{
|
{
|
||||||
@ -65,7 +50,6 @@ Part::Part(const Part& orig)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double Part::getChildMasses(double t)
|
double Part::getChildMasses(double t)
|
||||||
{
|
{
|
||||||
double childMasses{0.0};
|
double childMasses{0.0};
|
||||||
|
51
model/Part.h
51
model/Part.h
@ -22,17 +22,43 @@ public:
|
|||||||
Part(const std::string& name,
|
Part(const std::string& name,
|
||||||
const Matrix3& I,
|
const Matrix3& I,
|
||||||
double m,
|
double m,
|
||||||
const Vector3& centerMass,
|
const Vector3& centerMass);
|
||||||
double length,
|
|
||||||
double inRadTop,
|
|
||||||
double outRadTop,
|
|
||||||
double inRadBottom,
|
|
||||||
double outRadBottom);
|
|
||||||
|
|
||||||
virtual ~Part();
|
virtual ~Part();
|
||||||
|
|
||||||
Part(const Part&);
|
Part(const Part&);
|
||||||
|
|
||||||
|
Part& operator=(Part other)
|
||||||
|
{
|
||||||
|
if(this != &other)
|
||||||
|
{
|
||||||
|
std::swap(parent, other.parent);
|
||||||
|
std::swap(name, other.name);
|
||||||
|
std::swap(inertiaTensor, other.inertiaTensor);
|
||||||
|
std::swap(compositeInertiaTensor, other.compositeInertiaTensor);
|
||||||
|
std::swap(mass, other.mass);
|
||||||
|
std::swap(compositeMass, other.compositeMass);
|
||||||
|
std::swap(cm, other.cm);
|
||||||
|
std::swap(needsRecomputing, other.needsRecomputing);
|
||||||
|
std::swap(childParts, other.childParts);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
Part& operator=(Part&& other)
|
||||||
|
{
|
||||||
|
parent = std::move(other.parent);
|
||||||
|
name = std::move(other.name);
|
||||||
|
inertiaTensor = std::move(other.inertiaTensor);
|
||||||
|
compositeInertiaTensor = std::move(other.compositeInertiaTensor);
|
||||||
|
mass = std::move(other.mass);
|
||||||
|
compositeMass = std::move(other.compositeMass);
|
||||||
|
cm = std::move(other.cm);
|
||||||
|
needsRecomputing = std::move(other.needsRecomputing);
|
||||||
|
childParts = std::move(other.childParts);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
void setMass(double m) { mass = m; }
|
void setMass(double m) { mass = m; }
|
||||||
|
|
||||||
// Set the inertia tensor
|
// Set the inertia tensor
|
||||||
@ -42,11 +68,6 @@ public:
|
|||||||
// Special version of setCM that assumes the cm lies along the body x-axis
|
// Special version of setCM that assumes the cm lies along the body x-axis
|
||||||
void setCm(double x) { cm = {x, 0.0, 0.0}; }
|
void setCm(double x) { cm = {x, 0.0, 0.0}; }
|
||||||
|
|
||||||
void setLength(double l) { length = l; }
|
|
||||||
|
|
||||||
void setInnerRadius(double r) { innerRadiusTop = r; innerRadiusBottom = r; }
|
|
||||||
void setOuterRadius(double r) { outerRadiusTop = r; outerRadiusBottom = r; }
|
|
||||||
|
|
||||||
double getMass(double t)
|
double getMass(double t)
|
||||||
{
|
{
|
||||||
return mass;
|
return mass;
|
||||||
@ -101,14 +122,6 @@ private:
|
|||||||
|
|
||||||
Vector3 cm; // center of mass wrt middle of component
|
Vector3 cm; // center of mass wrt middle of component
|
||||||
|
|
||||||
double length;
|
|
||||||
|
|
||||||
double innerRadiusTop;
|
|
||||||
double outerRadiusTop;
|
|
||||||
|
|
||||||
double innerRadiusBottom;
|
|
||||||
double outerRadiusBottom;
|
|
||||||
|
|
||||||
bool needsRecomputing{false};
|
bool needsRecomputing{false};
|
||||||
|
|
||||||
/// @brief child parts and the relative positions of their center of mass w.r.t.
|
/// @brief child parts and the relative positions of their center of mass w.r.t.
|
||||||
|
@ -76,7 +76,7 @@ public:
|
|||||||
* @param cond time/state pair
|
* @param cond time/state pair
|
||||||
* @return true if the passed-in time/state satisfies the terminate condition
|
* @return true if the passed-in time/state satisfies the terminate condition
|
||||||
*/
|
*/
|
||||||
virtual bool terminateCondition(const std::pair<double, StateData>& cond) override;
|
bool terminateCondition(const std::pair<double, StateData>& cond) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief setName sets the rocket name
|
* @brief setName sets the rocket name
|
||||||
|
@ -52,12 +52,7 @@ TEST(PartTest, CreationTests)
|
|||||||
model::Part testPart("testPart",
|
model::Part testPart("testPart",
|
||||||
inertia,
|
inertia,
|
||||||
1.0,
|
1.0,
|
||||||
cm,
|
cm);
|
||||||
2.0,
|
|
||||||
1.0,
|
|
||||||
1.1,
|
|
||||||
1.1,
|
|
||||||
1.0);
|
|
||||||
|
|
||||||
Matrix3 inertia2;
|
Matrix3 inertia2;
|
||||||
inertia2 << 1, 0, 0,
|
inertia2 << 1, 0, 0,
|
||||||
@ -67,12 +62,7 @@ TEST(PartTest, CreationTests)
|
|||||||
model::Part testPart2("testPart2",
|
model::Part testPart2("testPart2",
|
||||||
inertia2,
|
inertia2,
|
||||||
1.0,
|
1.0,
|
||||||
cm2,
|
cm2);
|
||||||
2.0,
|
|
||||||
1.0,
|
|
||||||
1.1,
|
|
||||||
1.1,
|
|
||||||
1.0);
|
|
||||||
Vector3 R{2.0, 2.0, 2.0};
|
Vector3 R{2.0, 2.0, 2.0};
|
||||||
testPart.addChildPart(testPart2, R);
|
testPart.addChildPart(testPart2, R);
|
||||||
|
|
||||||
|
@ -3,11 +3,10 @@
|
|||||||
// C headers
|
// C headers
|
||||||
// C++ headers
|
// C++ headers
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <sstream>
|
#include <format>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
// 3rd party headers
|
// 3rd party headers
|
||||||
#include <fmt/core.h>
|
|
||||||
/// \endcond
|
/// \endcond
|
||||||
|
|
||||||
// qtrocket headers
|
// qtrocket headers
|
||||||
@ -56,7 +55,7 @@ double Bin::operator[](double key)
|
|||||||
if(key < iter->first)
|
if(key < iter->first)
|
||||||
{
|
{
|
||||||
throw std::out_of_range(
|
throw std::out_of_range(
|
||||||
fmt::format("{} less than lower bound {} of BinMap", key, iter->first));
|
std::format("{} less than lower bound {} of BinMap", key, iter->first));
|
||||||
}
|
}
|
||||||
// Increment it and start searching If we reach the end without finding an existing key
|
// Increment it and start searching If we reach the end without finding an existing key
|
||||||
// greater than our search term, then we've just hit the last bin and return that
|
// greater than our search term, then we've just hit the last bin and return that
|
||||||
@ -84,7 +83,7 @@ double Bin::getBinBase(double key)
|
|||||||
if(key < iter->first)
|
if(key < iter->first)
|
||||||
{
|
{
|
||||||
throw std::out_of_range(
|
throw std::out_of_range(
|
||||||
fmt::format("{} less than lower bound {} of BinMap", key, iter->first));
|
std::format("{} less than lower bound {} of BinMap", key, iter->first));
|
||||||
}
|
}
|
||||||
// Increment it and start searching If we reach the end without finding an existing key
|
// Increment it and start searching If we reach the end without finding an existing key
|
||||||
// greater than our search term, then we've just hit the last bin and return that
|
// greater than our search term, then we've just hit the last bin and return that
|
||||||
|
@ -25,5 +25,4 @@ target_include_directories(utils PRIVATE
|
|||||||
target_link_libraries(utils PUBLIC
|
target_link_libraries(utils PUBLIC
|
||||||
libcurl
|
libcurl
|
||||||
jsoncpp_static
|
jsoncpp_static
|
||||||
fmt::fmt-header-only
|
|
||||||
eigen)
|
eigen)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user