|
|
@ -5,6 +5,7 @@ |
|
|
|
#include "StaticSimGUI.h" |
|
|
|
#include "Util.h" |
|
|
|
#include "ColorbarPlugin.h" |
|
|
|
#include <imgui.h> |
|
|
|
|
|
|
|
namespace ssim { |
|
|
|
|
|
|
@ -13,18 +14,30 @@ namespace ssim { |
|
|
|
// menu_.draw_viewer_menu();
|
|
|
|
|
|
|
|
auto io_menu = [&]() { |
|
|
|
static std::string f_json; |
|
|
|
if (ImGui::Button("加载文件##IO", ImVec2(-1, 0))) { |
|
|
|
#ifndef DEBUG_SSIM |
|
|
|
std::string f_json = igl::file_dialog_open(); |
|
|
|
if(f_json=="") return; |
|
|
|
f_json = igl::file_dialog_open(); |
|
|
|
if (f_json == "") return; |
|
|
|
reload_json(f_json); |
|
|
|
#else |
|
|
|
f_json ="/debug/abspath/to/sim-test/rigid-test/cube/config.json/"; |
|
|
|
reload_json(CMAKE_SOURCE_DIR "/sim-test/rigid-test/cube/config.json"); |
|
|
|
#endif |
|
|
|
gui_ctrl_.is_initialized = true; |
|
|
|
gui_ctrl_.is_loaded_json = true; |
|
|
|
} |
|
|
|
|
|
|
|
if (gui_ctrl_.is_loaded_json) { |
|
|
|
ImGui::BeginChild("##filename", ImVec2(-1, ImGui::GetFontSize() * 3), false, |
|
|
|
ImGuiWindowFlags_HorizontalScrollbar); |
|
|
|
{ |
|
|
|
ImGui::Text("%s", f_json.c_str()); |
|
|
|
ImGui::SetScrollHereY(0.5f); |
|
|
|
} |
|
|
|
ImGui::EndChild(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
auto model_menu = [&]() { |
|
|
@ -58,8 +71,10 @@ namespace ssim { |
|
|
|
|
|
|
|
static bool is_drag[2]; |
|
|
|
ImGui::PushItemWidth(-80); |
|
|
|
is_drag[0]= ImGui::DragFloat3(("最小值 " + std::to_string(i + 1)+"##Dir").c_str(),v_min_point.data(),0.01,0.0,1.0,"%.3f"); |
|
|
|
is_drag[1]= ImGui::DragFloat3(("最大值 " + std::to_string(i + 1)+"##Dir").c_str(),v_max_point.data(),0.01,0.0,1.0,"%.3f"); |
|
|
|
is_drag[0] = ImGui::DragFloat3(("最小值 " + std::to_string(i + 1) + "##Dir").c_str(), |
|
|
|
v_min_point.data(), 0.01, 0.0, 1.0, "%.3f"); |
|
|
|
is_drag[1] = ImGui::DragFloat3(("最大值 " + std::to_string(i + 1) + "##Dir").c_str(), |
|
|
|
v_max_point.data(), 0.01, 0.0, 1.0, "%.3f"); |
|
|
|
ImGui::PopItemWidth(); |
|
|
|
if (is_drag[0] || is_drag[1]) { |
|
|
|
gui_ctrl_.is_modified = true; |
|
|
@ -88,9 +103,12 @@ namespace ssim { |
|
|
|
(float) i_NBC.force.z()}; |
|
|
|
static bool is_drag[3]; |
|
|
|
ImGui::PushItemWidth(-80); |
|
|
|
is_drag[0]= ImGui::DragFloat3(("最小值 " + std::to_string(i + 1)+"##Neu").c_str(),v_min_point.data(),0.01,0.0,1.0,"%.3f"); |
|
|
|
is_drag[1]= ImGui::DragFloat3(("最大值 " + std::to_string(i + 1)+"##Neu").c_str(),v_max_point.data(),0.01,0.0,1.0,"%.3f"); |
|
|
|
is_drag[2]= ImGui::DragFloat3(("力" + std::to_string(i + 1)+" (N)"+"##Neu").c_str(),v_force.data(),1,-1e10,1e10,"%.3f"); |
|
|
|
is_drag[0] = ImGui::DragFloat3(("最小值 " + std::to_string(i + 1) + "##Neu").c_str(), |
|
|
|
v_min_point.data(), 0.01, 0.0, 1.0, "%.3f"); |
|
|
|
is_drag[1] = ImGui::DragFloat3(("最大值 " + std::to_string(i + 1) + "##Neu").c_str(), |
|
|
|
v_max_point.data(), 0.01, 0.0, 1.0, "%.3f"); |
|
|
|
is_drag[2] = ImGui::DragFloat3(("力" + std::to_string(i + 1) + " (N)" + "##Neu").c_str(), |
|
|
|
v_force.data(), 1, -1e10, 1e10, "%.3f"); |
|
|
|
ImGui::PopItemWidth(); |
|
|
|
if (is_drag[0] || is_drag[1] || is_drag[2]) { |
|
|
|
gui_ctrl_.is_modified = true; |
|
|
@ -109,7 +127,7 @@ namespace ssim { |
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
if (ImGui::CollapsingHeader("材料设置", ImGuiTreeNodeFlags_DefaultOpen)) { |
|
|
|
static const int item_width=200; |
|
|
|
static const int item_width = 200; |
|
|
|
ImGui::SetNextItemWidth(item_width); |
|
|
|
ImGui::InputFloat("杨氏模量 (Pa)", &sp_StaticSim_->get_material_property().Youngs_Modulus, 1.0f, 2e11f, |
|
|
|
"%.2e"); |
|
|
@ -119,7 +137,8 @@ namespace ssim { |
|
|
|
"%.3f"); |
|
|
|
|
|
|
|
ImGui::SetNextItemWidth(item_width); |
|
|
|
ImGui::InputFloat("密度 (kg/m^3)", &sp_StaticSim_->get_material_property().density, 1.0f, 1000.0f, "%.3f"); |
|
|
|
ImGui::InputFloat("密度 (kg/m^3)", &sp_StaticSim_->get_material_property().density, 1.0f, 1000.0f, |
|
|
|
"%.3f"); |
|
|
|
} |
|
|
|
|
|
|
|
if (ImGui::Button(("原始模型"), ImVec2(-1, 0))) { |
|
|
@ -215,6 +234,37 @@ namespace ssim { |
|
|
|
ImGui::SameLine(); |
|
|
|
ImGui::Checkbox("导出坐标", &is_extract_coord); |
|
|
|
|
|
|
|
}; |
|
|
|
auto compare_menu = [&]() { |
|
|
|
|
|
|
|
double cpt_compliance = sp_StaticSim_->EvaluateTarget(ssim::SimTargetOption::COMPLIANCE)(0, 0); |
|
|
|
Eigen::VectorXd cpt_UNorm = sp_StaticSim_->EvaluateTarget(ssim::SimTargetOption::U_NORM); |
|
|
|
Eigen::VectorXd cpt_SVonMise = sp_StaticSim_->EvaluateTarget(ssim::SimTargetOption::S_VON_Mises); |
|
|
|
|
|
|
|
static double error_compliance; |
|
|
|
static double error_UNorm; |
|
|
|
static double error_SVonMise; |
|
|
|
|
|
|
|
static bool has_load_cmp_file = false; |
|
|
|
if (ImGui::Button("导入Ansys文件", ImVec2(-1, 0))) { |
|
|
|
std::string input_dir = ssim::directory_dialog_save(); |
|
|
|
spdlog::info("input from: {}", input_dir); |
|
|
|
double ref_compliance = cpt_compliance * 1.1;// TODO:fixme:read the file
|
|
|
|
Eigen::VectorXd ref_UNorm = cpt_UNorm * 1.1;// TODO:fixme
|
|
|
|
Eigen::VectorXd ref_SVonMise = cpt_SVonMise * 1.1;// TODO:fixme
|
|
|
|
error_compliance = std::abs(cpt_compliance - ref_compliance) / ref_compliance; |
|
|
|
error_UNorm = (cpt_UNorm - ref_UNorm).norm() / ref_UNorm.norm(); |
|
|
|
error_SVonMise = (cpt_SVonMise - ref_SVonMise).norm() / ref_SVonMise.norm(); |
|
|
|
has_load_cmp_file = true; |
|
|
|
} |
|
|
|
|
|
|
|
if (has_load_cmp_file) { |
|
|
|
ImGui::TextWrapped("柔顺度误差: %.2f %%", error_compliance * 100); |
|
|
|
ImGui::TextWrapped("位移范数误差: %.2f %%", error_UNorm * 100); |
|
|
|
ImGui::TextWrapped("冯氏应力误差: %.2f %%", error_SVonMise * 100); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
if (ImGui::CollapsingHeader("载入模型", ImGuiTreeNodeFlags_DefaultOpen)) { |
|
|
@ -229,6 +279,9 @@ namespace ssim { |
|
|
|
if (ImGui::CollapsingHeader("仿真结果", ImGuiTreeNodeFlags_DefaultOpen)) { |
|
|
|
result_menu(); |
|
|
|
} |
|
|
|
if (ImGui::CollapsingHeader("结果对比", ImGuiTreeNodeFlags_DefaultOpen)) { |
|
|
|
compare_menu(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|