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
SimplePositionMapInt Class Reference

#include <PositionMap.h>

Public Member Functions

virtual int GetMapValue (unsigned a_x, unsigned a_y)
 
virtual void SetMapValue (unsigned a_x, unsigned a_y, int a_value)
 
virtual void ClearMapValue (unsigned a_x, unsigned a_y)
 
virtual void IncMapValue (unsigned a_x, unsigned a_y)
 
virtual void DecMapValue (unsigned a_x, unsigned a_y)
 
virtual int GetMapDensity (unsigned a_x, unsigned a_y, unsigned a_range)
 
virtual int GetMapDensityEdge (unsigned a_x, unsigned a_y, unsigned a_range)
 
virtual bool GetMapPositive (unsigned a_x, unsigned a_y, unsigned a_range)
 
virtual int SumMap ()
 
 SimplePositionMapInt ()
 
 SimplePositionMapInt (Landscape *L)
 
virtual ~SimplePositionMapInt ()
 

Public Attributes

vector< int > m_TheMapSpmi
 
unsigned int m_maxx
 
unsigned int m_maxy
 

Constructor & Destructor Documentation

◆ SimplePositionMapInt() [1/2]

SimplePositionMapInt::SimplePositionMapInt ( )
99 {
100  ;// Default do nothing constructor
101 }

◆ SimplePositionMapInt() [2/2]

SimplePositionMapInt::SimplePositionMapInt ( Landscape L)
105 {
106  m_maxx = L->SupplySimAreaWidth();
108  m_TheMapSpmi.resize(m_maxx * m_maxy);
109  for (unsigned y = 0; y < m_maxy; y++)
110  {
111  for (unsigned x = 0; x < m_maxx; x++)
112  {
113  ClearMapValue(x, y);
114  }
115  }
116 }

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

◆ ~SimplePositionMapInt()

SimplePositionMapInt::~SimplePositionMapInt ( )
virtual
120 {
121  //delete[] m_TheMapSpmi;
122 }

Member Function Documentation

◆ ClearMapValue()

virtual void SimplePositionMapInt::ClearMapValue ( unsigned  a_x,
unsigned  a_y 
)
inlinevirtual
106  {
107  m_TheMapSpmi[a_x + a_y * m_maxx] = 0;
108  }

References m_maxx, and m_TheMapSpmi.

Referenced by SimplePositionMapInt().

◆ DecMapValue()

virtual void SimplePositionMapInt::DecMapValue ( unsigned  a_x,
unsigned  a_y 
)
inlinevirtual
116  {
117 
118  m_TheMapSpmi[a_x + a_y * m_maxx]--;
119 
120 #ifdef Poecilus_Debug
121  if (m_TheMapSpmi[a_x + a_y * m_maxx] < 1)
122  {
123  g_msg->Warn(WARN_BUG, "SimplePositionMapInt::DecMapValue - negative value in density ", m_TheMapSpmi[a_x + a_y * m_maxx]);
124  exit(-1);
125  }
126 #endif
127  }

References g_msg, m_maxx, m_TheMapSpmi, MapErrorMsg::Warn(), and WARN_BUG.

◆ GetMapDensity()

virtual int SimplePositionMapInt::GetMapDensity ( unsigned  a_x,
unsigned  a_y,
unsigned  a_range 
)
inlinevirtual
130  {
131  int dens = 0;
132  int temp_x = a_x;
133  int temp_y = a_y;
134  //int temp_x_end = a_x + a_range;
135  //if(temp_x_end > m_maxx) temp_x_end = m_maxx;
136  //int temp_y_end = a_y + a_range;c
137  //if (temp_y_end > m_maxy) temp_y_end = m_maxy;
138  //if (a_x < 0) a_x = 0;
139  //if (a_y < 0) a_y = 0;
140  for (unsigned x = a_x; x <a_x+a_range; x++)
141  {
142  temp_x = x;
143  if(x >= m_maxx) temp_x = x - m_maxx;
144  for (unsigned y = a_y; y < a_y+a_range; y++){
145  temp_y = y;
146  if(y >= m_maxy) temp_y = y - m_maxy;
147  dens += (m_TheMapSpmi[temp_x + temp_y * m_maxx]);
148  }
149  }
150  return dens;
151  }

