Skip to content

Commit

Permalink
Reformat to west-const for basic reference uses
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Jun 18, 2024
1 parent b4e413a commit 36bae52
Show file tree
Hide file tree
Showing 258 changed files with 2,309 additions and 2,309 deletions.
10 changes: 5 additions & 5 deletions src/OpenSimCreator/ComponentRegistry/ComponentRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ namespace osc

value_type const* begin() const
{
auto const& base = static_cast<ComponentRegistryBase const&>(*this);
const auto& base = static_cast<const ComponentRegistryBase&>(*this);
return static_cast<value_type const*>(base.begin());
}

value_type const* end() const
{
auto const& base = static_cast<ComponentRegistryBase const&>(*this);
const auto& base = static_cast<const ComponentRegistryBase&>(*this);
return static_cast<value_type const*>(base.end());
}

value_type const& operator[](size_t i) const
const value_type& operator[](size_t i) const
{
auto const& base = static_cast<ComponentRegistryBase const&>(*this);
return static_cast<value_type const&>(base[i]);
const auto& base = static_cast<const ComponentRegistryBase&>(*this);
return static_cast<const value_type&>(base[i]);
}

ComponentRegistryEntry<T>& emplace_back(
Expand Down
10 changes: 5 additions & 5 deletions src/OpenSimCreator/ComponentRegistry/ComponentRegistryBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include <typeinfo>

std::optional<size_t> osc::IndexOf(
ComponentRegistryBase const& registry,
const ComponentRegistryBase& registry,
std::string_view componentClassName)
{
for (size_t i = 0; i < registry.size(); ++i) {
OpenSim::Component const& prototype = registry[i].prototype();
const OpenSim::Component& prototype = registry[i].prototype();
if (prototype.getConcreteClassName() == componentClassName) {
return i;
}
Expand All @@ -20,11 +20,11 @@ std::optional<size_t> osc::IndexOf(
}

std::optional<size_t> osc::IndexOf(
ComponentRegistryBase const& registry,
OpenSim::Component const& component)
const ComponentRegistryBase& registry,
const OpenSim::Component& component)
{
for (size_t i = 0; i < registry.size(); ++i) {
OpenSim::Component const& prototype = registry[i].prototype();
const OpenSim::Component& prototype = registry[i].prototype();
if (typeid(prototype) == typeid(component)) {
return i;
}
Expand Down
10 changes: 5 additions & 5 deletions src/OpenSimCreator/ComponentRegistry/ComponentRegistryBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace osc
value_type const* begin() const { return m_Entries.data(); }
value_type const* end() const { return m_Entries.data() + m_Entries.size(); }
size_t size() const { return m_Entries.size(); }
value_type const& operator[](size_t i) const { return m_Entries[i]; }
const value_type& operator[](size_t i) const { return m_Entries[i]; }

protected:
ComponentRegistryBase(
Expand All @@ -47,14 +47,14 @@ namespace osc
std::vector<ComponentRegistryEntryBase> m_Entries;
};

std::optional<size_t> IndexOf(ComponentRegistryBase const&, std::string_view componentClassName);
std::optional<size_t> IndexOf(ComponentRegistryBase const&, OpenSim::Component const&);
std::optional<size_t> IndexOf(const ComponentRegistryBase&, std::string_view componentClassName);
std::optional<size_t> IndexOf(const ComponentRegistryBase&, const OpenSim::Component&);

template<typename T>
std::optional<size_t> IndexOf(ComponentRegistryBase const& registry)
std::optional<size_t> IndexOf(const ComponentRegistryBase& registry)
{
for (size_t i = 0; i < registry.size(); ++i) {
OpenSim::Component const& prototype = registry[i].prototype();
const OpenSim::Component& prototype = registry[i].prototype();
if (typeid(prototype) == typeid(T)) {
return i;
}
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSimCreator/ComponentRegistry/ComponentRegistryEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ namespace osc

T const& prototype() const
{
auto const& base = static_cast<ComponentRegistryEntryBase const&>(*this);
const auto& base = static_cast<const ComponentRegistryEntryBase&>(*this);
return static_cast<T const&>(base.prototype());
}

std::unique_ptr<T> instantiate() const
{
auto const& base = static_cast<ComponentRegistryEntryBase const&>(*this);
const auto& base = static_cast<const ComponentRegistryEntryBase&>(*this);
return std::unique_ptr<T>{static_cast<T*>(base.instantiate().release())};
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace osc

CStringView name() const { return m_Name; }
CStringView description() const { return m_Description; }
OpenSim::Component const& prototype() const { return *m_Prototype; }
const OpenSim::Component& prototype() const { return *m_Prototype; }
std::unique_ptr<OpenSim::Component> instantiate() const;

private:
Expand Down
20 changes: 10 additions & 10 deletions src/OpenSimCreator/ComponentRegistry/StaticComponentRegistries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace
{
std::shared_ptr<TJoint> j = std::make_shared<TJoint>();
int i = 0;
for (CStringView const& name : names)
for (const CStringView& name : names)
{
j->upd_coordinates(i++).setName(std::string{name});
}
Expand Down Expand Up @@ -383,7 +383,7 @@ namespace

// also, ensure all custom components are blacklisted (they should only appear
// in the explicitly-labelled custom components section)
for (auto const& customComponent : GetCustomComponentList()) {
for (const auto& customComponent : GetCustomComponentList()) {
rv.emplace(customComponent->getConcreteClassName());
}
return rv;
Expand Down Expand Up @@ -632,13 +632,13 @@ namespace
std::vector<std::shared_ptr<T const>> rv;
rv.reserve(ptrs.size());

auto const& protoLut = GetPrototypeLut();
auto const& blacklistLut = GetComponentBlacklist();
const auto& protoLut = GetPrototypeLut();
const auto& blacklistLut = GetComponentBlacklist();

for (int i = 0; i < ptrs.size(); ++i)
{
T const& v = *ptrs[i];
std::string const& name = v.getConcreteClassName();
const std::string& name = v.getConcreteClassName();
if (useBlacklist && blacklistLut.contains(name))
{
continue; // it's a blacklisted component, hide it in the UI
Expand All @@ -664,7 +664,7 @@ namespace
}
}

rgs::sort(rv, rgs::less{}, [](auto const& ptr) { return ptr->getConcreteClassName(); });
rgs::sort(rv, rgs::less{}, [](const auto& ptr) { return ptr->getConcreteClassName(); });

return rv;
}
Expand All @@ -681,8 +681,8 @@ namespace

for (int i = 0; i < ptrs.size(); ++i)
{
OpenSim::Component const& c = *ptrs[i];
std::string const& classname = c.getConcreteClassName();
const OpenSim::Component& c = *ptrs[i];
const std::string& classname = c.getConcreteClassName();

if (blacklisted.contains(classname))
{
Expand All @@ -699,7 +699,7 @@ namespace
rv.emplace_back(Clone(c));
}

rgs::sort(rv, rgs::less{}, [](auto const& ptr) { return ptr->getConcreteClassName(); });
rgs::sort(rv, rgs::less{}, [](const auto& ptr) { return ptr->getConcreteClassName(); });

return rv;
}
Expand All @@ -713,7 +713,7 @@ namespace
ComponentRegistry<T> rv{name, description};

// populate entries
auto const& lut = GetComponentDescriptionLookup();
const auto& lut = GetComponentDescriptionLookup();
for (std::shared_ptr<T const> const& el : protoLut)
{
std::string elName = el->getConcreteClassName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ CrossProductDefinedFrame::ParsedAxisArguments osc::fd::CrossProductDefinedFrame:
ss << getProperty_axis_edge_axis().getName() << ": has an invalid value ('" << get_axis_edge_axis() << "'): permitted values are -x, +x, -y, +y, -z, or +z";
OPENSIM_THROW_FRMOBJ(OpenSim::Exception, std::move(ss).str());
}
CoordinateDirection const& axisEdge = *maybeAxisEdge;
const CoordinateDirection& axisEdge = *maybeAxisEdge;

// ensure `first_cross_product_axis` is a correct property value
auto const maybeOtherEdge = CoordinateDirection::try_parse(get_first_cross_product_axis());
Expand All @@ -64,7 +64,7 @@ CrossProductDefinedFrame::ParsedAxisArguments osc::fd::CrossProductDefinedFrame:
ss << getProperty_first_cross_product_axis().getName() << ": has an invalid value ('" << get_first_cross_product_axis() << "'): permitted values are -x, +x, -y, +y, -z, or +z";
OPENSIM_THROW_FRMOBJ(OpenSim::Exception, std::move(ss).str());
}
CoordinateDirection const& otherEdge = *maybeOtherEdge;
const CoordinateDirection& otherEdge = *maybeOtherEdge;

// ensure `axis_edge_axis` is an orthogonal axis to `other_edge_axis`
if (axisEdge.axis() == otherEdge.axis()) {
Expand All @@ -76,7 +76,7 @@ CrossProductDefinedFrame::ParsedAxisArguments osc::fd::CrossProductDefinedFrame:
return ParsedAxisArguments{axisEdge, otherEdge};
}

SimTK::Transform osc::fd::CrossProductDefinedFrame::calcTransformInGround(SimTK::State const& state) const
SimTK::Transform osc::fd::CrossProductDefinedFrame::calcTransformInGround(const SimTK::State& state) const
{
// parse axis properties
auto const [axisEdge, otherEdge] = tryParseAxisArgumentsAsOrthogonalAxes();
Expand Down Expand Up @@ -114,8 +114,8 @@ SimTK::Transform osc::fd::CrossProductDefinedFrame::calcTransformInGround(SimTK:
// axes are in a circular X -> Y -> Z relationship w.r.t. cross products
struct ThirdEdgeOperands final
{
SimTK::UnitVec3 const& firstDir;
SimTK::UnitVec3 const& secondDir;
const SimTK::UnitVec3& firstDir;
const SimTK::UnitVec3& secondDir;
CoordinateAxis resultAxis;
};
ThirdEdgeOperands const ops = axisEdge.axis().next() == otherEdge.axis() ?
Expand All @@ -133,12 +133,12 @@ SimTK::Transform osc::fd::CrossProductDefinedFrame::calcTransformInGround(SimTK:
return SimTK::Transform{rotation, originLocationInGround};
}

SimTK::SpatialVec osc::fd::CrossProductDefinedFrame::calcVelocityInGround(SimTK::State const&) const
SimTK::SpatialVec osc::fd::CrossProductDefinedFrame::calcVelocityInGround(const SimTK::State&) const
{
return {}; // TODO: see OffsetFrame::calcVelocityInGround
}

SimTK::SpatialVec osc::fd::CrossProductDefinedFrame::calcAccelerationInGround(SimTK::State const&) const
SimTK::SpatialVec osc::fd::CrossProductDefinedFrame::calcAccelerationInGround(const SimTK::State&) const
{
return {}; // TODO: see OffsetFrame::calcAccelerationInGround
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ namespace osc::fd
};
ParsedAxisArguments tryParseAxisArgumentsAsOrthogonalAxes() const;

SimTK::Transform calcTransformInGround(SimTK::State const&) const final;
SimTK::SpatialVec calcVelocityInGround(SimTK::State const&) const final;
SimTK::SpatialVec calcAccelerationInGround(SimTK::State const&) const final;
SimTK::Transform calcTransformInGround(const SimTK::State&) const final;
SimTK::SpatialVec calcVelocityInGround(const SimTK::State&) const final;
SimTK::SpatialVec calcAccelerationInGround(const SimTK::State&) const final;
void extendAddToSystem(SimTK::MultibodySystem&) const final;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ void osc::fd::CrossProductEdge::generateDecorations(
}
}

EdgePoints osc::fd::CrossProductEdge::calcLocationsInGround(SimTK::State const& state) const
EdgePoints osc::fd::CrossProductEdge::calcLocationsInGround(const SimTK::State& state) const
{
auto const& [first, second] = getBothEdgePoints(state);
const auto& [first, second] = getBothEdgePoints(state);
return CrossProduct(first, second); // TODO: sort out magnitude etc.
}

std::pair<EdgePoints, EdgePoints> osc::fd::CrossProductEdge::getBothEdgePoints(SimTK::State const& state) const
std::pair<EdgePoints, EdgePoints> osc::fd::CrossProductEdge::getBothEdgePoints(const SimTK::State& state) const
{
return {
getConnectee<Edge>("first_edge").getLocationsInGround(state),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ namespace osc::fd
private:
EdgePoints calcLocationsInGround(const SimTK::State&) const final;

std::pair<EdgePoints, EdgePoints> getBothEdgePoints(SimTK::State const&) const;
std::pair<EdgePoints, EdgePoints> getBothEdgePoints(const SimTK::State&) const;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ namespace osc
class ICustomDecorationGenerator {
protected:
ICustomDecorationGenerator() = default;
ICustomDecorationGenerator(ICustomDecorationGenerator const&) = default;
ICustomDecorationGenerator(const ICustomDecorationGenerator&) = default;
ICustomDecorationGenerator(ICustomDecorationGenerator&&) noexcept = default;
ICustomDecorationGenerator& operator=(ICustomDecorationGenerator const&) = default;
ICustomDecorationGenerator& operator=(const ICustomDecorationGenerator&) = default;
ICustomDecorationGenerator& operator=(ICustomDecorationGenerator&&) noexcept = default;
public:
virtual ~ICustomDecorationGenerator() noexcept = default;

void generateCustomDecorations(
SimTK::State const& state,
const SimTK::State& state,
std::function<void(SceneDecoration&&)> const& callback) const
{
implGenerateCustomDecorations(state, callback);
}
private:
virtual void implGenerateCustomDecorations(
SimTK::State const&,
const SimTK::State&,
std::function<void(SceneDecoration&&)> const&
) const = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <oscar/Graphics/Scene/SceneDecoration.h>

void osc::mow::InMemoryMesh::implGenerateCustomDecorations(
SimTK::State const& state,
const SimTK::State& state,
std::function<void(SceneDecoration&&)> const& out) const
{
out({
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSimCreator/Documents/CustomComponents/InMemoryMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ namespace osc::mow
OpenSim_DECLARE_CONCRETE_OBJECT(InMemoryMesh, OpenSim::Geometry)
public:
InMemoryMesh() = default;
explicit InMemoryMesh(Mesh const& mesh_) : m_OscMesh{mesh_} {}
explicit InMemoryMesh(const Mesh& mesh_) : m_OscMesh{mesh_} {}

void implementCreateDecorativeGeometry(SimTK::Array_<SimTK::DecorativeGeometry>&) const override
{
// do nothing: OpenSim Creator will detect `ICustomDecorationDecorator` and use that
}
private:
void implGenerateCustomDecorations(SimTK::State const&, std::function<void(SceneDecoration&&)> const&) const override;
void implGenerateCustomDecorations(const SimTK::State&, std::function<void(SceneDecoration&&)> const&) const override;

Mesh m_OscMesh;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ void osc::fd::MidpointLandmark::generateDecorations(

SimTK::Vec3 osc::fd::MidpointLandmark::calcLocationInGround(const SimTK::State& state) const
{
auto const& [first, second] = lookupPoints();
const auto& [first, second] = lookupPoints();
return 0.5*(first.getLocationInGround(state) + second.getLocationInGround(state));
}

SimTK::Vec3 osc::fd::MidpointLandmark::calcVelocityInGround(const SimTK::State& state) const
{
auto const& [first, second] = lookupPoints();
const auto& [first, second] = lookupPoints();
return 0.5*(first.getVelocityInGround(state) + second.getVelocityInGround(state));
}

SimTK::Vec3 osc::fd::MidpointLandmark::calcAccelerationInGround(const SimTK::State& state) const
{
auto const& [first, second] = lookupPoints();
const auto& [first, second] = lookupPoints();
return 0.5*(first.getAccelerationInGround(state), second.getAccelerationInGround(state));
}

std::pair<OpenSim::Point const&, OpenSim::Point const&> osc::fd::MidpointLandmark::lookupPoints() const
std::pair<const OpenSim::Point&, const OpenSim::Point&> osc::fd::MidpointLandmark::lookupPoints() const
{
return {
getConnectee<OpenSim::Point>("first_point"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ namespace osc::fd
SimTK::Vec3 calcVelocityInGround(const SimTK::State&) const final;
SimTK::Vec3 calcAccelerationInGround(const SimTK::State&) const final;

std::pair<OpenSim::Point const&, OpenSim::Point const&> lookupPoints() const;
std::pair<const OpenSim::Point&, const OpenSim::Point&> lookupPoints() const;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void osc::fd::PointToPointEdge::generateDecorations(
));
}

EdgePoints osc::fd::PointToPointEdge::calcLocationsInGround(SimTK::State const& state) const
EdgePoints osc::fd::PointToPointEdge::calcLocationsInGround(const SimTK::State& state) const
{
return {
getConnectee<OpenSim::Point>("first_point").getLocationInGround(state),
Expand Down
Loading

0 comments on commit 36bae52

Please sign in to comment.