Atoms Crowd  7.0.0
LayoutGenerator.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Toolchefs license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 // ===========================================================================
9 
10 #include <Atoms/Globals.h>
11 #include <Atoms/AgentTypes.h>
12 #include <AtomsCore/Globals.h>
13 #include <Atoms/AgentType.h>
14 #include <Atoms/BehaviourModuleAttributeCache.h>
15 #include <Atoms/AgentInitData.h>
16 #include <atomic>
17 
18 namespace Atoms
19 {
20  class LayoutGenerator;
21 
22  typedef AtomsPtr<LayoutGenerator> LayoutGeneratorPtr;
23 
25 
30  class ATOMS_EXPORT LayoutGenerator
31  {
32  public:
33 
35 
38  LayoutGenerator(bool isStatic = true);
39 
41  virtual ~LayoutGenerator();
42 
44  virtual bool allowMultiLayoutGenerator();
45 
47  virtual bool allowMultiple();
48 
50  virtual bool mustBeFirst();
51 
53  inline bool isStaticGenerator() const;
54 
56  inline void setAsStaticGenerator(bool value);
57 
59  virtual std::vector<AgentInitData> generate(double time) = 0;
60 
62  virtual inline AgentTypePtr agentType(const int groupId, const std::string& groupIdStr);
63 
64  inline void setAgentTypeAttributeCache(const BehaviourModuleAttributeCache<std::string>& agentTypeAttributeCache);
65 
66  inline void setDirectionAttributeCache(const BehaviourModuleAttributeCache<AtomsCore::Vector3>& directionAttributeCache);
67 
68  inline void setUpVectorAttributeCache(const BehaviourModuleAttributeCache<AtomsCore::Vector3>& upVectorAttributeCache);
69 
70  inline std::atomic<size_t>& nextFreeId();
71 
72  inline const std::atomic<size_t>& nextFreeId() const;
73 
75  inline void setName(const std::string &name);
76 
78  inline const std::string &name();
79 
81  virtual const char *typeName() = 0;
82 
84  void setGroupIdOffset(const int offset);
85 
87  const int groupIdOffset();
88 
90  inline void setOffsetPelvisHeight(bool state);
91 
93  inline void setOffsetPelvisHeightOverride(const std::map<int, bool>& value);
94 
96  inline void setOffsetPelvisHeightAttributeCache(const BehaviourModuleAttributeCache<bool>& offsetPelvisHeightCache);
97 
99  static const std::string getDefaultAgentType();
100 
101  protected:
102 
103  // Apply pelvis height offset attribute cache
104  BehaviourModuleAttributeCache<bool> m_applyPelvisHeightOffsetCache;
105 
106  // agent type attribute cache
107  BehaviourModuleAttributeCache<std::string> m_agentTypeAttributeCache;
108 
109  // direction attribute cache
110  BehaviourModuleAttributeCache<AtomsCore::Vector3> m_directionAttributeCache;
111 
112  // up vector attribute cache
113  BehaviourModuleAttributeCache<AtomsCore::Vector3> m_upVectorAttributeCache;
114 
115  private:
116 
117  AgentTypePtr m_agentType;
118 
119  std::atomic<size_t> m_nextFreeId;
120 
121  bool m_staticGenerator;
122 
123  std::string m_name;
124 
125  int m_groupIdOffset;
126  };
127 }
128 
129 #include "LayoutGenerator.impl.h"
Layout generator.
Definition: LayoutGenerator.h:31
void setGroupIdOffset(const int offset)
Set the offset for the group ids of this layout generator.
void setOffsetPelvisHeightOverride(const std::map< int, bool > &value)
Sets the map per agent to offset height according to the distance between pelvis and foot.
virtual bool mustBeFirst()
Returns wheter this layout generator should be the first one in the stack.
virtual bool allowMultiple()
Returns whether an Agent Group can have multiple instances of this layout generator.
void setOffsetPelvisHeight(bool state)
Sets the flag to offset height according to the distance between pelvis and foot.
virtual ~LayoutGenerator()
Destructor.
const int groupIdOffset()
Get the offset for the group ids of this layout generator.
virtual std::vector< AgentInitData > generate(double time)=0
Generate a vector of agent init data.
virtual bool allowMultiLayoutGenerator()
Returns whether this layout generator can work in conjunction with other layout generators.
static const std::string getDefaultAgentType()
Get the default agent type name.
virtual const char * typeName()=0
Get the type name for this generator.
LayoutGenerator(bool isStatic=true)
Constructor.
Atoms namespace.
Definition: Agent.h:29
AtomsPtr< AgentType > AgentTypePtr
Agent type pointer.
Definition: AgentType.h:17