Skip to content

Commit

Permalink
Add tpelib::Shape::GetSize() and tpelib::Model::GetCanonicalLink() (#45)
Browse files Browse the repository at this point in the history
* implement missing Shape::GetSize(), add Model::GetCanonicalLink()
* add doxygen doc and GetSize() test case

Signed-off-by: claireyywang <clairewang@openrobotics.org>
  • Loading branch information
Claire Wang authored Apr 30, 2020
1 parent 15cb164 commit fa418b3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tpe/lib/src/Model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ Entity &Model::AddLink()
return *it->second.get();
}

//////////////////////////////////////////////////
Entity &Model::GetCanonicalLink()
{
// return first link as canonical link
return *this->GetChildren().begin()->second;
}


//////////////////////////////////////////////////
void Model::SetLinearVelocity(const math::Vector3d _velocity)
{
Expand Down
4 changes: 4 additions & 0 deletions tpe/lib/src/Model.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class IGNITION_PHYSICS_TPELIB_VISIBLE Model : public Entity
/// \return Newly created Link
public: Entity &AddLink();

/// \brief Get the canonical link of model
/// \return Entity the canonical (first) link
public: Entity &GetCanonicalLink();

/// \brief Set the linear velocity of model
/// \param[in] _velocity linear velocity
public: void SetLinearVelocity(const math::Vector3d _velocity);
Expand Down
6 changes: 6 additions & 0 deletions tpe/lib/src/Shape.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ void BoxShape::SetSize(const math::Vector3d &_size)
this->dirty = true;
}

//////////////////////////////////////////////////
math::Vector3d BoxShape::GetSize()
{
return this->size;
}

//////////////////////////////////////////////////
void BoxShape::UpdateBoundingBox()
{
Expand Down
1 change: 1 addition & 0 deletions tpe/lib/src/Shape_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ TEST(Shape, BoxShape)

math::Vector3d size(1.2, 3.6, 5.8);
shape.SetSize(size);
EXPECT_EQ(size, shape.GetSize());
math::AxisAlignedBox bbox = shape.GetBoundingBox();
EXPECT_EQ(math::Vector3d::Zero, bbox.Center());
EXPECT_EQ(size, bbox.Size());
Expand Down

0 comments on commit fa418b3

Please sign in to comment.