gwnavgeneration/common/bitarray2d_1024.h Source File

bitarray2d_1024.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_BitArray2d_1024_H
13 #define GwNavGen_BitArray2d_1024_H
14 
15 
19 
20 namespace Kaim
21 {
22 
23 
24 class BitArray2d_1024
25 {
26  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
27 public:
28  BitArray2d_1024(MemoryHeap* heap);
29 
30  KyResult InitMaxSize(KyInt32 maxCountX, KyInt32 maxCountY);
31 
32  KyResult SetSize(KyInt32 countX, KyInt32 countY);
33 
34  void SetPixel(KyInt32 x, KyInt32 y)
35  {
36  KY_DEBUG_ASSERTN(x >= 0 && x < m_countX && y >= 0 && y < m_countY, ("Pixel is outside bounds"));
37  m_lineBitArray.SetBit(y);
38  m_pixelBitArrays[y].SetBit(x);
39  }
40 
41  bool GetPixel(KyInt32 x, KyInt32 y) const
42  {
43  KY_DEBUG_ASSERTN(x >= 0 && x < m_countX && y >= 0 && y < m_countY, ("Pixel is outside bounds"));
44  return m_pixelBitArrays[y].GetBit(x) != 0;
45  }
46 
47  KyInt32 GetFirstY() const { return m_lineBitArray.GetFirstBitIdx(); }
48  KyInt32 GetLastY() const { return m_lineBitArray.GetLastBitIdx(); }
49 
50  KyInt32 GetFirstX(KyInt32 y) const { return m_pixelBitArrays[y].GetFirstBitIdx(); }
51  KyInt32 GetLastX(KyInt32 y) const { return m_pixelBitArrays[y].GetLastBitIdx(); }
52 
53  void ClearBits();
54 
55 private:
56  KyInt32 m_maxCountX;
57  KyInt32 m_maxCountY;
58 
59  KyInt32 m_countX;
60  KyInt32 m_countY;
61 
62  KyInt32 m_wordCountX;
63  KyInt32 m_wordCountY;
64 
65  BitArray_1024 m_lineBitArray;
66  KyArrayTLS<BitArray_1024> m_pixelBitArrays;
67 
68  KyArrayTLS_POD<KyUInt32> m_lineBitsMem;
69  KyArrayTLS_POD<KyUInt32> m_pixelBitsMem;
70 
71  MemoryHeap* m_heap;
72 };
73 
74 
75 }
76 
77 
78 #endif
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137