gwnavgeneration/boundary/boundarygraphblob.h Source File

boundarygraphblob.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 
18 
19 namespace Kaim
20 {
21 
22 
23 class BoundaryGraphBlobVertex
24 {
25  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
26 public:
27  BoundaryPos m_boundaryPos; // in world (not local)
28  KyFloat32 m_altitude;
29  KyUInt32 m_ins[4];
30  KyUInt32 m_outs[4];
31  BoundaryVertexStaticStatus m_staticStatus;
32  KyUInt32 m_index;
33 };
34 inline void SwapEndianness(Endianness::Target e, BoundaryGraphBlobVertex& self)
35 {
36  SwapEndianness(e, self.m_boundaryPos);
37  SwapEndianness(e, self.m_altitude);
38 
39  for (KyUInt32 i = 0; i < 4; ++i)
40  SwapEndianness(e, self.m_ins[i]);
41 
42  for (KyUInt32 i = 0; i < 4; ++i)
43  SwapEndianness(e, self.m_outs[i]);
44 
45  SwapEndianness(e, self.m_staticStatus);
46  SwapEndianness(e, self.m_index);
47 }
48 
49 
50 class BoundaryGraphBlobSimplifyPolyline
51 {
52  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
53 public:
54  KyUInt32 m_cycle;
55  BlobArray<KyUInt32> m_vertices;
56 };
57 inline void SwapEndianness(Endianness::Target e, BoundaryGraphBlobSimplifyPolyline& self)
58 {
59  SwapEndianness(e, self.m_cycle);
60  SwapEndianness(e, self.m_vertices);
61 }
62 
63 
64 class BoundaryGraphBlobEdge
65 {
66  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
67 public:
68  void SetBoundaryEdgeType(BoundaryEdgeType type) { m_type = (KyUInt32)type; }
69  BoundaryEdgeType GetBoundaryEdgeType() const { return (BoundaryEdgeType)m_type; }
70 
71 public:
72  CardinalDir m_dir;
73  KyUInt32 m_type;
74  KyUInt32 m_vertex[2];
75  KyUInt32 m_next;
76  KyUInt32 m_pair;
77  KyUInt32 m_index;
78 };
79 inline void SwapEndianness(Endianness::Target e, BoundaryGraphBlobEdge& self)
80 {
81  SwapEndianness(e, self.m_dir);
82  SwapEndianness(e, self.m_type);
83  SwapEndianness(e, self.m_vertex[0]);
84  SwapEndianness(e, self.m_vertex[1]);
85  SwapEndianness(e, self.m_next);
86  SwapEndianness(e, self.m_pair);
87  SwapEndianness(e, self.m_index);
88 }
89 
90 
91 class BoundaryGraphBlobContour
92 {
93  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
94 public:
95  KyUInt32 m_edgeCount;
96  KyUInt32 m_begin;
97  ContourWinding m_type;
98  PixelColor m_leftColor;
99  KyUInt32 m_index;
100 };
101 inline void SwapEndianness(Endianness::Target e, BoundaryGraphBlobContour& self)
102 {
103  SwapEndianness(e, self.m_edgeCount);
104  SwapEndianness(e, self.m_begin);
105  SwapEndianness(e, self.m_type);
106  SwapEndianness(e, self.m_leftColor);
107  SwapEndianness(e, self.m_index);
108 }
109 
110 
111 class BoundaryGraphBlobPolygon
112 {
113  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
114 public:
115  PixelColor m_leftColor;
116  BlobArray<KyUInt32> m_contours;
117 };
118 inline void SwapEndianness(Endianness::Target e, BoundaryGraphBlobPolygon& self)
119 {
120  SwapEndianness(e, self.m_leftColor);
121  SwapEndianness(e, self.m_contours);
122 }
123 
124 
125 class BoundaryGraphBlobSimplifiedHalfEdge
126 {
127  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
128 public:
129 public:
130  void SetBoundaryEdgeType(BoundaryEdgeType type) { m_type = (KyUInt32)type; }
131  BoundaryEdgeType GetBoundaryEdgeType() const { return (BoundaryEdgeType)m_type; }
132 
133 public:
134  KyUInt32 m_type;
135  KyUInt32 m_vertex[2];
136  KyUInt32 m_next;
137  KyUInt32 m_pair;
138  KyUInt32 m_index;
139 };
140 inline void SwapEndianness(Endianness::Target e, BoundaryGraphBlobSimplifiedHalfEdge& self)
141 {
142  SwapEndianness(e, self.m_type);
143  SwapEndianness(e, self.m_vertex[0]);
144  SwapEndianness(e, self.m_vertex[1]);
145  SwapEndianness(e, self.m_next);
146  SwapEndianness(e, self.m_pair);
147  SwapEndianness(e, self.m_index);
148 }
149 
150 
151 class BoundaryGraphBlobSimplifiedContour
152 {
153  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
154 public:
155  KyUInt32 m_edgeCount;
156  KyUInt32 m_begin;
157  ContourWinding m_winding;
158  PixelColor m_leftColor;
159  KyUInt32 m_index;
160 };
161 inline void SwapEndianness(Endianness::Target e, BoundaryGraphBlobSimplifiedContour& self)
162 {
163  SwapEndianness(e, self.m_edgeCount);
164  SwapEndianness(e, self.m_begin);
165  SwapEndianness(e, self.m_winding);
166  SwapEndianness(e, self.m_leftColor);
167  SwapEndianness(e, self.m_index);
168 }
169 
170 
171 class BoundaryGraphBlobSimplifiedPolygon
172 {
173  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
174 public:
175  PixelColor m_leftColor;
176  BlobArray<KyUInt32> m_simplifiedContours;
177 };
178 inline void SwapEndianness(Endianness::Target e, BoundaryGraphBlobSimplifiedPolygon& self)
179 {
180  SwapEndianness(e, self.m_leftColor);
181  SwapEndianness(e, self.m_simplifiedContours);
182 }
183 
184 
185 class BoundaryGraphBlob
186 {
187  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
188  KY_ROOT_BLOB_CLASS(Generator, BoundaryGraphBlob, 2)
189 
190 public:
191  typedef BoundaryGraphBlobVertex Vertex;
192  typedef BoundaryGraphBlobEdge Edge;
193  typedef BoundaryGraphBlobContour Contour;
194  typedef BoundaryGraphBlobPolygon Polygon;
195  typedef BoundaryGraphBlobSimplifyPolyline SimplifyPolyline;
196  typedef BoundaryGraphBlobSimplifiedHalfEdge SimplifiedHalfEdge;
197  typedef BoundaryGraphBlobSimplifiedContour SimplifiedContour;
198  typedef BoundaryGraphBlobSimplifiedPolygon SimplifiedPolygon;
199 
200 public:
201  KyFloat32 m_rasterPrecision;
202  PixelAndCellGrid m_pixelAndCellGrid;
203  CellDesc m_cellDesc;
204  BlobArray<Vertex> m_vertices;
205  BlobArray<Edge> m_edges;
206  BlobArray<Contour> m_contours;
207  BlobArray<Polygon> m_polygons;
208  BlobArray<SimplifyPolyline> m_simplifyPolylines;
209  BlobArray<SimplifiedHalfEdge> m_simplifiedEdges;
210  BlobArray<SimplifiedContour> m_simplifiedContours;
211  BlobArray<SimplifiedPolygon> m_simplifiedPolygons;
212 };
213 inline void SwapEndianness(Endianness::Target e, BoundaryGraphBlob& self)
214 {
215  SwapEndianness(e, self.m_rasterPrecision);
216  SwapEndianness(e, self.m_pixelAndCellGrid);
217  SwapEndianness(e, self.m_cellDesc);
218  SwapEndianness(e, self.m_vertices);
219  SwapEndianness(e, self.m_edges);
220  SwapEndianness(e, self.m_contours);
221  SwapEndianness(e, self.m_polygons);
222  SwapEndianness(e, self.m_simplifyPolylines);
223  SwapEndianness(e, self.m_simplifiedEdges);
224  SwapEndianness(e, self.m_simplifiedContours);
225  SwapEndianness(e, self.m_simplifiedPolygons);
226 }
227 
228 
229 }
230 
231 
232 
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
KyUInt32 CardinalDir
Defines a type that refers to one of the cardinal points on the compass:
Definition: cardinaldir.h:15
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
float KyFloat32
float
Definition: types.h:32