ALMaSS Rodenticide Model ODdox  1.0
MovementMap Class Reference

Movement maps are used for rapid computing of animal movement. More...

#include <MovementMap.h>

Public Member Functions

int GetMapValue (unsigned x, unsigned y)
 
 MovementMap (Landscape *L, int spref)
 
void SetMapValue (unsigned x, unsigned y, unsigned value)
 
void SetMapValue0 (unsigned x, unsigned y)
 
void SetMapValue1 (unsigned x, unsigned y)
 
void SetMapValue2 (unsigned x, unsigned y)
 
void SetMapValue3 (unsigned x, unsigned y)
 
 ~MovementMap ()
 

Public Attributes

uint32m_TheMap
 
uint32 maxx
 
uint32 maxy
 

Protected Member Functions

void Init (int spref)
 

Protected Attributes

Landscapem_ALandscape
 

Detailed Description

Movement maps are used for rapid computing of animal movement.

Constructor & Destructor Documentation

MovementMap::MovementMap ( Landscape L,
int  spref 
)

References Init(), m_ALandscape, m_TheMap, maxx, maxy, Landscape::SupplySimAreaHeight(), and Landscape::SupplySimAreaWidth().

51 {
52  m_ALandscape = L;
53  // must make sure that we have whole words
56  m_TheMap = new uint32[ maxx*maxy ];
57 
58  Init(spref);
59 }
uint32 * m_TheMap
Definition: MovementMap.h:53
uint32 maxx
Definition: MovementMap.h:54
__int32 uint32
Definition: ALMaSS_Setup.h:37
int SupplySimAreaWidth(void)
Definition: landscape.h:1556
Landscape * m_ALandscape
Definition: MovementMap.h:65
int SupplySimAreaHeight(void)
Definition: landscape.h:1561
uint32 maxy
Definition: MovementMap.h:55
void Init(int spref)
Definition: MovementMap.cpp:69
MovementMap::~MovementMap ( )

References m_TheMap.

63 {
64  delete m_TheMap;
65 }
uint32 * m_TheMap
Definition: MovementMap.h:53

Member Function Documentation

int MovementMap::GetMapValue ( unsigned  x,
unsigned  y 
)

References m_TheMap, and maxx.

398 {
399  uint32 theBit=x & 15;
400  // Multiply by two
401  theBit=theBit<<1;
402  // divide by 16
403  uint32 index= (x>>4)+(maxx*y);
404  return ((m_TheMap[index] >> theBit) & 0x03); // 0-3
405 }
uint32 * m_TheMap
Definition: MovementMap.h:53
uint32 maxx
Definition: MovementMap.h:54
__int32 uint32
Definition: ALMaSS_Setup.h:37
void MovementMap::Init ( int  spref)
protected

References m_ALandscape, SetMapValue(), Landscape::SupplyElementType(), Landscape::SupplySimAreaHeight(), and Landscape::SupplySimAreaWidth().

Referenced by MovementMap(), and MovementMap16::MovementMap16().

