|
@ -9,15 +9,18 @@ |
|
|
#include <ghc/fs_std.hpp> // filesystem |
|
|
#include <ghc/fs_std.hpp> // filesystem |
|
|
|
|
|
|
|
|
#include <SimState.hpp> |
|
|
#include <SimState.hpp> |
|
|
|
|
|
|
|
|
#ifdef RIGID_IPC_WITH_OPENGL |
|
|
#ifdef RIGID_IPC_WITH_OPENGL |
|
|
|
|
|
|
|
|
#include <viewer/UISimState.hpp> |
|
|
#include <viewer/UISimState.hpp> |
|
|
#include "viewer/UIStaticSimState.h" |
|
|
#include "viewer/UIStaticSimState.h" |
|
|
|
|
|
|
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#include <logger.hpp> |
|
|
#include <logger.hpp> |
|
|
#include <profiler.hpp> |
|
|
#include <profiler.hpp> |
|
|
#include "path_config.h" |
|
|
#include "path_config.h" |
|
|
int main(int argc, char* argv[]) |
|
|
int main(int argc, char *argv[]) { |
|
|
{ |
|
|
|
|
|
using namespace ipc::rigid; |
|
|
using namespace ipc::rigid; |
|
|
set_logger_level(spdlog::level::info); |
|
|
set_logger_level(spdlog::level::info); |
|
|
|
|
|
|
|
@ -29,46 +32,46 @@ int main(int argc, char* argv[]) |
|
|
bool with_viewer = false; |
|
|
bool with_viewer = false; |
|
|
#endif |
|
|
#endif |
|
|
app.add_flag("--gui,!--ngui", with_viewer, "use the OpenGL GUI") |
|
|
app.add_flag("--gui,!--ngui", with_viewer, "use the OpenGL GUI") |
|
|
->default_val(with_viewer); |
|
|
->default_val(with_viewer); |
|
|
|
|
|
|
|
|
std::string scene_path = ""; |
|
|
std::string scene_path = ""; |
|
|
app.add_option( |
|
|
app.add_option( |
|
|
"scene_path,-i,-s,--scene-path", scene_path, |
|
|
"scene_path,-i,-s,--scene-path", scene_path, |
|
|
"JSON file with input scene"); |
|
|
"JSON file with input scene"); |
|
|
|
|
|
|
|
|
std::string output_dir = ""; |
|
|
std::string output_dir = ""; |
|
|
app.add_option( |
|
|
app.add_option( |
|
|
"output_dir,-o,--output-path", output_dir, |
|
|
"output_dir,-o,--output-path", output_dir, |
|
|
"directory for results (ngui only)"); |
|
|
"directory for results (ngui only)"); |
|
|
|
|
|
|
|
|
std::string output_name = "sim.json"; |
|
|
std::string output_name = "sim.json"; |
|
|
app.add_option( |
|
|
app.add_option( |
|
|
"-f,--output-name", output_name, |
|
|
"-f,--output-name", output_name, |
|
|
"name for simulation file (ngui only)") |
|
|
"name for simulation file (ngui only)") |
|
|
->default_val(output_name); |
|
|
->default_val(output_name); |
|
|
|
|
|
|
|
|
int num_steps = -1; |
|
|
int num_steps = -1; |
|
|
app.add_option( |
|
|
app.add_option( |
|
|
"--num-steps", num_steps, "number of time-steps (ngui only)"); |
|
|
"--num-steps", num_steps, "number of time-steps (ngui only)"); |
|
|
|
|
|
|
|
|
int checkpoint_freq = -1; |
|
|
int checkpoint_freq = -1; |
|
|
app.add_option( |
|
|
app.add_option( |
|
|
"--chkpt,--checkpoint-frequency", checkpoint_freq, |
|
|
"--chkpt,--checkpoint-frequency", checkpoint_freq, |
|
|
"number of time-steps between checkpoints (ngui only)"); |
|
|
"number of time-steps between checkpoints (ngui only)"); |
|
|
|
|
|
|
|
|
spdlog::level::level_enum loglevel = spdlog::level::info; |
|
|
spdlog::level::level_enum loglevel = spdlog::level::info; |
|
|
app.add_option("--log,--loglevel", loglevel, "log level") |
|
|
app.add_option("--log,--loglevel", loglevel, "log level") |
|
|
->default_val(loglevel) |
|
|
->default_val(loglevel) |
|
|
->transform(CLI::CheckedTransformer( |
|
|
->transform(CLI::CheckedTransformer( |
|
|
SPDLOG_LEVEL_NAMES_TO_LEVELS, CLI::ignore_case)); |
|
|
SPDLOG_LEVEL_NAMES_TO_LEVELS, CLI::ignore_case)); |
|
|
|
|
|
|
|
|
int nthreads = tbb::task_scheduler_init::default_num_threads(); |
|
|
int nthreads = tbb::task_scheduler_init::default_num_threads(); |
|
|
app.add_option("--nthreads", nthreads, "maximum number of threads to use") |
|
|
app.add_option("--nthreads", nthreads, "maximum number of threads to use") |
|
|
->default_val(nthreads); |
|
|
->default_val(nthreads); |
|
|
|
|
|
|
|
|
std::string patch = ""; |
|
|
std::string patch = ""; |
|
|
app.add_option("--patch", patch, "patch to input file (ngui only)") |
|
|
app.add_option("--patch", patch, "patch to input file (ngui only)") |
|
|
->default_val(patch); |
|
|
->default_val(patch); |
|
|
|
|
|
|
|
|
CLI11_PARSE(app, argc, argv); |
|
|
CLI11_PARSE(app, argc, argv); |
|
|
|
|
|
|
|
@ -80,22 +83,45 @@ int main(int argc, char* argv[]) |
|
|
|
|
|
|
|
|
if (nthreads > tbb::task_scheduler_init::default_num_threads()) { |
|
|
if (nthreads > tbb::task_scheduler_init::default_num_threads()) { |
|
|
spdlog::warn( |
|
|
spdlog::warn( |
|
|
"Attempting to use more threads than available ({:d} > {:d})!", |
|
|
"Attempting to use more threads than available ({:d} > {:d})!", |
|
|
nthreads, tbb::task_scheduler_init::default_num_threads()); |
|
|
nthreads, tbb::task_scheduler_init::default_num_threads()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
tbb::global_control thread_limiter( |
|
|
tbb::global_control thread_limiter( |
|
|
tbb::global_control::max_allowed_parallelism, nthreads); |
|
|
tbb::global_control::max_allowed_parallelism, nthreads); |
|
|
|
|
|
|
|
|
if (with_viewer) { |
|
|
if (with_viewer) { |
|
|
#ifdef RIGID_IPC_WITH_OPENGL |
|
|
#ifdef RIGID_IPC_WITH_OPENGL |
|
|
// UISimState ui;
|
|
|
// UISimState ui;
|
|
|
// ui.launch(scene_path);
|
|
|
// ui.launch(scene_path);
|
|
|
// Static Simulation
|
|
|
// Static Simulation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// bool my_tool_active = true;
|
|
|
|
|
|
// bool switch_to_static;
|
|
|
|
|
|
// begin_viewer.callback_pre_draw = [&](igl::opengl::glfw::Viewer &viewer) {
|
|
|
|
|
|
// ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f), ImGuiCond_FirstUseEver);
|
|
|
|
|
|
// ImGui::SetNextWindowSize(ImVec2(0.0f, 0.0f), ImGuiCond_FirstUseEver);
|
|
|
|
|
|
//// ImGui::SetNextWindowSizeConstraints(
|
|
|
|
|
|
//// ImVec2(menu_width, -1.0f), ImVec2(menu_width, -1.0f));
|
|
|
|
|
|
// bool _viewer_menu_visible = true;
|
|
|
|
|
|
//
|
|
|
|
|
|
// ImGui::Begin(
|
|
|
|
|
|
// "控制菜单", &_viewer_menu_visible,
|
|
|
|
|
|
// ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize);
|
|
|
|
|
|
// ImGui::End();
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
// };
|
|
|
|
|
|
// begin_viewer.launch();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// std::cout << "switch is: " << my_tool_active << std::endl;
|
|
|
|
|
|
// exit(1);
|
|
|
ssim::SimTargetOption option; |
|
|
ssim::SimTargetOption option; |
|
|
option.set_option(option.U_NORM); |
|
|
option.set_option(option.U_NORM); |
|
|
std::string json_path=CMAKE_SOURCE_DIR "/sim-test/rigid-test/cube/config.json"; |
|
|
std::string json_path = CMAKE_SOURCE_DIR "/sim-test/rigid-test/cube/config.json"; |
|
|
std::shared_ptr<ssim::StaticSim> sp_StaticSim = std::make_shared<ssim::StaticSim>(option,json_path); |
|
|
std::shared_ptr<ssim::StaticSim> sp_StaticSim = std::make_shared<ssim::StaticSim>(option, json_path); |
|
|
|
|
|
|
|
|
UIStaticSimState ui(sp_StaticSim); |
|
|
UIStaticSimState ui(sp_StaticSim); |
|
|
ui.launch(scene_path); |
|
|
ui.launch(scene_path); |
|
@ -107,18 +133,17 @@ int main(int argc, char* argv[]) |
|
|
} else { |
|
|
} else { |
|
|
if (scene_path.empty()) { |
|
|
if (scene_path.empty()) { |
|
|
exit(app.exit(CLI::Error( |
|
|
exit(app.exit(CLI::Error( |
|
|
"scene_path", "Must provide a scene path in ngui mode!"))); |
|
|
"scene_path", "Must provide a scene path in ngui mode!"))); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (output_dir.empty()) { |
|
|
if (output_dir.empty()) { |
|
|
exit(app.exit(CLI::Error( |
|
|
exit(app.exit(CLI::Error( |
|
|
"output_dir", |
|
|
"output_dir", |
|
|
"Must provide a output directory in ngui mode!"))); |
|
|
"Must provide a output directory in ngui mode!"))); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Create the output directory if it does not exist
|
|
|
// Create the output directory if it does not exist
|
|
|
fs::create_directories(fs::path(output_dir)); |
|
|
fs::create_directories(fs::path(output_dir));PROFILER_OUTDIR(output_dir); |
|
|
PROFILER_OUTDIR(output_dir); |
|
|
|
|
|
std::string fout = fmt::format("{}/{}", output_dir, output_name); |
|
|
std::string fout = fmt::format("{}/{}", output_dir, output_name); |
|
|
|
|
|
|
|
|
SimState sim; |
|
|
SimState sim; |
|
|