Skip to content

Commit

Permalink
Fixed some bugs in Unicode, and a bug of Diff function's Sin Cos proc…
Browse files Browse the repository at this point in the history
…essing
  • Loading branch information
tomwillow committed Dec 7, 2021
1 parent 9ac29c4 commit fff2a14
Show file tree
Hide file tree
Showing 15 changed files with 708 additions and 427 deletions.
88 changes: 44 additions & 44 deletions Common/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,50 +70,50 @@ using std::to_string;
#define To_string to_string

#endif

inline String & operator<<(String &s, double d)
{
TCHAR temp[32];
_stprintf_s(temp, TEXT("%f"), d);
s += temp;
return s;
}

inline String & operator<<(String &s, size_t i)
{
TCHAR temp[32];
#ifdef _UNICODE
_itow_s(i, temp, 10);
#else
_itoa_s(i, temp, 10);
#endif
s += temp;
return s;
}

inline String & operator<<(String &s, int i)
{
TCHAR temp[32];
#ifdef _UNICODE
_itow_s(i, temp, 10);
#else
_itoa_s(i, temp, 10);
#endif
s += temp;
return s;
}

inline String & operator<<(String &s, TCHAR szStr[])
{
s += szStr;
return s;
}

inline String & operator<<(String &s,const String &s2)
{
s += s2;
return s;
}
//
//inline String & operator<<(String &s, double d)
//{
// TCHAR temp[32];
// _stprintf_s(temp, TEXT("%f"), d);
// s += temp;
// return s;
//}
//
//inline String & operator<<(String &s, size_t i)
//{
// TCHAR temp[32];
//#ifdef _UNICODE
// _itow_s(i, temp, 10);
//#else
// _itoa_s(i, temp, 10);
//#endif
// s += temp;
// return s;
//}
//
//inline String & operator<<(String &s, int i)
//{
// TCHAR temp[32];
//#ifdef _UNICODE
// _itow_s(i, temp, 10);
//#else
// _itoa_s(i, temp, 10);
//#endif
// s += temp;
// return s;
//}
//
//inline String & operator<<(String &s, TCHAR szStr[])
//{
// s += szStr;
// return s;
//}
//
//inline String & operator<<(String &s,const String &s2)
//{
// s += s2;
// return s;
//}

