16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-23 00:29:19 +02:00

Poprawki funkcji z mctools.

This commit is contained in:
firleju
2016-10-12 23:05:38 +02:00
parent c735bb2ddf
commit 529f70123a
2 changed files with 43 additions and 58 deletions

View File

@@ -13,8 +13,9 @@ Copyright (C) 2007-2014 Maciej Cierniak
*/ */
#include "mctools.h" #include "mctools.h"
#include <cmath> #include <cmath>
#include <ifstream> #include <istream>
using namespace std;
/*================================================*/ /*================================================*/
std::string Ups(std::string s) std::string Ups(std::string s)
@@ -180,79 +181,63 @@ std::string Cut_Space(std::string s, int Just)
std::string ExtractKeyWord(std::string InS, std::string KeyWord) std::string ExtractKeyWord(std::string InS, std::string KeyWord)
{ {
std::string result;
std::string s; std::string s;
unsigned char kwp;
InS = InS + " "; InS = InS + " ";
kwp = Pos(KeyWord, InS); std::size_t kwp = InS.find(KeyWord);
if (kwp > 0) if (kwp != string::npos)
{ {
s = Copy(InS, kwp, length(InS)); s = InS.substr(kwp, InS.length());
s = Copy(s, 1, Pos(" ", s) - 1); //s = Copy(InS, kwp, length(InS));
s = s.substr(0, s.find_first_of(" "));
//s = Copy(s, 1, Pos(" ", s) - 1);
} }
else else
s = ""; s = "";
ExtractKeyWord = s; return s;
return result;
} }
std::string DUE(std::string s) /*Delete Until Equal sign*/ std::string DUE(std::string s) /*Delete Until Equal sign*/
{ {
std::string result; //DUE = Copy(s, Pos("=", s) + 1, length(s));
DUE = Copy(s, Pos("=", s) + 1, length(s)); return s.substr(s.find("=") + 1, s.length());
return result;
} }
std::string DWE(std::string s) /*Delete While Equal sign*/ std::string DWE(std::string s) /*Delete While Equal sign*/
{ {
std::string result; size_t ep = s.find("=");
unsigned char ep; if (ep != string::npos)
//DWE = Copy(s, 1, ep - 1);
ep = Pos("=", s); return s.substr(0, ep);
if (ep > 0)
DWE = Copy(s, 1, ep - 1);
else else
DWE = s; return s;
return result;
} }
std::string Ld2Sp(std::string s) /*Low dash to Space sign*/ std::string Ld2Sp(std::string s) /*Low dash to Space sign*/
{ {
std::string result; std::string s2 = "";
unsigned char b; char tmp[] = { "_" };
std::string s2; for (int b = 0; b < s.length(); ++b)
{
s2 = ""; if (s[b] == tmp[0])
{ s2 = s2 + " ";
long b_end = length(s) + 1; else
for (b = 1; b < b_end; ++b) s2 = s2 + s[b];
if (s[b] == "_") }
s2 = s2 + " "; return s2;
else
s2 = s2 + s[b];
}
Ld2Sp = s2;
return result;
} }
std::string Tab2Sp(std::string s) /*Tab to Space sign*/ std::string Tab2Sp(std::string s) /*Tab to Space sign*/
{ {
std::string result; std::string s2 = "";
unsigned char b; char tmp[] = { (char)9 };
std::string s2; for (int b = 0; b < s.length(); ++b)
{
s2 = ""; if (s[b] == tmp[0])
{ s2 = s2 + " ";
long b_end = length(s) + 1; else
for (b = 1; b < b_end; ++b) s2 = s2 + s[b];
if (s[b] == (char)9) }
s2 = s2 + " "; return s2;
else
s2 = s2 + s[b];
}
Tab2Sp = s2;
return result;
} }
void ComputeArc(double X0, double Y0, double Xn, double Yn, double R, double L, double dL, void ComputeArc(double X0, double Y0, double Xn, double Yn, double R, double L, double dL,
@@ -275,11 +260,11 @@ void ComputeArc(double X0, double Y0, double Xn, double Yn, double R, double L,
if (dX != 0) if (dX != 0)
gamma = atan(dY * 1.0 / dX); gamma = atan(dY * 1.0 / dX);
else if (dY > 0) else if (dY > 0)
gamma = Pi * 1.0 / 2; gamma = pi * 1.0 / 2;
else else
gamma = 3 * Pi * 1.0 / 2; gamma = 3 * pi * 1.0 / 2;
alfa = L * 1.0 / R; alfa = L * 1.0 / R;
phi = gamma - (alfa + Pi * Round(R * 1.0 / AbsR)) * 1.0 / 2; phi = gamma - (alfa + pi * Round(R * 1.0 / AbsR)) * 1.0 / 2;
Xc = X0 - AbsR * cos(phi); Xc = X0 - AbsR * cos(phi);
Yc = Y0 - AbsR * sin(phi); Yc = Y0 - AbsR * sin(phi);
phi = phi + alfa * dL * 1.0 / L; phi = phi + alfa * dL * 1.0 / L;

View File

@@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/.
/*konwersja zmiennych na stringi, funkcje matematyczne, logiczne, lancuchowe, I/O etc*/ /*konwersja zmiennych na stringi, funkcje matematyczne, logiczne, lancuchowe, I/O etc*/
#include <string> #include <string>
#include <ifstream> #include <istream>
/*Ra: te sta³e nie s¹ u¿ywane... /*Ra: te sta³e nie s¹ u¿ywane...
@@ -29,12 +29,12 @@ http://mozilla.org/MPL/2.0/.
_Delimiter_Space=_Delimiter+[' ']; _Delimiter_Space=_Delimiter+[' '];
*/ */
static char _EOL[2] = { (char)13, (char)10 }; static char _EOL[2] = { (char)13, (char)10 };
//static char const _SPACE = " "; // to jest w <string> //static char const _SPACE = " ";
static char _Spacesigns[5] = { " ",_SPACE,(char)9, (char)13, (char)10}; static char _Spacesigns[4] = { (char)" ",(char)9, (char)13, (char)10};
static int const CutLeft = -1; static int const CutLeft = -1;
static int const CutRight = 1; static int const CutRight = 1;
static int const CutBoth = 0; /*Cut_Space*/ static int const CutBoth = 0; /*Cut_Space*/
static double const pi = 3.141592653589793;
int ConversionError = 0; int ConversionError = 0;
int LineCount = 0; int LineCount = 0;