70 {
71  char error_num[20];
72  for (int y=0; y<m_ALandscape->SupplySimAreaHeight(); y++)
73  {
74  for (int x=0; x<m_ALandscape->SupplySimAreaWidth(); x++)
75  {
76  TTypesOfLandscapeElement tole;
78  uint32 colour=0;
79  if (spref==0)
80  {
81  // Beetle
82  switch (tole)
83  {
84 
85  case tole_Hedges: // 130
86  case tole_RoadsideVerge: // 13
87  case tole_FieldBoundary: // 160
88  case tole_HedgeBank:
89  case tole_BeetleBank:
90  case tole_NaturalGrassWet:
91  case tole_RoadsideSlope:
92  colour=1;
93  break;
94  case tole_Marsh: // 95
95  case tole_Scrub: // 70
96  case tole_Railway: // 118
97  case tole_PermanentSetaside: // 33
98  case tole_RiversidePlants: // 98
99  case tole_PitDisused: // 75
100  case tole_Garden: //11
101  case tole_Track: // 123
102  case tole_SmallRoad: // 122
103  case tole_LargeRoad: // 121
104  case tole_MetalledPath:
105  case tole_Carpark:
106  case tole_Churchyard:
107  case tole_Saltmarsh:
108  case tole_PlantNursery:
109  case tole_Vildtager:
110  case tole_HeritageSite: colour = 2;
111  case tole_Copse:
112  case tole_WoodyEnergyCrop:
113  case tole_WoodlandMargin:
114  case tole_IndividualTree:
115  case tole_RiversideTrees: // 97
116  case tole_DeciduousForest: // 40
117  case tole_MixedForest: // 60
118  case tole_ConiferousForest: // 50
119  case tole_YoungForest:
120  case tole_StoneWall: // 15
121  case tole_ActivePit: // 115
122  break;
123  case tole_Field: // 20 & 30
124  case tole_UnsprayedFieldMargin :
125  case tole_PermPasture: // 35
126  case tole_PermPastureLowYield: // 35
127  case tole_PermPastureTussocky: // 26
128  case tole_Heath:
129  case tole_NaturalGrassDry: // 110
130  case tole_AmenityGrass:
131  case tole_Parkland:
132  case tole_Orchard:
133  case tole_OrchardBand:
134  case tole_MownGrass:
135  case tole_Wasteland: // 209
136  colour=0;
137  break;
138  case tole_Building: // 5
139  case tole_Freshwater: // 90
140  case tole_FishFarm: // 220
141  case tole_Pond:
142  case tole_River: // 96
143  case tole_Saltwater: // 80
144  case tole_Coast: // 100
145  case tole_BareRock: // 59
146  case tole_UrbanNoVeg:
147  case tole_UrbanPark:
148  case tole_BuiltUpWithParkland:
149  case tole_SandDune:
150  case tole_Stream:
151  case tole_Pylon:
152  case tole_WindTurbine:
153  colour = 3;
154  break;
155  case tole_Foobar: // 999 !! type unknown - should not happen
156  default:
157  sprintf( error_num, "%d", tole );
158  g_msg->Warn( WARN_FILE,
159  "MovementMap::Init(): Unknown landscape element type:",
160  error_num );
161  exit( 1 );
162  }
163  }
164  else if (spref==1) { // Partridge
165  switch (tole)
166  {
167  case tole_Hedges: // 130
168  case tole_PermanentSetaside: // 33
169  case tole_RoadsideVerge: // 13
170  case tole_FieldBoundary: // 160
171  case tole_HedgeBank:
172  case tole_BeetleBank:
173  case tole_UnsprayedFieldMargin: // 31
174  case tole_Vildtager:
175  colour=3;
176  break;
177  case tole_Railway: // 118
178  case tole_Scrub: // 70
179  case tole_Field: // 20 & 30
180  case tole_PermPasture: // 35
181  case tole_NaturalGrassDry: // 110
182  case tole_RiversidePlants: // 98
183  case tole_RoadsideSlope:
184  case tole_RiversideTrees: // 97
185  case tole_YoungForest: //55
186  case tole_Wasteland:
187  colour=2;
188  break;
189  case tole_PitDisused: // 75
190  case tole_NaturalGrassWet:
191  case tole_Marsh: // 95
192  case tole_Garden: //11
193  case tole_Track: // 123
194  case tole_SmallRoad: // 122
195  case tole_LargeRoad: // 121
196  colour=1;
197  break;
198  case tole_IndividualTree:
199  case tole_PlantNursery:
200  case tole_WindTurbine:
201  case tole_WoodyEnergyCrop:
202  case tole_WoodlandMargin:
203  case tole_Pylon:
204  case tole_DeciduousForest: // 40
205  case tole_MixedForest: // 60
206  case tole_ConiferousForest: // 50
207  case tole_StoneWall: // 15
208  case tole_Building: // 5
209  case tole_ActivePit: // 115
210  case tole_Pond:
211  case tole_Freshwater: // 90
212  case tole_FishFarm:
213  case tole_River: // 96
214  case tole_Saltwater: // 80
215  case tole_Coast: // 100
216  case tole_BareRock: // 59
217  case tole_AmenityGrass:
218  case tole_Parkland:
219  case tole_UrbanNoVeg:
220  case tole_UrbanPark:
221  case tole_BuiltUpWithParkland:
222  case tole_SandDune:
223  case tole_Copse:
224  case tole_MetalledPath:
225  case tole_Carpark:
226  case tole_Churchyard:
227  case tole_Saltmarsh:
228  case tole_Stream:
229  case tole_HeritageSite:
230  colour=0;
231  break;
232  case tole_Foobar: // 999 !! type unknown - should not happen
233  default:
234  sprintf( error_num, "%d", tole );
235  g_msg->Warn( WARN_FILE,
236  "MovementMap::Init(): Unknown landscape element type:",
237  error_num );
238  exit( 1 );
239  }
240  } // End partridge
241  else if (spref==2)
242  { // Spider
243  switch ( tole )
244  {
245  case tole_IndividualTree:
246  case tole_WindTurbine:
247  case tole_WoodyEnergyCrop:
248  case tole_WoodlandMargin:
249  case tole_Pylon:
250  case tole_NaturalGrassWet:
251  case tole_MetalledPath:
252  case tole_Carpark:
253  case tole_Churchyard:
254  case tole_Saltmarsh:
255  case tole_HeritageSite:
256  case tole_Hedges:
257  case tole_HedgeBank:
258  case tole_BeetleBank:
259  case tole_Marsh:
260  case tole_PermanentSetaside:
261  case tole_NaturalGrassDry:
262  case tole_RiversidePlants:
263  case tole_RiversideTrees:
264  case tole_DeciduousForest:
265  case tole_MixedForest:
266  case tole_ConiferousForest:
267  case tole_YoungForest:
268  case tole_StoneWall:
269  case tole_Building:
270  case tole_ActivePit:
271  case tole_PitDisused:
272  case tole_Scrub:
273  case tole_Track:
274  case tole_SmallRoad:
275  case tole_LargeRoad:
276  case tole_BareRock:
277  case tole_UrbanNoVeg:
278  case tole_SandDune:
279  case tole_Copse:
280  case tole_MownGrass:
281  colour = 2;
282  break;
283  case tole_PlantNursery:
284  case tole_Vildtager:
285  case tole_RoadsideSlope:
286  case tole_PermPasture: //moved from case 2 to case 3
287  case tole_PermPastureLowYield:
288  case tole_PermPastureTussocky: //moved from case 2 to case 3
289  case tole_RoadsideVerge:
290  case tole_Railway:
291  case tole_FieldBoundary:
292  case tole_Garden:
293  case tole_Coast:
294  case tole_Heath:
295  case tole_AmenityGrass:
296  case tole_Parkland:
297  case tole_BuiltUpWithParkland:
298  case tole_UrbanPark:
299  case tole_Wasteland:
300  colour = 3;
301  break;
302  case tole_Pond:
303  case tole_Freshwater:
304  case tole_FishFarm:
305  case tole_River:
306  case tole_Saltwater:
307  case tole_Stream:
308  colour=0;
309  break;
310  case tole_Field: // Special case
311  case tole_UnsprayedFieldMargin: // Special case
312  colour=1;
313  break;
314  default:
315  sprintf( error_num, "%d", tole );
316  g_msg->Warn( WARN_FILE,
317  "MovementMap::Init(): Unknown landscape element type:",
318  error_num );
319  exit( 1 );
320  }// End spider
321  }
322  SetMapValue(x,y,colour);
323  }
324  }
325 }
__int32 uint32
Definition: ALMaSS_Setup.h:37
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1029
int SupplySimAreaWidth(void)
Definition: landscape.h:1556
Landscape * m_ALandscape
Definition: MovementMap.h:65
int SupplySimAreaHeight(void)
Definition: landscape.h:1561
void SetMapValue(unsigned x, unsigned y, unsigned value)
Definition: MovementMap.cpp:329
void MovementMap::SetMapValue ( unsigned  x,
unsigned  y,
unsigned  value 
)