References m_maxx, m_maxy, and m_TheMapSpmi.

◆ GetMapDensityEdge()

virtual int SimplePositionMapInt::GetMapDensityEdge ( unsigned  a_x,
unsigned  a_y,
unsigned  a_range 
)
inlinevirtual
153  {
154  if (a_x + a_range >= m_maxx) a_range = m_maxx - a_x;
155  if (a_y + a_range >= m_maxy) a_range = m_maxy - a_y;
156  int dens = 0;
157  for (unsigned x = a_x; x < a_x + a_range; x++)
158  {
159  for (unsigned y = a_y; y < a_y + a_range; y++)
160  dens += (m_TheMapSpmi[x + y * m_maxx]);
161  }
162  return dens;
163  }

References m_maxx, m_maxy, and m_TheMapSpmi.

◆ GetMapPositive()

virtual bool SimplePositionMapInt::GetMapPositive ( unsigned  a_x,
unsigned  a_y,
unsigned  a_range 
)
inlinevirtual
165  {
166  for (unsigned x = a_x; x < a_x + a_range; x++)
167  {
168  for (unsigned y = a_y; y < a_y + a_range; y++)
169  if (m_TheMapSpmi[x + y * m_maxx]>0) return true;
170  }
171  return false;
172  }

References m_maxx, and m_TheMapSpmi.

◆ GetMapValue()

virtual int SimplePositionMapInt::GetMapValue ( unsigned  a_x,
unsigned  a_y 
)
inlinevirtual
96  {
97  return m_TheMapSpmi[a_x + a_y * m_maxx];
98  }

References m_maxx, and m_TheMapSpmi.

◆ IncMapValue()

virtual void SimplePositionMapInt::IncMapValue ( unsigned  a_x,
unsigned  a_y 
)
inlinevirtual
111  {
112  m_TheMapSpmi[a_x + a_y * m_maxx]++;
113  }

References m_maxx, and m_TheMapSpmi.

◆ SetMapValue()

virtual void SimplePositionMapInt::SetMapValue ( unsigned  a_x,
unsigned  a_y,
int  a_value 
)
inlinevirtual
101  {
102  m_TheMapSpmi[a_x + a_y * m_maxx] = a_value;
103  }

References m_maxx, and m_TheMapSpmi.

◆ SumMap()

virtual int SimplePositionMapInt::SumMap ( )
inlinevirtual

Used as a debug test to be sure all additions/deletions are done correctly.

176  {
178  int nos = 0;
179  const unsigned sz = m_maxy * m_maxx;
180  for (unsigned i = 0; i < sz; i++) nos += m_TheMapSpmi[i];
181  return nos;
182  }

References m_maxx, m_maxy, and m_TheMapSpmi.

Member Data Documentation

◆ m_maxx

◆ m_maxy

unsigned int SimplePositionMapInt::m_maxy

◆ m_TheMapSpmi


The documentation for this class was generated from the following files:
SimplePositionMapInt::m_maxx
unsigned int m_maxx
Definition: PositionMap.h:94
SimplePositionMapInt::m_maxy
unsigned int m_maxy
Definition: PositionMap.h:94
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
SimplePositionMapInt::m_TheMapSpmi
vector< int > m_TheMapSpmi
Definition: PositionMap.h:93
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
SimplePositionMapInt::ClearMapValue
virtual void ClearMapValue(unsigned a_x, unsigned a_y)
Definition: PositionMap.h:105
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
WARN_BUG
Definition: MapErrorMsg.h:34