Loading [MathJax]/extensions/ams.js
ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SimplePositionMap Class Reference

Used to map locations of individuals for density estimates - space inefficient but good for testing. More...

#include <PositionMap.h>

Inheritance diagram for SimplePositionMap:
ScalablePositionMap

Public Member Functions

virtual bool GetMapValue (unsigned a_x, unsigned a_y)
 
virtual void SetMapValue (unsigned a_x, unsigned a_y)
 
virtual void ClearMapValue (unsigned a_x, unsigned a_y)
 
virtual int GetMapDensity (unsigned a_x, unsigned a_y, unsigned a_range)
 
virtual bool GetMapPositive (unsigned a_x, unsigned a_y, unsigned a_range)
 
 SimplePositionMap ()
 
 SimplePositionMap (unsigned a_size)
 
 SimplePositionMap (Landscape *L)
 
virtual ~SimplePositionMap ()
 

Public Attributes

bool * m_TheMap
 
unsigned int m_maxx
 
unsigned int m_maxy
 

Detailed Description

Used to map locations of individuals for density estimates - space inefficient but good for testing.

Constructor & Destructor Documentation

◆ SimplePositionMap() [1/3]

SimplePositionMap::SimplePositionMap ( )
56 {
57  ;// Default do nothing constructor
58 }

◆ SimplePositionMap() [2/3]

SimplePositionMap::SimplePositionMap ( unsigned  a_size)
77 {
78  m_maxx = a_size;
79  m_maxy = m_maxx;
80  m_TheMap = new bool[m_maxx * m_maxy];
81  for (unsigned y = 0; y < m_maxy; y++)
82  {
83  for (unsigned x = 0; x < m_maxx; x++)
84  {
85  ClearMapValue(x, y);
86  }
87  }
88 }

References ClearMapValue(), m_maxx, m_maxy, and m_TheMap.

◆ SimplePositionMap() [3/3]

SimplePositionMap::SimplePositionMap ( Landscape L)
62 {
65  m_TheMap = new bool[m_maxx * m_maxy];
66  for (unsigned y = 0; y < m_maxy; y++)
67  {
68  for (unsigned x = 0; x < m_maxx; x++)
69  {
70  ClearMapValue(x, y);
71  }
72  }
73 }

References ClearMapValue(), m_maxx, m_maxy, m_TheMap, Landscape::SupplySimAreaHeight(), and Landscape::SupplySimAreaWidth().

◆ ~SimplePositionMap()

SimplePositionMap::~SimplePositionMap ( )
virtual
92 {
93  delete[] m_TheMap;
94 }

References m_TheMap.

Member Function Documentation

◆ ClearMapValue()

◆ GetMapDensity()

virtual int SimplePositionMap::GetMapDensity ( unsigned  a_x,
unsigned  a_y,
unsigned  a_range 
)
inlinevirtual

Reimplemented in ScalablePositionMap.

66  {
67  int dens=0;
68  for (unsigned x = a_x; x<a_x+a_range; x++)
69  {
70  for (unsigned y = a_y; y<a_y+a_range; y++)
71  if (m_TheMap[x+y*m_maxx]) dens++;
72  }
73  return dens;
74  }

References m_maxx, and m_TheMap.

Referenced by Spider_Base::GetPosMapDensity().

◆ GetMapPositive()

virtual bool SimplePositionMap::GetMapPositive ( unsigned  a_x,
unsigned  a_y,
unsigned  a_range 
)
inlinevirtual

Reimplemented in ScalablePositionMap.

76  {
77  for (unsigned x = a_x; x<a_x+a_range; x++)
78  {
79  for (unsigned y = a_y; y<a_y+a_range; y++)
80  if (m_TheMap[x+y*m_maxx]) return true;
81  }
82  return false;
83  }

References m_maxx, and m_TheMap.

Referenced by Spider_Base::GetPosMapPositive().

◆ GetMapValue()

virtual bool SimplePositionMap::GetMapValue ( unsigned  a_x,
unsigned  a_y 
)
inlinevirtual

◆ SetMapValue()

Member Data Documentation

◆ m_maxx

◆ m_maxy

unsigned int SimplePositionMap::m_maxy

◆ m_TheMap


The documentation for this class was generated from the following files:
SimplePositionMap::ClearMapValue
virtual void ClearMapValue(unsigned a_x, unsigned a_y)
Definition: PositionMap.h:60
Landscape::SupplySimAreaHeight
int SupplySimAreaHeight(void)
Gets the simulation landscape height.
Definition: Landscape.h:2302
Landscape::SupplySimAreaWidth
int SupplySimAreaWidth(void)
Gets the simulation landscape width.
Definition: Landscape.h:2297
SimplePositionMap::m_maxx
unsigned int m_maxx
Definition: PositionMap.h:49
SimplePositionMap::m_TheMap
bool * m_TheMap
Definition: PositionMap.h:48
SimplePositionMap::m_maxy
unsigned int m_maxy
Definition: PositionMap.h:49