References m_TheMap, and maxx.

Referenced by IDMap< TAnimal * >::IDMap(), Init(), and MovementMap16::Init().

330 {
331 
332  uint32 theBit= x & 15; // Identify the bit within 16 possibilities
333 
334  // Multiply by two
335  theBit=theBit<<1; // Double it because we use two bits per location
336 
337  // divide by 16
338  // Calculate index:
339  uint32 index= (x>>4)+(y*maxx); // maxx is the number of uints per row + x/16 because there are 16 locations per uint
340 
341  value &= 0x03;
342  uint32 NewVal = m_TheMap[index] & ~( 0x03 << theBit ); // Make a hole two bits wide at the right location
343  m_TheMap[index] = NewVal | (value << theBit); // Fill the hole
344 
345 }
uint32 * m_TheMap
Definition: MovementMap.h:53
uint32 maxx
Definition: MovementMap.h:54
__int32 uint32
Definition: ALMaSS_Setup.h:37
void MovementMap::SetMapValue0 ( unsigned  x,
unsigned  y 
)

References m_TheMap, and maxx.

350 {
351  uint32 theBit=x & 15;
352  theBit=theBit<<1; // Multiply by two
353  // divide by 16
354  uint32 index= (x>>4)+(y*maxx);
355  m_TheMap[index] &= ~(0x03<< theBit);
356 }
uint32 * m_TheMap
Definition: MovementMap.h:53
uint32 maxx
Definition: MovementMap.h:54
__int32 uint32
Definition: ALMaSS_Setup.h:37
void MovementMap::SetMapValue1 ( unsigned  x,
unsigned  y 
)

