Skip to content

Commit

Permalink
Merge pull request #62 from tataratat/lets-inherit
Browse files Browse the repository at this point in the history
dynamic spline core
  • Loading branch information
j042 committed Nov 23, 2022
2 parents 122c5f9 + 5b0d4a0 commit bf5bb5e
Show file tree
Hide file tree
Showing 128 changed files with 9,924 additions and 7,426 deletions.
49 changes: 14 additions & 35 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,18 @@
### First Step
- Assign Labels : Type of PR (Bug/Feature), Scope (tiny, small,... huge)
- Request a reviewer or assign tasks
- Then start to fill the following form:
# Overview
Description

# Addressed issues
* the list
* of issues
* e.g. #200
## Addressed issues
* Issues addressed

# Description
A more detailed
description of your
changes goes here
## Showcase
A short / one-liner example to highlight the (new) feature
```
import splinepy
## Subsection
more details

### Subsubsection 2
more and more details

## New Feature Showcase
If applicable, a short / one-liner example to highlight the new feature


# Check list
### Test documentation
* [ ] Build `--minimal`
* [ ] Build
* [ ] Executed Tests
* [ ] Executed Examples

### Documentation of changes and theory
* [ ] I have updated the relevant documentations, as far as necessary.

### Style guide compliance
* [ ] Edited `C++` files formatted with clang-format (`14.x.x`+)
* [ ] Edited Python files formatted to style guide from PEP8
new, feature = splinepy.tataratat()
```

## Checklists
* [ ] Documentations are up-to-date.
* [ ] Added example(s)
* [ ] Added test(s)
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Builds and runs tests

on:
pull_request
push

permissions:
contents: read
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/test_full.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Builds and runs tests

on:
pull_request

permissions:
contents: read

jobs:
build_and_tests:

runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.9]
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: install dependencies
run: pip install numpy pytest

- name: build splinepy linux
if: matrix.os == 'ubuntu-latest'
run: CC=gcc-10 CXX=g++-10 python3 setup.py install

- name: build splinepy macos
if: matrix.os == 'macos-latest'
run: python3 setup.py install

- name: test
run: pytest tests
40 changes: 33 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,36 @@ cmake_minimum_required(VERSION 3.12.0)

project(splinepy VERSION 0.0.2 LANGUAGES CXX)

# build options
option(SPLINEPY_COMPILE_SPLINELIB "Compile splinelib together." ON)
option(VERBOSE_MAKE "Verbose `make` output." OFF)
option(MINIMAL "Compile a minimal set of splines." OFF)
option(SPLINEPY_VERBOSE_MAKE
"Verbose `make` output. Alias to CMAKE_VERBOSE_MAKEFILE" OFF)
option(SPLINEPY_MORE "Compile a full set of splines." OFF)
option(SPLINEPY_BUILD_SHARED "build shared library for splinepy" OFF)
option(SPLINEPY_COMPILE_PYTHON "Compile python module." ON)
option(SPLINEPY_ENABLE_WARNINGS "Add warning flags" OFF)


