gwnavgeneration/common/bitarray2d_1024.h Source File

bitarray2d_1024.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 
8 
9 
10 
11 #pragma once
12 
13 
17 
18 namespace Kaim
19 {
20 
21 
22 class BitArray2d_1024
23 {
24  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
25 public:
26  BitArray2d_1024(MemoryHeap* heap);
27 
28  KyResult InitMaxSize(KyInt32 maxCountX, KyInt32 maxCountY);
29 
30  KyResult SetSize(KyInt32 countX, KyInt32 countY);
31 
32  void SetPixel(KyInt32 x, KyInt32 y)
33  {
34  KY_DEBUG_ASSERTN(x >= 0 && x < m_countX && y >= 0 && y < m_countY, ("Pixel is outside bounds"));
35  m_lineBitArray.SetBit(y);
36  m_pixelBitArrays[y].SetBit(x);
37  }
38 
39  bool GetPixel(KyInt32 x, KyInt32 y) const
40  {
41  KY_DEBUG_ASSERTN(x >= 0 && x < m_countX && y >= 0 && y < m_countY, ("Pixel is outside bounds"));
42  return m_pixelBitArrays[y].GetBit(x) != 0;
43  }
44 
45  KyInt32 GetFirstY() const { return m_lineBitArray.GetFirstBitIdx(); }
46  KyInt32 GetLastY() const { return m_lineBitArray.GetLastBitIdx(); }
47 
48  KyInt32 GetFirstX(KyInt32 y) const { return m_pixelBitArrays[y].GetFirstBitIdx(); }
49  KyInt32 GetLastX(KyInt32 y) const { return m_pixelBitArrays[y].GetLastBitIdx(); }
50 
51  void ClearBits();
52 
53 private:
54  KyInt32 m_maxCountX;
55  KyInt32 m_maxCountY;
56 
57  KyInt32 m_countX;
58  KyInt32 m_countY;
59 
60  KyInt32 m_wordCountX;
61  KyInt32 m_wordCountY;
62 
63  BitArray_1024 m_lineBitArray;
64  KyArrayTLS<BitArray_1024> m_pixelBitArrays;
65 
66  KyArrayTLS_POD<KyUInt32> m_lineBitsMem;
67  KyArrayTLS_POD<KyUInt32> m_pixelBitsMem;
68 
69  MemoryHeap* m_heap;
70 };
71 
72 
73 }
74 
75 
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
std::int32_t KyInt32
int32_t
Definition: types.h:24