|
|
@ -7,6 +7,7 @@ |
|
|
|
#include <viewer/imgui_ext.hpp> |
|
|
|
|
|
|
|
#include <logger.hpp> |
|
|
|
#include "string" |
|
|
|
|
|
|
|
namespace ipc::rigid { |
|
|
|
|
|
|
@ -147,34 +148,61 @@ namespace ipc::rigid { |
|
|
|
|
|
|
|
if (ImGui::Button("开始计算")) { |
|
|
|
sp_StaticSim_->simulation(); |
|
|
|
|
|
|
|
gui_ctrl_.is_modified = true; |
|
|
|
gui_ctrl_.is_solved = true; |
|
|
|
} |
|
|
|
// ImGui::RadioButton("开始计算##SimPlayer", &player_state, PlayerState::Playing);
|
|
|
|
// ImGui::RadioButton("暂停##SimPlayer", &player_state, PlayerState::Paused);
|
|
|
|
ImGui::Checkbox("边界条件", &gui_ctrl_.is_visible_BC); |
|
|
|
ImGui::Checkbox("网格可视化",&gui_ctrl_.mesh_visible); |
|
|
|
ImGui::Checkbox("网格可视化", &gui_ctrl_.mesh_visible); |
|
|
|
// --------------------------------------------------------------------
|
|
|
|
if (ImGui::CollapsingHeader( |
|
|
|
"边界条件设置##SimPlayer", ImGuiTreeNodeFlags_DefaultOpen)) { |
|
|
|
ImGui::Checkbox("边界包围盒", &m_bkp_has_intersections); |
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
for (int i = 0; i < sp_StaticSim_->DirichletBCs.size(); ++i) { |
|
|
|
// each boundary
|
|
|
|
// ImGui::Checkbox("受力", &m_state.m_solve_collisions);
|
|
|
|
auto &i_DBC = sp_StaticSim_->DirichletBCs[i]; |
|
|
|
std::vector<float> v_min_point = {(float) i_DBC.relMinBBox.x(), (float) i_DBC.relMinBBox.y(), |
|
|
|
(float) i_DBC.relMinBBox.z()}; |
|
|
|
std::vector<float> v_max_point = {(float) i_DBC.relMaxBBox.x(), (float) i_DBC.relMaxBBox.y(), |
|
|
|
(float) i_DBC.relMaxBBox.z()}; |
|
|
|
ImGui::SliderFloat3("最小值", v_min_point.data(), -50, 50, "%.3f"); |
|
|
|
ImGui::SliderFloat3("最大值", v_max_point.data(), -50, 50, "%.3f"); |
|
|
|
i_DBC.relMinBBox={v_min_point[0],v_min_point[1],v_min_point[2]}; |
|
|
|
i_DBC.relMaxBBox={v_max_point[0],v_max_point[1],v_max_point[2]}; |
|
|
|
"边界条件", ImGuiTreeNodeFlags_DefaultOpen)) { |
|
|
|
ImGui::Checkbox("边界可视化", &gui_ctrl_.is_visible_BC); |
|
|
|
if (ImGui::CollapsingHeader( |
|
|
|
"Dirichlet边界", ImGuiTreeNodeFlags_DefaultOpen)) { |
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
for (int i = 0; i < sp_StaticSim_->DirichletBCs.size(); ++i) { |
|
|
|
// each boundary
|
|
|
|
// ImGui::Checkbox("受力", &m_state.m_solve_collisions);
|
|
|
|
auto &i_DBC = sp_StaticSim_->DirichletBCs[i]; |
|
|
|
std::vector<float> v_min_point = {(float) i_DBC.relMinBBox.x(), (float) i_DBC.relMinBBox.y(), |
|
|
|
(float) i_DBC.relMinBBox.z()}; |
|
|
|
std::vector<float> v_max_point = {(float) i_DBC.relMaxBBox.x(), (float) i_DBC.relMaxBBox.y(), |
|
|
|
(float) i_DBC.relMaxBBox.z()}; |
|
|
|
ImGui::InputFloat3(("Dirichlet最小值 " + std::to_string(i + 1)).c_str(), v_min_point.data()); |
|
|
|
ImGui::InputFloat3(("Dirichlet最大值 " + std::to_string(i + 1)).c_str(), v_min_point.data()); |
|
|
|
i_DBC.relMinBBox = {v_min_point[0], v_min_point[1], v_min_point[2]}; |
|
|
|
i_DBC.relMaxBBox = {v_max_point[0], v_max_point[1], v_max_point[2]}; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (ImGui::CollapsingHeader( |
|
|
|
"Neumann边界", ImGuiTreeNodeFlags_DefaultOpen)) { |
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
for (int i = 0; i < sp_StaticSim_->NeumannBCs.size(); ++i) { |
|
|
|
auto &i_NBC = sp_StaticSim_->NeumannBCs[i]; |
|
|
|
std::vector<float> v_min_point = {(float) i_NBC.relMinBBox.x(), (float) i_NBC.relMinBBox.y(), |
|
|
|
(float) i_NBC.relMinBBox.z()}; |
|
|
|
std::vector<float> v_max_point = {(float) i_NBC.relMaxBBox.x(), (float) i_NBC.relMaxBBox.y(), |
|
|
|
(float) i_NBC.relMaxBBox.z()}; |
|
|
|
std::vector<float> v_force = {(float) i_NBC.force.x(), (float) i_NBC.force.y(), |
|
|
|
(float) i_NBC.force.z()}; |
|
|
|
|
|
|
|
ImGui::InputFloat3(("Neumann最小值 " + std::to_string(i + 1)).c_str(), v_min_point.data()); |
|
|
|
ImGui::InputFloat3(("Neumann最大值 " + std::to_string(i + 1)).c_str(), v_min_point.data()); |
|
|
|
ImGui::InputFloat3(("Neumann力 " + std::to_string(i + 1)).c_str(), v_force.data()); |
|
|
|
i_NBC.relMinBBox = {v_min_point[0], v_min_point[1], v_min_point[2]}; |
|
|
|
i_NBC.relMaxBBox = {v_max_point[0], v_max_point[1], v_max_point[2]}; |
|
|
|
i_NBC.force={v_force[0],v_force[1],v_force[2]}; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// ImGui::Checkbox("受力大小", &m_bkp_optimization_failed);
|
|
|
|
// ImGui::SameLine();
|
|
|
|
// ImGui::HelpMarker("yes - stop playing if step optimization failed.");
|
|
|
@ -197,17 +225,10 @@ namespace ipc::rigid { |
|
|
|
// }
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
if (ImGui::CollapsingHeader("材料设置", ImGuiTreeNodeFlags_DefaultOpen)) { |
|
|
|
static float f0 = 0.001f; |
|
|
|
static float f1 = 0.001f; |
|
|
|
static float f2 = 0.001f; |
|
|
|
ImGui::InputFloat("杨氏模量", &f0, 0.01f, 1.0f, "%.3f"); |
|
|
|
ImGui::InputFloat("泊松比", &f1, 0.01f, 1.0f, "%.3f"); |
|
|
|
ImGui::InputFloat("密度", &f2, 0.01f, 1.0f, "%.3f"); |
|
|
|
} |
|
|
|
if (ImGui::CollapsingHeader( |
|
|
|
"其他设置", ImGuiTreeNodeFlags_DefaultOpen)) { |
|
|
|
static float f3 = 0.01f; |
|
|
|
ImGui::InputFloat("时间步", &f3, 0.01f, 1.0f, "%.2f"); |
|
|
|
|
|
|
|
ImGui::InputFloat("杨氏模量", &sp_StaticSim_->get_material_property().Youngs_Modulus, 1.0f, 1e10f, "%.3f"); |
|
|
|
ImGui::InputFloat("泊松比", &sp_StaticSim_->get_material_property().Poisson_ratio, 0.01f, 1.0f, "%.3f"); |
|
|
|
ImGui::InputFloat("密度", &sp_StaticSim_->get_material_property().density, 1.0f, 1000.0f, "%.3f"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -231,7 +252,7 @@ namespace ipc::rigid { |
|
|
|
char *desc = "121.88"; |
|
|
|
// ImGui::Text("柔顺度(compliance)");
|
|
|
|
// sp_StaticSim_->EvaluateTarget(ssim::SimTargetOption::COMPLIANCE)(0,0);
|
|
|
|
ImGui::TextWrapped("柔顺度 (compliance): %.3f", 12222.2); |
|
|
|
ImGui::TextWrapped("柔顺度 (compliance): %.3e", sp_StaticSim_->EvaluateTarget(ssim::SimTargetOption::COMPLIANCE)(0,0)); |
|
|
|
if (ImGui::IsItemHovered()) { |
|
|
|
// 显示工具的提示
|
|
|
|
ImGui::BeginTooltip(); |
|
|
|