References m_TheMap, and maxx.

361 {
362  uint32 theBit=x & 15;
363  theBit=theBit<<1; // Multiply by two
364  // divide by 16
365  uint32 index= (x>>4)+(maxx*y);
366  m_TheMap[index] &= ~(0x03 << theBit);
367  m_TheMap[index] |= (0x01 << theBit);
368 }
uint32 * m_TheMap
Definition: MovementMap.h:53
uint32 maxx
Definition: MovementMap.h:54
__int32 uint32
Definition: ALMaSS_Setup.h:37
void MovementMap::SetMapValue2 ( unsigned  x,
unsigned  y 
)

References m_TheMap, and maxx.

373 {
374  uint32 theBit=x & 15;
375  // Multiply by two
376  theBit=theBit<<1;
377  // divide by 16
378  uint32 index= (x>>4)+(maxx*y);
379  m_TheMap[index] &= ~(0x03 << theBit);
380  m_TheMap[index] |= (0x02 << theBit);
381 }
uint32 * m_TheMap
Definition: MovementMap.h:53
uint32 maxx
Definition: MovementMap.h:54
__int32 uint32
Definition: ALMaSS_Setup.h:37
void MovementMap::SetMapValue3 ( unsigned  x,
unsigned  y 
)

References m_TheMap, and maxx.

386 {
387  uint32 theBit=x & 15;
388  // Multiply by two
389  theBit=theBit<<1;
390  // divide by 16
391  uint32 index= (x>>4)+(maxx*y);
392  m_TheMap[index] |= (0x03 << theBit);
393 }
uint32 * m_TheMap
Definition: MovementMap.h:53
uint32 maxx
Definition: MovementMap.h:54
__int32 uint32
Definition: ALMaSS_Setup.h:37

Member Data Documentation

Landscape* MovementMap::m_ALandscape
protected

The documentation for this class was generated from the following files: