AnimatLab  2
Test
AnimatUtils.cpp
1 
2 #include "StdAfx.h"
3 #include "IMovableItemCallback.h"
4 #include "ISimGUICallback.h"
5 #include "AnimatBase.h"
6 
7 
8 namespace AnimatSim
9 {
10 
11  //float ANIMAT_PORT EvalGraph(unsigned char iGraphType, float fltA, float fltB, float fltC, float fltD, float fltQty)
12  //{
13  // float fltVal=0;
14  //
15 
16  // switch(iGraphType)
17  // {
18  // case LINEAR_GRAPH:
19  // if(fltA) fltVal = ((fltB/fltA)*fltQty + fltC);
20  // break;
21 
22  // case BELL_GRAPH:
23  // if(fltB)
24  // {
25  // fltVal = pow((float) (fltQty-fltA), (float) 2.0);
26  // fltVal = exp(-fltC * fltVal);
27  // fltVal = (fltB * fltVal) + fltD;
28  // }
29  // //fltVal = (fltB * exp(-fltC * pow((fltQty-fltA), 2.0))) + fltD
30 
31  // //fltVal = (fltB * exp(-fltC * pow(((fltQty-fltA)/fltB), 2.0))) + fltD;
32  // break;
33 
34  // case SIGMOID_GRAPH:
35  // fltVal = (fltB/(1+exp(fltC*(fltA-fltQty)))) + fltD;
36  // break;
37 
38  // case INVERSE_GRAPH:
39  // fltVal = pow((fltQty-fltC), fltB);
40  // if(fltVal)
41  // fltVal = (fltA / fltVal) + fltD;
42  // else
43  // fltVal = 0;
44  // break;
45  // //fltVal = (fltA / ((fltQty-fltC)^fltB)) + fltD;
46 
47  // case QUADRATIC_GRAPH:
48  // fltVal = (fltA * pow((fltQty-fltC), fltB)) + fltD;
49  // break;
50 
51  // }
52  //
53  // return fltVal;
54  //}
55 
56 
57  std::string ANIMAT_PORT GetFilePath(std::string strProjectPath, std::string strFilename)
58  {
59  //If they specify a full path name here then we will use that.
60  //but if it is only a file name then we assume that the file
61  //is located in the project path.
62  std::string strPath;
63  if(!Std_IsFullPath(strFilename))
64  {
65 #ifndef WIN32
66  //If we are not on a windows system then replace // slashes with
67  strFilename = Std_Replace(strFilename, "\\", "/");
68 #endif
69  strPath = strProjectPath + strFilename;
70  }
71  else
72  strPath = strFilename;
73 
74  return strPath;
75  }
76 
77  //float ANIMAT_PORT LoadScaledNumber(CStdXml oXml, std::string strName, bool bThrowError = true, float fltDefault = 0)
78  //{
79  // float fltValue = fltDefault;
80 
81  // if(oXml.FindChildElement(strName, bThrowError))
82  // {
83  // oXml.IntoChildElement(strName);
84  // fltValue = oXml.GetAttribFloat("Actual", bThrowError, fltDefault);
85  // oXml.OutOfElem();
86  // }
87 
88  // return fltValue;
89  //}
90 
91 } //AnimatSim
92 
Base class file for all Animat simulation objects.
Root namespace for the base simulation library for AnimatLab.
bool Std_IsFullPath(std::string strPath)
determines if this is a full path name.
std::string Std_Replace(std::string strVal, std::string strFind, std::string strReplace)
Replaces a substring with another string.