ALMaSS Rodenticide ODdox  1.1
The rodenticide model description following ODdox protocol
MovementMap16 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)
 
void SetMapValue (unsigned x, unsigned y, unsigned value)
 
void ClearMapValue (unsigned x, unsigned y)
 
 MovementMap16 (Landscape *L)
 
 ~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::MovementMap16 ( Landscape L)
424 {
425  m_ALandscape = L;
426  // must make sure that we have whole words
429  m_TheMap = new uint32[ maxx*maxy ];
430 
431  Init();
432 }

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

◆ ~MovementMap16()

MovementMap16::~MovementMap16 ( )
436 {
437  delete m_TheMap;
438 }

References m_TheMap.

Member Function Documentation

◆ ClearMapValue()

void MovementMap16::ClearMapValue ( unsigned  x,
unsigned  y 
)
477 {
478  uint32 theWord=x & 1; // is the last bit set?
479  theWord=theWord<<4; // Multiply by 16
480  // divide by 2
481  uint32 index= (x>>1)+(y*maxx); // y and x/2
482  m_TheMap[index] &= ~(0xFFFF<< theWord);
483 }

References m_TheMap, and maxx.

◆ GetMapValue()

int MovementMap16::GetMapValue ( unsigned  x,
unsigned  y 
)
487 {
488  uint32 theWord=x & 1;
489  // Multiply by 16
490  theWord=theWord<<4;
491  // divide by 16
492  uint32 index= (x>>1)+(maxx*y);
493  return ((m_TheMap[index] >> theWord) & 0xFFFF); //
494 }

References m_TheMap, and maxx.

◆ Init()

void MovementMap16::Init ( )
protected
443 {
444 
445  for (int y=0; y<m_ALandscape->SupplySimAreaHeight(); y++)
446  {
447  for (int x=0; x<m_ALandscape->SupplySimAreaWidth(); x++)
448  {
449  SetMapValue(x,y,0);
450  }
451  }
452 }

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

Referenced by MovementMap16().

◆ SetMapValue()

void MovementMap16::SetMapValue ( unsigned  x,
unsigned  y,
unsigned  value 
)
457 {
458 
459  uint32 theWord= x & 1; // is the last bit set?
460 
461  // Multiply by 16o
462  theWord=theWord<<4;
463 
464  // divide by 16
465  // Calculate index:
466  uint32 index= (x>>1)+(y*maxx);
467 
468  value &= 0xFF;
469  uint32 NewVal = m_TheMap[index] & ~( 0xFFFF << theWord );
470  m_TheMap[index] = NewVal | (value << theWord);
471 
472 }

References m_TheMap, and maxx.

Referenced by Init().

Member Data Documentation

◆ m_ALandscape

Landscape* MovementMap16::m_ALandscape
protected

Referenced by Init(), and MovementMap16().

◆ m_TheMap

uint32* MovementMap16::m_TheMap

◆ maxx

uint32 MovementMap16::maxx

◆ maxy

uint32 MovementMap16::maxy

Referenced by MovementMap16().


The documentation for this class was generated from the following files:
uint32
unsigned int uint32
Definition: ALMaSS_Setup.h:34
MovementMap16::Init
void Init()
Definition: MovementMap.cpp:442
Landscape::SupplySimAreaHeight
int SupplySimAreaHeight(void)
Definition: landscape.h:1637
Landscape::SupplySimAreaWidth
int SupplySimAreaWidth(void)
Definition: landscape.h:1632
MovementMap16::m_TheMap
uint32 * m_TheMap
Definition: MovementMap.h:77
MovementMap16::maxy
uint32 maxy
Definition: MovementMap.h:79
MovementMap16::maxx
uint32 maxx
Definition: MovementMap.h:78
MovementMap16::SetMapValue
void SetMapValue(unsigned x, unsigned y, unsigned value)
Definition: MovementMap.cpp:456
MovementMap16::m_ALandscape
Landscape * m_ALandscape
Definition: MovementMap.h:86