AnimatLab  2
Test
Cylinder.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 "Cylinder.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;
51  m_fltHeight = 1;
52  m_iSides = 10;
53 }
54 
62 {
63 
64 }
65 
66 float Cylinder::Radius() {return m_fltRadius;}
67 
68 void Cylinder::Radius(float fltVal, bool bUseScaling)
69 {
70  Std_IsAboveMin((float) 0, fltVal, true, "Cylinder.Radius");
71  if(bUseScaling)
73  else
74  m_fltRadius = fltVal;
75 
76  Resize();
77 }
78 
79 
80 float Cylinder::Height() {return m_fltHeight;}
81 
82 void Cylinder::Height(float fltVal, bool bUseScaling)
83 {
84  Std_IsAboveMin((float) 0, fltVal, true, "Cylinder.Height");
85  if(bUseScaling)
87  else
88  m_fltHeight = fltVal;
89 
90  Resize();
91 }
100 void Cylinder::Sides(int iVal)
101 {
102  Std_IsAboveMin((int) 10, iVal, true, "Cone.Sides", true);
103  m_iSides = iVal;
104 
105  Resize();
106 }
107 
116 int Cylinder::Sides() {return m_iSides;}
117 
118 bool Cylinder::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
119 {
120  std::string strType = Std_CheckString(strDataType);
121 
122  if(RigidBody::SetData(strType, strValue, false))
123  return true;
124 
125  if(strType == "RADIUS")
126  {
127  Radius((float) atof(strValue.c_str()));
128  return true;
129  }
130 
131  if(strType == "HEIGHT")
132  {
133  Height((float) atof(strValue.c_str()));
134  return true;
135  }
136 
137  if(strType == "SIDES")
138  {
139  Sides(atoi(strValue.c_str()));
140  return true;
141  }
142 
143  //If it was not one of those above then we have a problem.
144  if(bThrowError)
145  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
146 
147  return false;
148 }
149 
150 void Cylinder::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
151 {
152  RigidBody::QueryProperties(aryProperties);
153 
154  aryProperties.Add(new TypeProperty("Radius", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
155  aryProperties.Add(new TypeProperty("Height", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
156  aryProperties.Add(new TypeProperty("Sides", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
157 }
158 
159 void Cylinder::Load(CStdXml &oXml)
160 {
161  RigidBody::Load(oXml);
162 
163  oXml.IntoElem(); //Into RigidBody Element
164  Radius(oXml.GetChildFloat("Radius", m_fltRadius));
165  Height(oXml.GetChildFloat("Height"), m_fltHeight);
166  Sides(oXml.GetChildInt("Sides", m_iSides));
167  oXml.OutOfElem(); //OutOf RigidBody Element
168 }
169 
170 
171  } //Bodies
172  } //Environment
173 } //AnimatSim
Base class file for all Animat simulation objects.
Declares the simulation recorder class.
Declares the cylinder class.
Root namespace for the base simulation library for AnimatLab.
Declares the body part class.
float m_fltRadius
The radius of the cylinder.
Definition: Cylinder.h:28
int m_iSides
The number of sides used to draw the cylinder.
Definition: Cylinder.h:34
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
float m_fltHeight
The height of the cylinder.
Definition: Cylinder.h:31
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
virtual float Height()
Gets the height.
Definition: Cylinder.cpp:80
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.
A standard xml manipulation class.
Definition: StdXml.h:19
Declares the node class.
virtual int Sides()
Gets the number of sides used to draw the cylinder.
Definition: Cylinder.cpp:116
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.
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
virtual float Radius()
Gets the radius.
Definition: Cylinder.cpp:66