prototype_link_entity.h
Go to the documentation of this file.
1 
8 #ifndef PROTOTYPE_LINK_ENTITY_H
9 #define PROTOTYPE_LINK_ENTITY_H
10 
11 namespace argos {
12  class CPrototypeLinkEntity;
13 }
14 
15 #include <argos3/core/simulator/entity/embodied_entity.h>
16 #include <argos3/core/utility/math/convex_hull.h>
17 #include <argos3/core/utility/math/quaternion.h>
18 #include <argos3/core/utility/math/vector3.h>
19 
20 #include <unordered_map>
21 
22 namespace argos {
23 
24  class CPrototypeLinkEntity : public CEntity {
25 
26  public:
27 
29 
30  using TVector = std::vector<CPrototypeLinkEntity*>;
31  using TVectorIterator = std::vector<CPrototypeLinkEntity*>::iterator;
32  using TVectorConstIterator = std::vector<CPrototypeLinkEntity*>::const_iterator;
33 
34  public:
35  enum EGeometry {
37  BOX,
40  };
41 
42  public:
43 
45 
46  virtual ~CPrototypeLinkEntity() {}
47 
48  virtual void Init(TConfigurationNode& t_tree);
49 
50  virtual std::string GetTypeDescription() const {
51  return "link";
52  }
53 
55  return m_eGeometry;
56  }
57 
58  const CVector3& GetExtents() const {
59  return m_cExtents;
60  }
61 
62  const std::vector<CVector3>& GetConvexHullPoints() const {
63  ARGOS_ASSERT(m_eGeometry == EGeometry::CONVEX_HULL,
64  "CPrototypeLinkEntity::GetConvexHullPoints(), id=\"" <<
65  GetContext() << GetId() <<
66  "\": is not a convex hull.");
67  return m_vecConvexHullPoints;
68  }
69 
70  const std::vector<CConvexHull::SFace>& GetConvexHullFaces() const {
71  ARGOS_ASSERT(m_eGeometry == EGeometry::CONVEX_HULL,
72  "CPrototypeLinkEntity::GetConvexHullFaces(), id=\"" <<
73  GetContext() << GetId() <<
74  "\": is not a convex hull.");
75  return m_vecConvexHullFaces;
76  }
77 
78  Real GetMass() const {
79  return m_fMass;
80  }
81 
83  return *m_psAnchor;
84  }
85 
86  const SAnchor& GetAnchor() const {
87  return *m_psAnchor;
88  }
89 
90  private:
91 
92  EGeometry m_eGeometry;
93  CVector3 m_cExtents;
94  Real m_fMass;
95  SAnchor* m_psAnchor;
96 
97  std::vector<CVector3> m_vecConvexHullPoints;
98  std::vector<CConvexHull::SFace> m_vecConvexHullFaces;
99  };
100 
101 }
102 
103 #endif
#define ARGOS_ASSERT(condition, message)
When code is compiled in debug, this macro throws an ARGoS exception with the passed message if the s...
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Basic class for an entity that contains other entities.
The basic entity type.
Definition: entity.h:90
std::vector< CEntity * > TVector
A vector of entities.
Definition: entity.h:97
const std::string & GetId() const
Returns the id of this entity.
Definition: entity.h:157
std::string GetContext() const
Returns the context of this entity.
Definition: entity.cpp:79
An anchor related to the body of an entity.
Definition: physics_model.h:38
A 3D vector class.
Definition: vector3.h:31
CPrototypeLinkEntity(CComposableEntity *pc_parent)
const CVector3 & GetExtents() const
std::vector< CPrototypeLinkEntity * >::const_iterator TVectorConstIterator
std::vector< CPrototypeLinkEntity * >::iterator TVectorIterator
const std::vector< CVector3 > & GetConvexHullPoints() const
const SAnchor & GetAnchor() const
virtual std::string GetTypeDescription() const
Returns a string label for this class.
const std::vector< CConvexHull::SFace > & GetConvexHullFaces() const
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.