gwnavgeneration/boundary/boundarysimplifypolyline.h Source File

boundarysimplifypolyline.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 
8 
9 
10 
11 // primary contact: GUAL - secondary contact: NOBODY
12 #ifndef GwNavGen_BoundarySimplifyPolyline_H
13 #define GwNavGen_BoundarySimplifyPolyline_H
14 
15 
20 
21 namespace Kaim
22 {
23 
24 
25 class BoundarySimplifyVertex
26 {
27  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
28 public:
29  BoundarySimplifyVertex() : m_vertex(KY_NULL), m_inSmallEdge(KY_NULL), m_outSmallEdge(KY_NULL) {}
30 
31  BoundarySimplifyVertex(BoundaryEdge* inSmallEdge, BoundaryVertex* vertex, BoundaryEdge* outSmallEdge)
32  {
33  m_pos.x = (KyFloat32)vertex->m_exclBoundaryPos.x;
34  m_pos.y = (KyFloat32)vertex->m_exclBoundaryPos.y;
35  m_pos.z = vertex->m_altitude;
36  m_vertex = vertex;
37  m_inSmallEdge = inSmallEdge;
38  m_outSmallEdge = outSmallEdge;
39  }
40 
41 public:
42  Vec3f m_pos; // x and y are the Pixel position, their are not real float positions
43  BoundaryVertex* m_vertex;
44  BoundaryEdge* m_inSmallEdge;
45  BoundaryEdge* m_outSmallEdge;
46 };
47 
48 typedef SharedPoolList<BoundarySimplifyVertex>::NodePool BoundaryVertexPool;
49 typedef SharedPoolList<BoundarySimplifyVertex> BoundaryVertexList;
50 typedef SharedPoolList<BoundarySimplifyVertex>::Iterator BoundaryVertexListIterator;
51 typedef SharedPoolList<BoundarySimplifyVertex>::ConstIterator BoundaryVertexListConstIterator;
52 // Linked list of BoundaryVertices for simplification usage
53 class BoundarySimplifyPolyline
54 {
55  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
56 public:
57  typedef BoundarySimplifyVertex Vertex;
58 
59 public:
60  BoundarySimplifyPolyline(BoundaryVertexPool* pool) : m_vertices(pool)
61  {
62  Init(KyUInt32MAXVAL, ContourWinding_Unset, BoundaryEdgeType_Unset, PolylineCycleStatus_Unset);
63  }
64 
65  void Init(KyUInt32 index, ContourWinding contourWinding, BoundaryEdgeType edgeType, BoundaryPolylineCycleStatus cycle)
66  {
67  m_index = index;
68  m_contourWinding = contourWinding;
69  m_edgeType = edgeType;
70  m_vertices.Clear();
71  m_cycleStatus = cycle;
72  m_next = KY_NULL;
73  }
74 
75  void AddVertex(BoundaryEdge* inEdge, BoundaryVertex* vertex, BoundaryEdge* outEdge)
76  {
77  BoundarySimplifyVertex simplifyVertex(inEdge, vertex, outEdge);
78  m_vertices.PushBack(simplifyVertex);
79 
80  if (inEdge)
81  PutEdgeInPolyline(inEdge);
82 
83  if (outEdge)
84  PutEdgeInPolyline(outEdge);
85  }
86 
87  void PutEdgeInPolyline(BoundaryEdge* edge)
88  {
89  edge->m_simplifyPolyline = this;
90  edge->m_simplifyPolylineOrder = BoundaryOrder_Straight;
91 
92  if (edge->m_pair)
93  {
94  edge->m_pair->m_simplifyPolyline = this;
95  edge->m_pair->m_simplifyPolylineOrder = BoundaryOrder_Reverse;
96  }
97  }
98 
99 public:
100  KyUInt32 m_index;
101  BoundaryVertexList m_vertices;
102  ContourWinding m_contourWinding;
103  BoundaryEdgeType m_edgeType;
104  BoundaryPolylineCycleStatus m_cycleStatus; // if (m_cycle == Polyline_Cycle) then m_vertices.first != vertices.last
105  BoundarySimplifyPolyline* m_next;
106 };
107 
108 
109 }
110 
111 
112 #endif
#define KY_NULL
Null value.
Definition: types.h:247
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
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