Skip to content

Commit

Permalink
Merge pull request #11 from BardoBard/trapezoidal_map_v
Browse files Browse the repository at this point in the history
Trapezoidal map v
  • Loading branch information
BardoBard authored Nov 27, 2023
2 parents 22b064f + 71da1e8 commit 0fc82d3
Show file tree
Hide file tree
Showing 37 changed files with 1,599 additions and 246 deletions.
Binary file added .github/images/keyboard_buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/images/large_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/images/mouse_buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/images/simple_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/out*/

#packages ignore
/packages/.*?/*
/packages/

#git
.git
Expand Down
19 changes: 16 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,28 @@ cmake_minimum_required(VERSION 3.1...3.23)

# c++ 20
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED YES)

# Project name
project(Visualization)

set(PACKAGE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/packages)
set(TRAJECTORY_HOTSPOTS_SOLUTION_DIR ${PACKAGE_DIR}/Trajectory_Hotspots/Trajectory_Hotspots)
set(TRAJECTORY_HOTSPOTS_DIR ${PACKAGE_DIR}/Trajectory_Hotspots/Trajectory_Hotspots/Trajectory_Hotspots)

set(TRAJECTORY_HOTSPOTS_PACKAGE_CPP_FILES
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/aabb.cpp"
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/float.cpp"
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/segment.cpp"
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/segment_search_tree.cpp"
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/trajectory.cpp"
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/vec2.cpp"
"${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/Trajectory_Hotspots/trapezoidal_map.cpp"
)
include_directories(
${PACKAGE_DIR}/packages/.?*/
${PACKAGE_DIR}/packages/.?*/
)

