Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LICENSE + CI sript updated + general code improvements #7

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/workflows/runTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,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_QUICK_HULL_TESTS=ON -DCMAKE_CONFIGURATION_TYPES="Release" -DCMAKE_BUILD_TYPE:STRING=Release ${{ matrix.compiler_opt }}
run: cmake -B./build -DCMAKE_INSTALL_PREFIX:STRING=./artifacts/ -DFast-Quick-Hull-BUILD_SAMPLES=OFF -DFast-Quick-Hull-BUILD_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 Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin
build
.vscode
TODO
20 changes: 13 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GroupSources.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/AutoCollect.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/MakeLibrary.cmake)

option(Fast-Quick-Hull-THREAD_POOL_OPT "thread pool enabled (ON) or disabled (OFF)" ON)
project(Fast-Quick-Hull-Prj)
add_subdirectory(src)

option(Fast-Quick-Hull-THREAD_POOL_OPT "thread pool enabled (ON) or disabled (OFF)" ON)
option(Fast-Quick-Hull-BUILD_SAMPLES "Build the samples showing how to use the package" ON)
option(Fast-Quick-Hull-BUILD_TESTS "" OFF)

find_package(Python3 REQUIRED COMPONENTS Interpreter Development)

add_subdirectory(src)

if(Fast-Quick-Hull-BUILD_TESTS OR Fast-Quick-Hull-BUILD_SAMPLES)
add_subdirectory(utils)
endif()

if(Fast-Quick-Hull-BUILD_SAMPLES)
project(Fast-Quick-Hull-Samples)
add_subdirectory(samples)
endif()

option(BUILD_QUICK_HULL_TESTS "" OFF)
if(BUILD_QUICK_HULL_TESTS)
project(Fast-Quick-Hull-Tests)
if(Fast-Quick-Hull-BUILD_TESTS)
add_subdirectory(tests)
endif()
endif()
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

34 changes: 9 additions & 25 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
add_library(Utils
${CMAKE_CURRENT_SOURCE_DIR}/utils/ImporterSTL.h
${CMAKE_CURRENT_SOURCE_DIR}/utils/ImporterSTL.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utils/Logger.h
${CMAKE_CURRENT_SOURCE_DIR}/utils/Logger.cpp
)

target_include_directories(Utils PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/utils
)

target_link_libraries(Utils PUBLIC
Fast-Quick-Hull
)

target_compile_definitions(Utils PRIVATE
-D ANIMALS_FOLDER="${CMAKE_CURRENT_SOURCE_DIR}/Animals/"
)

macro(MAKE_SAMPLE NAME)
add_executable(${NAME} ${NAME}.cpp)
target_link_libraries(${NAME} PUBLIC
Utils
)
add_custom_command(TARGET ${NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Plotter.py ${CMAKE_CURRENT_BINARY_DIR}/Plotter.py)
add_executable(${NAME} ${NAME}.cpp)
target_link_libraries(${NAME} PUBLIC
QuickHullUtils
)
add_custom_command(TARGET ${NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Plotter.py ${CMAKE_CURRENT_BINARY_DIR}/Plotter.py)
target_compile_definitions(${NAME} PRIVATE
-D PYTHON_CMD="${Python3_EXECUTABLE}"
)
endmacro()


Expand Down
16 changes: 10 additions & 6 deletions samples/Plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@

from mpl_toolkits.mplot3d.art3d import Poly3DCollection
import matplotlib.pyplot as plt
import json
import sys


import json, sys, os

def get_json_from_file(name):
with open(name) as json_file:
Expand Down Expand Up @@ -77,10 +74,17 @@ def plot_STL(file, ax):
scale = your_mesh.points.flatten()
ax.auto_scale_xyz(scale, scale, scale)

def getPathName(filename):
base = os.path.basename(filename)
sep = base.find('.')
return base[0:sep]

logName = sys.argv[1]
stlLocation = sys.argv[2]
fig = plt.figure()
ax = fig.gca(projection='3d')
plot_CH(logName, 'green', ax)
plot_STL(stlLocation, ax)
if 2 < len(sys.argv):
stlLocation = sys.argv[2]
plot_STL(stlLocation, ax)
ax.set_title(getPathName(logName))
plt.show()
73 changes: 0 additions & 73 deletions samples/PlotterOld.py

This file was deleted.

7 changes: 4 additions & 3 deletions samples/Sample01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* report any bug to andrecasa91@gmail.com.
**/

#include <Logger.h>
#include <Utils.h>

#include <iostream>

int main() {
Expand All @@ -23,8 +24,8 @@ int main() {
logConvexhull(convex_hull_facets_incidences, convex_hull_normals, cloud,
"Sample01.json");

std::cout << "call 'python Plotter.py Sample01.json' to see results"
<< std::endl;
std::cout << "call '" << PYTHON_CMD
<< " Plotter.py Sample01.json' to see results" << std::endl;

return EXIT_SUCCESS;
}
16 changes: 8 additions & 8 deletions samples/Sample02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* report any bug to andrecasa91@gmail.com.
**/

#include <ImporterSTL.h>
#include <Utils.h>

#include <iostream>

int main() {
Expand All @@ -22,12 +23,11 @@ int main() {
stlNames.push_back("Snake"); // 3691 vertices
stlNames.push_back("Eagle"); // 4271 vertices

for (auto it = stlNames.begin(); it != stlNames.end(); ++it) {
std::cout << "computing convex hull of " << *it;
for (const auto &name : stlNames) {
std::cout << "computing convex hull of " << name;

// import the stl describing the shape of this animal
const std::string stl_location = getAnimalSTLLocation(*it);
const auto vertices_cloud = importSTL(stl_location);
const auto vertices_cloud = importAnimalStl(name);

// compute the convex hull of of the imported vertices cloud
std::vector<hull::Coordinate> convex_hull_normals;
Expand All @@ -38,10 +38,10 @@ int main() {
// Log the result into a textual file, which can be visualized
// running the python script Plotter.py
logConvexhull(convex_hull_facets_incidences, convex_hull_normals,
vertices_cloud, *it + ".json");
vertices_cloud, name + ".json");
std::cout << " done" << std::endl;
std::cout << "call 'python Plotter.py " << *it << ".json " << stl_location
<< "' to see results" << std::endl
std::cout << "call '" << PYTHON_CMD << " Plotter.py " << name << ".json "
<< getAnimalStlPath(name) << "' to see results" << std::endl
<< std::endl;
}

Expand Down
72 changes: 0 additions & 72 deletions samples/utils/ImporterSTL.cpp

This file was deleted.

17 changes: 0 additions & 17 deletions samples/utils/ImporterSTL.h

This file was deleted.

Loading
Loading