gwnavruntime/pathfollower/circlearcsplineturn.h Source File

circlearcsplineturn.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 // primary contact: LAPA - secondary contact: NOBODY
8 #ifndef Navigation_CircleArcSplineBubbleData_H
9 #define Navigation_CircleArcSplineBubbleData_H
10 
11 
15 
16 
17 //#define CircleArcSplineBubbleData_MaintainGateAndRadiusRange
18 
19 
20 namespace Kaim
21 {
22 
23 class CircleArcSplineComputer;
24 class CircleArcSplineTurn;
25 class Channel;
26 
27 
28 // Internal: Class used to enrich Bubbles with some data useful for
29 // CircleArcSpline computation.
30 class CircleArcSplineBubbleData
31 {
32 public:
33  CircleArcSplineBubbleData() { Reset(); }
34 
35  BubbleType GetBubbleType() const { return m_bubbleType; }
36 
37 #ifdef CircleArcSplineBubbleData_MaintainGateAndRadiusRange
38  KyUInt32 GetFirstGateIndex() const { return m_firstGateIndex; }
39  KyUInt32 GetLastGateIndex() const { return m_lastGateIndex; }
40  KyFloat32 GetMinRadius() const { return m_minRadius; }
41  KyFloat32 GetMaxRadius() const { return m_maxRadius; }
42 #endif // CircleArcSplineBubbleData_MaintainGateAndRadiusRange
43 
44  const Vec3f& GetMidPoint() const { return m_midPoint; }
45  const Vec2f& GetMedianTurnAxis() const { return m_medianTurnAxis; }
46  const Vec3f& GetEntryPos() const { return m_entryPos; }
47  const Vec3f& GetExitPos() const { return m_exitPos; }
48  KyUInt32 GetEntrySectionIdx() const { return m_entrySectionIdx; }
49  KyUInt32 GetExitSectionIdx() const { return m_exitSectionIdx; }
50  const Vec2f& GetEntryDir() const { return m_entryDir; }
51  const Vec2f& GetExitDir() const { return m_exitDir; }
52  KyUInt32 GetRadiusIndexInProfile() const { return m_radiusIndexInProfile; }
53  bool HasRangeBeenDefined() const { return m_hasRangeBeenDefined; }
54 
55  void Reset()
56  {
57  m_bubbleType = UndefinedBubbleType;
58  m_radiusIndexInProfile = KyUInt32MAXVAL;
59 
60 #ifdef CircleArcSplineBubbleData_MaintainGateAndRadiusRange
61  m_firstGateIndex = KyUInt32MAXVAL;
62  m_lastGateIndex = KyUInt32MAXVAL;
63  m_minRadius = KyFloat32MAXVAL;
64  m_maxRadius = 0.0f;
65 #endif // CircleArcSplineBubbleData_MaintainGateAndRadiusRange
66 
67  m_hasRangeBeenDefined = false;
68  m_entrySectionIdx = KyUInt32MAXVAL;
69  m_exitSectionIdx = KyUInt32MAXVAL;
70  }
71 
72 private:
73  friend class CircleArcSplineTurn;
74  BubbleType m_bubbleType;
75  KyUInt32 m_radiusIndexInProfile;
76 
77 #ifdef CircleArcSplineBubbleData_MaintainGateAndRadiusRange
78  // Both are inclusive. Used to update min and max radius values.
79  KyUInt32 m_firstGateIndex;
80  KyUInt32 m_lastGateIndex;
81 
82  // The range of radius of the Bubbles with same center that do not cross any
83  // channel borders within the firstGate/lastGate range.
84  KyFloat32 m_minRadius;
85  KyFloat32 m_maxRadius;
86 #endif // CircleArcSplineBubbleData_MaintainGateAndRadiusRange
87 
88  bool m_hasRangeBeenDefined;
89  Vec2f m_medianTurnAxis; // The axis bisecting incoming border and outgoing border
90  Vec3f m_midPoint; // The point at MedianTurnAxis and Bubble circle intersection. We try to keep this position on the Bubble when optimizing the spline.
91 
92  Vec3f m_entryPos;
93  KyUInt32 m_entrySectionIdx;
94  Vec2f m_entryDir;
95 
96  Vec3f m_exitPos;
97  KyUInt32 m_exitSectionIdx;
98  Vec2f m_exitDir;
99 };
100 
101 
102 
103 // Internal: Class aggregating all useful information about a turn when building
104 // a CircleArcSpline.
105 class CircleArcSplineTurn
106 {
107 public:
108  CircleArcSplineTurn() : m_channel(KY_NULL) {}
109  CircleArcSplineTurn(const Channel* channel) : m_channel(channel) {}
110  CircleArcSplineTurn(const CircleArcSplineTurn& other) { *this = other; }
111 
112  void operator=(const CircleArcSplineTurn& other)
113  {
114  m_channel = other.m_channel;
115  m_bubble = other.m_bubble;
116  m_bubbleData = other.m_bubbleData;
117  }
118 
119  void Reset();
120 
121  const Bubble& GetBubble() const { return m_bubble; }
122  const CircleArcSplineBubbleData& GetBubbleData() const { return m_bubbleData; }
123 
124  void SetBubble(const Bubble& bubble, BubbleType bubbleType);
125 
126  void SetRadiusIndexInProfile(KyUInt32 radiusIndexInProfile) { m_bubbleData.m_radiusIndexInProfile = radiusIndexInProfile; }
127  void UpdateDataAsSinglePoint(const Vec3f& position, KyUInt32 sectionIdx);
128  void UpdateDataAsSinglePoint(const Vec3f& position, KyUInt32 sectionIdx, const Vec2f& entryDir, const Vec2f& exitDir);
129  void UpdateData(const Vec3f& entryPos, KyUInt32 entrySectionIdx, const Vec3f& exitPos, KyUInt32 exitSectionIdx);
130  void UpdateData(const Vec3f& entryPos, KyUInt32 entrySectionIdx, const Vec3f& exitPos, KyUInt32 exitSectionIdx, const Vec2f& entryDir, const Vec2f& exitDir);
131 
132 #ifdef CircleArcSplineBubbleData_MaintainGateAndRadiusRange
133  KyFloat32 GetMinDistLeft() const;
134  KyFloat32 GetMinDistRight() const;
135 #endif // CircleArcSplineBubbleData_MaintainGateAndRadiusRange
136 
137  bool IsASmallTurn(KyFloat32 fullTurnToleranceSin) const;
138 
139 private:
140  void ComputeMedianTurnAxis();
141 #ifdef CircleArcSplineBubbleData_MaintainGateAndRadiusRange
142  void ComputeRadiusRange();
143 #endif // CircleArcSplineBubbleData_MaintainGateAndRadiusRange
144 
145 private:
146  friend class CircleArcSplineComputer;
147  const Channel* m_channel;
148  Bubble m_bubble;
149  CircleArcSplineBubbleData m_bubbleData;
150 };
151 
152 
153 typedef SharedPoolList<CircleArcSplineTurn> TurnList;
154 
155 
156 } // namespace Kaim
157 
158 #endif // Navigation_CircleArcSplineBubbleData_H
#define KyFloat32MAXVAL
The maximum value that can be stored in the KyFloat32 variable type.
Definition: types.h:227
#define KY_NULL
Null value.
Definition: types.h:247
BubbleType
Defines the type of a bubble accordingly to the place it has in a BubbleArray, a BubbleList, etc.
Definition: bubble.h:26
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43