gwnavgeneration/boundary/boundarysimplifypolyline.h Source File

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