gwnavgeneration/raster/dynamicrastercell.h Source File

dynamicrastercell.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 // primary contact: GUAL - secondary contact: NOBODY
9 #ifndef GwNavGen_DynamicRasterCell_H
10 #define GwNavGen_DynamicRasterCell_H
11 
12 
21 
22 namespace Kaim
23 {
24 
25 class GeneratorSystem;
26 class SingleStagePixel;
27 class InputCellBlob;
28 class NavTag;
29 
30 
31 class DynamicRasterCell
32 {
33  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
34  KY_CLASS_WITHOUT_COPY(DynamicRasterCell)
35 
36 public:
37  DynamicRasterCell(
38  const GeneratorParameters& config, const CellDesc& cellDesc,
39  const KyArrayPOD<const InputCellBlob*>* inputCells,
40  const KyArrayTLS_POD<const NavTag*>* navTagArray,
41  KyFloat32 modifiedRasterPrecision = 0.0f,
42  const PixelBox* modifiedPixelBox = KY_NULL);
43 
44  void Setup(const GeneratorParameters& config, const CellDesc& cellDesc,
45  const KyArrayPOD<const InputCellBlob*>* inputCells, KyFloat32 rasterPrecision, const PixelBox& pixelBox);
46 
47  // To be called before the fill of dynamicColumns: GetDynamicColumn().PushPixel().
48  void BeginColumns();
49 
50  // To be called between BeginColumns() and EndColumns().
51  void PushPixel(const PixelPos& pixelPos, const SingleStagePixel& pixel, KyUInt32 navTagIdx, KyUInt32 ownerIdx = KyUInt32MAXVAL);
52 
53  // To be called between BeginColumns() and EndColumns().
54  void PushPixelToLocal(const PixelPos& localPixelPos, const SingleStagePixel& pixel, KyUInt32 navTagIdx);
55 
56  // To be called between BeginColumns() and EndColumns().
57  void PushPixel(KyInt32 rowMajorIdx, const SingleStagePixel& pixel, KyUInt32 navTagIdx, KyUInt32 ownerIdx = KyUInt32MAXVAL);
58 
59  // To be called after the fill of dynamicColumns: GetDynamicColumn().PushPixel().
60  // Copy dynamicColumns to finalColumns and release dynamicColumns.
61  void EndColumns();
62 
63  // Once EndColumns() has been called, read FinalColumns.
64  const BoxOfArrays<KyFloat32>::Column& GetFinalColumnFromLocal(const PixelPos& localPixelPos) const;
65 
66  // Once EndColumns() has been called, read FinalColumns.
67  const BoxOfArrays<KyFloat32>::Column& GetFinalColumn(const PixelPos& pixelPos) const;
68 
69  // Once EndColumns() has been called, read FinalColumns.
70  const BoxOfArrays<KyUInt32>::Column& GetFinalNavTagColumnFromLocal(const PixelPos& localPixelPos) const;
71 
72  // Once EndColumns() has been called, read FinalColumns.
73  const BoxOfArrays<KyUInt32>::Column& GetFinalNavTagIndicesColumn(const PixelPos& pixelPos) const;
74 
75  // Write Raster file and Raster 3d obj file if specified in the generatorConfig, for debug purpose.
76  KyResult WriteIntermediateRasterFile(GeneratorSystem* system) const;
77 
78  bool IsEmpty() const { return m_isEmpty; }
79  bool AreAllInputCellsOverlapping() const {return m_inputCells->GetCount() == 1 || m_areAllInputCellsOverlapping; }
80  bool HasMultipleNavTags() const { return m_hasMultipleNavTags; }
81 
82  void SetHasMultipleNavTags(bool hasMultipleNavTags) { m_hasMultipleNavTags = hasMultipleNavTags; }
83 
84  const PixelBox& GetPixelBox() const { return m_pixelBox; }
85  const CellDesc& GetCellDesc() const { return m_cellDesc; }
86 
87  const BoxOfArrays<KyFloat32>& GetFinalColumns() const { return m_finalColumns; }
88  BoxOfArrays<KyFloat32>& GetFinalColumns() { return m_finalColumns; }
89 
90  const BoxOfArrays<KyUInt32>& GetFinalColorColumns() const { return m_finalNavTagIdxColumns; }
91  BoxOfArrays<KyUInt32>& GetFinalColorColumns() { return m_finalNavTagIdxColumns; }
92 
93  // Copies the final columns from another raster. Fails if celldesc is not the same.
94  KyResult Copy(const DynamicRasterCell& from);
95 
96  KyInt32 GetPixelSize() const { return IntCoordSystem::IntPixelSize(); }
97  KyFloat32 GetRasterPrecision() const { return m_rasterPrecision; }
98 
99  const KyArrayTLS_POD<const NavTag*>& GetNavTagArray() const { return *m_navTagArray; }
100 private:
101  void ComputeUniqueTagVolumes(KyArray<RasterCellTagVolume>& rasterVolumes);
102  void MakeFinalColumns();
103  void ReleaseDynamicColumns();
104 
105 private:
106  KyFloat32 m_rasterPrecision;
107  GeneratorParameters m_config;
108  CellDesc m_cellDesc;
109  PixelBox m_pixelBox;
110  const KyArrayPOD<const InputCellBlob*>* m_inputCells;
111  const KyArrayTLS_POD<const NavTag*>* m_navTagArray;
112 
113  // dynamic columns
114  DynamicRasterColumnPool m_dynamicColumns;
115 
116  // final columns
117  BoxOfArrays<KyFloat32> m_finalColumns;
118 
119  // final navTag
120  BoxOfArrays<KyUInt32> m_finalNavTagIdxColumns;
121 
122  bool m_isEmpty;
123  bool m_hasMultipleNavTags; //extracted by the CellRasterizerFromPdgInput
124  bool m_areAllInputCellsOverlapping; //this flag is set and computed during MakeFinalColumns()
125 
126  friend class DynamicRasterCellBlobBuilder;
127 };
128 
129 
130 
131 // --------------------------------- inline implementation ---------------------------------
132 
133 inline void DynamicRasterCell::PushPixelToLocal(const PixelPos& localPixelPos, const SingleStagePixel& pixel, KyUInt32 navTagIdx)
134 {
135  KyInt32 idx = m_pixelBox.GetRowMajorIndexFromLocalPos(localPixelPos);
136  PushPixel(idx, pixel, navTagIdx);
137 }
138 
139 inline void DynamicRasterCell::PushPixel(const PixelPos& pixelPos, const SingleStagePixel& pixel, KyUInt32 navTagIdx, KyUInt32 ownerIdx)
140 {
141  KyInt32 idx = m_pixelBox.GetRowMajorIndex(pixelPos);
142  PushPixel(idx, pixel, navTagIdx, ownerIdx);
143 }
144 
145 inline const BoxOfArrays<KyFloat32>::Column& DynamicRasterCell::GetFinalColumnFromLocal(const PixelPos& localPixelPos) const
146 {
147  return m_finalColumns.GetColumn(localPixelPos.x, localPixelPos.y);
148 }
149 
150 inline const BoxOfArrays<KyFloat32>::Column& DynamicRasterCell::GetFinalColumn(const PixelPos& pixelPos) const
151 {
152  KyInt32 idx = m_pixelBox.GetRowMajorIndex(pixelPos);
153  return m_finalColumns.GetColumn(idx);
154 }
155 
156 inline const BoxOfArrays<KyUInt32>::Column& DynamicRasterCell::GetFinalNavTagColumnFromLocal(const PixelPos& localPixelPos) const
157 {
158  return m_finalNavTagIdxColumns.GetColumn(localPixelPos.x, localPixelPos.y);
159 }
160 
161 inline const BoxOfArrays<KyUInt32>::Column& DynamicRasterCell::GetFinalNavTagIndicesColumn(const PixelPos& pixelPos) const
162 {
163  KyInt32 idx = m_pixelBox.GetRowMajorIndex(pixelPos);
164  return m_finalNavTagIdxColumns.GetColumn(idx);
165 }
166 
167 
168 }
169 
170 
171 #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
#define KY_NULL
Null value.
Definition: types.h:247
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
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