Skip to content

Commit

Permalink
Attempting Mac build fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sherm1 committed Oct 24, 2023
1 parent 4d07e46 commit e3e2057
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 22 deletions.
49 changes: 36 additions & 13 deletions multibody/topology/link_joint_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,19 +266,16 @@ class LinkJointGraph {
}

const std::vector<Link>& links() const { return data_.links; }
const Link& links(LinkIndex link_index) const {
return links().at(link_index);
}
inline const Link& links(LinkIndex link_index) const; // Defined below.

const std::vector<Joint>& joints() const { return data_.joints; }
const Joint& joints(JointIndex joint_index) const {
return joints().at(joint_index);
}
inline const Joint& joints(JointIndex joint_index) const; // Defined below.

const std::vector<Constraint>& constraints() const {
return data_.constraints;
}
const Constraint& constraints(ConstraintIndex constraint_index) const {
return constraints().at(constraint_index);
}
// Defined below.
inline const Constraint& constraints(ConstraintIndex constraint_index) const;

/** Links with this index or higher were added during modeling. */
int num_user_links() const { return data_.num_user_links; }
Expand Down Expand Up @@ -408,11 +405,9 @@ class LinkJointGraph {
private:
friend class SpanningForest;

Link& mutable_link(LinkIndex link_index) { return data_.links[link_index]; }
inline Link& mutable_link(LinkIndex link_index); // Defined below.

Joint& mutable_joint(JointIndex joint_index) {
return data_.joints[joint_index];
}
inline Joint& mutable_joint(JointIndex joint_index); // Defined below.

// For use by SpanningForest.
void set_primary_mobod_for_link(LinkIndex link_index,
Expand Down Expand Up @@ -737,6 +732,12 @@ class LinkJointGraph::Link {
CompositeLinkIndex composite_link_index_; // Invalid if not in composite.
};

// Definitions deferred until Link available.

inline auto LinkJointGraph::links(LinkIndex link_index) const -> const Link& {
return links().at(link_index);
}

inline MobodIndex LinkJointGraph::link_to_mobod(LinkIndex index) const {
return links(index).mobod_;
}
Expand All @@ -763,6 +764,10 @@ inline bool LinkJointGraph::must_treat_as_massless(LinkIndex link_index) const {
return link.treat_as_massless();
}

inline auto LinkJointGraph::mutable_link(LinkIndex link_index) -> Link& {
return data_.links[link_index];
}

/* Overloads to make JointFlags behave in a civilized manner. */
inline JointFlags operator|(JointFlags left, JointFlags right) {
return static_cast<JointFlags>(static_cast<unsigned>(left) |
Expand Down Expand Up @@ -887,6 +892,13 @@ class LinkJointGraph::Joint {
how_modeled_;
};

// Definitions deferred until Joint available.

inline auto LinkJointGraph::joints(JointIndex joint_index) const
-> const Joint& {
return joints().at(joint_index);
}

inline void LinkJointGraph::set_mobod_for_joint(JointIndex joint_index,
MobodIndex mobod_index) {
Joint& joint = mutable_joint(joint_index);
Expand All @@ -906,6 +918,10 @@ inline void LinkJointGraph::change_joint_flags(JointIndex joint_index,
mutable_joint(joint_index).set_flags(flags);
}

inline auto LinkJointGraph::mutable_joint(JointIndex joint_index) -> Joint& {
return data_.joints[joint_index];
}

/** A constraint that restricts the relative motion of two Links. The
parent/child distinction sets the sign convention for the constraint
multipliers. Added welds between a primary %Link and one of its shadow Links
Expand Down Expand Up @@ -942,6 +958,13 @@ class LinkJointGraph::Constraint {
LinkIndex child_link_index_;
};

// Definitions deferred until Constraint availble.

inline auto LinkJointGraph::constraints(ConstraintIndex constraint_index) const
-> const Constraint& {
return constraints().at(constraint_index);
}

struct LinkJointGraph::JointType {
std::string type_name;
int nq{-1};
Expand Down
37 changes: 28 additions & 9 deletions multibody/topology/spanning_forest.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,17 @@ class SpanningForest {
const std::vector<Mobod>& mobods() const { return data_.mobods; }
/** Provides convenient access to a particular Mobod.
@pre mobod_index is in range */
const Mobod& mobods(MobodIndex mobod_index) const {
return mobods()[mobod_index];
}
inline const Mobod& mobods(MobodIndex mobod_index) const; // Defined below.

/** The mobilized body (Mobod) corresponding to the World Link. */
const Mobod& world_mobod() const { return mobods(MobodIndex(0)); }

/** Constraints we added to close loops we had to cut. */
const std::vector<LoopConstraint>& loop_constraints() const {
return data_.loop_constraints;
}
const LoopConstraint& loop_constraints(LoopConstraintIndex index) const {
return loop_constraints()[index];
}
inline const LoopConstraint& loop_constraints( // Defined below.
LoopConstraintIndex index) const;

/** The partitioning of the forest of mobilized bodies into trees. Each Tree
has a base (root) mobilized body that is connected directly to the World
Expand All @@ -200,7 +198,7 @@ class SpanningForest {
const std::vector<Tree>& trees() const { return data_.trees; }
/** Provides convenient access to a particular Tree.
@pre tree_index is in range */
const Tree& trees(TreeIndex tree_index) const { return trees()[tree_index]; }
inline const Tree& trees(TreeIndex tree_index) const; // Defined below.

/** Returns the height of the Forest, defined as the height of the tallest
Tree in the Forest, plus 1 for World. This is always at least 1 since World
Expand Down Expand Up @@ -248,13 +246,14 @@ class SpanningForest {
Mobod represents a Composite of many Links, the Link returned here is the
"representative" Link, that is, the one whose mobilizer is used for the whole
Composite. Cost is O(1) and very fast. */
inline LinkIndex mobod_to_link(MobodIndex mobod_index) const; // see below
// Defined below.
inline LinkIndex mobod_to_link(MobodIndex mobod_index) const;

/** Returns all the Links mobilized by this Mobod. The "representative"
Link returned by mobod_to_link() comes first, then any other Links in the
same Composite. */
inline const std::vector<LinkIndex>& mobod_to_links(
MobodIndex mobod_index) const; // see below
MobodIndex mobod_index) const; // Defined below.

/** Returns the total number of generalized position coordinates q used by
this model. O(1), very fast. */
Expand Down Expand Up @@ -609,6 +608,13 @@ class SpanningForest::Mobod {
int nv_{-1}; // within the full v vector
};

// Definitions deferred until Mobod available.

inline auto SpanningForest::mobods(MobodIndex mobod_index) const
-> const Mobod& {
return mobods()[mobod_index];
}

//============================= Loop Constraint ================================
/** Weld constraints added during modeling to close loops. */
class SpanningForest::LoopConstraint {
Expand Down Expand Up @@ -636,6 +642,13 @@ class SpanningForest::LoopConstraint {
ConstraintIndex graph_constraint_index_; // As added to the graph.
};

// Definitions deferred until LoopConstraint available.

inline auto SpanningForest::loop_constraints(LoopConstraintIndex index) const
-> const LoopConstraint& {
return loop_constraints()[index];
}

//================================== Tree ======================================
/** Everything you might want to know about an individual tree in the forest.
A Tree consists of consecutively numbered Mobod nodes in depth first order.
Expand Down Expand Up @@ -703,6 +716,12 @@ class SpanningForest::Tree {
const SpanningForest* forest_{nullptr}; // The containing forest.
};

// Definitions deferred until Tree available.

inline auto SpanningForest::trees(TreeIndex tree_index) const -> const Tree& {
return trees()[tree_index];
}

//================================ inlines =====================================

inline LinkIndex SpanningForest::mobod_to_link(MobodIndex mobod_index) const {
Expand Down

0 comments on commit e3e2057

Please sign in to comment.