diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml deleted file mode 100644 index 82e7db7f..00000000 --- a/.github/workflows/CD.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: test_github_actions -on: [push] -jobs: - build: - strategy: - matrix: - include: - - os: windows-latest - extension: bat - name: windows - - os: ubuntu-latest - extension: sh - name: linux - - os: macos-latest - extension: osx - name: macOS - runs-on: ${{ matrix.os }} - steps: - - name: checkout - uses: actions/checkout@v2 - with: - submodules: true - - name: setup python - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - name: build - run: ./build_mtree.${{ matrix.extension }} - - name: package addon - run: python .github/scripts/setup_addon.py - - name: upload zipped addon - uses: actions/upload-artifact@v2 - with: - name: modular_tree_${{ matrix.name }} - path: tmp/*.zip - - release: - needs: build - runs-on: ubuntu-latest - env: - STATUS: ${{ !endsWith(github.ref, 'master') && 'alpha' || '' }} - steps: - - name: checkout - uses: actions/checkout@v2 - - name: Download build artifacts - uses: actions/download-artifact@v2 - - name: Display structure of downloaded files - run: ls -R - - name: Get version - id: vars - run: echo ::set-output name=version::$(cat VERSION) - - name: Update release - uses: johnwbyrd/update-release@v1.0.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - files: ./modular_tree_windows/modular_tree_${{ steps.vars.outputs.version }}_windows.zip ./modular_tree_linux/modular_tree_${{ steps.vars.outputs.version }}_linux.zip ./modular_tree_macOS/modular_tree_${{ steps.vars.outputs.version }}_macOS.zip - release: Release V${{ steps.vars.outputs.version }}${{ env.STATUS }} - tag: ${{ steps.vars.outputs.version }}${{ env.STATUS }} - message: V${{ steps.vars.outputs.version }} - body: '' - diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml new file mode 100644 index 00000000..cb2ca013 --- /dev/null +++ b/.github/workflows/build_release.yml @@ -0,0 +1,62 @@ +name: build +on: + push: + tags: + - '**' +jobs: + build: + strategy: + matrix: + include: + - os: windows-latest + extension: bat + name: windows + - os: ubuntu-latest + extension: sh + name: linux + - os: macos-latest + extension: osx + name: macOS + runs-on: ${{ matrix.os }} + steps: + - name: checkout + uses: actions/checkout@v4 + with: + submodules: true + - name: setup python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + - name: generate cmake files + run: cmake -S src -B build + - name: build + run: cmake --build build + + - name: upload addon + uses: actions/upload-artifact@v4 + with: + name: modular_tree_${{ matrix.name }} + path: addon + + release: + needs: build + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Download build artifacts + uses: actions/download-artifact@v4 + - name: Display structure of downloaded files + run: ls -R + - name: Zip artifacts + run: | + for dir in modular_tree_*; do + if [ -d "$dir" ]; then + zip -r "${dir}.zip" "${dir}" + fi + done + - name: Create release + uses: softprops/action-gh-release@v2 + if: github.ref_type == 'tag' + with: + files: modular_tree_*.zip diff --git a/.gitignore b/.gitignore index f52089dc..090b8443 100644 --- a/.gitignore +++ b/.gitignore @@ -1,42 +1,13 @@ -*/build/ -*__pycache__/ -*Debug/ -m_tree/m_tree.egg-info/ - - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app -*.pyd -*.pdb -**/.vscode/ -m_tree.egg-info/ -*.exp -*/binaries/ -tmp/* +# IDEs +**/.idea +**/.vscode +**/.vs + +# Misc +**/__pycache__ + +# Build +build +addon/lib/*.pyd +addon/lib/*.pdb +*.zip \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 496303df..00000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "m_tree/dependencies/vcpkg"] - path = m_tree/dependencies/vcpkg - url = https://github.com/microsoft/vcpkg.git -[submodule "m_tree/dependencies/pybind11"] - path = m_tree/dependencies/pybind11 - url = https://github.com/pybind/pybind11.git diff --git a/README.md b/README.md index 06a3be8e..ebc0a7e9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +# Note! +This repository is a fork that supports 4.2+ Blender versions. It is built with Python 3.11, which is currently bundled into Blender. + +It has changes to the build process, making it easier to update in the future. + + # Mtree Mtree (previously Modular Tree) is a library for making 3d trees. It comes as an addon for blender but the c++ library can be used separately. @@ -14,19 +20,21 @@ Mtree (previously Modular Tree) is a library for making 3d trees. It comes as an ## Installation (blender addon) -Go to the [latest release]. Under `Assets`, select the version corresponding to your os.\ -Follow the [blender documentation][blender addon doc] to install the downloaded addon. +Go to the [latest release]. Under `Assets`, select the version corresponding to your os. + +Follow the [Blender documentation][blender addon doc] to install the downloaded addon. ## Development ### Dependencies - [Cmake] -- Blender 2.93 or higher (if you want to to develop the blender addon) +- Blender 4.2 or higher ### Installation -1. Clone the repository reccursively `git clone --recursive https://github.com/MaximeHerpin/modular_tree` -2. Execute the `build_mtree` bash script corresponding to your platform. -3. If all went well, a cmake project has been generated under `mtree/build`. -4. You can bundle the blender addon by calling the [addon bundling script]. +1. Clone the repository reccursively `git clone https://github.com/ethanporcaro/modular_tree_py311` +2. Generate Cmake files with `cmake -S src -B build` +3. Build the project with `cmake --build build` +3. If all went well, your addon will be generated and zipped to `modular_tree_{platform}.zip` where `{platform}` is the name of your operating system. + ### Usage A `Tree` is generated by executing a succession of `TreeFunction`. When being executed, a `TreeFunction` modifies the structure of the tree, and then calls children functions recursively.\ @@ -60,7 +68,7 @@ trunk->add_child(branches_dead); Tree tree(trunk); ``` ## License -Blender being under the GPL license, the blender addon (all files under `python_classes` as well as `__init__.py`) is under the [GPLv3] license.\ +Blender being under the GPL license, the blender addon (all files under `addon`) is under the [GPLv3] license.\ The Mtree library is under the [MIT] license. diff --git a/VERSION b/VERSION index 9a186cb0..f95f2082 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4_0_2 \ No newline at end of file +5_0_0 \ No newline at end of file diff --git a/__init__.py b/addon/__init__.py similarity index 62% rename from __init__.py rename to addon/__init__.py index ab130856..67ad04fd 100644 --- a/__init__.py +++ b/addon/__init__.py @@ -11,29 +11,26 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import os -from pathlib import Path -from . import python_classes - +from . import nodes +from . import operators bl_info = { - "name" : "Modular Tree", - "author" : "Maxime", - "description" : "create trees", - "blender" : (2, 83, 0), - "version" : (4, 0, 2), - "location" : "", - "warning" : "", - "category" : "Generic" + "name": "Modular Tree", + "author": "Maxime", + "description": "create trees", + "blender": (4, 4, 3), + "version": (5, 0, 0), + "location": "", + "warning": "", + "category": "Generic" } -# auto_load.init() - def register(): - python_classes.register() - # auto_load.register() + operators.register() + nodes.register() + def unregister(): - python_classes.unregister() - # auto_load.unregister() + operators.unregister() + nodes.unregister() \ No newline at end of file diff --git a/python_classes/resources/__init__.py b/addon/lib/__init__.py similarity index 100% rename from python_classes/resources/__init__.py rename to addon/lib/__init__.py diff --git a/python_classes/nodes/__init__.py b/addon/nodes/__init__.py similarity index 100% rename from python_classes/nodes/__init__.py rename to addon/nodes/__init__.py diff --git a/python_classes/nodes/base_types/__init__.py b/addon/nodes/base_types/__init__.py similarity index 100% rename from python_classes/nodes/base_types/__init__.py rename to addon/nodes/base_types/__init__.py diff --git a/python_classes/nodes/base_types/node.py b/addon/nodes/base_types/node.py similarity index 100% rename from python_classes/nodes/base_types/node.py rename to addon/nodes/base_types/node.py diff --git a/python_classes/nodes/base_types/node_tree.py b/addon/nodes/base_types/node_tree.py similarity index 100% rename from python_classes/nodes/base_types/node_tree.py rename to addon/nodes/base_types/node_tree.py diff --git a/python_classes/nodes/base_types/socket.py b/addon/nodes/base_types/socket.py similarity index 100% rename from python_classes/nodes/base_types/socket.py rename to addon/nodes/base_types/socket.py diff --git a/python_classes/nodes/node_categories.py b/addon/nodes/node_categories.py similarity index 100% rename from python_classes/nodes/node_categories.py rename to addon/nodes/node_categories.py diff --git a/python_classes/nodes/properties/__init__.py b/addon/nodes/properties/__init__.py similarity index 100% rename from python_classes/nodes/properties/__init__.py rename to addon/nodes/properties/__init__.py diff --git a/python_classes/nodes/properties/ramp_property.py b/addon/nodes/properties/ramp_property.py similarity index 90% rename from python_classes/nodes/properties/ramp_property.py rename to addon/nodes/properties/ramp_property.py index b66988e1..0beef230 100644 --- a/python_classes/nodes/properties/ramp_property.py +++ b/addon/nodes/properties/ramp_property.py @@ -1,6 +1,6 @@ import bpy from ..base_types.node import MtreePropertyNode -from ....m_tree import SimpleCurveProperty, PropertyWrapper +from ...lib.m_tree import SimpleCurveProperty, PropertyWrapper class RampPropertyNode(bpy.types.Node, MtreePropertyNode): bl_idname = "mt_RampPropertyNode" diff --git a/python_classes/nodes/properties/random_property.py b/addon/nodes/properties/random_property.py similarity index 89% rename from python_classes/nodes/properties/random_property.py rename to addon/nodes/properties/random_property.py index 50ae2f1f..a150a2c6 100644 --- a/python_classes/nodes/properties/random_property.py +++ b/addon/nodes/properties/random_property.py @@ -1,6 +1,6 @@ import bpy from ..base_types.node import MtreePropertyNode -from ....m_tree import RandomProperty, PropertyWrapper +from ...lib.m_tree import RandomProperty, PropertyWrapper class RandomPropertyNode(bpy.types.Node, MtreePropertyNode): bl_idname = "mt_RandomPropertyNode" diff --git a/python_classes/nodes/sockets/__init__.py b/addon/nodes/sockets/__init__.py similarity index 100% rename from python_classes/nodes/sockets/__init__.py rename to addon/nodes/sockets/__init__.py diff --git a/python_classes/nodes/sockets/float_socket.py b/addon/nodes/sockets/float_socket.py similarity index 100% rename from python_classes/nodes/sockets/float_socket.py rename to addon/nodes/sockets/float_socket.py diff --git a/python_classes/nodes/sockets/int_socket.py b/addon/nodes/sockets/int_socket.py similarity index 100% rename from python_classes/nodes/sockets/int_socket.py rename to addon/nodes/sockets/int_socket.py diff --git a/python_classes/nodes/sockets/property_socket.py b/addon/nodes/sockets/property_socket.py similarity index 94% rename from python_classes/nodes/sockets/property_socket.py rename to addon/nodes/sockets/property_socket.py index d643026a..b98c2191 100644 --- a/python_classes/nodes/sockets/property_socket.py +++ b/addon/nodes/sockets/property_socket.py @@ -1,6 +1,6 @@ import bpy from ..base_types.socket import MtreeSocket -from ....m_tree import ConstantProperty, RandomProperty, PropertyWrapper +from ...lib.m_tree import ConstantProperty, RandomProperty, PropertyWrapper class MtreePropertySocket(bpy.types.NodeSocket, MtreeSocket): bl_idname = 'mt_PropertySocket' diff --git a/python_classes/nodes/sockets/tree_socket.py b/addon/nodes/sockets/tree_socket.py similarity index 100% rename from python_classes/nodes/sockets/tree_socket.py rename to addon/nodes/sockets/tree_socket.py diff --git a/python_classes/nodes/tree_function_nodes/__init__.py b/addon/nodes/tree_function_nodes/__init__.py similarity index 100% rename from python_classes/nodes/tree_function_nodes/__init__.py rename to addon/nodes/tree_function_nodes/__init__.py diff --git a/python_classes/nodes/tree_function_nodes/branch_node.py b/addon/nodes/tree_function_nodes/branch_node.py similarity index 98% rename from python_classes/nodes/tree_function_nodes/branch_node.py rename to addon/nodes/tree_function_nodes/branch_node.py index 92600903..05b59a14 100644 --- a/python_classes/nodes/tree_function_nodes/branch_node.py +++ b/addon/nodes/tree_function_nodes/branch_node.py @@ -1,7 +1,7 @@ from random import randint import bpy from ..base_types.node import MtreeFunctionNode -from ....m_tree import BranchFunction +from ...lib.m_tree import BranchFunction class BranchNode(bpy.types.Node, MtreeFunctionNode): bl_idname = "mt_BranchNode" diff --git a/python_classes/nodes/tree_function_nodes/pipe_radius_node.py b/addon/nodes/tree_function_nodes/pipe_radius_node.py similarity index 94% rename from python_classes/nodes/tree_function_nodes/pipe_radius_node.py rename to addon/nodes/tree_function_nodes/pipe_radius_node.py index 2311ada1..1c8f9fdb 100644 --- a/python_classes/nodes/tree_function_nodes/pipe_radius_node.py +++ b/addon/nodes/tree_function_nodes/pipe_radius_node.py @@ -1,6 +1,6 @@ import bpy from ..base_types.node import MtreeFunctionNode -from ....m_tree import PipeRadiusFunction +from ...lib.m_tree import PipeRadiusFunction class PipeRadiusNode(bpy.types.Node, MtreeFunctionNode): bl_idname = "mt_PipeRadiusNode" diff --git a/python_classes/nodes/tree_function_nodes/tree_mesher_node.py b/addon/nodes/tree_function_nodes/tree_mesher_node.py similarity index 96% rename from python_classes/nodes/tree_function_nodes/tree_mesher_node.py rename to addon/nodes/tree_function_nodes/tree_mesher_node.py index 372bcd04..b48b192a 100644 --- a/python_classes/nodes/tree_function_nodes/tree_mesher_node.py +++ b/addon/nodes/tree_function_nodes/tree_mesher_node.py @@ -1,7 +1,7 @@ import time import numpy as np import bpy -from .... import m_tree +from ...lib import m_tree from ..base_types.node import MtreeNode def on_update_prop(node, context): @@ -103,12 +103,12 @@ def fill_blender_mesh(self, mesh, cpp_mesh): mesh.loops.add(len(faces)) mesh.loops.foreach_set("vertex_index", faces) - loop_start = np.arange(0, len(faces), 4, dtype=np.int) - loop_total = np.ones(len(faces)//4, dtype = np.int)*4 + loop_start = np.arange(0, len(faces), 4, dtype=int) + loop_total = np.ones(len(faces)//4, dtype = int)*4 mesh.polygons.add(len(faces)//4) mesh.polygons.foreach_set("loop_start", loop_start) mesh.polygons.foreach_set("loop_total", loop_total) - mesh.polygons.foreach_set('use_smooth', np.ones(len(faces)//4, dtype=np.bool)) + mesh.polygons.foreach_set('use_smooth', np.ones(len(faces)//4, dtype=bool)) uv_data = cpp_mesh.get_uvs() diff --git a/python_classes/nodes/tree_function_nodes/trunk_node.py b/addon/nodes/tree_function_nodes/trunk_node.py similarity index 97% rename from python_classes/nodes/tree_function_nodes/trunk_node.py rename to addon/nodes/tree_function_nodes/trunk_node.py index 8bc3294e..0178ac97 100644 --- a/python_classes/nodes/tree_function_nodes/trunk_node.py +++ b/addon/nodes/tree_function_nodes/trunk_node.py @@ -1,7 +1,7 @@ from random import randint import bpy from ..base_types.node import MtreeFunctionNode -from ....m_tree import TrunkFunction +from ...lib.m_tree import TrunkFunction class TrunkNode(bpy.types.Node, MtreeFunctionNode): bl_idname = "mt_TrunkNode" diff --git a/python_classes/operators.py b/addon/operators.py similarity index 98% rename from python_classes/operators.py rename to addon/operators.py index 67f156b4..54683a0c 100644 --- a/python_classes/operators.py +++ b/addon/operators.py @@ -6,7 +6,7 @@ import gpu import numpy as np -from .. import m_tree +from .lib import m_tree from .resources.node_groups import distribute_leaves diff --git a/m_tree/source/mesh/VertexGroup.cpp b/addon/resources/__init__.py similarity index 100% rename from m_tree/source/mesh/VertexGroup.cpp rename to addon/resources/__init__.py diff --git a/resources/geo_node/geo_nodes_2_93.blend b/addon/resources/geo_node/geo_nodes.blend similarity index 60% rename from resources/geo_node/geo_nodes_2_93.blend rename to addon/resources/geo_node/geo_nodes.blend index c5351d87..1607baad 100644 Binary files a/resources/geo_node/geo_nodes_2_93.blend and b/addon/resources/geo_node/geo_nodes.blend differ diff --git a/python_classes/resources/node_groups.py b/addon/resources/node_groups.py similarity index 100% rename from python_classes/resources/node_groups.py rename to addon/resources/node_groups.py diff --git a/python_classes/resources/resource_utils.py b/addon/resources/resource_utils.py similarity index 83% rename from python_classes/resources/resource_utils.py rename to addon/resources/resource_utils.py index 5729f2b9..fca6761f 100644 --- a/python_classes/resources/resource_utils.py +++ b/addon/resources/resource_utils.py @@ -2,7 +2,7 @@ from pathlib import Path import bpy -MTREE_RESOURCE_DIR = (Path(__file__).parent.parent.parent / "resources").resolve() +MTREE_RESOURCE_DIR = Path(__file__).parent.resolve() class ResourceUtils: @@ -13,7 +13,7 @@ def append_geo_node(cls, name:str): group = bpy.data.node_groups.get(name, None) if group is None: - directory = os.path.join(cls.geo_nodes_dir, "geo_nodes_2_93.blend", "NodeTree") + directory = os.path.join(cls.geo_nodes_dir, "geo_nodes.blend", "NodeTree") filepath = os.path.join(directory, name) bpy.ops.wm.append(filepath=filepath,filename=name,directory=directory, autoselect=False) group = bpy.data.node_groups[name] diff --git a/m_tree/test.py b/addon/test.py similarity index 74% rename from m_tree/test.py rename to addon/test.py index 7c4d89ee..7db3c7f9 100644 --- a/m_tree/test.py +++ b/addon/test.py @@ -1,9 +1,8 @@ -import m_tree -# import pickle - - +from lib import m_tree tree = m_tree.Tree() trunk_function = m_tree.TrunkFunction() tree.set_trunk_function(trunk_function) +print(tree) + diff --git a/build_mtree.bat b/build_mtree.bat deleted file mode 100644 index 101a92f1..00000000 --- a/build_mtree.bat +++ /dev/null @@ -1,7 +0,0 @@ -py -3.9 m_tree/install.py - -COPY ".\m_tree\binaries\Release\m_tree.cp39-win_amd64.pyd" "./m_tree.cp39-win_amd64.pyd" - -PAUSE - - diff --git a/build_mtree.osx b/build_mtree.osx deleted file mode 100755 index b21881a2..00000000 --- a/build_mtree.osx +++ /dev/null @@ -1,5 +0,0 @@ -python3 m_tree/install.py -cp ./m_tree/binaries/m_tree.cpython-39-darwin.so ./m_tree.cpython-39-darwin.so - - - diff --git a/build_mtree.sh b/build_mtree.sh deleted file mode 100755 index e25604fc..00000000 --- a/build_mtree.sh +++ /dev/null @@ -1,5 +0,0 @@ -python3 m_tree/install.py -cp ./m_tree/binaries/m_tree.cpython-39-x86_64-linux-gnu.so ./m_tree.cpython-39-x86_64-linux-gnu.so - - - diff --git a/m_tree/CMakeLists.txt b/m_tree/CMakeLists.txt deleted file mode 100644 index 7101dfd4..00000000 --- a/m_tree/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - - -set(CMAKE_TOOLCHAIN_FILE ./dependencies/vcpkg/scripts/buildsystems/vcpkg.cmake) - -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/binaries) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/binaries) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/binaries) - -project(m_tree) - - -add_subdirectory(./source) -add_subdirectory(./python_bindings) -add_subdirectory(./tests) - diff --git a/m_tree/dependencies/pybind11 b/m_tree/dependencies/pybind11 deleted file mode 160000 index e25b1505..00000000 --- a/m_tree/dependencies/pybind11 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e25b1505dbca042289c4076141092cff49b0b96b diff --git a/m_tree/dependencies/vcpkg b/m_tree/dependencies/vcpkg deleted file mode 160000 index 261c458a..00000000 --- a/m_tree/dependencies/vcpkg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 261c458af6e3eed5d099144aff95d2b5035f656b diff --git a/m_tree/install.py b/m_tree/install.py deleted file mode 100644 index d3b71049..00000000 --- a/m_tree/install.py +++ /dev/null @@ -1,58 +0,0 @@ -import os -import re -import sys -import platform -import subprocess - -from distutils.version import LooseVersion - - -VCPKG_PATH = os.path.join(os.path.dirname(__file__), "dependencies", "vcpkg") - -PACKAGES = ["eigen3"] - - -def install(): - try: - out = subprocess.check_output(['cmake', '--version']) - except OSError: - raise RuntimeError("CMake must be installed") - - if platform.system() == "Windows": - cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', out.decode()).group(1)) - if cmake_version < '3.1.0': - raise RuntimeError("CMake >= 3.1.0 is required on Windows") - - install_vcpkg_dependencies() - build() - - -def install_vcpkg_dependencies(): - print(f"system is {platform.system()}") - if platform.system() == "Windows": - subprocess.run(f"bootstrap-vcpkg.bat", cwd=VCPKG_PATH, shell=True) - else: - subprocess.run(os.path.join(VCPKG_PATH, "bootstrap-vcpkg.sh")) - for package in PACKAGES: - print(f"installing {package}") - if platform.system() == "Windows": - triplet = ":x64-windows" - elif platform.system() == "Linux": - triplet = ":x64-linux" - else: - triplet = ":x64-osx" - subprocess.check_call([os.path.join(VCPKG_PATH, "vcpkg"), "install", package+triplet]) - -def build(): - build_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "build")) - if not os.path.exists(build_dir): - os.makedirs(build_dir) - - subprocess.check_call(['cmake', "../", "-DPYBIND11_PYTHON_VERSION=3.9"], cwd=build_dir) - subprocess.check_call(['cmake', '--build', '.', "--config", "Release"], cwd=build_dir) - - print([i for i in os.listdir(os.path.join(os.path.dirname(__file__), "binaries"))]) - - -if __name__ == "__main__": - install() \ No newline at end of file diff --git a/m_tree/python_bindings/CMakeLists.txt b/m_tree/python_bindings/CMakeLists.txt deleted file mode 100644 index 13f4974b..00000000 --- a/m_tree/python_bindings/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - -set(CMAKE_TOOLCHAIN_FILE ../dependencies/vcpkg/scripts/buildsystems/vcpkg.cmake CACHE STRING "") - -add_subdirectory(../dependencies/pybind11 [EXCLUDE_FROM_ALL]) - -file(GLOB_RECURSE sources - "./*.hpp" - "./*.cpp" -) - -pybind11_add_module(m_tree ${sources}) -target_link_libraries(m_tree PRIVATE m_tree-lib) \ No newline at end of file diff --git a/python_classes/__init__.py b/python_classes/__init__.py deleted file mode 100644 index 3b11733a..00000000 --- a/python_classes/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -from . import operators -from . import nodes - -def register(): - operators.register() - nodes.register() - - -def unregister(): - operators.unregister() - nodes.unregister() \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..427b11bb --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.11) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +set(ADDON_DIRECTORY ${CMAKE_SOURCE_DIR}/../addon) +set(ADDON_LIB_DIRECTORY ${ADDON_DIRECTORY}/lib/$<0:>) # Strip configuration subdirectory (Debug, etc.) +set(BUILD_DIRECTORY ${CMAKE_SOURCE_DIR}/../build/$<0:>) + +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BUILD_DIRECTORY}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${ADDON_LIB_DIRECTORY}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIRECTORY}) + +project(m_tree) + +add_subdirectory(./source) +add_subdirectory(./python_bindings) +add_subdirectory(./tests) \ No newline at end of file diff --git a/m_tree/LICENSE.md b/src/LICENSE.md similarity index 100% rename from m_tree/LICENSE.md rename to src/LICENSE.md diff --git a/src/python_bindings/CMakeLists.txt b/src/python_bindings/CMakeLists.txt new file mode 100644 index 00000000..15426de1 --- /dev/null +++ b/src/python_bindings/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.11) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +include(FetchContent) +FetchContent_Declare( + pybind11 + GIT_REPOSITORY https://github.com/pybind/pybind11 + GIT_SHALLOW TRUE +) +FetchContent_MakeAvailable(pybind11) + +file(GLOB_RECURSE sources + "./*.hpp" + "./*.cpp" +) + +pybind11_add_module(m_tree ${sources}) +target_link_libraries(m_tree PRIVATE m_tree-lib) \ No newline at end of file diff --git a/m_tree/python_bindings/main.cpp b/src/python_bindings/main.cpp similarity index 100% rename from m_tree/python_bindings/main.cpp rename to src/python_bindings/main.cpp diff --git a/m_tree/source/CMakeLists.txt b/src/source/CMakeLists.txt similarity index 68% rename from m_tree/source/CMakeLists.txt rename to src/source/CMakeLists.txt index b98b9e1b..7e96484c 100644 --- a/m_tree/source/CMakeLists.txt +++ b/src/source/CMakeLists.txt @@ -1,11 +1,18 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.11) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -O3 -fPIC") -find_package(Eigen3 CONFIG REQUIRED) +include(FetchContent) + +FetchContent_Declare( + Eigen + GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git + GIT_SHALLOW TRUE +) +FetchContent_MakeAvailable(Eigen) file(GLOB_RECURSE sources "./*.hpp" diff --git a/m_tree/source/mesh/Attribute.hpp b/src/source/mesh/Attribute.hpp similarity index 100% rename from m_tree/source/mesh/Attribute.hpp rename to src/source/mesh/Attribute.hpp diff --git a/m_tree/source/mesh/Mesh.cpp b/src/source/mesh/Mesh.cpp similarity index 100% rename from m_tree/source/mesh/Mesh.cpp rename to src/source/mesh/Mesh.cpp diff --git a/m_tree/source/mesh/Mesh.hpp b/src/source/mesh/Mesh.hpp similarity index 100% rename from m_tree/source/mesh/Mesh.hpp rename to src/source/mesh/Mesh.hpp diff --git a/m_tree/source/meshers/base_types/TreeMesher.cpp b/src/source/mesh/VertexGroup.cpp similarity index 100% rename from m_tree/source/meshers/base_types/TreeMesher.cpp rename to src/source/mesh/VertexGroup.cpp diff --git a/m_tree/source/mesh/VertexGroup.hpp b/src/source/mesh/VertexGroup.hpp similarity index 100% rename from m_tree/source/mesh/VertexGroup.hpp rename to src/source/mesh/VertexGroup.hpp diff --git a/m_tree/source/tree/GrowthInfo.cpp b/src/source/meshers/base_types/TreeMesher.cpp similarity index 100% rename from m_tree/source/tree/GrowthInfo.cpp rename to src/source/meshers/base_types/TreeMesher.cpp diff --git a/m_tree/source/meshers/base_types/TreeMesher.hpp b/src/source/meshers/base_types/TreeMesher.hpp similarity index 100% rename from m_tree/source/meshers/base_types/TreeMesher.hpp rename to src/source/meshers/base_types/TreeMesher.hpp diff --git a/m_tree/source/meshers/manifold_mesher/ManifoldMesher.cpp b/src/source/meshers/manifold_mesher/ManifoldMesher.cpp similarity index 100% rename from m_tree/source/meshers/manifold_mesher/ManifoldMesher.cpp rename to src/source/meshers/manifold_mesher/ManifoldMesher.cpp diff --git a/m_tree/source/meshers/manifold_mesher/ManifoldMesher.hpp b/src/source/meshers/manifold_mesher/ManifoldMesher.hpp similarity index 100% rename from m_tree/source/meshers/manifold_mesher/ManifoldMesher.hpp rename to src/source/meshers/manifold_mesher/ManifoldMesher.hpp diff --git a/m_tree/source/meshers/manifold_mesher/smoothing.cpp b/src/source/meshers/manifold_mesher/smoothing.cpp similarity index 100% rename from m_tree/source/meshers/manifold_mesher/smoothing.cpp rename to src/source/meshers/manifold_mesher/smoothing.cpp diff --git a/m_tree/source/meshers/manifold_mesher/smoothing.hpp b/src/source/meshers/manifold_mesher/smoothing.hpp similarity index 100% rename from m_tree/source/meshers/manifold_mesher/smoothing.hpp rename to src/source/meshers/manifold_mesher/smoothing.hpp diff --git a/m_tree/source/meshers/splines_mesher/BasicMesher.cpp b/src/source/meshers/splines_mesher/BasicMesher.cpp similarity index 100% rename from m_tree/source/meshers/splines_mesher/BasicMesher.cpp rename to src/source/meshers/splines_mesher/BasicMesher.cpp diff --git a/m_tree/source/meshers/splines_mesher/BasicMesher.hpp b/src/source/meshers/splines_mesher/BasicMesher.hpp similarity index 100% rename from m_tree/source/meshers/splines_mesher/BasicMesher.hpp rename to src/source/meshers/splines_mesher/BasicMesher.hpp diff --git a/m_tree/source/tree_functions/LeavesFunction.cpp b/src/source/tree/GrowthInfo.cpp similarity index 100% rename from m_tree/source/tree_functions/LeavesFunction.cpp rename to src/source/tree/GrowthInfo.cpp diff --git a/m_tree/source/tree/GrowthInfo.hpp b/src/source/tree/GrowthInfo.hpp similarity index 100% rename from m_tree/source/tree/GrowthInfo.hpp rename to src/source/tree/GrowthInfo.hpp diff --git a/m_tree/source/tree/Node.cpp b/src/source/tree/Node.cpp similarity index 100% rename from m_tree/source/tree/Node.cpp rename to src/source/tree/Node.cpp diff --git a/m_tree/source/tree/Node.hpp b/src/source/tree/Node.hpp similarity index 100% rename from m_tree/source/tree/Node.hpp rename to src/source/tree/Node.hpp diff --git a/m_tree/source/tree/Tree.cpp b/src/source/tree/Tree.cpp similarity index 100% rename from m_tree/source/tree/Tree.cpp rename to src/source/tree/Tree.cpp diff --git a/m_tree/source/tree/Tree.hpp b/src/source/tree/Tree.hpp similarity index 100% rename from m_tree/source/tree/Tree.hpp rename to src/source/tree/Tree.hpp diff --git a/m_tree/source/tree_functions/BranchFunction.cpp b/src/source/tree_functions/BranchFunction.cpp similarity index 100% rename from m_tree/source/tree_functions/BranchFunction.cpp rename to src/source/tree_functions/BranchFunction.cpp diff --git a/m_tree/source/tree_functions/BranchFunction.hpp b/src/source/tree_functions/BranchFunction.hpp similarity index 100% rename from m_tree/source/tree_functions/BranchFunction.hpp rename to src/source/tree_functions/BranchFunction.hpp diff --git a/m_tree/source/tree_functions/GrowthFunction.cpp b/src/source/tree_functions/GrowthFunction.cpp similarity index 100% rename from m_tree/source/tree_functions/GrowthFunction.cpp rename to src/source/tree_functions/GrowthFunction.cpp diff --git a/m_tree/source/tree_functions/GrowthFunction.hpp b/src/source/tree_functions/GrowthFunction.hpp similarity index 100% rename from m_tree/source/tree_functions/GrowthFunction.hpp rename to src/source/tree_functions/GrowthFunction.hpp diff --git a/m_tree/source/tree_functions/LeavesFunction.hpp b/src/source/tree_functions/LeavesFunction.cpp similarity index 100% rename from m_tree/source/tree_functions/LeavesFunction.hpp rename to src/source/tree_functions/LeavesFunction.cpp diff --git a/m_tree/source/utilities/RandomGenerator.cpp b/src/source/tree_functions/LeavesFunction.hpp similarity index 100% rename from m_tree/source/utilities/RandomGenerator.cpp rename to src/source/tree_functions/LeavesFunction.hpp diff --git a/m_tree/source/tree_functions/PipeRadiusFunction.cpp b/src/source/tree_functions/PipeRadiusFunction.cpp similarity index 100% rename from m_tree/source/tree_functions/PipeRadiusFunction.cpp rename to src/source/tree_functions/PipeRadiusFunction.cpp diff --git a/m_tree/source/tree_functions/PipeRadiusFunction.hpp b/src/source/tree_functions/PipeRadiusFunction.hpp similarity index 100% rename from m_tree/source/tree_functions/PipeRadiusFunction.hpp rename to src/source/tree_functions/PipeRadiusFunction.hpp diff --git a/m_tree/source/tree_functions/TrunkFunction.cpp b/src/source/tree_functions/TrunkFunction.cpp similarity index 100% rename from m_tree/source/tree_functions/TrunkFunction.cpp rename to src/source/tree_functions/TrunkFunction.cpp diff --git a/m_tree/source/tree_functions/TrunkFunction.hpp b/src/source/tree_functions/TrunkFunction.hpp similarity index 100% rename from m_tree/source/tree_functions/TrunkFunction.hpp rename to src/source/tree_functions/TrunkFunction.hpp diff --git a/m_tree/source/tree_functions/base_types/Property.hpp b/src/source/tree_functions/base_types/Property.hpp similarity index 100% rename from m_tree/source/tree_functions/base_types/Property.hpp rename to src/source/tree_functions/base_types/Property.hpp diff --git a/m_tree/source/tree_functions/base_types/TreeFunction.cpp b/src/source/tree_functions/base_types/TreeFunction.cpp similarity index 100% rename from m_tree/source/tree_functions/base_types/TreeFunction.cpp rename to src/source/tree_functions/base_types/TreeFunction.cpp diff --git a/m_tree/source/tree_functions/base_types/TreeFunction.hpp b/src/source/tree_functions/base_types/TreeFunction.hpp similarity index 100% rename from m_tree/source/tree_functions/base_types/TreeFunction.hpp rename to src/source/tree_functions/base_types/TreeFunction.hpp diff --git a/m_tree/source/utilities/GeometryUtilities.cpp b/src/source/utilities/GeometryUtilities.cpp similarity index 100% rename from m_tree/source/utilities/GeometryUtilities.cpp rename to src/source/utilities/GeometryUtilities.cpp diff --git a/m_tree/source/utilities/GeometryUtilities.hpp b/src/source/utilities/GeometryUtilities.hpp similarity index 100% rename from m_tree/source/utilities/GeometryUtilities.hpp rename to src/source/utilities/GeometryUtilities.hpp diff --git a/m_tree/source/utilities/NodeUtilities.cpp b/src/source/utilities/NodeUtilities.cpp similarity index 100% rename from m_tree/source/utilities/NodeUtilities.cpp rename to src/source/utilities/NodeUtilities.cpp diff --git a/m_tree/source/utilities/NodeUtilities.hpp b/src/source/utilities/NodeUtilities.hpp similarity index 100% rename from m_tree/source/utilities/NodeUtilities.hpp rename to src/source/utilities/NodeUtilities.hpp diff --git a/src/source/utilities/RandomGenerator.cpp b/src/source/utilities/RandomGenerator.cpp new file mode 100644 index 00000000..e69de29b diff --git a/m_tree/source/utilities/RandomGenerator.hpp b/src/source/utilities/RandomGenerator.hpp similarity index 100% rename from m_tree/source/utilities/RandomGenerator.hpp rename to src/source/utilities/RandomGenerator.hpp diff --git a/m_tree/tests/CMakeLists.txt b/src/tests/CMakeLists.txt similarity index 91% rename from m_tree/tests/CMakeLists.txt rename to src/tests/CMakeLists.txt index a78316bf..5f6b8248 100644 --- a/m_tree/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.11) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/m_tree/tests/main.cpp b/src/tests/main.cpp similarity index 100% rename from m_tree/tests/main.cpp rename to src/tests/main.cpp