# config
set(exe_dest "bin")
set(incl_dest "include")
set(lib_dest "lib")
set(cfg_dest "${lib_dest}/cmake/${PROJECT_NAME}")
set(gen_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(version_config "${gen_dir}/${PROJECT_NAME}ConfigVersion.cmake")
set(project_config "${gen_dir}/${PROJECT_NAME}Config.cmake")
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")


# global flags
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
set(SPLINEPY_FLAGS -fPIC)
set(SPLINEPY_OPTIMIZATION_FLAGS -O3)
set(SPLINEPY_OPTIMIZATION_FLAGS $<$<NOT:$<CONFIG:Debug>>:-O3>)
set(SPLINEPY_DEFS)

# compiler specific flags
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
list(APPEND SPLINEPY_OPTIMIZATION_FLAGS -ffast-math)
set(SPLINEPY_WARNING_FLAGS
Expand All @@ -20,18 +41,23 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-Wall -Wextra -Wmost -Wextra -Wpedantic -Wunreachable-code
-Wshadow -Wfloat-equal -Weffc++ -Wno-unused-parameter
-Wno-unused-variable)
else()
message(WARNING
"Unsupported compiler."
"splinepy is tested with GNU and Clang.")
endif()

if(SPLINEPY_ENABLE_WARNINGS)
set(SPLINEPY_FLAGS ${SPLINEPY_FLAGS} ${SPLINEPY_WARNING_FLAGS})
endif()

set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
set(CMAKE_CXX_STANDARD 20)

if(VERBOSE_MAKE)
if(SPLINEPY_VERBOSE_MAKE)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()

if(SPLINEPY_MORE)
set(SPLINEPY_DEFS ${SPLINEPY_DEFS} SPLINEPY_MORE)
endif(SPLINEPY_MORE)

add_subdirectory(third_party)
add_subdirectory(cpp/splinepy)
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ Followings are some preferences:

We are aware that there are inconsistency. However, it will be updated! And new implementations from now on will follow the preferences above.


### Automatic formatting / style check
gustaf uses combination of [yapf](https://github.com/google/yapf) and [autopep8](https://github.com/hhatto/autopep8) for automatic formatting. Then [flake8](https://github.com/pycqa/flake8) to double check everything.

To check the format and style of your code use the following commands:
```bash
pip install yapf autopep8 flake8
cd <splinepy-root>
yapf -i -r splinepy examples tests
autopep8 --select=W291,W292,W293,W504,E265,E501,E711,E722 -r -i --aggressive splinepy examples tests
flake8 splinepy examples tests
```

## Pull request suggessions
Followings are gentle suggestions for PRs, so that the pre-alpha phase can end as soon as possible:
- small, separable features
Expand Down
14 changes: 13 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 j042
Copyright (c) 2021 Jaewook Lee

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -19,3 +19,15 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


splinepy/utils/data.py:TrackedArray, make_tracked_array
The MIT License (MIT)

Copyright (c) 2019 Michael Dawson-Haggerty

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4 changes: 4 additions & 0 deletions cmake/config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
check_required_components("@PROJECT_NAME@")
113 changes: 93 additions & 20 deletions cpp/splinepy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,98 @@
# build fitting first - currently very independent
add_subdirectory(fitting)


## create splinepy target - enables cpp standalone use
# define srcs
set(SPLINEPY_SRCS
${PROJECT_SOURCE_DIR}/cpp/splinepy/splines/create_bezier.cpp
${PROJECT_SOURCE_DIR}/cpp/splinepy/splines/create_rational_bezier.cpp
${PROJECT_SOURCE_DIR}/cpp/splinepy/splines/create_bspline.cpp
${PROJECT_SOURCE_DIR}/cpp/splinepy/splines/create_nurbs.cpp
)


# target
if(SPLINEPY_BUILD_SHARED)
add_library(splinepy SHARED ${SPLINEPY_SRCS})
else()
add_library(splinepy STATIC ${SPLINEPY_SRCS})
endif(SPLINEPY_BUILD_SHARED)
# alias for convenience
add_library(splinepy::splinepy ALIAS splinepy)


# include
target_include_directories(splinepy
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/cpp>
$<INSTALL_INTERFACE:${incl_dest}>)


# link
target_link_libraries(splinepy
PUBLIC
fitting
bezman
napf
SplineLib::splines
SplineLib::input_output)


# flags
target_compile_options(splinepy
PRIVATE
${SPLINEPY_FLAGS}
${SPLINEPY_OPTIMIZATION_FLAGS})


# defs
target_compile_definitions(splinepy
PRIVATE
${SPLINEPY_DEFS})

# features
target_compile_features(splinepy
PUBLIC
cxx_std_17)

# python?
if(SPLINEPY_COMPILE_PYTHON)
add_subdirectory(py)
else()
# make Py<spline-class> available
add_library(splinepy INTERFACE)
add_library(splinepy::splinepy ALIAS splinepy)

# include
target_include_directories(splinepy
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/cpp>)
#$<INSTALL_INTERFACE:${incl_dest}>

# link
target_link_libraries(splinepy
INTERFACE
pybind11::headers
fitting
bezman
napf
SplineLib::splines
SplineLib::input_output)
endif()


# cmake config files
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${version_config}" COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${cfg_dest}"
)


# install
install(
TARGETS splinepy
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION ${lib_dest}
ARCHIVE DESTINATION ${lib_dest}
INCLUDES DESTINATION "${incl_dest}"
)
install(
FILES "${project_config}" "${version_config}"
DESTINATION "${cfg_dest}"
)
install(
EXPORT "${TARGETS_EXPORT_NAME}"
NAMESPACE "${namespace}"
DESTINATION "${cfg_dest}"
)
# .hpp files - keep tree
install(DIRECTORY "${PROJECT_SOURCE_DIR}/cpp/splinepy"
DESTINATION ${incl_dest} # target directory
FILES_MATCHING PATTERN "*.hpp"
)
17 changes: 16 additions & 1 deletion cpp/splinepy/fitting/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
set(SRCS_FITTING fitting.cpp)

add_library(fitting OBJECT ${SRCS_FITTING})
if(SPLINEPY_BUILD_SHARED)
add_library(fitting SHARED ${SRCS_FITTING})
else()
add_library(fitting STATIC ${SRCS_FITTING})
endif()
target_include_directories(fitting PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# 11 is enough, but 17 allows nested namespace..
target_compile_features(fitting PUBLIC cxx_std_17)

target_compile_options(fitting PRIVATE ${SPLINEPY_FLAGS})
if(CMAKE_BUILD_TYPE MATCHES Release)
target_compile_options(fitting PRIVATE ${SPLINEPY_OPTIMIZAION_FLAGS})
endif()

install(
TARGETS fitting
EXPORT ${TARGETS_EXPORT_NAME}
LIBRARY DESTINATION ${lib_dest}
LIBRARY DESTINATION ${lib_dest}
INCLUDES DESTINATION ${incl_dest}
)
Loading

0 comments on commit bf5bb5e

Please sign in to comment.