Skip to content

BREAKING: feat: integer position support + numpy return + decode/encode functions + normals #24

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

Merged
merged 19 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
85cfa42
feat: add flag for integer positions
william-silversmith Dec 11, 2021
7ad3ca3
feat: use parallel builds
william-silversmith Dec 13, 2021
b1105d9
install: add numpy dependency
william-silversmith Dec 13, 2021
c8b55d6
feat: automatically detect integer encoding for position attribute
william-silversmith Dec 13, 2021
a010675
perf: use correct optimization flags for MSVC
william-silversmith Dec 13, 2021
5dd9489
chore: add myself as author
william-silversmith Dec 13, 2021
6db4349
chore: update appveyor to install numpy
william-silversmith Dec 14, 2021
8db12d7
BREAKING: DracoPy returns numpy arrays with dimension 2
william-silversmith Dec 14, 2021
de445b2
chore: update build system, include arm64 linux
william-silversmith Dec 14, 2021
a03b1a5
build: fix QEMU for arm64 linux
william-silversmith Dec 14, 2021
742b8b2
chore: we're not dropping py36 support yet
william-silversmith Dec 14, 2021
ef58da8
refactor: collapse all encoding options into encode/decode functions
william-silversmith Dec 14, 2021
b00ba9c
docs: update examples
william-silversmith Dec 14, 2021
7fb5517
docs: show function sigs
william-silversmith Dec 14, 2021
79c5f6d
feat: add assertions to check inputs for known ranges
william-silversmith Dec 14, 2021
a578f25
fix: incorrect type annotation
william-silversmith Dec 14, 2021
f89c00d
feat: add normal decoding (thanks FaruNuriSonmez!)
william-silversmith Dec 14, 2021
8d28379
test: add bunny with normals
william-silversmith Dec 14, 2021
2826e74
docs: credit authors of normal decoding
william-silversmith Dec 14, 2021
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
10 changes: 9 additions & 1 deletion .github/workflows/build_wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04, macos-latest]
arch: [auto]
include:
- os: ubuntu-20.04
arch: aarch64

steps:
- uses: actions/checkout@v2

- name: Set up QEMU
if: ${{ matrix.arch == 'aarch64' }}
uses: docker/setup-qemu-action@v1

- name: Build wheels
uses: joerick/cibuildwheel@v1.10.0
uses: joerick/cibuildwheel@v1.12.0
# to supply options, put them in 'env', like:
env:
CIBW_BEFORE_BUILD: git submodule init && git submodule update && pip install oldest-supported-numpy scikit-build
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ import os
import DracoPy

with open('bunny.drc', 'rb') as draco_file:
file_content = draco_file.read()
mesh_object = DracoPy.decode_buffer_to_mesh(file_content)
print('number of points in original file: {0}'.format(len(mesh_object.points)))
print('number of faces in original file: {0}'.format(len(mesh_object.faces)))
encoding_test = DracoPy.encode_mesh_to_buffer(mesh_object.points, mesh_object.faces)
with open('bunny_test.drc', 'wb') as test_file:
test_file.write(encoding_test)

with open('bunny_test.drc', 'rb') as test_file:
file_content = test_file.read()
mesh_object = DracoPy.decode_buffer_to_mesh(file_content)
print('number of points in test file: {0}'.format(len(mesh_object.points)))
print('number of faces in test file: {0}'.format(len(mesh_object.faces)))
mesh = DracoPy.decode(draco_file.read())

print(f"number of points: {len(mesh.points)}")
print(f"number of faces: {len(mesh.faces)}")
print(f"number of normals: {len(mesh.normals)}")

# Note: If mesh.points is an integer numpy array,
# it will be encoded as an integer attribute. Otherwise,
# it will be encoded as floating point.
binary = DracoPy.encode(mesh.points, mesh.faces)
with open('bunny_test.drc', 'wb') as test_file:
test_file.write(encoding_test)

```

DracoPy is a Python wrapper for Google's Draco mesh compression library.
Expand All @@ -31,7 +31,7 @@ Binary wheels are available for users with Python >= 3.6 and pip >= 20.

Installation from source requires Python >= 3.6, pip >= 10, and a C++ compiler that is fully compatible with C++11.

It supports Linux, OS X, and Windows.
It supports Linux, OS X, and Windows. Numpy is required.

```bash
pip install DracoPy
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ environment:
install:
# We need wheel installed to build wheels
- "git submodule update --init --recursive"
- "%PYTHON%\\python.exe -m pip install wheel scikit-build"
- "%PYTHON%\\python.exe -m pip install wheel scikit-build oldest-supported-numpy"

build: off

Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[build-system]
requires = ["setuptools", "scikit-build >= 0.9.0", "wheel"]
requires = [
"setuptools",
"scikit-build >= 0.9.0",
"wheel",
"numpy"
]
24 changes: 16 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
from skbuild.exceptions import SKBuildError
from skbuild.cmaker import get_cmake_version

import numpy as np
import multiprocessing as mp

if not "CMAKE_BUILD_PARALLEL_LEVEL" in os.environ:
os.environ["CMAKE_BUILD_PARALLEL_LEVEL"] = str(mp.cpu_count())

def read(fname):
with open(os.path.join(os.path.dirname(__file__), fname), 'rt') as f:
return f.read()
Expand Down Expand Up @@ -51,21 +57,20 @@ def read(fname):
if sys.platform == 'win32':
extra_link_args = ['/LIBPATH:{0}'.format(lib_dir)] + library_link_args
extra_compile_args = [
'/std:c++17','-O3'
]
'/std:c++17', '/O2',
]
else:
extra_link_args = ['-L{0}'.format(lib_dir)] + library_link_args
extra_compile_args = [
'-std=c++11','-O3'
]

'-std=c++11','-O3'
]

setup(
name='DracoPy',
version='0.0.19',
description = 'Python wrapper for Google\'s Draco Mesh Compression Library',
author = 'Manuel Castro',
author_email = '[email protected]',
author = 'Manuel Castro, William Silversmith :: Contributors :: Fatih Erol, Faru Nuri Sonmez',
author_email = '[email protected], [email protected]',
url = 'https://github.com/seung-lab/DracoPy',
long_description=read('README.md'),
long_description_content_type="text/markdown",
Expand All @@ -80,7 +85,10 @@ def read(fname):
sources=[ os.path.join(src_dir, 'DracoPy.cpp') ],
depends=[ os.path.join(src_dir, 'DracoPy.h') ],
language='c++',
include_dirs = [ os.path.join(CMAKE_INSTALL_DIR(), 'include/')],
include_dirs = [
np.get_include(),
os.path.join(CMAKE_INSTALL_DIR(), 'include/'),
],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args
)
Expand Down
Loading