ALMaSS Rodenticide Model ODdox  1.0
MovementMap16 Class Reference

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

#include <MovementMap.h>

Public Member Functions

void ClearMapValue (unsigned x, unsigned y)
 
int GetMapValue (unsigned x, unsigned y)
 
 MovementMap16 (Landscape *L)
 
void SetMapValue (unsigned x, unsigned y, unsigned value)
 
 ~MovementMap16 ()
 

Public Attributes

uint32m_TheMap
 
uint32 maxx
 
uint32 maxy
 

Protected Member Functions

void Init ()
 

Protected Attributes

Landscapem_ALandscape
 

Detailed Description

Movement maps are used for rapid computing of animal movement.

Constructor & Destructor Documentation

MovementMap16::MovementMap16 ( Landscape L)

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

412 {
413  m_ALandscape = L;
414  // must make sure that we have whole words
417  m_TheMap = new uint32[ maxx*maxy ];
418 
419  Init();
420 }
void Init()
Definition: MovementMap.cpp:430
__int32 uint32
Definition: ALMaSS_Setup.h:37
Landscape * m_ALandscape
Definition: MovementMap.h:86
int SupplySimAreaWidth(void)
Definition: landscape.h:1556
uint32 maxy
Definition: MovementMap.h:79
int SupplySimAreaHeight(void)
Definition: landscape.h:1561
uint32 * m_TheMap
Definition: MovementMap.h:77
uint32 maxx
Definition: MovementMap.h:78
MovementMap16::~MovementMap16 ( )

References MovementMap::m_TheMap.

424 {
425  delete m_TheMap;
426 }
uint32 * m_TheMap
Definition: MovementMap.h:77

Member Function Documentation

void MovementMap16::ClearMapValue ( unsigned  x,
unsigned  y 
)

References MovementMap::m_TheMap, and MovementMap::maxx.

465 {
466  uint32 theWord=x & 1; // is the last bit set?
467  theWord=theWord<<4; // Multiply by 16
468  // divide by 2
469  uint32 index= (x>>1)+(y*maxx); // y and x/2
470  m_TheMap[index] &= ~(0xFFFF<< theWord);
471 }
__int32 uint32
Definition: ALMaSS_Setup.h:37
uint32 * m_TheMap
Definition: MovementMap.h:77
uint32 maxx
Definition: MovementMap.h:78
int MovementMap16::GetMapValue ( unsigned  x,
unsigned  y 
)

References MovementMap::m_TheMap, and MovementMap::maxx.

475 {
476  uint32 theWord=x & 1;
477  // Multiply by 16
478  theWord=theWord<<4;
479  // divide by 16
480  uint32 index= (x>>1)+(maxx*y);
481  return ((m_TheMap[index] >> theWord) & 0xFFFF); //
482 }
__int32 uint32
Definition: ALMaSS_Setup.h:37
uint32 * m_TheMap
Definition: MovementMap.h:77
uint32 maxx
Definition: MovementMap.h:78
void MovementMap16::Init ( )
protected

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

431 {
432 
433  for (int y=0; y<m_ALandscape->SupplySimAreaHeight(); y++)
434  {
435  for (int x=0; x<m_ALandscape->SupplySimAreaWidth(); x++)
436  {
437  SetMapValue(x,y,0);
438  }
439  }
440 }
Landscape * m_ALandscape
Definition: MovementMap.h:86
int SupplySimAreaWidth(void)
Definition: landscape.h:1556
int SupplySimAreaHeight(void)
Definition: landscape.h:1561
void SetMapValue(unsigned x, unsigned y, unsigned value)
Definition: MovementMap.cpp:444
void MovementMap16::SetMapValue ( unsigned  x,
unsigned  y,
unsigned  value 
)

References MovementMap::m_TheMap, and MovementMap::maxx.

445 {
446 
447  uint32 theWord= x & 1; // is the last bit set?
448 
449  // Multiply by 16o
450  theWord=theWord<<4;
451 
452  // divide by 16
453  // Calculate index:
454  uint32 index= (x>>1)+(y*maxx);
455 
456  value &= 0xFF;
457  uint32 NewVal = m_TheMap[index] & ~( 0xFFFF << theWord );
458  m_TheMap[index] = NewVal | (value << theWord);
459 
460 }
__int32 uint32
Definition: ALMaSS_Setup.h:37
uint32 * m_TheMap
Definition: MovementMap.h:77
uint32 maxx
Definition: MovementMap.h:78

Member Data Documentation

Landscape* MovementMap16::m_ALandscape
protected
uint32* MovementMap16::m_TheMap
uint32 MovementMap16::maxx
uint32 MovementMap16::maxy

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