199 lines
5.4 KiB
C
199 lines
5.4 KiB
C
|
#pragma once
|
|||
|
#include "DataManagerGlobal.h"
|
|||
|
#include <string>
|
|||
|
#include <vector>
|
|||
|
#include <cmath>
|
|||
|
#include <stdexcept>
|
|||
|
//#include <format>
|
|||
|
#include <memory>
|
|||
|
#include "tangible_string_helper.h"
|
|||
|
#include "ModelData.h"
|
|||
|
/// <summary>
|
|||
|
/// 肋位/站位/坐标转换类
|
|||
|
/// </summary>
|
|||
|
class DATAMANAGER_DLL_API_EXPORTS ChangeFSPos
|
|||
|
{
|
|||
|
private:
|
|||
|
static inline double Lbp = 0.0;
|
|||
|
static inline double stnap = 0.0;
|
|||
|
static inline double stnfp = 0.0;
|
|||
|
static inline double rfrno = 0.0;
|
|||
|
static inline int iframe = 1;
|
|||
|
|
|||
|
static inline int nfrtab = 0; // 肋位数
|
|||
|
static inline std::vector<int> frno; // 肋位号
|
|||
|
static inline std::vector<double> frsp; // 肋距
|
|||
|
static inline std::vector<double> yfr; // 肋位号的纵向坐标位置
|
|||
|
static inline double yreffr = 0.0; // 0号肋号位置
|
|||
|
|
|||
|
static inline double stationpos = 0.0; // 0号站号起始位置
|
|||
|
static inline int nsp = 0; // 站数
|
|||
|
static inline std::vector<double> sno; // 站号
|
|||
|
static inline std::vector<double> ssp; // 站距
|
|||
|
static inline std::vector<double> ys; // 站号的纵向坐标位置
|
|||
|
|
|||
|
public:
|
|||
|
static inline std::string fn = "f4";
|
|||
|
|
|||
|
// #region 转换函数
|
|||
|
|
|||
|
// from Y coord to S(Station) or F(Frame)
|
|||
|
public:
|
|||
|
static void reset();
|
|||
|
|
|||
|
static void gpos_lpos(double gpos, int Ref, std::string &tlpos);
|
|||
|
|
|||
|
static void lpos_gpos(const std::string &lpos, double &vgpos);
|
|||
|
|
|||
|
// static void Frout(double gpos, ref double Vlpos, ref double Add)
|
|||
|
//{
|
|||
|
// double Afrsp, Apos, Afr1;
|
|||
|
// int Afrno, Sign, I;
|
|||
|
// double[] Dfr1 = new double[nfrtab + 2];
|
|||
|
|
|||
|
// Vlpos = 0;
|
|||
|
// Add = 0;
|
|||
|
|
|||
|
// if (nfrtab == 0)
|
|||
|
// {
|
|||
|
// throw new Exception("未定义肋位,清先定义肋位!");
|
|||
|
// }
|
|||
|
|
|||
|
// Sign = 2 * iframe - 1;
|
|||
|
|
|||
|
// if (nfrtab == 0)
|
|||
|
// return;
|
|||
|
// double ystart = yfr[1];
|
|||
|
|
|||
|
// for (I = 2; I <= nfrtab; I++)
|
|||
|
// Dfr1[I] = Sign * (yfr[I] - ystart);
|
|||
|
// Dfr1[nfrtab + 1] = Dfr1[nfrtab - 1] + (frno[nfrtab] - frno[nfrtab - 1]) * frsp[nfrtab];
|
|||
|
|
|||
|
// Apos = Sign * (gpos - ystart);
|
|||
|
// Afr1 = Dfr1[2];
|
|||
|
// Afrsp = frsp[1];
|
|||
|
// Afrno = frno[1];
|
|||
|
// for (I = 1; I <= (nfrtab); I++)
|
|||
|
// {
|
|||
|
// Afr1 = Dfr1[I + 1];
|
|||
|
// Afrsp = frsp[I];
|
|||
|
// Afrno = frno[I];
|
|||
|
|
|||
|
// if (Apos <= Afr1)
|
|||
|
// break;
|
|||
|
// }
|
|||
|
|
|||
|
// if (I >nfrtab)
|
|||
|
// {
|
|||
|
// I = nfrtab;
|
|||
|
// }
|
|||
|
// Vlpos = Afrno + (Apos - Dfr1[I]) / Afrsp;
|
|||
|
// Add = Sign * FNFract((Vlpos)) * Afrsp;
|
|||
|
// if (Math.Abs(Math.Abs(Add) - Afrsp) < 0.0005)
|
|||
|
// {
|
|||
|
// Vlpos = Vlpos + 1;
|
|||
|
// Add = 0;
|
|||
|
// }
|
|||
|
// if (Math.Abs(Add) < 0.0005) Add = 0;
|
|||
|
|
|||
|
// if (Math.Floor(Vlpos + 0.001) > Math.Floor(Vlpos))
|
|||
|
// Vlpos = Vlpos + 0.00001;
|
|||
|
// Vlpos = Math.Floor(Vlpos);
|
|||
|
//}
|
|||
|
/// <summary>
|
|||
|
/// 纵坐标转换成肋位号
|
|||
|
/// </summary>
|
|||
|
/// <param name="gpos"></param>
|
|||
|
/// <param name="Vlpos"></param>
|
|||
|
/// <param name="Add"></param>
|
|||
|
/// <returns></returns>
|
|||
|
static bool Frout(double gpos, double &Vlpos, double &Add);
|
|||
|
|
|||
|
static double FNFract(double X);
|
|||
|
|
|||
|
static double FNFract_(double X);
|
|||
|
|
|||
|
static void frin(double vlpos, double add, double &gpos, int iframe, double rfrno, double Yreffr, double nfrtab, std::vector<int> &frno, std::vector<double> &yfr, std::vector<double> &frsp);
|
|||
|
|
|||
|
static int fnmax(int X1, int X2);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 纵坐标转换成站号
|
|||
|
/// </summary>
|
|||
|
/// <param name="gpos"></param>
|
|||
|
/// <param name="Vlpos"></param>
|
|||
|
/// <param name="Add"></param>
|
|||
|
/// <returns></returns>
|
|||
|
static bool Sout(double gpos, double &Vlpos, double &Add);
|
|||
|
/// <summary>
|
|||
|
/// 站号转换成纵坐标
|
|||
|
/// </summary>
|
|||
|
/// <param name="vlpos"></param>
|
|||
|
/// <param name="add"></param>
|
|||
|
/// <param name="gpos"></param>
|
|||
|
static bool Sin(double vlpos, double add, double &gpos);
|
|||
|
|
|||
|
static bool ResetS(double &vlpos, double &add);
|
|||
|
|
|||
|
// #endregion
|
|||
|
|
|||
|
// #region 对外接口
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Y坐标表示 可输入以 "F"、"S","M"表示的坐标,返回纵向坐标位置
|
|||
|
/// </summary>
|
|||
|
/// <param name="str"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public:
|
|||
|
static double ShowX(const std::string &str);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 返回肋位号表示(#...)
|
|||
|
/// </summary>
|
|||
|
/// <param name="str">参数输入纵向坐标位置,不能输入含字母的数据</param>
|
|||
|
/// <returns></returns>
|
|||
|
static std::string ShowF_Sharp(std::string &str);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 返回肋位号表示(F...)
|
|||
|
/// </summary>
|
|||
|
/// <param name="str">参数输入纵向坐标位置,不能输入含字母的数据</param>
|
|||
|
/// <returns></returns>
|
|||
|
static std::string ShowF(std::string str);
|
|||
|
|
|||
|
//'返回用站号表示的坐标, 参数输入纵向坐标位置,不能输入含字母的数据
|
|||
|
static std::string ShowS(std::string str);
|
|||
|
//'返回用站号表示的坐标, 参数输入纵向坐标位置,不能输入含字母的数据
|
|||
|
static std::string ShowNonPlusS(std::string &str);
|
|||
|
/// <summary>
|
|||
|
/// 获取肋位和站号计算所需数据
|
|||
|
/// </summary>
|
|||
|
/// <remarks></remarks>
|
|||
|
static void ChangeFSPos::SetSecConvert(ModelData *model);
|
|||
|
/// <summary>
|
|||
|
/// 获取肋位坐标集合
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
static std::vector<double> GetFX();
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取站位坐标集合
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
static std::vector<double> GetSX();
|
|||
|
|
|||
|
// #endregion
|
|||
|
|
|||
|
// #region 例子调用
|
|||
|
|
|||
|
/* ChangeFSPos cfspos = new ChangeFSPos();
|
|||
|
cfspos.setSecConvert();
|
|||
|
|
|||
|
string a = cfspos.showY("F 1+0.023");
|
|||
|
string b = cfspos.showF("123.123");
|
|||
|
string c = cfspos.showS("205.222");
|
|||
|
MessageBox.Show(textBox3.Text);*/
|
|||
|
|
|||
|
// #endregion
|
|||
|
};
|