Skip to content

Commit 7ec3782

Browse files
authored
Merge pull request #15 from BardoBard/merge
Merge
2 parents 30b26b4 + c7f929c commit 7ec3782

40 files changed

+734
-589
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "packages/Trajectory_Hotspots"]
22
path = packages/Trajectory_Hotspots
33
url = https://github.com/NHLStenden-ISAL/Trajectory_Hotspots.git
4+
[submodule "packages/docs"]
5+
path = packages/docs
6+
url = https://github.com/BardoBard/Trajectory-Hotspots-Visualization.wiki.git

CMakeLists.txt

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,26 @@ set(PACKAGE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/packages)
1212
set(TRAJECTORY_HOTSPOTS_SOLUTION_DIR ${PACKAGE_DIR}/Trajectory_Hotspots/Trajectory_Hotspots)
1313
set(TRAJECTORY_HOTSPOTS_DIR ${PACKAGE_DIR}/Trajectory_Hotspots/Trajectory_Hotspots/Trajectory_Hotspots)
1414

15-
set(TRAJECTORY_HOTSPOTS_PACKAGE_CPP_FILES
16-
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/aabb.cpp"
17-
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/float.cpp"
18-
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/segment.cpp"
19-
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/segment_search_tree.cpp"
20-
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/trajectory.cpp"
21-
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/vec2.cpp"
22-
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/trapezoidal_map.cpp"
23-
)
24-
include_directories(
25-
${PACKAGE_DIR}/packages/.?*/
15+
file(GLOB_RECURSE TRAJECTORY_HOTSPOTS_PACKAGE_CPP_FILES
16+
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/*.cpp"
2617
)
18+
19+
# Remove the main.cpp file
20+
list(REMOVE_ITEM TRAJECTORY_HOTSPOTS_PACKAGE_CPP_FILES "${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/Trajectory_Hotspots.cpp")
21+
2722
# Add subdirectories
2823
add_subdirectory(Trajectory-Hotspots-Parser)
2924
add_subdirectory(Trajectory-Hotspots-Visualization)
30-
add_subdirectory(Trajectory-Hotspots-Benchmark)
25+
add_subdirectory(Trajectory-Hotspots-Benchmark)
26+
27+
28+
# Get all subdirectories
29+
get_directory_property(subdir_list DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} SUBDIRECTORIES)
30+
31+
# Add documentation to each subdirectory
32+
foreach(subdir ${subdir_list})
33+
get_filename_component(sub_proj_name "${subdir}" NAME)
34+
35+
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/packages/docs/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${sub_proj_name}/docs/ FILES_MATCHING PATTERN "*.md")
36+
# Copy the docs from github wiki
37+
endforeach()

README.md

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ Everything here incorporates the [Trajectory-Hotspots](https://github.com/NHLSte
22
as a submodule. The visualization is based on the algorithms used in the library.
33

44
---
5-
## Installation
6-
7-
1. [Download Latest Version](https://github.com/BardoBard/Trajectory-Hotspots-Visualization/releases/latest) and unzip.
8-
2. Add path to your Trajectory.txt with options to the Config.txt file.
9-
3. Run the executable from the unzipped folder and give location of Config.txt file as argument.
10-
115
---
126

137
# Trajectory-Hotspots-Visualization
@@ -40,34 +34,6 @@ Mouse:
4034
![mouse_buttons.png](.github/images/mouse_buttons.png)
4135
---
4236

43-
## Clone
44-
45-
clone with submodules
46-
47-
```bash
48-
git clone --recursive -j8 --branch "master" https://github.com/BardoBard/Trajectory-Hotspots-Visualization.git "Visualization"
49-
```
50-
51-
get the latest version of trajectory-hotspots
52-
```bash
53-
git submodule update --remote --merge
54-
```
55-
56-
This assumes you have **vcpkg** and **cmake**. If not, follow the instructions on
57-
the [website](https://vcpkg.io/en/getting-started.html).
58-
59-
#### Install:
60-
61-
install might take a while
62-
63-
```bash
64-
vcpkg install qt5
65-
vcpkg install cgal
66-
vcpkg install opengl
67-
68-
vcpkg integrate install
69-
```
70-
7137
## Dependencies
7238

7339
| Dependency | Version |
Lines changed: 66 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,96 @@
1-
int zero = 0;
2-
QApplication app = QApplication(zero, nullptr);
3-
QWidget* active_window = QApplication::activeWindow();
1+
#include <Window/file_pick_table_widget.h>
2+
#include <Window/main_window.h>
43

5-
void fixed_length_contiguous(const Trajectory& trajectory)
6-
{
7-
ankerl::nanobench::doNotOptimizeAway(trajectory.get_hotspot_fixed_length_contiguous(5));
8-
}
4+
std::string out_path = std::filesystem::current_path().string() + "\\templates\\";
95

6+
/// \brief Generates an output file of the benchmark data of the given type.
7+
/// \param path path to the output file
8+
/// \param type_name name of the output file type
9+
/// \param mustache_template mustache template for the output file
10+
/// \param bench benchmark data
11+
/// \param template_path path to the mustache template file
1012
void generate_file_type(const std::string& path, const std::string& type_name, const char* mustache_template,
1113
ankerl::nanobench::Bench const& bench, std::filesystem::path template_path)
1214
{
1315
template_path = std::filesystem::path(path).append("mustache-template." + type_name);
1416

17+
if (!parser::dir_exists(path))
18+
std::filesystem::create_directory(path);
19+
1520
if (!parser::file_exists(template_path.string()))
16-
throw std::runtime_error("Mustache template file does not exist");
21+
//make new file
22+
{
23+
std::ofstream template_file(template_path.string());
24+
template_file << mustache_template;
25+
template_file.close();
26+
}
1727

1828
const std::string mustache_template_string = parser::get_file_raw(template_path.string());
1929

20-
std::cout << "Generating " << type_name << " file..." << std::endl;
21-
std::cout << mustache_template_string << std::endl;
2230
std::ofstream render_out(path + bench.title() + "-visualization." + type_name);
2331

24-
ankerl::nanobench::render(template_path.string().c_str(), bench, render_out);
32+
ankerl::nanobench::render(mustache_template_string.c_str(), bench, render_out);
2533
}
2634

27-
void generate_file_type(const std::string& path, const std::string& type_name, const char* mustache_template,
28-
ankerl::nanobench::Bench const& bench)
35+
/// \brief Callback function for the benchmarking tool when a file is picked
36+
static inline file_pick_table_widget::t_file_pick_callback benchmark_callback = [&](const std::string& file_path)
2937
{
30-
generate_file_type(path, type_name, mustache_template, bench, parser::current_path_string);
31-
}
38+
const std::vector<parser::parsed_trajectory> trajectories = parser::parse_config(file_path, ' ');
3239

33-
int main(const int argc, const char* argv[])
34-
{
35-
if (argc < 2)
40+
ankerl::nanobench::Bench bench;
41+
42+
bench.performanceCounters(true);
43+
bench.title("benchmark");
44+
45+
std::cout << "Benchmarking..." << std::endl;
46+
47+
for (const auto& parsed_trajectory : trajectories)
3648
{
37-
std::cerr << "Please provide a file path to the config file" << std::endl;
38-
return 0;
49+
bench.warmup(10).minEpochIterations(100).run(parsed_trajectory.name, [&]
50+
{
51+
ankerl::nanobench::doNotOptimizeAway(parsed_trajectory.run_trajectory_function());
52+
});
3953
}
40-
const std::string file_path = argv[1];
41-
const std::string out_path = argc > 2 ? argv[2] : std::filesystem::current_path().string();
42-
try
43-
{
44-
const std::vector<parser::parsed_trajectory> trajectories = parser::parse_config(file_path, ' ');
4554

46-
ankerl::nanobench::Bench bench;
55+
generate_file_type(out_path, "json", ankerl::nanobench::templates::json(), bench, out_path);
4756

48-
bench.performanceCounters(true);
49-
bench.title("benchmark");
57+
generate_file_type(out_path, "html", ankerl::nanobench::templates::htmlBoxplot(), bench, out_path);
5058

51-
std::cout << "Benchmarking..." << std::endl;
52-
for (const auto& parsed_trajectory : trajectories)
53-
{
54-
bench.warmup(10).minEpochIterations(100).run(parsed_trajectory.name, [&]
55-
{
56-
ankerl::nanobench::doNotOptimizeAway(parsed_trajectory.run_trajectory_function());
57-
});
58-
}
59+
generate_file_type(out_path, "csv", ankerl::nanobench::templates::csv(), bench, out_path);
5960

60-
generate_file_type(out_path, "json", ankerl::nanobench::templates::json(), bench, out_path);
61+
std::cout << "Output written to: " << out_path << std::endl;
62+
};
6163

62-
generate_file_type(out_path, "html", ankerl::nanobench::templates::htmlBoxplot(), bench, out_path);
64+
int main(int argc, char* argv[])
65+
{
66+
Float::fixed_epsilon = 0.01f;
67+
if (argc > 2)
68+
{
69+
std::cerr << "Too many arguments provided" << std::endl;
70+
return 0;
71+
}
6372

64-
generate_file_type(out_path, "csv", ankerl::nanobench::templates::csv(), bench, out_path);
73+
if (argc == 2)
74+
out_path = parser::dir_exists(parser::current_path_string + "\\" + argv[1])
75+
? parser::current_path_string + "\\" + argv[1]
76+
: argv[1];
77+
78+
try
79+
{
80+
QApplication app(argc, nullptr);
81+
QWidget* active_window = QApplication::activeWindow();
82+
main_window main_window(active_window, benchmark_callback, {"Benchmark", "Benchmarking tool"}, "Help");
83+
main_window.show();
84+
85+
app.exec();
86+
}
87+
catch (const parser::parsing_error& e)
88+
{
89+
std::cerr << "Something went wrong during the benchmark: " << e.what() << std::endl;
6590
}
66-
catch (const std::exception& e)
91+
catch (...)
6792
{
68-
std::cout << e.what() << std::endl;
69-
return 1;
93+
std::cerr << "Something went wrong during the benchmark." << std::endl;
7094
}
7195
return 0;
7296
}

Trajectory-Hotspots-Benchmark/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,14 @@ target_link_libraries(${PROJECT_NAME} PRIVATE Trajectory-Hotspots-Visualization_
3131
target_link_libraries(${PROJECT_NAME} PRIVATE Trajectory-Hotspots-Parser_lib)
3232
target_link_libraries(${PROJECT_NAME} PRIVATE nanobench)
3333

34-
target_precompile_headers(${PROJECT_NAME} PRIVATE pch.h)
34+
target_precompile_headers(${PROJECT_NAME} PRIVATE pch.h)
35+
36+
# copy etc to build directory
37+
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../etc/
38+
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/etc/)
39+
40+
# copy examples to build directory
41+
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../examples/
42+
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/examples/)
43+
44+
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../templates DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

Trajectory-Hotspots-Parser/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Project name
22
project(Trajectory-Hotspots-Parser)
33

4+
# Copy examples to build directory
5+
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../examples/
6+
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/examples/)
7+
48
# Recursive globbing to find all files in a directory
59
file(
610
GLOB_RECURSE cppfiles

0 commit comments

Comments
 (0)