COMPASSi/trunk/code/projects/DataManager/Infrastructure.Data/StabCalculation/BasicInf.cpp

435 lines
12 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ====================================================================================================
// ====================================================================================================
#include "StabCalculation/BasicInf.h"
#include "StabCalculation/StabCalculation.h"
BasicInf::BasicInf(bool hasIntact, bool hasInclining, bool hasDamProb)
{
// #region 公共
try
{
ShipName = StabCalcBaseData::FindByParamID("ShipName");
Design = StabCalcBaseData::FindByParamID("Design");
Signature = StabCalcBaseData::FindByParamID("Signature"); //20170901 added by czb
CalDate = StabCalcBaseData::FindByParamID("CalDate");
WorkNo = StabCalcBaseData::FindByParamID("WorkNo");
}
catch (...)
{
ShipName = "";
Design = "";
Signature = "";
CalDate = "";
}
StabCalcBaseData::FindByParamID("Origin", Origin);
StabCalcBaseData::FindByParamID("XType", XType);
{
// #region LabelX初始化
int nX = StabCalcBaseData::xlabel_data_grid_view.size(); // X标记个数
if (nX > 0)
{
if (nX < 2)
{
throw std::runtime_error("X标记表错误标记个数小于2");
}
LabelX = std::vector<double>(nX); // X标记表X数组
for (int i = 0; i < nX; i++)
{
LabelX[i] = StabCalcBaseData::xlabel_data_grid_view[i].x;
}
}
else
{
LabelX = std::vector<double>();
}
}
// #endregion
StabCalcBaseData::FindByParamID("IsCatamaran", IsCatamaran);
StabCalcBaseData::FindByParamID("L", L);
try
{
StabCalcBaseData::FindByParamID("Lpp", Lpp);
}
catch (...)
{
Lpp = L;
}
OrgOff = Lpp * Origin / 2; //20161014 by czb
// car-20190628 改回按站位定义
//#region LabelX初始化 cqr-20190109 改为固定的-1到21站
//{
// int nX = 23;// 计算-1到21站 mod.XLabel.Count; // X标记个数
// LabelX = new double[nX]; // X标记表X数组
// for (int i = 0; i < nX; i++)
// {
// LabelX[i] = (i - 1) * Lpp / 20 - Lpp * (Origin + 1) / 2; // 艉原点 Origin=-1舯原点时 Origin=0要减Lpp/2 //mod.XLabel[i].X;
// }
//}
//#endregion
StabCalcBaseData::FindByParamID("B", B);
StabCalcBaseData::FindByParamID("D", D);
StabCalcBaseData::FindByParamID("d", d);
// #region 计算吃水列表
//double.TryParse(mod.BInf.FindByParamID("DraftEvalMax").Value, out DraftEvalMax);
//double.TryParse(mod.BInf.FindByParamID("DraftEvalInterval").Value, out DraftEvalInterval);
DraftList = StabCalcBaseData::FindByParamID("DraftList");
{
// 将 std::string 转换为 QString
QString DraftList_tmp = QString::fromStdString(DraftList);
// 使用 QString::split() 方法,按多个分隔符拆分字符串,并移除空项
QStringList qlistDraftList = DraftList_tmp.split(QRegExp("[;:,\\s]+"), QString::SkipEmptyParts); // \\s 用于匹配空格
// 将 QStringList 转换为 std::vector<std::string>
std::vector<std::string> ds;
for (const QString& token : qlistDraftList) {
ds.push_back(token.toStdString());
}
int nds = ds.size();
if (nds > 0)
{
std::vector<double> Dft(nds);
std::vector<double> Dft1;
for (int i = 0; i < nds; i++)
{
Dft[i] = std::stod(ds[i]);
Dft[i] = std::round(Dft[i] * std::pow(10, 3)) / std::pow(10, 3); // 输入计算吃水只保留三位小数
}
std::sort(Dft.begin(), Dft.end()); // 排序
// #region 排除Dft中的重复值 得到Dft1
Dft1.push_back(Dft[0]);
double td = Dft[0];
for (int i = 1; i < nds; i++)
{
//20200511 by czb原函数不能完全排除重复值只能排除相邻的重复值
if (std::find(Dft1.begin(), Dft1.end(), Dft[i]) != Dft1.end())
{
continue;
}
Dft1.push_back(Dft[i]);
}
// #endregion
Draft = Dft1;
}
else
{
Draft = std::vector<double>();
}
}
// #endregion
// #endregion
// #region 静水力、完整稳性、破损稳性、许用重心高度
StabCalcBaseData::FindByParamID("Density", Density);
if (Density <= 0.01)
{
Density = 1.0; // 20160725新增解决舷外水密度未赋值的情况发生
}
//int.TryParse(mod.BInf.FindByParamID("HullAffect").Value, out HullAffect);
//double.TryParse(mod.BInf.FindByParamID("HullAffectCoef").Value, out HullAffectCoef);
// #region 静水力计算纵倾列表 20200511 by czb
std::string TrimList = StabCalcBaseData::FindByParamID("TrimList");
{
// 用于存储分隔符字符
std::vector<QChar> delimiters = { ';', ':', ',', '', '', '', ' ' };
// 使用QString的split函数按分隔符拆分字符串并移除空项
QStringList qlistTrimList = QString::fromStdString(TrimList).split(QRegExp("[;: ]+"), QString::SkipEmptyParts);
// 将QStringList转为std::vector<std::string>
std::vector<std::string> ds;
std::transform(qlistTrimList.begin(), qlistTrimList.end(), std::back_inserter(ds), [](const QString& s) { return s.toStdString(); });
int nds = ds.size();
if (nds > 0)
{
std::vector<double> Dft(nds);
std::vector<double> Dft1;
for (int i = 0; i < nds; i++)
{
Dft[i] = std::stod(ds[i]);
Dft[i] = std::round(Dft[i] * std::pow(10, 3)) / std::pow(10, 3); // 输入值只保留三位小数
}
std::sort(Dft.begin(), Dft.end()); // 排序
// #region 增加0为第一个排除Dft中的重复值 得到Dft1
double td = 0;
Dft1.push_back(td);
for (int i = 0; i < nds; i++)
{
if (std::find(Dft1.begin(), Dft1.end(), Dft[i]) != Dft1.end())
{
continue;
}
Dft1.push_back(Dft[i]);
}
// #endregion
Trims = Dft1;
}
else
{
Trims = { 0 };
}
}
// #endregion
StabCalcBaseData::FindByParamID("AngleEvalMax", AngleEvalMax);
StabCalcBaseData::FindByParamID("AngleEvalInterval", AngleEvalInterval);
// #endregion
//cqr-20190702 舱容计算步长
try
{
StabCalcBaseData::FindByParamID("TankCapStep", this->TankCapStep); //20190601 added by czb
}
catch (...)
{
this->TankCapStep = 0; //没填时为0
}
if (hasIntact) //20191108 modified by czb
{
// #region 完整稳性、破损稳性、许用重心高度
ShipType = StabCalcBaseData::FindByParamID("ShipType");
//int.TryParse(mod.BInf.FindByParamID("ChildType").Value, out ChildType);
StabCalcBaseData::FindByParamID("IsSelfNav", IsSelfNav);
// bool.TryParse(mod.BInf.FindByParamID("IsHighspeed").Value, out IsHighspeed);
try //20190225增加高速船项 by czb
{
StabCalcBaseData::FindByParamID("IsHighspeed", IsHighspeed);
// double.TryParse(mod.BInf.FindByParamID("Vd").Value, out Vd);
}
catch (...) // 打开旧文件直接计算时会读不到这个值需要用户打开计算参数编辑界面才会初始化BInf添加IsHighspeed信息
{
IsHighspeed = false;
// Vd = 0;
}
StabCalcBaseData::FindByParamID("IsBox", IsBox);
StabCalcBaseData::FindByParamID("IsDoubleDeck", IsDoubleDeck); //20201214 by czb 远洋渔船
NavArea = StabCalcBaseData::FindByParamID("NavArea");
StabCalcBaseData::FindByParamID("NavSeg", NavSeg);
StabCalcBaseData::FindByParamID("Vm", Vm);
StabCalcBaseData::FindByParamID("IsFullWindScale", IsFullWindScale);
//double.TryParse(mod.BInf.FindByParamID("FullWindScaleArea").Value, out FullWindScaleArea); //20160801删除此输入参数
//double.TryParse(mod.BInf.FindByParamID("FullWindScaleMoment").Value, out FullWindScaleMoment); //20160801删除此输入参数
// #region 侧投影计算纵剖面列表
ProfileYList = StabCalcBaseData::FindByParamID("ProfileYList");
{
// 将 std::string 转换为 QString
QString ProfileYList_tmp = QString::fromStdString(ProfileYList);
// 使用 QString::split() 方法,按多个分隔符拆分字符串,并移除空项
QStringList qlistProfileYList = ProfileYList_tmp.split(QRegExp("[;:,]+"), QString::SkipEmptyParts);
// 将 QStringList 转换为 std::vector<std::string>
std::vector<std::string> ds;
for (const QString& token : qlistProfileYList) {
ds.push_back(token.toStdString());
}
int nds = ds.size();
if (nds > 0)
{
std::vector<double> Dft(nds);
std::vector<double> Dft1;
for (int i = 0; i < nds; i++)
{
Dft[i] = std::stod(ds[i]);
Dft[i] = std::round(Dft[i] * std::pow(10, 3)) / std::pow(10, 3); // 输入计算吃水只保留三位小数
}
std::sort(Dft.begin(), Dft.end()); // 排序
// #region 排除Dft中的重复值 得到Dft1
Dft1.push_back(Dft[0]);
double td = Dft[0];
for (int i = 1; i < nds; i++)
{
if (td == Dft[i])
{
continue;
}
else
{
Dft1.push_back(Dft[i]);
td = Dft[i];
}
}
// #endregion
ProfileY = Dft1;
}
else
{
ProfileY = std::vector<double>();
}
}
// #endregion
StabCalcBaseData::FindByParamID("BilgeKeelArea", BilgeKeelArea);
StabCalcBaseData::FindByParamID("BilgeType", BilgeType);
StabCalcBaseData::FindByParamID("BilgeC2", BilgeC2);
StabCalcBaseData::FindByParamID("BilgeC3", BilgeC3);
StabCalcBaseData::FindByParamID("BilgeC4", BilgeC4);
StabCalcBaseData::FindByParamID("HasMudHold", HasMudHold);
StabCalcBaseData::FindByParamID("StaticAngleReq", StaticAngleReq);
try //cqr-20190702
{
StabCalcBaseData::FindByParamID("IsStaticAngleReturnTest", IsStaticAngleReturnTest); //20190601 added by czb
StabCalcBaseData::FindByParamID("TankCapStep", TankCapStep);
}
catch (...)
{
IsStaticAngleReturnTest = false;
TankCapStep = 0.1;
}
StabCalcBaseData::FindByParamID("RollingPeriod", RollingPeriod); //20201214 by czb 远洋渔船
StabCalcBaseData::FindByParamID("RollingAngle", RollingAngle); //20201214 by czb 远洋渔船
//CriteriaFactor = mod.BInf.FindByParamID("CriteriaFactor").Value;
try
{
IntactRemark = StabCalcBaseData::FindByParamID("IntactRemark"); //20170601 by czb
}
catch (...)
{
IntactRemark = "";
}
// #endregion
}
if (hasInclining) //20191108 modified by czb
{
// #region 倾斜试验
StabCalcBaseData::FindByParamID("IncliningDensity", IncliningDensity);
StabCalcBaseData::FindByParamID("AT", AT);
StabCalcBaseData::FindByParamID("IncliningAH0", IncliningAH0);
StabCalcBaseData::FindByParamID("IncliningMobileWeightNo", IncliningMobileWeightNo);
int iTmp;
StabCalcBaseData::FindByParamID("IncliningDeviceType", iTmp);
IncliningDeviceType = iTmp;
StabCalcBaseData::FindByParamID("IncliningDeviceNo", IncliningDeviceNo);
StabCalcBaseData::FindByParamID("IncliningRecordNo", IncliningRecordNo);
StabCalcBaseData::FindByParamID("IncliningAngleAlgorithm", IncliningAngleAlgorithm);
StabCalcBaseData::FindByParamID("IncliningGMAlgorithm", IncliningGMAlgorithm);
// #endregion
}
if (hasDamProb) //cqr-20210817
{
try
{
StabCalcBaseData::FindByParamID("Ls_p", Ls_p);
}
catch (...)
{
Ls_p = 0;
}
try
{
StabCalcBaseData::FindByParamID("Bs_p", Bs_p);
}
catch (...)
{
Bs_p = 0;
}
try
{
StabCalcBaseData::FindByParamID("Xa_p", Xa_p);
}
catch (...)
{
Xa_p = 0;
}
}
}
BasicInf::BasicInf()
{
StabCalcBaseData::FindByParamID("IncliningDensity", IncliningDensity);
StabCalcBaseData::FindByParamID("AT", AT);
StabCalcBaseData::FindByParamID("IncliningAH0", IncliningAH0);
StabCalcBaseData::FindByParamID("IncliningMobileWeightNo", IncliningMobileWeightNo);
int iTmp;
StabCalcBaseData::FindByParamID("IncliningDeviceType", iTmp);
IncliningDeviceType = iTmp;
StabCalcBaseData::FindByParamID("IncliningDeviceNo", IncliningDeviceNo);
StabCalcBaseData::FindByParamID("IncliningRecordNo", IncliningRecordNo);
StabCalcBaseData::FindByParamID("IncliningAngleAlgorithm", IncliningAngleAlgorithm);
StabCalcBaseData::FindByParamID("IncliningGMAlgorithm", IncliningGMAlgorithm);
}
double BasicInf::getXofAP() const
{
return -OrgOff - Lpp / 2;
}
double BasicInf::getXofMP() const
{
return -OrgOff;
}
double BasicInf::getXofFP() const
{
return -OrgOff + Lpp / 2;
}
double BasicInf::XofAP2User(double x)
{
return x - OrgOff - Lpp / 2;
}
double BasicInf::XofUser2AP(double x)
{
return x + OrgOff + Lpp / 2;
}
double BasicInf::XofMP2User(double x)
{
return x - OrgOff;
}
double BasicInf::XofUser2MP(double x)
{
return x + OrgOff;
}