AnimatLab  2
Test
Sphere.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 "Sphere.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_fltRadius = 1;
53 }
54 
62 {
63 
64 }
65 
66 float Sphere::Radius() {return m_fltRadius;}
67 
68 void Sphere::Radius(float fltVal, bool bUseScaling)
69 {
70  Std_IsAboveMin((float) 0, fltVal, true, "Sphere.Radius");
71  if(bUseScaling)
73  else
74  m_fltRadius = fltVal;
75 
76  Resize();
77 }
78 
87 void Sphere::LatitudeSegments(int iVal)
88 {
89  Std_IsAboveMin((int) 10, iVal, true, "Sphere.LatitudeSegments", true);
90  m_iLatitudeSegments = iVal;
91  Resize();
92 }
93 
103 
113 {
114  Std_IsAboveMin((int) 10, iVal, true, "Sphere.LongtitudeSegments", true);
115  m_iLongtitudeSegments = iVal;
116  Resize();
117 }
118 
128 
129 bool Sphere::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
130 {
131  std::string strType = Std_CheckString(strDataType);
132 
133  if(RigidBody::SetData(strType, strValue, false))
134  return true;
135 
136  if(strType == "RADIUS")
137  {
138  Radius((float) atof(strValue.c_str()));
139  return true;
140  }
141 
142  if(strType == "LATITUDESEGMENTS")
143  {
144  LatitudeSegments(atoi(strValue.c_str()));
145  return true;
146  }
147 
148  if(strType == "LONGTITUDESEGMENTS")
149  {
150  LongtitudeSegments(atoi(strValue.c_str()));
151  return true;
152  }
153 
154  //If it was not one of those above then we have a problem.
155  if(bThrowError)
156  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
157 
158  return false;
159 }
160 
161 void Sphere::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
162 {
163  RigidBody::QueryProperties(aryProperties);
164 
165  aryProperties.Add(new TypeProperty("Radius", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
166  aryProperties.Add(new TypeProperty("LatitudeSegments", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
167  aryProperties.Add(new TypeProperty("LongtitudeSegments", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
168 }
169 
170 void Sphere::Load(CStdXml &oXml)
171 {
172  RigidBody::Load(oXml);
173 
174  oXml.IntoElem(); //Into RigidBody Element
175  Radius(oXml.GetChildFloat("Radius", m_fltRadius));
176  LatitudeSegments(oXml.GetChildInt("LatitudeSegments", m_iLatitudeSegments));
177  LongtitudeSegments(oXml.GetChildInt("LongtitudeSegments", m_iLongtitudeSegments));
178  oXml.OutOfElem(); //OutOf RigidBody Element
179 }
180 
181 
182  } //Bodies
183  } //Environment
184 } //AnimatSim
virtual ~Sphere()
Destructor.
Definition: Sphere.cpp:61
Base class file for all Animat simulation objects.
Declares the simulation recorder class.
Declares the sphere class.
int m_iLongtitudeSegments
Number of segments along the longtitude direction that are used to build the sphere.
Definition: Sphere.h:34
Root namespace for the base simulation library for AnimatLab.
Declares the body part class.
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
Declares the key frame class.
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.
int m_iLatitudeSegments
Number of segments along the latitude direction that are used to build the sphere.
Definition: Sphere.h:31
Declares a light manager object.
Sphere()
Default constructor.
Definition: Sphere.cpp:48
Declares the bounding box class.
A standard xml manipulation class.
Definition: StdXml.h:19
Declares the node class.
float m_fltRadius
The radius of the sphere.
Definition: Sphere.h:28
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
Definition: StdXml.cpp:56
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.
virtual int LongtitudeSegments()
Gets the longtitude segments.
Definition: Sphere.cpp:127
Declares the structure class.
Declares the odor type class.
virtual float Radius()
Gets the radius.
Definition: Sphere.cpp:66
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.
virtual int LatitudeSegments()
Gets the latitude segments.
Definition: Sphere.cpp:102
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