Skip to content

Commit

Permalink
Merge pull request #7 from andreacasalino/Refactoring
Browse files Browse the repository at this point in the history
refactoring
  • Loading branch information
andreacasalino committed Apr 20, 2024
2 parents 8166dfb + 2e2018f commit 15c9837
Show file tree
Hide file tree
Showing 53 changed files with 1,659 additions and 1,644 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/runTests.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Unit Tests

on:
push:
branches:
Expand All @@ -14,22 +16,31 @@ jobs:
include:
- name: ubuntu-gcc
os: ubuntu-latest
compiler_opt: "-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -G \"Unix Makefiles\""
compiler_opt: "-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++"
build_system: '-G Ninja'
- name: ubuntu-clang
os: ubuntu-latest
compiler_opt: "-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G \"Unix Makefiles\""
compiler_opt: "-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++"
build_system: '-G Ninja'
- name: windows-VS
os: windows-latest
compiler_opt: ""
build_system: ''

runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2.0.0
- name: Checkout submodules
run: git submodule update --init --recursive
- name: show HEAD
run: git rev-parse HEAD
- name: Install openMp
if: matrix.name == 'ubuntu-clang'
run: sudo apt-get update; sudo apt-get install -y libomp5 libomp-dev
- name: Install Ninja
if: matrix.build_system == '-G Ninja'
uses: seanmiddleditch/gha-setup-ninja@master
- name: CMake configure
run: cmake -B./build -DCMAKE_INSTALL_PREFIX:STRING=./artifacts/ -DBUILD_GJK_EPA_TESTS=ON -DCMAKE_CONFIGURATION_TYPES="Release" -DCMAKE_BUILD_TYPE:STRING=Release ${{ matrix.compiler_opt }}
run: cmake -B./build -DCMAKE_INSTALL_PREFIX:STRING=./artifacts/ -DBUILD_GJK_EPA_SAMPLES=OFF -DBUILD_GJK_EPA_TESTS=ON -DCMAKE_CONFIGURATION_TYPES="Release" -DCMAKE_BUILD_TYPE:STRING=Release ${{ matrix.build_system }} ${{ matrix.compiler_opt }}
- name: Build
run: cmake --build ./build --config Release
- name: Install
Expand All @@ -39,4 +50,4 @@ jobs:
- uses: actions/upload-artifact@v2
with:
path: artifacts
name: ${{ matrix.name }}
name: ${{ matrix.name }}
17 changes: 8 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# include cmake custom functions
set(WITH_SOURCE_TREE ON)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GroupSources.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/AutoCollect.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/MakeLibrary.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FetchDependency.cmake)

option(GJK_EPA_DIAGNOSTIC "Diagnostic log enabled (ON) or disabled (OFF)" OFF)
option(BUILD_GJK_EPA_SAMPLES "Build the samples showing how to use the package" ON)
option(BUILD_GJK_EPA_TESTS "" OFF)

add_subdirectory(src)

option(BUILD_GJK_EPA_SAMPLES "Build the samples showing how to use the package" ON)
if(BUILD_GJK_EPA_TESTS OR BUILD_GJK_EPA_SAMPLES)
add_subdirectory(utils)
endif()

if(BUILD_GJK_EPA_SAMPLES)
project(Flexible-GJK-and-EPA-Samples)
add_subdirectory(samples)
endif()

option(BUILD_GJK_EPA_TESTS "" OFF)
if(BUILD_GJK_EPA_TESTS)
project(Flexible-GJK-and-EPA-Tests)
add_subdirectory(tests)
endif()
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2024 Andrea Casalino

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ They are used a lot in the domain of computer graphics, to:

![Sample](sample.png)

With respect to other similar solvers, the one proposed allows to easily:
With respect to similar implementations, this one allows to easily:

* account for roto-traslation for the shapes, without explicitly computes the vertices coordinates after the roto-traslation
* possibility to use a template container to describe your the convex shape, using the 3D coordinate representation
* account for roto-traslation, without explicitly computes the vertices coordinates after the roto-traslation
* use a template container to describe your the convex shape, using the 3D coordinate representation
of your favourite algebra library ([Eigen](https://eigen.tuxfamily.org/dox/group__TutorialMatrixArithmetic.html), etc...)

Before diving into the code, it is strongly recomended to have a look at the [documentation](./doc/GJK_EPA.pdf).
Expand Down Expand Up @@ -102,9 +102,9 @@ if (result_meaning) {
## SAMPLES
The relevant code is contained in ./src, while ./Samples contains samples showing how to use this library.
In particular, after running the samples, some .json files will be produced storing the results.
A python script can be later used to visualize the results.
The relevant code is contained in the [src](./src) folder, while [samples](./samples) contains examples showing how to use this library.
In particular, after running each sample, some .json files will be produced storing the results.
A python script can be later used to visualize the results. The syntax to use will appear in the console after computing each individual result.
## CMAKE SUPPORT
Expand Down
82 changes: 0 additions & 82 deletions cmake/AutoCollect.cmake

This file was deleted.

10 changes: 10 additions & 0 deletions cmake/FetchDependency.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function(FetchDep URL TAG MSG CMAKE_NAME)
message(STATUS ${MSG})
include(FetchContent)
FetchContent_Declare(
${CMAKE_NAME}
GIT_REPOSITORY ${URL}
GIT_TAG ${TAG}
)
FetchContent_MakeAvailable(${CMAKE_NAME})
endfunction()
49 changes: 0 additions & 49 deletions cmake/GroupSources.cmake

This file was deleted.

22 changes: 0 additions & 22 deletions cmake/MakeLibrary.cmake

This file was deleted.

23 changes: 2 additions & 21 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
message(STATUS "fetching nlohmann json for logging samples results")
include(FetchContent)
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG 7194245a314d142a5560f6906a87f7c67ebbcf2e
)
FetchContent_MakeAvailable(nlohmann_json)

macro(COPY_SCRIPT TARGET SCRIPT)
add_custom_command(TARGET ${TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${SCRIPT}.py ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT}.py)
endmacro()

macro(MAKE_SAMPLE NAME)
add_executable(${NAME} ${NAME}.cpp
Utils.h Utils.cpp
Logger.h Logger.cpp
)
add_executable(${NAME} ${NAME}.cpp)
target_link_libraries(${NAME} PUBLIC
GJK-EPA
nlohmann_json::nlohmann_json
GJK-EPA-Utils
)

COPY_SCRIPT(${NAME} Visualize)
endmacro()

MAKE_SAMPLE(Readme)
Expand Down
Loading

0 comments on commit 15c9837

Please sign in to comment.