Skip to content

Commit 00e49b0

Browse files
BREAKING: feat: integer position support + numpy return + decode/encode functions + normals (#24)
* feat: add flag for integer positions * feat: use parallel builds * install: add numpy dependency * feat: automatically detect integer encoding for position attribute * perf: use correct optimization flags for MSVC * chore: add myself as author * chore: update appveyor to install numpy * BREAKING: DracoPy returns numpy arrays with dimension 2 * chore: update build system, include arm64 linux * build: fix QEMU for arm64 linux * chore: we're not dropping py36 support yet * refactor: collapse all encoding options into encode/decode functions * docs: update examples * docs: show function sigs * feat: add assertions to check inputs for known ranges * fix: incorrect type annotation * feat: add normal decoding (thanks FaruNuriSonmez!) Also adds integer positions for point cloud * test: add bunny with normals * docs: credit authors of normal decoding
1 parent 575bbbc commit 00e49b0

File tree

11 files changed

+25696
-5564
lines changed

11 files changed

+25696
-5564
lines changed

.github/workflows/build_wheel.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,20 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-20.04, macos-latest]
15+
arch: [auto]
16+
include:
17+
- os: ubuntu-20.04
18+
arch: aarch64
1519

1620
steps:
1721
- uses: actions/checkout@v2
1822

23+
- name: Set up QEMU
24+
if: ${{ matrix.arch == 'aarch64' }}
25+
uses: docker/setup-qemu-action@v1
26+
1927
- name: Build wheels
20-
uses: joerick/cibuildwheel@v1.10.0
28+
uses: joerick/cibuildwheel@v1.12.0
2129
# to supply options, put them in 'env', like:
2230
env:
2331
CIBW_BEFORE_BUILD: git submodule init && git submodule update && pip install oldest-supported-numpy scikit-build

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ import os
88
import DracoPy
99

1010
with open('bunny.drc', 'rb') as draco_file:
11-
file_content = draco_file.read()
12-
mesh_object = DracoPy.decode_buffer_to_mesh(file_content)
13-
print('number of points in original file: {0}'.format(len(mesh_object.points)))
14-
print('number of faces in original file: {0}'.format(len(mesh_object.faces)))
15-
encoding_test = DracoPy.encode_mesh_to_buffer(mesh_object.points, mesh_object.faces)
16-
with open('bunny_test.drc', 'wb') as test_file:
17-
test_file.write(encoding_test)
18-
19-
with open('bunny_test.drc', 'rb') as test_file:
20-
file_content = test_file.read()
21-
mesh_object = DracoPy.decode_buffer_to_mesh(file_content)
22-
print('number of points in test file: {0}'.format(len(mesh_object.points)))
23-
print('number of faces in test file: {0}'.format(len(mesh_object.faces)))
11+
mesh = DracoPy.decode(draco_file.read())
12+
13+
print(f"number of points: {len(mesh.points)}")
14+
print(f"number of faces: {len(mesh.faces)}")
15+
print(f"number of normals: {len(mesh.normals)}")
16+
17+
# Note: If mesh.points is an integer numpy array,
18+
# it will be encoded as an integer attribute. Otherwise,
19+
# it will be encoded as floating point.
20+
binary = DracoPy.encode(mesh.points, mesh.faces)
21+
with open('bunny_test.drc', 'wb') as test_file:
22+
test_file.write(encoding_test)
23+
2424
```
2525

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

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

34-
It supports Linux, OS X, and Windows.
34+
It supports Linux, OS X, and Windows. Numpy is required.
3535

3636
```bash
3737
pip install DracoPy

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ environment:
1414
install:
1515
# We need wheel installed to build wheels
1616
- "git submodule update --init --recursive"
17-
- "%PYTHON%\\python.exe -m pip install wheel scikit-build"
17+
- "%PYTHON%\\python.exe -m pip install wheel scikit-build oldest-supported-numpy"
1818

1919
build: off
2020

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
[build-system]
2-
requires = ["setuptools", "scikit-build >= 0.9.0", "wheel"]
2+
requires = [
3+
"setuptools",
4+
"scikit-build >= 0.9.0",
5+
"wheel",
6+
"numpy"
7+
]

setup.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
from skbuild.exceptions import SKBuildError
88
from skbuild.cmaker import get_cmake_version
99

10+
import numpy as np
11+
import multiprocessing as mp
12+
13+
if not "CMAKE_BUILD_PARALLEL_LEVEL" in os.environ:
14+
os.environ["CMAKE_BUILD_PARALLEL_LEVEL"] = str(mp.cpu_count())
15+
1016
def read(fname):
1117
with open(os.path.join(os.path.dirname(__file__), fname), 'rt') as f:
1218
return f.read()
@@ -51,21 +57,20 @@ def read(fname):
5157
if sys.platform == 'win32':
5258
extra_link_args = ['/LIBPATH:{0}'.format(lib_dir)] + library_link_args
5359
extra_compile_args = [
54-
'/std:c++17','-O3'
55-
]
60+
'/std:c++17', '/O2',
61+
]
5662
else:
5763
extra_link_args = ['-L{0}'.format(lib_dir)] + library_link_args
5864
extra_compile_args = [
59-
'-std=c++11','-O3'
60-
]
61-
65+
'-std=c++11','-O3'
66+
]
6267

6368
setup(
6469
name='DracoPy',
6570
version='0.0.19',
6671
description = 'Python wrapper for Google\'s Draco Mesh Compression Library',
67-
author = 'Manuel Castro',
68-
author_email = 'macastro@princeton.edu',
72+
author = 'Manuel Castro, William Silversmith :: Contributors :: Fatih Erol, Faru Nuri Sonmez',
73+
author_email = 'macastro@princeton.edu, ws9@princeton.edu',
6974
url = 'https://github.com/seung-lab/DracoPy',
7075
long_description=read('README.md'),
7176
long_description_content_type="text/markdown",
@@ -80,7 +85,10 @@ def read(fname):
8085
sources=[ os.path.join(src_dir, 'DracoPy.cpp') ],
8186
depends=[ os.path.join(src_dir, 'DracoPy.h') ],
8287
language='c++',
83-
include_dirs = [ os.path.join(CMAKE_INSTALL_DIR(), 'include/')],
88+
include_dirs = [
89+
np.get_include(),
90+
os.path.join(CMAKE_INSTALL_DIR(), 'include/'),
91+
],
8492
extra_compile_args=extra_compile_args,
8593
extra_link_args=extra_link_args
8694
)

0 commit comments

Comments
 (0)