1122 lines
41 KiB
C++
1122 lines
41 KiB
C++
|
#include "StabilityModel.h"
|
|||
|
#include <QFile>
|
|||
|
#include "MessageHandle.h"
|
|||
|
#include "CmdDefine.h"
|
|||
|
|
|||
|
#include "Logger.h"
|
|||
|
#include <algorithm>
|
|||
|
#include <cctype>
|
|||
|
#include "Constants.h"
|
|||
|
#include "PathUtil.h"
|
|||
|
#include <cmath>
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
extern "C"
|
|||
|
{
|
|||
|
#endif
|
|||
|
//tool ship ------------start
|
|||
|
void StabilityModel::tool_ship_prej_infor_from(const json& j)
|
|||
|
{
|
|||
|
ModelData& _modelData = getDataManagerPtr()->getModelData();
|
|||
|
if(j.contains("tool_ship_project_information"))
|
|||
|
{
|
|||
|
const json& tool_ship_project_information = j["tool_ship_project_information"];
|
|||
|
QString str_prj_name = PathUtil::jsonContainsKeyToQString(tool_ship_project_information,"prj_name");
|
|||
|
QString str_work_no = PathUtil::jsonContainsKeyToQString(tool_ship_project_information,"work_no");
|
|||
|
QString str_designer = PathUtil::jsonContainsKeyToQString(tool_ship_project_information,"designer");
|
|||
|
QString str_owner = PathUtil::jsonContainsKeyToQString(tool_ship_project_information,"owner");
|
|||
|
QString str_signature = PathUtil::jsonContainsKeyToQString(tool_ship_project_information,"signature");
|
|||
|
QString str_cal_date = PathUtil::jsonContainsKeyToQString(tool_ship_project_information,"cal_date");
|
|||
|
_modelData.setPrjName(str_prj_name);
|
|||
|
_modelData.setWorkNO(str_work_no);
|
|||
|
_modelData.setDesigner(str_designer);
|
|||
|
_modelData.setOwner(str_owner);
|
|||
|
_modelData.setSignature(str_signature);
|
|||
|
_modelData.setCalDate(str_cal_date);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
void StabilityModel::tool_ship_prej_infor_to(json& j)
|
|||
|
{
|
|||
|
ModelData& _modelData = getDataManagerPtr()->getModelData();
|
|||
|
json jobj = json::object();
|
|||
|
jobj["prj_name"] = _modelData.getPrjName().toStdString();
|
|||
|
jobj["work_no"] = _modelData.getWorkNO().toStdString();
|
|||
|
jobj["designer"] = _modelData.getDesigner().toStdString();
|
|||
|
jobj["owner"] = _modelData.getOwner().toStdString();
|
|||
|
jobj["signature"] = _modelData.getSignature().toStdString();
|
|||
|
|
|||
|
// 解析日期字符串为 tm 结构
|
|||
|
std::string dateStr = _modelData.getCalDate().toStdString();
|
|||
|
std::tm tm = {};
|
|||
|
std::istringstream ss(dateStr);
|
|||
|
ss >> std::get_time(&tm, "%Y年%m月%d日");
|
|||
|
|
|||
|
|
|||
|
// 将 tm 结构格式化为所需格式的字符串
|
|||
|
std::ostringstream result;
|
|||
|
result << std::put_time(&tm, "%Y-%m-%d");
|
|||
|
// 输出结果
|
|||
|
jobj["cal_date"] = result.str(); // 输出 2017-04-27
|
|||
|
|
|||
|
j["tool_ship_project_information"] = jobj;
|
|||
|
}
|
|||
|
//tool ship ------------end
|
|||
|
|
|||
|
void StabilityModel::tool_ship_main_elements_from(const json& j)
|
|||
|
{
|
|||
|
ModelData& _modelData = getDataManagerPtr()->getModelData();
|
|||
|
if(j.contains("tool_ship_main_elements"))
|
|||
|
{
|
|||
|
const json& tool_ship_main_elements = j["tool_ship_main_elements"];
|
|||
|
std::string str_shiptype = PathUtil::jsonContainsKeyToString(tool_ship_main_elements,"shiptype");
|
|||
|
_modelData.setShipType(str_shiptype);
|
|||
|
|
|||
|
vector<int> vnav_area;
|
|||
|
int i_chk_nav_area_a = PathUtil::jsonContainsKeyToInt(tool_ship_main_elements,"chk_nav_area_a");
|
|||
|
int i_chk_nav_area_b = PathUtil::jsonContainsKeyToInt(tool_ship_main_elements,"chk_nav_area_b");
|
|||
|
int i_chk_nav_area_c = PathUtil::jsonContainsKeyToInt(tool_ship_main_elements,"chk_nav_area_c");
|
|||
|
int i_chk_nav_area_t = PathUtil::jsonContainsKeyToInt(tool_ship_main_elements,"chk_nav_area_t");
|
|||
|
int i_chk_nav_area_u = PathUtil::jsonContainsKeyToInt(tool_ship_main_elements,"chk_nav_area_u");
|
|||
|
vnav_area.emplace_back(i_chk_nav_area_a);
|
|||
|
vnav_area.emplace_back(i_chk_nav_area_b);
|
|||
|
vnav_area.emplace_back(i_chk_nav_area_c);
|
|||
|
vnav_area.emplace_back(i_chk_nav_area_t);
|
|||
|
vnav_area.emplace_back(i_chk_nav_area_u);
|
|||
|
_modelData.setNavArea(vnav_area);
|
|||
|
|
|||
|
vector<int> vNav_Section;
|
|||
|
int i_chk_nav_area_j1 = PathUtil::jsonContainsKeyToInt(tool_ship_main_elements,"chk_nav_area_j1");
|
|||
|
int i_chk_nav_area_j2 = PathUtil::jsonContainsKeyToInt(tool_ship_main_elements,"chk_nav_area_j2");
|
|||
|
vNav_Section.emplace_back(i_chk_nav_area_j1);
|
|||
|
vNav_Section.emplace_back(i_chk_nav_area_j2);
|
|||
|
_modelData.setNavSection(vNav_Section);
|
|||
|
|
|||
|
|
|||
|
double d_ship_l = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_l");
|
|||
|
double d_ship_d = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_d");
|
|||
|
double d_ship_disp = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_disp");
|
|||
|
double d_ship_lpp = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_lpp");
|
|||
|
double d_ship_loa = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_loa");
|
|||
|
double d_ship_density = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_density");
|
|||
|
double d_ship_v = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_v");
|
|||
|
double d_ship_noe = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_noe");
|
|||
|
double d_ship_b = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_b");
|
|||
|
double d_ship_t = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_t");
|
|||
|
|
|||
|
double d_ship_cb = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_cb");
|
|||
|
double d_ship_lw = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_lw");
|
|||
|
double d_ship_le = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_le");
|
|||
|
double d_ship_dmax = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_dmax");
|
|||
|
double d_ship_ne = PathUtil::jsonContainsKeyToDouble(tool_ship_main_elements,"ship_ne");
|
|||
|
|
|||
|
_modelData.setL(d_ship_l);
|
|||
|
_modelData.setD(d_ship_d);
|
|||
|
_modelData.setDisp(d_ship_disp);
|
|||
|
_modelData.setLpp(d_ship_lpp);
|
|||
|
_modelData.setLoa(d_ship_loa);
|
|||
|
_modelData.setDensity(d_ship_density);
|
|||
|
_modelData.setV(d_ship_v);
|
|||
|
_modelData.setNOe(d_ship_noe);
|
|||
|
_modelData.setB(d_ship_b);
|
|||
|
_modelData.setT(d_ship_t);
|
|||
|
_modelData.setCb(d_ship_cb);
|
|||
|
_modelData.setLw(d_ship_lw);
|
|||
|
_modelData.setLe(d_ship_le);
|
|||
|
_modelData.setTMax(d_ship_dmax);
|
|||
|
_modelData.setNe(d_ship_ne);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void StabilityModel::tool_ship_main_elements_to(json& j)
|
|||
|
{
|
|||
|
ModelData& _modelData = getDataManagerPtr()->getModelData();
|
|||
|
json jobj = json::object();
|
|||
|
jobj["shiptype"] = _modelData.getShipTypeString();
|
|||
|
jobj["chk_self_propelled"] = _modelData.getSelfPropelled();
|
|||
|
vector<int> v_nav_area = _modelData.getNavArea();
|
|||
|
if(v_nav_area.size() < 5)
|
|||
|
{
|
|||
|
jobj["chk_nav_area_a"] = 0;
|
|||
|
jobj["chk_nav_area_b"] = 0;
|
|||
|
jobj["chk_nav_area_c"] = 0;
|
|||
|
jobj["chk_nav_area_t"] = 0;
|
|||
|
jobj["chk_nav_area_u"] = 0;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
jobj["chk_nav_area_a"] = v_nav_area[0];
|
|||
|
jobj["chk_nav_area_b"] = v_nav_area[1];
|
|||
|
jobj["chk_nav_area_c"] = v_nav_area[2];
|
|||
|
jobj["chk_nav_area_t"] = v_nav_area[3];
|
|||
|
jobj["chk_nav_area_u"] = v_nav_area[4];
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
vector<int> v_nav_section = _modelData.getNavSection();
|
|||
|
if(v_nav_section.size() <2)
|
|||
|
{
|
|||
|
jobj["chk_nav_area_j1"] = 0;
|
|||
|
jobj["chk_nav_area_j2"] = 0;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
jobj["chk_nav_area_j1"] = v_nav_section[0];
|
|||
|
jobj["chk_nav_area_j2"] = v_nav_section[1];
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
jobj["ship_l"] = _modelData.getL();
|
|||
|
jobj["ship_d"] = _modelData.getD();
|
|||
|
jobj["ship_disp"] = _modelData.getDisp();
|
|||
|
jobj["ship_lpp"] = _modelData.getLpp();
|
|||
|
jobj["ship_loa"] = _modelData.getLoa();
|
|||
|
jobj["ship_density"] = _modelData.getDensity();
|
|||
|
|
|||
|
jobj["ship_v"] = _modelData.getV();
|
|||
|
jobj["ship_noe"] = _modelData.getNOe();
|
|||
|
jobj["ship_b"] = _modelData.getB();
|
|||
|
jobj["ship_t"] = _modelData.getT();
|
|||
|
jobj["ship_cb"] = _modelData.getCb();
|
|||
|
|
|||
|
jobj["ship_lw"] = _modelData.getLw();
|
|||
|
jobj["ship_le"] = _modelData.getLe();
|
|||
|
jobj["ship_dmax"] = _modelData.getTMax();
|
|||
|
|
|||
|
jobj["ship_ne"] = _modelData.getNe();
|
|||
|
|
|||
|
j["tool_ship_main_elements"] = jobj;
|
|||
|
}
|
|||
|
|
|||
|
void StabilityModel::tool_ship_hull_scale_from(const json& j)
|
|||
|
{
|
|||
|
ModelData& _modelData = getDataManagerPtr()->getModelData();
|
|||
|
if(j.contains("tool_ship_hull_scale"))
|
|||
|
{
|
|||
|
const json& tool_ship_hull_scale = j["tool_ship_hull_scale"];
|
|||
|
int i_rb_select_0 = PathUtil::jsonContainsKeyToInt(tool_ship_hull_scale,"rb_select_0");
|
|||
|
int i_rb_select_1 = PathUtil::jsonContainsKeyToInt(tool_ship_hull_scale,"rb_select_1");
|
|||
|
int _X0Pos = 0;
|
|||
|
if(i_rb_select_0 == 1 && i_rb_select_1 == 0)
|
|||
|
{
|
|||
|
_X0Pos = -1;
|
|||
|
}
|
|||
|
else if(i_rb_select_0 == 0 && i_rb_select_1 == 1)
|
|||
|
{
|
|||
|
_X0Pos = 0;
|
|||
|
}
|
|||
|
else if(i_rb_select_0 == 0 && i_rb_select_1 == 0)
|
|||
|
{
|
|||
|
_X0Pos = 1;
|
|||
|
}
|
|||
|
else if(i_rb_select_0 == 1 && i_rb_select_1 == 0)
|
|||
|
{
|
|||
|
_X0Pos = 2;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_X0Pos = 2;
|
|||
|
}
|
|||
|
_modelData.setX0Pos(_X0Pos);
|
|||
|
|
|||
|
//tabControl_1
|
|||
|
if(tool_ship_hull_scale.contains("tabControl_1"))
|
|||
|
{
|
|||
|
const json& tabControl_1 = tool_ship_hull_scale["tabControl_1"];
|
|||
|
double fF0X = PathUtil::jsonContainsKeyToDouble(tabControl_1,"txt_x_frame");
|
|||
|
_modelData.setF0X(fF0X);
|
|||
|
|
|||
|
if(tabControl_1.contains("tabControl_data"))
|
|||
|
{
|
|||
|
const json& tabControl_data = tabControl_1["tabControl_data"];
|
|||
|
if(tabControl_data.is_array())
|
|||
|
{
|
|||
|
int ino = 0;
|
|||
|
std::vector<std::pair<int, Frame_M>>& mFrames =_modelData.getFrames();
|
|||
|
if(mFrames.size() == 0)
|
|||
|
{
|
|||
|
ino = 0;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
auto it = mFrames.begin();
|
|||
|
ino = it->first;
|
|||
|
}
|
|||
|
mFrames.clear();
|
|||
|
|
|||
|
for (auto& data : tabControl_data)
|
|||
|
{
|
|||
|
if(!data.empty())
|
|||
|
{
|
|||
|
std::string str_start_no = PathUtil::jsonContainsKeyToString(data,"start_no");
|
|||
|
std::string str_end_no = PathUtil::jsonContainsKeyToString(data,"end_no");
|
|||
|
double d_dis = PathUtil::jsonContainsKeyToDouble(data,"dis");
|
|||
|
Frame_M fm;
|
|||
|
fm.m_ID = ino;
|
|||
|
fm.m_NumS = std::stoi(str_start_no);
|
|||
|
if(str_end_no == "")
|
|||
|
{
|
|||
|
fm.m_Num = 999;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
fm.m_Num = std::stoi(str_end_no);
|
|||
|
}
|
|||
|
|
|||
|
mFrames.push_back({fm.m_ID,fm});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//tabControl_2
|
|||
|
if(tool_ship_hull_scale.contains("tabControl_2"))
|
|||
|
{
|
|||
|
const json& tabControl_2 = tool_ship_hull_scale["tabControl_2"];
|
|||
|
double st0X = PathUtil::jsonContainsKeyToDouble(tabControl_2,"txt_x_frame");
|
|||
|
_modelData.setSt0X(st0X);
|
|||
|
|
|||
|
if(tabControl_2.contains("tabControl_data"))
|
|||
|
{
|
|||
|
const json& tabControl_data = tabControl_2["tabControl_data"];
|
|||
|
if(tabControl_data.is_array())
|
|||
|
{
|
|||
|
int ino = 0;
|
|||
|
std::vector<std::pair<int, Station_M>>& mStation =_modelData.getStation();
|
|||
|
if(mStation.size() == 0)
|
|||
|
{
|
|||
|
ino = 0;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
auto it = mStation.begin();
|
|||
|
ino = it->first;
|
|||
|
}
|
|||
|
mStation.clear();
|
|||
|
|
|||
|
for (auto& data : tabControl_data)
|
|||
|
{
|
|||
|
if(!data.empty())
|
|||
|
{
|
|||
|
std::string _no = PathUtil::jsonContainsKeyToString(data,"no");
|
|||
|
std::string _pos = PathUtil::jsonContainsKeyToString(data,"pos");
|
|||
|
Station_M sm;
|
|||
|
sm.m_ID = ino;
|
|||
|
sm.m_Num = std::stod(_no);
|
|||
|
sm.m_Pos = std::stod(_pos);
|
|||
|
mStation.push_back({sm.m_ID,sm});
|
|||
|
ino++;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//tabControl_3
|
|||
|
if(tool_ship_hull_scale.contains("tabControl_3"))
|
|||
|
{
|
|||
|
const json& tabControl_3 = tool_ship_hull_scale["tabControl_3"];
|
|||
|
if(tabControl_3.contains("tabControl_data"))
|
|||
|
{
|
|||
|
const json& tabControl_data = tabControl_3["tabControl_data"];
|
|||
|
if(tabControl_data.is_array())
|
|||
|
{
|
|||
|
int ino = 0;
|
|||
|
std::vector<std::pair<int, WaterlinePos_M>>& _WaterLinesPos = _modelData.getWaterlinePos();
|
|||
|
if(_WaterLinesPos.size() == 0)
|
|||
|
{
|
|||
|
ino = 0;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
auto it = _WaterLinesPos.begin();
|
|||
|
ino = it->first;
|
|||
|
}
|
|||
|
_WaterLinesPos.clear();
|
|||
|
|
|||
|
for (auto& data : tabControl_data)
|
|||
|
{
|
|||
|
if(!data.empty())
|
|||
|
{
|
|||
|
std::string str_no = PathUtil::jsonContainsKeyToString(data,"no");
|
|||
|
std::string str_pos = PathUtil::jsonContainsKeyToString(data,"pos");
|
|||
|
|
|||
|
WaterlinePos_M lm;
|
|||
|
lm.m_ID = ino;
|
|||
|
lm.m_Num = std::stod(str_no);
|
|||
|
lm.m_Pos = std::stod(str_pos) / 1000.0;
|
|||
|
|
|||
|
_WaterLinesPos.push_back({lm.m_ID,lm});
|
|||
|
ino++;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//tabControl_4
|
|||
|
if(tool_ship_hull_scale.contains("tabControl_4"))
|
|||
|
{
|
|||
|
const json& tabControl_4 = tool_ship_hull_scale["tabControl_4"];
|
|||
|
if(tabControl_4.contains("tabControl_data"))
|
|||
|
{
|
|||
|
const json& tabControl_data = tabControl_4["tabControl_data"];
|
|||
|
if(tabControl_data.is_array())
|
|||
|
{
|
|||
|
int ino = 0;
|
|||
|
std::vector<std::pair<int, ButtocklinePos_M>>& _ButtocklinePos = _modelData.getButtocklinePos();
|
|||
|
if(_ButtocklinePos.size() == 0)
|
|||
|
{
|
|||
|
ino = 0;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
auto it = _ButtocklinePos.begin();
|
|||
|
ino = it->first;
|
|||
|
}
|
|||
|
_ButtocklinePos.clear();
|
|||
|
|
|||
|
for (auto& data : tabControl_data)
|
|||
|
{
|
|||
|
if(!data.empty())
|
|||
|
{
|
|||
|
std::string str_no = PathUtil::jsonContainsKeyToString(data,"no");
|
|||
|
std::string str_pos = PathUtil::jsonContainsKeyToString(data,"pos");
|
|||
|
|
|||
|
ButtocklinePos_M bm;
|
|||
|
bm.m_ID = ino;
|
|||
|
bm.m_Num = std::stod(str_no);
|
|||
|
bm.m_Pos = std::stod(str_pos)/1000.0;
|
|||
|
|
|||
|
_ButtocklinePos.push_back({bm.m_ID,bm});
|
|||
|
ino++;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void StabilityModel::tool_ship_hull_scale_to(json& j)
|
|||
|
{
|
|||
|
ModelData& _modelData = getDataManagerPtr()->getModelData();
|
|||
|
json jobj = json::object();
|
|||
|
int _X0Pos = _modelData.getX0Pos();
|
|||
|
int rb_select_0 = 0;
|
|||
|
int rb_select_1 = 0;
|
|||
|
switch(_X0Pos)
|
|||
|
{
|
|||
|
case -1:
|
|||
|
rb_select_0 = 1;
|
|||
|
rb_select_1 = 0;
|
|||
|
break;
|
|||
|
case 0:
|
|||
|
rb_select_0 = 0;
|
|||
|
rb_select_1 = 1;
|
|||
|
break;
|
|||
|
case 1:
|
|||
|
rb_select_0 = 0;
|
|||
|
rb_select_1 = 0;
|
|||
|
break;
|
|||
|
default:
|
|||
|
rb_select_0 = 1;
|
|||
|
rb_select_1 = 0;
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
jobj["rb_select_0"] = rb_select_0;
|
|||
|
jobj["rb_select_1"] = rb_select_1;
|
|||
|
|
|||
|
//tabControl_1 组织
|
|||
|
json tabControl_1 = json::object();
|
|||
|
tabControl_1["txt_x_frame"] = _modelData.getF0X();
|
|||
|
json tabControl_1_data = nlohmann::json::array();
|
|||
|
|
|||
|
std::vector<std::pair<int, Frame_M>>& mFrames =_modelData.getFrames();
|
|||
|
for (auto it = mFrames.begin(); it != mFrames.end(); ++it)
|
|||
|
{
|
|||
|
int key = it->first;
|
|||
|
Frame_M& data_fram = it->second;
|
|||
|
|
|||
|
json data = json::object();
|
|||
|
data["start_no"] = ::to_string(data_fram.m_NumS);
|
|||
|
data["end_no"] = data_fram.m_Num == 999 ? "": ::to_string(data_fram.m_Num);
|
|||
|
data["dis"] = data_fram.m_Dis;
|
|||
|
tabControl_1_data.push_back(data);
|
|||
|
}
|
|||
|
tabControl_1["tabControl_data"] = tabControl_1_data;
|
|||
|
jobj["tabControl_1"] = tabControl_1;
|
|||
|
|
|||
|
|
|||
|
//tabControl_2 组织
|
|||
|
|
|||
|
json tabControl_2 = json::object();
|
|||
|
|
|||
|
double txt_x_frame_2 = 0;
|
|||
|
if(_modelData.getSt0X() < -9998)
|
|||
|
{
|
|||
|
txt_x_frame_2 = (0 - _modelData.getLpp() / 2);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
txt_x_frame_2 = _modelData.getSt0X();
|
|||
|
}
|
|||
|
tabControl_2["txt_x_frame"] = txt_x_frame_2;
|
|||
|
json tabControl_2_data = nlohmann::json::array();
|
|||
|
std::vector<std::pair<int, Station_M>>& mStation =_modelData.getStation();
|
|||
|
std::map<double,double> vData;
|
|||
|
for (auto it = mStation.begin(); it != mStation.end(); ++it)
|
|||
|
{
|
|||
|
int key = it->first;
|
|||
|
Station_M& data_station = it->second;
|
|||
|
|
|||
|
vData.insert(make_pair(data_station.m_Num,data_station.m_Pos));
|
|||
|
}
|
|||
|
auto it = vData.begin();
|
|||
|
for (; it != vData.end(); ++it)
|
|||
|
{
|
|||
|
json data = json::object();
|
|||
|
data["no"] = ::to_string(it->first);
|
|||
|
data["pos"] = ::to_string(it->second);
|
|||
|
tabControl_2_data.push_back(data);
|
|||
|
}
|
|||
|
tabControl_2["tabControl_data"] = tabControl_2_data;
|
|||
|
jobj["tabControl_2"] = tabControl_2;
|
|||
|
|
|||
|
//tabControl_3 组织
|
|||
|
json tabControl_3 = json::object();
|
|||
|
json tabControl_3_data = nlohmann::json::array();
|
|||
|
std::vector<std::pair<int, WaterlinePos_M>>& _WaterLinesPos = _modelData.getWaterlinePos();
|
|||
|
for (auto it = _WaterLinesPos.begin(); it != _WaterLinesPos.end(); ++it)
|
|||
|
{
|
|||
|
int key = it->first;
|
|||
|
|
|||
|
WaterlinePos_M& data_WaterlinePo = it->second;
|
|||
|
|
|||
|
json data = json::object();
|
|||
|
data["no"] = data_WaterlinePo.m_Num.toStdString();
|
|||
|
data["pos"] = ::to_string(data_WaterlinePo.m_Pos * 1000);
|
|||
|
tabControl_3_data.push_back(data);
|
|||
|
}
|
|||
|
tabControl_3["tabControl_data"] = tabControl_3_data;
|
|||
|
jobj["tabControl_3"] = tabControl_3;
|
|||
|
|
|||
|
//tabControl_4 组织
|
|||
|
json tabControl_4 = json::object();
|
|||
|
json tabControl_4_data = nlohmann::json::array();
|
|||
|
|
|||
|
std::vector<std::pair<int, ButtocklinePos_M>>& _ButtocklinePos = _modelData.getButtocklinePos();
|
|||
|
|
|||
|
for (auto it = _ButtocklinePos.begin(); it != _ButtocklinePos.end(); ++it)
|
|||
|
{
|
|||
|
int key = it->first;
|
|||
|
ButtocklinePos_M& data_ButtocklinePos = it->second;
|
|||
|
json data = json::object();
|
|||
|
data["no"] = data_ButtocklinePos.m_Num.toStdString();
|
|||
|
data["pos"] = ::to_string(data_ButtocklinePos.m_Pos * 1000);
|
|||
|
tabControl_4_data.push_back(data);
|
|||
|
}
|
|||
|
tabControl_4["tabControl_data"] = tabControl_4_data;
|
|||
|
jobj["tabControl_4"] = tabControl_4;
|
|||
|
|
|||
|
j["tool_ship_hull_scale"] = jobj;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
bool StabilityModel::stabilityCalc(std::vector<string>& commandLines, E_AnalysisModuleOperation_Type type)
|
|||
|
{
|
|||
|
m_pDataManager->resetCheck();
|
|||
|
bool bRet = false;
|
|||
|
switch (type)
|
|||
|
{
|
|||
|
case E_AnalysisModuleOperation_Type_Create:
|
|||
|
break;
|
|||
|
case E_AnalysisModuleOperation_Type_Calc:
|
|||
|
bRet = stabilityCalcMainContent(commandLines);
|
|||
|
break;
|
|||
|
case E_AnalysisModuleOperation_Type_Delete:
|
|||
|
break;
|
|||
|
case E_AnalysisModuleOperation_Type_Size:
|
|||
|
break;
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
return bRet;
|
|||
|
}
|
|||
|
|
|||
|
bool StabilityModel::stabilityCalcMainContent(std::vector<string>& commandLines)
|
|||
|
{
|
|||
|
std::vector<string> subItems = GetStabNodeOnly(commandLines);
|
|||
|
|
|||
|
|
|||
|
QFileInfo fileInfo(m_strCurentUsingFilePath);
|
|||
|
QString path_fileName_no_suffix = fileInfo.completeBaseName(); // 返回不带后缀的文件名
|
|||
|
QString fileName_suffix = fileInfo.fileName();
|
|||
|
QString filepath = fileInfo.filePath();
|
|||
|
// 获取不带文件名的路径
|
|||
|
QString dirPath = fileInfo.absolutePath();
|
|||
|
|
|||
|
QString hullStlFilename = dirPath +path_fileName_no_suffix + ".hull.stl";
|
|||
|
QString tankStlFilename = dirPath + path_fileName_no_suffix + ".tank.stl";
|
|||
|
QString tankStlFilenameOrg = dirPath + path_fileName_no_suffix + ".tank";
|
|||
|
QString hullStlFilenameOrg = dirPath + path_fileName_no_suffix + ".hull";
|
|||
|
|
|||
|
QString headFileNamePath = dirPath +"/" + path_fileName_no_suffix;
|
|||
|
|
|||
|
{
|
|||
|
//20211208 by czb, modified
|
|||
|
//var dic = this.Certicalculation.StabTable;
|
|||
|
//var ds = new CCS.StabDB.ModelDS();
|
|||
|
//ds.ReadXml(new StringReader(dic["Stab"].Value));
|
|||
|
ExportBInfDef();
|
|||
|
ExportXLabel();
|
|||
|
ExportOffsetLabel();
|
|||
|
|
|||
|
|
|||
|
//20190601 added by czb
|
|||
|
m_pDataManager->updateCompartmentData();
|
|||
|
|
|||
|
|
|||
|
// begin:20190812 added by czb ,增加检查功能
|
|||
|
//var subItems = param as List<string>;
|
|||
|
string errMsg = ""; //20171101 added by czb
|
|||
|
string curMsg = ""; //20200120 by czb,错误检查问题修正
|
|||
|
if (StringHelper::Contains(subItems, "静水力"))
|
|||
|
{
|
|||
|
curMsg = m_pDataManager->CheckHydostatic(); //20200120 by czb,错误检查问题修正
|
|||
|
if (!curMsg.empty())
|
|||
|
{
|
|||
|
errMsg += "静水力数据错误\r\n" + curMsg + "\r\n";
|
|||
|
}
|
|||
|
}
|
|||
|
if (StringHelper::Contains(subItems, "舱容"))
|
|||
|
{
|
|||
|
curMsg = m_pDataManager->CheckTankcapacity(); //20200120 by czb,错误检查问题修正
|
|||
|
if (!curMsg.empty())
|
|||
|
{
|
|||
|
errMsg += "舱容数据错误\r\n" + curMsg + "\r\n";
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (StringHelper::Contains(subItems, "完整稳性"))
|
|||
|
{
|
|||
|
curMsg = m_pDataManager->CheckIntact(); //20200120 by czb,错误检查问题修正
|
|||
|
if (!curMsg.empty())
|
|||
|
{
|
|||
|
errMsg += "完整稳性数据错误\r\n" + curMsg + "\r\n";
|
|||
|
}
|
|||
|
}
|
|||
|
if (StringHelper::Contains(subItems, "破损稳性"))
|
|||
|
{
|
|||
|
curMsg = m_pDataManager->CheckDamage(); //20200120 by czb,错误检查问题修正
|
|||
|
if (!curMsg.empty())
|
|||
|
{
|
|||
|
errMsg += "破损稳性数据错误\r\n" + curMsg + "\r\n";
|
|||
|
}
|
|||
|
}
|
|||
|
if (StringHelper::Contains(subItems, "概率破损")) //20210803 by czb 错误检查问题修正
|
|||
|
{
|
|||
|
curMsg = m_pDataManager->CheckDamageProb();
|
|||
|
if (!curMsg.empty())
|
|||
|
{
|
|||
|
errMsg += "概率破损数据错误\r\n" + curMsg + "\r\n";
|
|||
|
}
|
|||
|
}
|
|||
|
if (StringHelper::Contains(subItems, "倾斜试验"))
|
|||
|
{
|
|||
|
curMsg = m_pDataManager->CheckInclining(); //20200120 by czb,错误检查问题修正
|
|||
|
if (!curMsg.empty())
|
|||
|
{
|
|||
|
errMsg += "倾斜试验数据错误\r\n" + curMsg + "\r\n";
|
|||
|
}
|
|||
|
}
|
|||
|
errMsg = StringHelper::trim(errMsg);
|
|||
|
if (!errMsg.empty())
|
|||
|
{
|
|||
|
//throw new Exception(errMsg);
|
|||
|
return false;
|
|||
|
}
|
|||
|
// end:20190812 added by czb ,增加检查功能
|
|||
|
if (StringHelper::isEmptyOrWhiteSpace(filepath.toStdString()))
|
|||
|
{
|
|||
|
return false; //20191230 added by czb,仅用于数检
|
|||
|
}
|
|||
|
|
|||
|
m_pDataManager->saveStabFile(headFileNamePath + ".Stab");
|
|||
|
|
|||
|
// return true;
|
|||
|
}
|
|||
|
|
|||
|
{
|
|||
|
|
|||
|
if (StringHelper::Contains(subItems,"静水力") ||
|
|||
|
StringHelper::Contains(subItems, "完整稳性") ||
|
|||
|
StringHelper::Contains(subItems, "破损稳性") ||
|
|||
|
StringHelper::Contains(subItems, "概率破损") ||
|
|||
|
StringHelper::Contains(subItems, "许用重心高度")||
|
|||
|
StringHelper::Contains(subItems, "倾斜试验"))
|
|||
|
{ //20210803 by czb
|
|||
|
|
|||
|
|
|||
|
VersionData& Version = m_pDataManager->getVersionData();
|
|||
|
if ((Version.m_OcmFileTime > Version.m_HullStlTime) || (Version.m_CalcShellTableTime > Version.m_HullStlTime) || !QFile::exists(hullStlFilename))
|
|||
|
{ //20170401 by czb,仅当几何模型更新,或,计算船壳表更新,或,网格文件不存在,才需要重新输出网格文件
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
//ExportHullCalFile(fileName, path, this.Certicalculation.StabDS);
|
|||
|
m_pDataManager->ExportHullCalFile(path_fileName_no_suffix.toStdString(), dirPath.toStdString());//20211208 by czb, modified
|
|||
|
|
|||
|
//OnOutput("已生成船壳网格文件\r\n");//20161129 by czb,补充
|
|||
|
//bCreateHullStl = true;
|
|||
|
//this.Version.HullStlTime = File.GetLastWriteTimeUtc(hullStlFilenameOrg); //20170401,记录新的网格文件时间
|
|||
|
|
|||
|
//如新建了网格文件,则时间版本会有更新,需要保存csx文件,20170401 by czb
|
|||
|
//Global.FireEvent(EventTopicNames.DataDirtyStateChanged, this, new EventArgs<int>(1));
|
|||
|
}
|
|||
|
catch (const std::exception&)
|
|||
|
{
|
|||
|
//MessageBox.Show(ex.Message);
|
|||
|
//OnOutput("计算出错! " + ex.Message + "\r\n");//cqr-20190730 增加“计算出错!”//20161112 by czb,弹出窗口修改为输出窗口显示
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
{
|
|||
|
|
|||
|
if (m_pDataManager->isCalcTank(subItems))
|
|||
|
{
|
|||
|
VersionData& Version = m_pDataManager->getVersionData();
|
|||
|
if ((Version.m_OcmFileTime > Version.m_TankStlTime) || (Version.m_CalcCompartmentTableTime > Version.m_TankStlTime) || !QFile::exists(tankStlFilename))
|
|||
|
{ //20170401 by czb,仅当几何模型更新,或,计算舱室表更新,或网格文件不存在,需要重新输出网格文件
|
|||
|
try
|
|||
|
{
|
|||
|
//ExportSpaceCalFile(fileName, path, this.Certicalculation.StabDS);
|
|||
|
m_pDataManager->ExportSpaceCalFile(path_fileName_no_suffix.toStdString(), dirPath.toStdString()); //20211208 by czb, modified
|
|||
|
//OnOutput("已生成舱室网格文件\r\n");//20161129 by czb,补充
|
|||
|
|
|||
|
//bCreateTankStl = true;
|
|||
|
//this.Version.TankStlTime = File.GetLastWriteTimeUtc(tankStlFilenameOrg);
|
|||
|
//如新建了网格文件,则时间版本会有更新,需要保存csx文件,20170401 by czb
|
|||
|
//Global.FireEvent(EventTopicNames.DataDirtyStateChanged, this, new EventArgs<int>(1));
|
|||
|
|
|||
|
}
|
|||
|
catch (const std::exception&)
|
|||
|
{
|
|||
|
//MessageBox.Show(ex.Message);
|
|||
|
// OnOutput("计算出错! " + ex.Message + "\r\n");//cqr-20190730 增加“计算出错!” //20161112 by czb,弹出窗口修改为输出窗口显示
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
void StabilityModel::ExportBInfDef()
|
|||
|
{
|
|||
|
if (!m_pDataManager)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
//const ShipInfo_M& info = m_pDataManager->getShipInfo();
|
|||
|
|
|||
|
ModelData& info = m_pDataManager->getModelData();
|
|||
|
BInf r;
|
|||
|
r.caption = "原点位置";
|
|||
|
r.unit = "";
|
|||
|
r.paramid = "Origin";
|
|||
|
r.value = std::to_string(info.getX0Pos());
|
|||
|
r.value_type = "int";
|
|||
|
r.remark = "";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
|
|||
|
r.caption = "船名";
|
|||
|
r.unit = "";
|
|||
|
r.paramid = "ShipName";
|
|||
|
r.value = info.getPrjName().toStdString();
|
|||
|
r.value_type = "string";
|
|||
|
r.remark = "";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
|
|||
|
//20161209 by czb,新增
|
|||
|
|
|||
|
r.caption = "控制号";
|
|||
|
r.unit = "";
|
|||
|
r.paramid = "WorkNo";
|
|||
|
r.value = info.getWorkNO().toStdString();
|
|||
|
r.value_type = "string";
|
|||
|
r.remark = "";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
|
|||
|
|
|||
|
r.caption = "设计单位";
|
|||
|
r.unit = "";
|
|||
|
r.paramid = "Design";
|
|||
|
r.value = info.getDesigner().toStdString();
|
|||
|
r.value_type = "string";
|
|||
|
r.remark = "";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
|
|||
|
|
|||
|
r.caption = "计算签名";//20170901 added by czb
|
|||
|
r.unit = "";
|
|||
|
r.paramid = "Signature";
|
|||
|
r.value = info.getSignature().toStdString();
|
|||
|
r.value_type = "string";
|
|||
|
r.remark = "";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
|
|||
|
|
|||
|
r.caption = "计算日期";
|
|||
|
r.unit = "";
|
|||
|
r.paramid = "CalDate";
|
|||
|
r.value = info.getCalDate().toStdString(); //20170118
|
|||
|
r.value_type = "string";
|
|||
|
r.remark = "";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
|
|||
|
|
|||
|
r.caption = "船长";
|
|||
|
r.unit = "m";
|
|||
|
r.paramid = "L";
|
|||
|
r.value = std::to_string(info.getL());
|
|||
|
r.value_type = "double";
|
|||
|
r.remark = "";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
|
|||
|
|
|||
|
r.caption = "垂线间长";
|
|||
|
r.unit = "m";
|
|||
|
r.paramid = "Lpp";
|
|||
|
r.value = std::to_string(info.getLpp());
|
|||
|
r.value_type = "double";
|
|||
|
r.remark = "";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
|
|||
|
|
|||
|
r.caption = "船宽";
|
|||
|
r.unit = "m";
|
|||
|
r.paramid = "B";
|
|||
|
r.value = std::to_string(info.getB());
|
|||
|
r.value_type = "double";
|
|||
|
r.remark = "";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
|
|||
|
|
|||
|
r.caption = "型深";
|
|||
|
r.unit = "m";
|
|||
|
r.paramid = "D";
|
|||
|
r.value = std::to_string(info.getD());
|
|||
|
r.value_type = "double";
|
|||
|
r.remark = "";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
|
|||
|
|
|||
|
r.caption = "吃水";
|
|||
|
r.unit = "m";
|
|||
|
r.paramid = "d";
|
|||
|
r.value = std::to_string(info.getT());
|
|||
|
r.value_type = "double";
|
|||
|
r.remark = "";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
|
|||
|
|
|||
|
r.caption = "舷外水密度";
|
|||
|
r.unit = "t/m3";
|
|||
|
r.paramid = "Density";
|
|||
|
r.value = std::to_string(info.getDensity());
|
|||
|
r.value_type = "double";
|
|||
|
r.remark = "";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
|
|||
|
|
|||
|
r.caption = "航区";
|
|||
|
r.unit = "";
|
|||
|
r.paramid = "NavArea";
|
|||
|
r.value = "";
|
|||
|
QStringList vNaveArea = info.getNavAreaEX();
|
|||
|
if (vNaveArea.size() > 0)
|
|||
|
{
|
|||
|
for(QString str : vNaveArea)
|
|||
|
{
|
|||
|
//if (str == "T") //20180701 added by czb
|
|||
|
// r.value += "特定航线江海直达" + ";";
|
|||
|
//else
|
|||
|
r.value += str.toStdString() + ";";
|
|||
|
}
|
|||
|
if (r.value.length() > 0)
|
|||
|
{
|
|||
|
r.value = r.value.erase(r.value.length() - 1); // 删除最后一个字符
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
r.value_type = "string";
|
|||
|
r.remark = "";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
|
|||
|
|
|||
|
r.caption = "航段";
|
|||
|
r.unit = "";
|
|||
|
r.paramid = "NavSeg";
|
|||
|
r.value = "";
|
|||
|
QStringList vNaveSection = info.getNavSectionEx();
|
|||
|
if (vNaveSection.size() > 0)
|
|||
|
{
|
|||
|
//foreach (string str in info.NavSection)
|
|||
|
//{
|
|||
|
// r.value += str + ";";
|
|||
|
//}
|
|||
|
//if (r.value.Length > 0)
|
|||
|
//{
|
|||
|
// r.value = r.value.Substring(0, r.value.Length - 1);
|
|||
|
//}
|
|||
|
//20161102 by czb,航段为单选,整型,0-无,1-J1,2-J2
|
|||
|
//if (info.NavSection.Contains("J2"))
|
|||
|
//{
|
|||
|
// r.value = "2";
|
|||
|
//}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// r.value = "1";
|
|||
|
//}
|
|||
|
//20210517 by czb, 修改,J1航段要求高于J2
|
|||
|
if (vNaveSection.contains("J1"))
|
|||
|
{
|
|||
|
r.value = "1";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
r.value = "2";
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
r.value = "0";
|
|||
|
}
|
|||
|
//r.value = r.value == "" ? "0" : r.value;
|
|||
|
r.value_type = "int";
|
|||
|
r.remark = "";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
|
|||
|
|
|||
|
r.caption = "自航船";
|
|||
|
r.unit = "";
|
|||
|
r.paramid = "IsSelfNav";
|
|||
|
r.value = info.getSelfPropelled() == 1 ? "TRUE" : "";
|
|||
|
r.value_type = "bool";
|
|||
|
r.remark = "TRUE;FALSE";
|
|||
|
m_pDataManager->addBInfo(r);
|
|||
|
}
|
|||
|
|
|||
|
//导出船体X标尺
|
|||
|
void StabilityModel::ExportXLabel()
|
|||
|
{
|
|||
|
// #region 基本信息 船体标尺 XLabel
|
|||
|
|
|||
|
if (!m_pDataManager)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
BInf* xType = m_pDataManager->FindByParamID("XType");
|
|||
|
if (xType)
|
|||
|
{
|
|||
|
if (xType->value == "1") //肋位
|
|||
|
{
|
|||
|
std::map<int, double> Frames;
|
|||
|
CalFrame(Frames);
|
|||
|
for(auto pairData : Frames)
|
|||
|
{
|
|||
|
ExportFrame("#" + std::to_string(pairData.first), pairData.second);
|
|||
|
}
|
|||
|
}
|
|||
|
else //站位
|
|||
|
{
|
|||
|
std::map<double, double> Stations;
|
|||
|
CalStation(Stations);
|
|||
|
for (auto& item : Stations)
|
|||
|
{
|
|||
|
ExportFrame("$" + std::to_string(item.first), item.second);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//导出船体型值标尺
|
|||
|
void StabilityModel::ExportOffsetLabel() //20190405 added by czb
|
|||
|
{
|
|||
|
m_pDataManager->updateStationLabel();
|
|||
|
//水线
|
|||
|
m_pDataManager->updateWaterlinePositions();
|
|||
|
//纵剖线
|
|||
|
m_pDataManager->updateButtocklineLabel();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void StabilityModel::CalStation(std::map<double, double>& Stations)
|
|||
|
{
|
|||
|
std::vector<std::pair<int, Station_M>>& stations = m_pDataManager->getModelData().getStation();
|
|||
|
auto it = stations.begin();
|
|||
|
for (; it != stations.end(); ++it)
|
|||
|
{
|
|||
|
Stations.insert(std::make_pair(it->second.m_Num, it->second.m_Pos));
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void StabilityModel::ExportFrame(string ID, double X)
|
|||
|
{
|
|||
|
|
|||
|
//modified by jzw 20230308 解决数据已存在无法添加的问题
|
|||
|
|
|||
|
XLabel r;
|
|||
|
r.id = ID;
|
|||
|
r.x = StringHelper::roundToNDecimalPlaces(X, 4);
|
|||
|
|
|||
|
m_pDataManager->AddXLabelRow(r);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void StabilityModel::CalFrame(std::map<int, double>& Frames)
|
|||
|
{
|
|||
|
//肋位表ChangeFSPos.SetSecConvert
|
|||
|
ModelData& model = m_pDataManager->getModelData();
|
|||
|
|
|||
|
int iframe1 = -1; //默认是递增
|
|||
|
iframe1 = model.getiFrame();
|
|||
|
int iframe = std::abs(iframe1);
|
|||
|
//int rfrno = 0; //默认是从0号肋位开始
|
|||
|
double yreffr = model.getF0X(); //0号肋位起始位置
|
|||
|
|
|||
|
std::vector<std::pair<int, Frame_M>>& modelFrames = model.getFrames();
|
|||
|
int count = modelFrames.size() + 1; //肋位个数
|
|||
|
if (count == 0)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
std::vector<int> frno1(count, 0); // 初始化 count 个默认值为 0
|
|||
|
std::vector<double> frsp1(count, 0); // 初始化 count 个默认值为 0
|
|||
|
|
|||
|
|
|||
|
int i = 0;
|
|||
|
for(auto& pairdata : modelFrames)
|
|||
|
{
|
|||
|
frno1[i] = pairdata.second.m_NumS;
|
|||
|
frsp1[i] = pairdata.second.m_Dis;
|
|||
|
i++;
|
|||
|
frno1[i] = pairdata.second.m_Num;
|
|||
|
frsp1[i] = pairdata.second.m_Dis;
|
|||
|
}
|
|||
|
|
|||
|
for (i = 0; i < count - 1; i++)
|
|||
|
{
|
|||
|
int start = frno1[i];
|
|||
|
int end = frno1[i + 1];
|
|||
|
|
|||
|
for (int k = start; k < end; k++)
|
|||
|
{
|
|||
|
Frames.insert(std::make_pair(k, ChangeFSPos::ShowX("#" + std::to_string(k))));
|
|||
|
}
|
|||
|
if (i == count - 2)
|
|||
|
{
|
|||
|
Frames.insert(std::make_pair(end, ChangeFSPos::ShowX("#" + std::to_string(end))));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
std::vector<string> StabilityModel::GetStabNodeOnly(std::vector<string>& commandLines)
|
|||
|
{
|
|||
|
// 使用 QStringList 来拆分字符串
|
|||
|
//QStringList createItems = str.split(',');
|
|||
|
|
|||
|
// 存储需要的节点
|
|||
|
std::vector<string> treeNode;
|
|||
|
|
|||
|
// 遍历 createItems,依次处理
|
|||
|
for (const auto& item : commandLines)
|
|||
|
{
|
|||
|
|
|||
|
if (item == "Hydrostatic")
|
|||
|
{
|
|||
|
if (std::find(treeNode.begin(), treeNode.end(), "静水力") == treeNode.end())
|
|||
|
{
|
|||
|
treeNode.push_back("静水力");
|
|||
|
}
|
|||
|
}
|
|||
|
else if (item == "Tankcapacity")
|
|||
|
{
|
|||
|
if (std::find(treeNode.begin(), treeNode.end(), "舱容") == treeNode.end())
|
|||
|
{
|
|||
|
treeNode.push_back("舱容");
|
|||
|
}
|
|||
|
}
|
|||
|
else if (item == "Intact")
|
|||
|
{
|
|||
|
if (std::find(treeNode.begin(), treeNode.end(), "完整稳性") == treeNode.end())
|
|||
|
{
|
|||
|
treeNode.push_back("完整稳性");
|
|||
|
}
|
|||
|
}
|
|||
|
else if (item == "AllowKG")
|
|||
|
{
|
|||
|
if (std::find(treeNode.begin(), treeNode.end(), "许用重心高度") == treeNode.end())
|
|||
|
{
|
|||
|
treeNode.push_back("许用重心高度");
|
|||
|
}
|
|||
|
}
|
|||
|
else if (item == "Damage")
|
|||
|
{
|
|||
|
if (std::find(treeNode.begin(), treeNode.end(), "破损稳性") == treeNode.end())
|
|||
|
{
|
|||
|
treeNode.push_back("破损稳性");
|
|||
|
}
|
|||
|
}
|
|||
|
else if (item == "DamageProb") // 20210803 by czb
|
|||
|
{
|
|||
|
if (std::find(treeNode.begin(), treeNode.end(), "概率破损") == treeNode.end())
|
|||
|
{
|
|||
|
treeNode.push_back("概率破损");
|
|||
|
}
|
|||
|
}
|
|||
|
else if (item == "Inclining")
|
|||
|
{
|
|||
|
if (std::find(treeNode.begin(), treeNode.end(), "倾斜试验") == treeNode.end())
|
|||
|
{
|
|||
|
treeNode.push_back("倾斜试验");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return treeNode;
|
|||
|
}
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
}
|
|||
|
#endif
|