Skip to content

Commit

Permalink
update to c++17
Browse files Browse the repository at this point in the history
  • Loading branch information
Kei18 committed Feb 18, 2024
1 parent 101ad46 commit 5bf6ed2
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
submodules: true

- name: build
run: bash ./third_party/openFrameworks/scripts/osx/download_libs.sh && make
run: bash ./third_party/openFrameworks/scripts/osx/download_libs.sh && make -j4
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "third_party/openFrameworks"]
path = third_party/openFrameworks
url = https://github.com/openframeworks/openFrameworks.git
[submodule "third_party/argparse"]
path = third_party/argparse
url = https://github.com/p-ranav/argparse.git
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/make
export MAC_OS_MIN_VERSION = 10.15
export MAC_OS_CPP_VER = -std=c++17
export PLATFORM_DEFINES_EXTRA = OF_USING_STD_FS=1

OF_ROOT=${CURDIR}/third_party/openFrameworks
OF_INCLUDE =$(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
include $(OF_INCLUDE)
2 changes: 1 addition & 1 deletion include/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ struct Graph {
int width; // grid width
int height; // grid height
Graph();
Graph(char* filename); // taking map filename
Graph(std::string& filename); // taking map filename
~Graph();
};
2 changes: 1 addition & 1 deletion src/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static const std::regex r_height = std::regex(R"(height\s(\d+))");
static const std::regex r_width = std::regex(R"(width\s(\d+))");
static const std::regex r_map = std::regex(R"(map)");

Graph::Graph(char* filename) : V(Vertices()), width(0), height(0)
Graph::Graph(std::string& filename) : V(Vertices()), width(0), height(0)
{
std::ifstream file(filename);
if (!file) {
Expand Down
33 changes: 21 additions & 12 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,37 @@
#include <regex>

#include "../include/ofApp.hpp"
#include "../third_party/argparse/include/argparse/argparse.hpp"
#include "ofMain.h"

const std::regex r_config = std::regex(R"(^\d+:(.+))");
const std::regex r_pos = std::regex(R"(\((\d+),(\d+)\),)");

int main(int argc, char *argv[])
int main(int argc, char* argv[])
{
// simple arguments check
if (argc < 3 || !std::ifstream(argv[1]) || !std::ifstream(argv[2])) {
std::cout << "Please check the arguments, e.g.,\n"
<< "> mapf-visualizer assets/random-32-32-20.map "
"assets/demo_random-32-32-20.txt"
<< std::endl;
return 0;
argparse::ArgumentParser program("mapf-visualizer", "0.1.0");
program.add_argument("-m", "--map").help("map file").required();
program.add_argument("-p", "--plan").help("plan file").required();
program.add_argument("--capture-only")
.help("take a screen shot and save it in ~/Desktop/")
.default_value(false)
.implicit_value(true);

try {
program.parse_known_args(argc, argv);
} catch (const std::runtime_error& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
std::exit(1);
}

// load graph
Graph G(argv[1]);
auto map_name = program.get<std::string>("map");
Graph G(map_name);

// // load plan
auto solution_file = std::ifstream(argv[2]);
// const auto plan_name = ;
auto solution_file = std::ifstream(program.get<std::string>("plan"));
Solution solution;
std::string line;
std::smatch m, results;
Expand All @@ -45,7 +55,6 @@ int main(int argc, char *argv[])

// visualize
ofSetupOpenGL(100, 100, OF_WINDOW);
ofRunApp(new ofApp(&G, &solution,
(argc > 3 && std::string(argv[3]) == "capture_mode")));
ofRunApp(new ofApp(&G, &solution, program.get<bool>("capture-only")));
return 0;
}
1 change: 1 addition & 0 deletions third_party/argparse
Submodule argparse added at 1b3abd

0 comments on commit 5bf6ed2

Please sign in to comment.