# Add subdirectories
add_subdirectory(Trajectory-Hotspots-Visualization)
add_subdirectory(Trajectory-Hotspots-Parser)
add_subdirectory(Trajectory-Hotspots-Visualization)
add_subdirectory(Trajectory-Hotspots-Benchmark)
27 changes: 27 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": []
}
]
}
72 changes: 69 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,78 @@
Everything here incorporates the [Trajectory-Hotspots](https://github.com/NHLStenden-ISAL/Trajectory_Hotspots) library
as a submodule. The visualization is based on the algorithms used in the library.

---
## Installation

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

---

# Trajectory-Hotspots-Visualization

Visualizes trajectories and their hotspots in 2D.

### Examples:

<img src=".github/images/simple_example.png" alt="simple_example" style="margin-right: 9%;" width="45%" title="Trajectory"/> <img src=".github/images/large_example.png" alt="simple_example" width="45%" title="Trajectory"/>

---

# Trajectory-Hotspots-Benchmark

Benchmarking tool for the Trajectory-Hotspots library. The benchmarking tool is

---

## Buttons

Keyboard:

---
![keyboard_buttons.png](.github/images/keyboard_buttons.png)

Mouse:

---

![mouse_buttons.png](.github/images/mouse_buttons.png)
---

## Clone

clone with submodules

```bash
git clone --recursive -j8 --branch "master" https://github.com/BardoBard/Trajectory-Hotspots-Visualization.git "Visualization"
```

get the latest version of trajectory-hotspots
```bash
git submodule update --remote --merge
```

This assumes you have **vcpkg** and **cmake**. If not, follow the instructions on
the [website](https://vcpkg.io/en/getting-started.html).

#### Install:

install might take a while

```bash
vcpkg install qt5
vcpkg install cgal
vcpkg install opengl

vcpkg integrate install
```

## Dependencies

- QT5
- CGAL
- OpenGl32
| Dependency | Version |
|------------|--------------|
| CGAL | 5.6 |
| CGAL[QT] | - |
| OpenGl | 2022-12-04#3 |
| Nanobench | 4.3.11 |
72 changes: 72 additions & 0 deletions Trajectory-Hotspots-Benchmark/Benchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
int zero = 0;
QApplication app = QApplication(zero, nullptr);
QWidget* active_window = QApplication::activeWindow();

void fixed_length_contiguous(const Trajectory& trajectory)
{
ankerl::nanobench::doNotOptimizeAway(trajectory.get_hotspot_fixed_length_contiguous(5));
}

void generate_file_type(const std::string& path, const std::string& type_name, const char* mustache_template,
ankerl::nanobench::Bench const& bench, std::filesystem::path template_path)
{
template_path = std::filesystem::path(path).append("mustache-template." + type_name);

if (!parser::file_exists(template_path.string()))
throw std::runtime_error("Mustache template file does not exist");

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

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

ankerl::nanobench::render(template_path.string().c_str(), bench, render_out);
}

void generate_file_type(const std::string& path, const std::string& type_name, const char* mustache_template,
ankerl::nanobench::Bench const& bench)
{
generate_file_type(path, type_name, mustache_template, bench, parser::current_path_string);
}

int main(const int argc, const char* argv[])
{
if (argc < 2)
{
std::cerr << "Please provide a file path to the config file" << std::endl;
return 0;
}
const std::string file_path = argv[1];
const std::string out_path = argc > 2 ? argv[2] : std::filesystem::current_path().string();
try
{
const std::vector<parser::parsed_trajectory> trajectories = parser::parse_config(file_path, ' ');

ankerl::nanobench::Bench bench;

bench.performanceCounters(true);
bench.title("benchmark");

std::cout << "Benchmarking..." << std::endl;
for (const auto& parsed_trajectory : trajectories)
{
bench.warmup(10).minEpochIterations(100).run(parsed_trajectory.name, [&]
{
ankerl::nanobench::doNotOptimizeAway(parsed_trajectory.run_trajectory_function());
});
}

generate_file_type(out_path, "json", ankerl::nanobench::templates::json(), bench, out_path);

generate_file_type(out_path, "html", ankerl::nanobench::templates::htmlBoxplot(), bench, out_path);

generate_file_type(out_path, "csv", ankerl::nanobench::templates::csv(), bench, out_path);
}
catch (const std::exception& e)
{
std::cout << e.what() << std::endl;
return 1;
}
return 0;
}
34 changes: 34 additions & 0 deletions Trajectory-Hotspots-Benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Project name
project(Trajectory-Hotspots-Benchmark)

include(FetchContent)

FetchContent_Declare(

nanobench

GIT_REPOSITORY https://github.com/martinus/nanobench.git

GIT_TAG v4.1.0

GIT_SHALLOW TRUE)


FetchContent_MakeAvailable(nanobench)

# Recursive globbing to find all files in a directory
file(
GLOB_RECURSE cppfiles
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/*.h
)

# Create the executable target and specify the source files
add_executable(${PROJECT_NAME} ${cppfiles})

# Link necessary libraries and include directories
target_link_libraries(${PROJECT_NAME} PRIVATE Trajectory-Hotspots-Visualization_lib)
target_link_libraries(${PROJECT_NAME} PRIVATE Trajectory-Hotspots-Parser_lib)
target_link_libraries(${PROJECT_NAME} PRIVATE nanobench)

target_precompile_headers(${PROJECT_NAME} PRIVATE pch.h)
28 changes: 28 additions & 0 deletions Trajectory-Hotspots-Benchmark/pch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Created by Bardio - NHL_STENDEN
//
#pragma once

#include <string>
#include <vector>
#include <filesystem>
#include <iostream>

//nanobench
#include <nanobench.h>

#include <Trajectory-Hotspots-Visualization/pch.h>
#include <Trajectory_Hotspots/pch.h>
#include <Trajectory_Hotspots/vec2.h>
#include <Trajectory_Hotspots/Float.h>
#include <Trajectory_Hotspots/AABB.h>
#include <Trajectory_Hotspots/segment.h>
#include <Trajectory_Hotspots/segment_search_tree.h>
#include <Trajectory_Hotspots/trapezoidal_map.h>
#include <Trajectory_Hotspots/trajectory.h>

//parser
#include <Trajectory-Hotspots-Parser/file_parser.h>

#include "Window/window.h"
#include "Trajectory-Hotspots-Wrappers/drawable_trajectory.h"
17 changes: 17 additions & 0 deletions Trajectory-Hotspots-Parser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Project name
project(Trajectory-Hotspots-Parser)

# Recursive globbing to find all files in a directory
file(
GLOB_RECURSE cppfiles
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/*.h
)

# Create the library target and specify the source files
add_library(${PROJECT_NAME}_lib ${cppfiles} ${TRAJECTORY_HOTSPOTS_PACKAGE_CPP_FILES} ${TRAJECTORY_HOTSPOTS_PACKAGE_CPP_FILES} )
target_include_directories(${PROJECT_NAME}_lib
PUBLIC
..
${PROJECT_SOURCE_DIR}/
${TRAJECTORY_HOTSPOTS_SOLUTION_DIR}/)
Loading

0 comments on commit 0fc82d3

Please sign in to comment.