AnimatLab  2
Test
Ellipsoid.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 "Ellipsoid.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_fltMajorRadius = 0.1f;
51  m_fltMinorRadius = 0.3f;
52  m_iLatSegments = 20;
53  m_iLongSegments = 20;
54 }
55 
63 {
64 
65 }
66 
68 
69 void Ellipsoid::MajorRadius(float fltVal, bool bUseScaling)
70 {
71  Std_IsAboveMin((float) 0, fltVal, true, "Ellipsoid.MajorRadius");
72 
73  if(bUseScaling)
75  else
76  m_fltMajorRadius = fltVal;
77 
78  Resize();
79 }
80 
82 
83 void Ellipsoid::MinorRadius(float fltVal, bool bUseScaling)
84 {
85  Std_IsAboveMin((float) 0, fltVal, true, "Ellipsoid.MinorRadius");
86 
87  if(bUseScaling)
89  else
90  m_fltMinorRadius = fltVal;
91 
92  Resize();
93 }
94 
104 {
105  Std_IsAboveMin((int) 10, iVal, true, "Ellipsoid.LatSegments", true);
106  m_iLatSegments = iVal;
107 
108  Resize();
109 }
110 
120 
130 {
131  Std_IsAboveMin((int) 10, iVal, true, "Ellipsoid.LongSegments", true);
132  m_iLongSegments = iVal;
133 
134  Resize();
135 }
136 
146 
147 bool Ellipsoid::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 == "MAJORRADIUS")
155  {
156  MajorRadius((float) atof(strValue.c_str()));
157  return true;
158  }
159 
160  if(strType == "MINORRADIUS")
161  {
162  MinorRadius((float) atof(strValue.c_str()));
163  return true;
164  }
165 
166  if(strType == "LATITUDESEGMENTS")
167  {
168  LatSegments((float) atof(strValue.c_str()));
169  return true;
170  }
171 
172  if(strType == "LONGTITUDESEGMENTS")
173  {
174  LongSegments(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 Ellipsoid::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
186 {
187  RigidBody::QueryProperties(aryProperties);
188 
189  aryProperties.Add(new TypeProperty("MajorRadius", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
190  aryProperties.Add(new TypeProperty("MinorRadius", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
191  aryProperties.Add(new TypeProperty("LatitudeSegments", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
192  aryProperties.Add(new TypeProperty("LongtitudeSegments", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
193 }
194 
195 void Ellipsoid::Load(CStdXml &oXml)
196 {
197  RigidBody::Load(oXml);
198 
199  oXml.IntoElem(); //Into RigidBody Element
200 
201  MajorRadius(oXml.GetChildFloat("MajorRadius", m_fltMajorRadius));
202  MinorRadius(oXml.GetChildFloat("MinorRadius", m_fltMinorRadius));
203  LatSegments(oXml.GetChildInt("LatitudeSegments", m_iLatSegments));
204  LongSegments(oXml.GetChildInt("LongtitudeSegments", m_iLongSegments));
205 
206  oXml.OutOfElem(); //OutOf RigidBody Element
207 }
208 
209 
210  } //Bodies
211  } //Environment
212 } //AnimatSim
Base class file for all Animat simulation objects.
Declares the simulation recorder class.
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 float MinorRadius()
Gets the minor axis radius.
Definition: Ellipsoid.cpp:81
virtual bool IntoElem()
Goes into the next element where the cursor is located.
Definition: StdXml.cpp:42
virtual int LatSegments()
Gets the number of segments used to draw the ellipsoid in the latitude direction. ...
Definition: Ellipsoid.cpp:119
virtual float MajorRadius()
Gets the major axis radius.
Definition: Ellipsoid.cpp:67
float m_fltMinorRadius
The radius of the minor axis of the ellipsoid.
Definition: Ellipsoid.h:31
Class that stores information about types for QueryProperty information.
Definition: TypeProperty.h:35
float m_fltMajorRadius
The radius of the major axis of the ellipsoid.
Definition: Ellipsoid.h:28
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.
Declares a light manager object.
Declares the bounding box class.
int m_iLatSegments
The number of segments used to draw in the latitude direction.
Definition: Ellipsoid.h:34
A standard xml manipulation class.
Definition: StdXml.h:19
Declares the node class.
virtual int LongSegments()
Gets the number of segments used to draw the ellipsoid in the longtitude direction.
Definition: Ellipsoid.cpp:145
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.
Declares the structure class.
Declares the odor type class.
Declares the ellipsoid class.
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
int m_iLongSegments
The number of segments used to draw in the longtitude direction.
Definition: Ellipsoid.h:37