inline void Replace(String &src, const String sub,const String dest)
{
Expand Down
4 changes: 2 additions & 2 deletions Control/TCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ void TCanvas::OnDraw(HDC hdc)
if (pElement->id == ShowId)
{
String sId;
sId<<TEXT("id:")<<To_string(ShowId);
sId << TEXT(" pt") << To_string(ShowIndex);
sId+=TEXT("id:")+To_string(ShowId);
sId+=TEXT(" pt") +To_string(ShowIndex);

TDraw::DrawAdjustedText(hdc, pConfig->RealToScreen(pElement->GetAbsolutePointByIndex(ShowIndex)), ClientRect, sId.c_str(),10,false, pConfig);
}
Expand Down
28 changes: 14 additions & 14 deletions Dialog/DialogAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,9 +908,9 @@ namespace DialogAnimation
if (pElement->CanBeDragged())//非机架及RealLine,Driver,Constraint
{
s.clear();
s << TEXT("ID:") << pElement->id;
s << TEXT(" ") << pElement->GetElementTypeName();//“连杆”
s << TEXT(" ") << pElement->Name;
s+= TEXT("ID:") + To_string(pElement->id);
s += TEXT(" ") + pElement->GetElementTypeName();//“连杆”
s += TEXT(" ") + String(pElement->Name);
for (size_t i = 0; i < pElement->vecDpt.size(); ++i)//遍历每个相对点
{
for (auto ValueType : { X, Y, PHI })//x,y,phi各加一个
Expand All @@ -920,12 +920,12 @@ namespace DialogAnimation
TListBoxItem tempItem;

s_dpt.clear();
s_dpt << TEXT("pt") << i;
s_dpt +=TEXT("pt") + i;
switch (ValueType)
{
case X:s_dpt << TEXT(" x"); break;
case Y:s_dpt << TEXT(" y"); break;
case PHI:s_dpt << TEXT(" phi"); break;
case X:s_dpt +=TEXT(" x"); break;
case Y:s_dpt +=TEXT(" y"); break;
case PHI:s_dpt +=TEXT(" phi"); break;
}
ListBoxLeft.AddString((s + s_dpt).c_str());

Expand Down Expand Up @@ -957,19 +957,19 @@ namespace DialogAnimation
String GetUnitName(enumListBoxItemType type, enumListBoxItemValueType value_type)
{
String s = GetTypeName(type);
s << TEXT(" (");
s += TEXT(" (");
switch (value_type)
{
case X:s << TEXT("mm"); break;
case Y:s << TEXT("mm"); break;
case PHI:s << TEXT("rad"); break;
case X:s += TEXT("mm"); break;
case Y:s += TEXT("mm"); break;
case PHI:s += TEXT("rad"); break;
}

switch (type)
{
case D:s << TEXT(")"); break;
case V:s << TEXT("/s)"); break;
case A:s << TEXT("/s^2)"); break;
case D:s += TEXT(")"); break;
case V:s += TEXT("/s)"); break;
case A:s += TEXT("/s^2)"); break;
}
return s;
}
Expand Down
40 changes: 40 additions & 0 deletions Linkage Mechanism Laboratory.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,82 @@ VisualStudioVersion = 16.0.29519.87
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Linkage Mechanism Laboratory", "Linkage Mechanism Laboratory.vcxproj", "{265569DC-34A0-49B3-9BE3-5133199DB24D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test_TExpressionTree", "Test_TExpressionTree\Test_TExpressionTree.vcxproj", "{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x64 = Release|x64
STUDENT Release|Any CPU = STUDENT Release|Any CPU
STUDENT Release|Mixed Platforms = STUDENT Release|Mixed Platforms
STUDENT Release|Win32 = STUDENT Release|Win32
STUDENT Release|x64 = STUDENT Release|x64
TEACHER Release|Any CPU = TEACHER Release|Any CPU
TEACHER Release|Mixed Platforms = TEACHER Release|Mixed Platforms
TEACHER Release|Win32 = TEACHER Release|Win32
TEACHER Release|x64 = TEACHER Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{265569DC-34A0-49B3-9BE3-5133199DB24D}.Debug|Any CPU.ActiveCfg = Debug|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.Debug|Win32.ActiveCfg = Debug|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.Debug|Win32.Build.0 = Debug|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.Debug|x64.ActiveCfg = Debug|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.Release|Any CPU.ActiveCfg = Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.Release|Mixed Platforms.Build.0 = Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.Release|Win32.ActiveCfg = Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.Release|Win32.Build.0 = Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.Release|x64.ActiveCfg = Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.STUDENT Release|Any CPU.ActiveCfg = STUDENT Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.STUDENT Release|Mixed Platforms.ActiveCfg = STUDENT Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.STUDENT Release|Mixed Platforms.Build.0 = STUDENT Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.STUDENT Release|Win32.ActiveCfg = STUDENT Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.STUDENT Release|Win32.Build.0 = STUDENT Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.STUDENT Release|x64.ActiveCfg = STUDENT Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.TEACHER Release|Any CPU.ActiveCfg = TEACHER Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.TEACHER Release|Mixed Platforms.ActiveCfg = TEACHER Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.TEACHER Release|Mixed Platforms.Build.0 = TEACHER Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.TEACHER Release|Win32.ActiveCfg = TEACHER Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.TEACHER Release|Win32.Build.0 = TEACHER Release|Win32
{265569DC-34A0-49B3-9BE3-5133199DB24D}.TEACHER Release|x64.ActiveCfg = TEACHER Release|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.Debug|Any CPU.ActiveCfg = Debug|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.Debug|Win32.ActiveCfg = Debug|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.Debug|Win32.Build.0 = Debug|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.Debug|x64.ActiveCfg = Debug|x64
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.Debug|x64.Build.0 = Debug|x64
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.Release|Any CPU.ActiveCfg = Release|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.Release|Mixed Platforms.Build.0 = Release|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.Release|Win32.ActiveCfg = Release|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.Release|Win32.Build.0 = Release|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.Release|x64.ActiveCfg = Release|x64
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.Release|x64.Build.0 = Release|x64
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.STUDENT Release|Any CPU.ActiveCfg = Release|x64
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.STUDENT Release|Any CPU.Build.0 = Release|x64
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.STUDENT Release|Mixed Platforms.ActiveCfg = Release|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.STUDENT Release|Mixed Platforms.Build.0 = Release|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.STUDENT Release|Win32.ActiveCfg = Release|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.STUDENT Release|Win32.Build.0 = Release|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.STUDENT Release|x64.ActiveCfg = Release|x64
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.STUDENT Release|x64.Build.0 = Release|x64
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.TEACHER Release|Any CPU.ActiveCfg = Release|x64
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.TEACHER Release|Any CPU.Build.0 = Release|x64
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.TEACHER Release|Mixed Platforms.ActiveCfg = Release|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.TEACHER Release|Mixed Platforms.Build.0 = Release|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.TEACHER Release|Win32.ActiveCfg = Release|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.TEACHER Release|Win32.Build.0 = Release|Win32
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.TEACHER Release|x64.ActiveCfg = Release|x64
{D3AE7C6E-A730-40F7-B70F-BAF4B4493FBF}.TEACHER Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
80 changes: 40 additions & 40 deletions Solver/TEquations.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ class TEquations
TPEquations Equations, EquationsV, EquationsA;
TVariableTable VariableTableSolved;//已解出变量表

void TEquations::CalcPhiValue(Ostream *pOS,const TPEquations &Equations, TVector &PhiValue);
void TEquations::MatrixMultiplyVector(TVector &Result, const TMatrix &Matrix, const TVector &Vector);
void TEquations::CalcJacobianValue(Ostream *pOS, TMatrix &JacobianValueResult, const TJacobian &Jacobian);
int TEquations::GetMaxAbsRowIndex(const TMatrix &A, int RowStart, int RowEnd, int Col);
void TEquations::SwapRow(TMatrix &A, TVector &b, int i, int j);
bool TEquations::AllIs0(TVector &V);
bool TEquations::VectorAdd(TVector &Va, const TVector &Vb);
void TEquations::Output(Ostream *pOS, TMatrix& m);
void TEquations::Output(Ostream *pOS, TVector& v);
void TEquations::ReleaseTPEquations(TPEquations &Equations);
void TEquations::ReleaseJacobian(TJacobian &Jacobian);
void TEquations::SubsVar(Ostream *pOS, TPEquations &Equations, TVariableTable &LinkVariableTable, String VarStr, double Value);
void TEquations::BuildJacobian_inner(TJacobian &JacobianResult,const TPEquations &Equations,TVariableTable &VariableTable);
void CalcPhiValue(Ostream *pOS,const TPEquations &Equations, TVector &PhiValue);
void MatrixMultiplyVector(TVector &Result, const TMatrix &Matrix, const TVector &Vector);
void CalcJacobianValue(Ostream *pOS, TMatrix &JacobianValueResult, const TJacobian &Jacobian);
int GetMaxAbsRowIndex(const TMatrix &A, int RowStart, int RowEnd, int Col);
void SwapRow(TMatrix &A, TVector &b, int i, int j);
bool AllIs0(TVector &V);
bool VectorAdd(TVector &Va, const TVector &Vb);
void Output(Ostream *pOS, TMatrix& m);
void Output(Ostream *pOS, TVector& v);
void ReleaseTPEquations(TPEquations &Equations);
void ReleaseJacobian(TJacobian &Jacobian);
void SubsVar(Ostream *pOS, TPEquations &Equations, TVariableTable &LinkVariableTable, String VarStr, double Value);
void BuildJacobian_inner(TJacobian &JacobianResult,const TPEquations &Equations,TVariableTable &VariableTable);
public:
TEquations();
~TEquations();
Expand All @@ -43,36 +43,36 @@ class TEquations
TVariableTable VariableTableV; //速度总变量表
TVariableTable VariableTableA; //速度总变量表

TExpressionTree * TEquations::GetLastExpressionTree()
TExpressionTree * GetLastExpressionTree()
{
return Equations.back();
}
void TEquations::BuildEquationsV(Ostream *pOS);
void TEquations::BuildEquationsA_Phitt(Ostream *pOS);
void TEquations::CalcEquationsARight(Ostream *pOS, TVector &Right);
void TEquations::OutputPhi(Ostream *pOS, TPEquations &Equations);
void TEquations::BuildJacobian(Ostream *pOS);//建立Jacobian
void TEquations::CopyJacobian(TJacobian &Result, const TJacobian &Origin);
void TEquations::OutputJacobian(Ostream *pOS, const TJacobian &Jacobian);
void TEquations::BuildVariableTableV(Ostream *pOS);
void TEquations::BuildVariableTableA(Ostream *pOS);
size_t TEquations::GetEquationsCount();
void TEquations::AddEquation(Ostream *pOS, String szInput, bool istemp);//添加方程
void TEquations::RemoveTempEquations();//移除临时方程
enumError TEquations::SolveLinear(TMatrix &A, TVector &x, TVector &b);//解线性方程组 系数A,未知数x
void TEquations::SolveEquations(Ostream *pOS);//求解方程组
void TEquations::SolveEquationsV(Ostream *pOS);//求解方程组V
void TEquations::SolveEquationsA(Ostream *pOS);//求解方程组A
void TEquations::SimplifyEquations(Ostream *pOS);//将方程组中的简单方程解出
void TEquations::DefineVariable(Ostream *pOS, const String input_str, const String input_num = TEXT(""), bool bIgnoreReDef = false);
void TEquations::DefineOneVariable(Ostream *pOS, String var, double value,bool bIgnoreReDef = false);
void TEquations::Subs(Ostream *pOS, const String var, double value);
void TEquations::Subs(Ostream *pOS, const String subsVars, const String subsValues);//代入
void TEquations::Subs(Ostream *pOS,const std::vector<String> &subsVars,const std::vector<double> &subsValue);//代入
void TEquations::SubsV(Ostream *pOS, String VarStr, double Value);
void TEquations::SubsA(Ostream *pOS, String VarStr, double Value);
double TEquations::GetValue(const String &var);
void TEquations::CalcJacobianMultiplyVector(TPEquations &EquationsResult, const TJacobian &Jacobian, const TVector &Vector);
void BuildEquationsV(Ostream *pOS);
void BuildEquationsA_Phitt(Ostream *pOS);
void CalcEquationsARight(Ostream *pOS, TVector &Right);
void OutputPhi(Ostream *pOS, TPEquations &Equations);
void BuildJacobian(Ostream *pOS);//建立Jacobian
void CopyJacobian(TJacobian &Result, const TJacobian &Origin);
void OutputJacobian(Ostream *pOS, const TJacobian &Jacobian);
void BuildVariableTableV(Ostream *pOS);
void BuildVariableTableA(Ostream *pOS);
size_t GetEquationsCount();
void AddEquation(Ostream *pOS, String szInput, bool istemp);//添加方程
void RemoveTempEquations();//移除临时方程
enumError SolveLinear(TMatrix &A, TVector &x, TVector &b);//解线性方程组 系数A,未知数x
void SolveEquations(Ostream *pOS);//求解方程组
void SolveEquationsV(Ostream *pOS);//求解方程组V
void SolveEquationsA(Ostream *pOS);//求解方程组A
void SimplifyEquations(Ostream *pOS);//将方程组中的简单方程解出
void DefineVariable(Ostream *pOS, const String input_str, const String input_num = TEXT(""), bool bIgnoreReDef = false);
void DefineOneVariable(Ostream *pOS, String var, double value,bool bIgnoreReDef = false);
void Subs(Ostream *pOS, const String var, double value);
void Subs(Ostream *pOS, const String subsVars, const String subsValues);//代入
void Subs(Ostream *pOS,const std::vector<String> &subsVars,const std::vector<double> &subsValue);//代入
void SubsV(Ostream *pOS, String VarStr, double Value);
void SubsA(Ostream *pOS, String VarStr, double Value);
double GetValue(const String &var);
void CalcJacobianMultiplyVector(TPEquations &EquationsResult, const TJacobian &Jacobian, const TVector &Vector);

};

Loading

0 comments on commit fff2a14

Please sign in to comment.