AnimatLab  2
Test
ReceptiveField.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 #include "IMovableItemCallback.h"
9 #include "ISimGUICallback.h"
10 #include "AnimatBase.h"
11 #include "ReceptiveField.h"
12 
13 namespace AnimatSim
14 {
15  namespace Environment
16  {
24 {
25  m_vVertex[0] = 0; m_vVertex[1] = 0; m_vVertex[2] = 0;
26  m_fltCurrent = 0;
27 }
28 
40 ReceptiveField::ReceptiveField(float fltX, float fltY, float fltZ, float fltCurrent)
41 {
42  m_vVertex[0] = fltX; m_vVertex[1] = fltY; m_vVertex[2] = fltZ;
43  m_fltCurrent = fltCurrent;
44 }
45 
53 {
54 }
55 
64 void ReceptiveField::SetVertex(CStdFPoint vPoint)
65 {
66  m_vVertex[0] = vPoint.x;
67  m_vVertex[1] = vPoint.y;
68  m_vVertex[2] = vPoint.z;
69 }
70 
81 {
82  if(this->m_vVertex[0] > lpItem->m_vVertex[0])
83  return false;
84 
85  if(this->m_vVertex[1] > lpItem->m_vVertex[1])
86  return false;
87 
88  if(this->m_vVertex[2] > lpItem->m_vVertex[2])
89  return false;
90 
91  if(this->operator==(lpItem))
92  return false;
93 
94  return true;
95 }
96 
107 {return !this->operator<(lpItem);}
108 
122 {
123  if( fabs(this->m_vVertex[0] - lpItem->m_vVertex[0]) < 1e-4 &&
124  fabs(this->m_vVertex[1] - lpItem->m_vVertex[1]) < 1e-4 &&
125  fabs(this->m_vVertex[2] - lpItem->m_vVertex[2]) < 1e-4)
126  return true;
127 
128  return false;
129 }
130 
145 bool ReceptiveField::LessThanThan(float fltX, float fltY, float fltZ)
146 {
147  //If the x values are not identical then decide if it is less than using the x value.
148  if(fabs(this->m_vVertex[0] - fltX) > 1e-4)
149  {
150  if(this->m_vVertex[0] > fltX)
151  return false;
152  else
153  return true;
154  }
155 
156  //If the x values are identical and the y values are not identical then decide if it is less than using the y value.
157  if(fabs(this->m_vVertex[1] - fltY) > 1e-4)
158  {
159  if(this->m_vVertex[1] > fltY)
160  return false;
161  else
162  return true;
163  }
164 
165  //And so on.
166  if(fabs(this->m_vVertex[2] - fltZ) > 1e-4)
167  {
168  if(this->m_vVertex[2] > fltZ)
169  return false;
170  else
171  return true;
172  }
173 
174  //if we get to this point then it is only because the vertices are identical
175  return false;
176 }
177 
192 bool ReceptiveField::GreaterThanThan(float fltX, float fltY, float fltZ)
193 {return !this->LessThanThan(fltX, fltY, fltZ);}
194 
207 bool ReceptiveField::Equals(float fltX, float fltY, float fltZ)
208 {
209  if( fabs(this->m_vVertex[0] - fltX) < 1e-4 &&
210  fabs(this->m_vVertex[1] - fltY) < 1e-4 &&
211  fabs(this->m_vVertex[2] - fltZ) < 1e-4)
212  return true;
213 
214  return false;
215 }
216 
217 void ReceptiveField::Load(CStdXml &oXml)
218 {
219  AnimatBase::Load(oXml);
220 
221  oXml.IntoElem();
222 
223  CStdFPoint vPoint;
224  Std_LoadPoint(oXml, "Vertex", vPoint);
225  SetVertex(vPoint);
226 
227  oXml.OutOfElem();
228 }
229 
230 
231  } //Environment
232 } //AnimatSim
bool operator<(ReceptiveField *lpItem)
Method used to sort the ReceptiveField by vertex.
Base class file for all Animat simulation objects.
bool GreaterThanThan(float fltX, float fltY, float fltZ)
Method used to sort the ReceptiveField by vertex.
Root namespace for the base simulation library for AnimatLab.
StdVector3 m_vVertex
The vertex of the center of the receptive field in global coordinates.
bool operator==(ReceptiveField *lpItem)
Checks whether the vertices of the receptive fields are the same.
bool Equals(float fltX, float fltY, float fltZ)
Tests if objects are considered equal.
float m_fltCurrent
The accumulated current for this receptive field.
bool LessThanThan(float fltX, float fltY, float fltZ)
Method used to sort the ReceptiveField by vertex.
virtual void Load(StdUtils::CStdXml &oXml)
Loads the item using an XML data packet.
Definition: AnimatBase.cpp:771
bool operator>(ReceptiveField *lpItem)
Method used to sort the ReceptiveField by vertex.
void SetVertex(CStdFPoint vPoint)
Sets the vertex.
bool Std_LoadPoint(CStdXml &oXml, std::string strName, CStdIPoint &oPoint, bool bThrowError)
Standard load point.
Receptive field that generates current based on the amount of contact force, and how close it is to t...
Declares the receptive field class.