AnimatLab  2
Test
Torus.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 
12 #include "Node.h"
13 #include "IPhysicsMovableItem.h"
14 #include "IPhysicsBody.h"
15 #include "BoundingBox.h"
16 #include "MovableItem.h"
17 #include "BodyPart.h"
18 #include "ReceptiveField.h"
19 #include "ContactSensor.h"
20 #include "RigidBody.h"
21 #include "Torus.h"
22 #include "Structure.h"
23 #include "Organism.h"
24 #include "ActivatedItem.h"
25 #include "ActivatedItemMgr.h"
26 #include "DataChartMgr.h"
27 #include "ExternalStimuliMgr.h"
28 #include "KeyFrame.h"
29 #include "SimulationRecorder.h"
30 #include "OdorType.h"
31 #include "Odor.h"
32 #include "Light.h"
33 #include "LightManager.h"
34 #include "Simulator.h"
35 
36 namespace AnimatSim
37 {
38  namespace Environment
39  {
40  namespace Bodies
41  {
49 {
50  m_fltOutsideRadius = 0.5f;
51  m_fltInsideRadius = 0.1f;
52  m_iSides = 20;
53  m_iRings = 20;
54 }
55 
63 {
64 
65 }
66 
68 
69 void Torus::OutsideRadius(float fltVal, bool bUseScaling)
70 {
71  Std_IsAboveMin((float) 0, fltVal, true, "Torus.OutsideRadius");
72 
73  if(bUseScaling)
75  else
76  m_fltOutsideRadius = fltVal;
77 
78  Resize();
79 }
80 
82 
83 void Torus::InsideRadius(float fltVal, bool bUseScaling)
84 {
85  Std_IsAboveMin((float) 0, fltVal, true, "Torus.InsideRadius");
86 
87  if(bUseScaling)
89  else
90  m_fltInsideRadius = fltVal;
91 
92  Resize();
93 }
94 
103 void Torus::Sides(int iVal)
104 {
105  Std_IsAboveMin((int) 10, iVal, true, "Torus.Sides", true);
106  m_iSides = iVal;
107 
108  Resize();
109 }
110 
119 int Torus::Sides() {return m_iSides;}
120 
129 void Torus::Rings(int iVal)
130 {
131  Std_IsAboveMin((int) 10, iVal, true, "Torus.Rings", true);
132  m_iRings = iVal;
133 
134  Resize();
135 }
136 
145 int Torus::Rings() {return m_iRings;}
146 
147 bool Torus::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
148 {
149  std::string strType = Std_CheckString(strDataType);
150 
151  if(RigidBody::SetData(strType, strValue, false))
152  return true;
153 
154  if(strType == "OUTSIDERADIUS")
155  {
156  OutsideRadius((float) atof(strValue.c_str()));
157  return true;
158  }
159 
160  if(strType == "INSIDERADIUS")
161  {
162  InsideRadius((float) atof(strValue.c_str()));
163  return true;
164  }
165 
166  if(strType == "SIDES")
167  {
168  Sides(atoi(strValue.c_str()));
169  return true;
170  }
171 
172  if(strType == "RINGS")
173  {
174  Rings(atoi(strValue.c_str()));
175  return true;
176  }
177 
178  //If it was not one of those above then we have a problem.
179  if(bThrowError)
180  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
181 
182  return false;
183 }
184 
185 void Torus::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
186 {
187  RigidBody::QueryProperties(aryProperties);
188 
189  aryProperties.Add(new TypeProperty("OutsideRadius", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
190  aryProperties.Add(new TypeProperty("InsideRadius", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
191  aryProperties.Add(new TypeProperty("Sides", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
192  aryProperties.Add(new TypeProperty("Rings", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
193 }
194 
195 void Torus::Load(CStdXml &oXml)
196 {
197  RigidBody::Load(oXml);
198 
199  oXml.IntoElem(); //Into RigidBody Element
200 
201  OutsideRadius(oXml.GetChildFloat("OutsideRadius", m_fltOutsideRadius));
202  InsideRadius(oXml.GetChildFloat("InsideRadius", m_fltInsideRadius));
203  Sides(oXml.GetChildInt("Sides", m_iSides));
204  Rings(oXml.GetChildInt("Rings", m_iRings));
205 
206  oXml.OutOfElem(); //OutOf RigidBody Element
207 }
208 
209 
210  } //Bodies
211  } //Environment
212 } //AnimatSim
Base class file for all Animat simulation objects.
virtual float InsideRadius()
Gets the inside radius.
Definition: Torus.cpp:81
Declares the simulation recorder class.
Root namespace for the base simulation library for AnimatLab.
Declares the Torus class.
Declares the body part class.
virtual int Rings()
Gets the number of rings used to draw the Torus.
Definition: Torus.cpp:145
Simulator * m_lpSim
The pointer to a Simulation.
Definition: AnimatBase.h:43
virtual bool IntoElem()
Goes into the next element where the cursor is located.
Definition: StdXml.cpp:42
Class that stores information about types for QueryProperty information.
Definition: TypeProperty.h:35
float m_fltInsideRadius
The inside radius of the torus.
Definition: Torus.h:31
int m_iRings
The number of rings used to draw the torus.
Definition: Torus.h:37
Declares the key frame class.
virtual int Sides()
Gets the number of sides used to draw the Torus.
Definition: Torus.cpp:119
Declares the organism class.
virtual int GetChildInt(std::string strElementName)
Gets an integer value from the element with the specified name.
Definition: StdXml.cpp:456
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
Declares a light object.
virtual void Resize()
Called when this object has been resized.
Definition: BodyPart.cpp:141
Declares the activated item class.
virtual ~Torus()
Destructor.
Definition: Torus.cpp:62
Declares a light manager object.
Torus()
Default constructor.
Definition: Torus.cpp:48
Declares the bounding box class.
A standard xml manipulation class.
Definition: StdXml.h:19
Declares the node class.
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
Definition: StdXml.cpp:56
float m_fltOutsideRadius
The outside radius of the torus.
Definition: Torus.h:28
Declares the data chart manager class.
Declares the rigid body class.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
int m_iSides
The number of sides used to draw the torus.
Definition: Torus.h:34
Declares the structure class.
Declares the odor type class.
virtual float OutsideRadius()
Gets the outside radius.
Definition: Torus.cpp:67
virtual float InverseDistanceUnits()
Gets the inverse distance units.
Definition: Simulator.cpp:1742
Declares the odor class.
Declares the simulator class.
Declares the activated item manager class.
Declares the contact sensor class.
Declares the external stimuli manager class.
Declares the receptive field class.
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.
Definition: StdXml.cpp:617