From 31d24ed9d32ab39ad8a20eeeac23e16aa937af6b Mon Sep 17 00:00:00 2001 From: jan Date: Thu, 19 Apr 2018 20:15:01 -0700 Subject: [PATCH] rename to adze --- README.md | 55 +++++++++++++++++++++++++++++++++++++ {chop => adze}/__init__.py | 14 ++++++---- {chop => adze}/boundary.py | 0 {chop => adze}/moments.py | 0 {chop => adze}/shapes.py | 0 {chop => adze}/split.py | 0 {chop => adze}/transform.py | 0 {chop => adze}/util.py | 0 {chop => adze}/voxel.py | 0 setup.py | 48 ++++++++++++++++++++++++++++++++ tpy_r3d.py | 6 ++-- 11 files changed, 114 insertions(+), 9 deletions(-) create mode 100644 README.md rename {chop => adze}/__init__.py (89%) rename {chop => adze}/boundary.py (100%) rename {chop => adze}/moments.py (100%) rename {chop => adze}/shapes.py (100%) rename {chop => adze}/split.py (100%) rename {chop => adze}/transform.py (100%) rename {chop => adze}/util.py (100%) rename {chop => adze}/voxel.py (100%) create mode 100644 setup.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..0e60000 --- /dev/null +++ b/README.md @@ -0,0 +1,55 @@ +# adze + +**adze** is a Python package for accurate polyhedron clipping + and anti-aliased voxelization. + +**Homepage:** https://mpxd.net/code/jan/adze + +**Capabilities:** + - Clipping or splitting arbitrary polyhedra + - by a plane or a collection of planes (i.e. a convex polyhedron) + - Voxelizing arbitrary polyhedra + - + + +## Installation + +**Dependencies:** +* python 3.5 or newer +* numpy + + +Install with pip from PyPi (preferred): +```bash +pip install adze +``` + +Install directly from git repository: +```bash +pip install git+https://mpxd.net/code/jan/adze.git@release +``` + +## Documentation +Most functions and classes are documented inline. + +To read the inline help, +```python3 +import adze +help(adze) +help(adze.split) +``` + + +## Examples + +TODO +Read an OASIS file and write it back out: +```python3 + import fatamorgana + + with open('test.oas', 'rb') as f: + layout = fatamorgana.OasisLayout.read(f) + + with open('test_write.oas', 'wb') as f: + layout.write(f) +``` diff --git a/chop/__init__.py b/adze/__init__.py similarity index 89% rename from chop/__init__.py rename to adze/__init__.py index fb8aeed..e45d3d7 100644 --- a/chop/__init__.py +++ b/adze/__init__.py @@ -1,6 +1,5 @@ ''' - -Library for accurate polyhedron clipping and anti-aliased voxelization. +adze is a library for accurate polyhedron clipping and anti-aliased voxelization. Written with python + numpy. Most operations are performed using an ordered adjacency-list polyhedron represenation, @@ -19,9 +18,9 @@ Basic operations include same_side_as_normal = clip(poly, plane) volume = get_volume(poly) - volume, m_x, m_y, m_z = get_moments(poly, order=1) + volume, m_x, m_y, m_z = get_moments(poly, order=1) -Anti-aliased voxelization is done on a non-uniform rectangular grid, specified by the cell +Anti-aliased voxelization is done on a non-uniform rectangular grid, specified by the cell edge coordinates: x_planes = numpy.linspace(-5, 5, 100) y_planes = numpy.linspace(-10, 10, 5) @@ -43,12 +42,15 @@ In the polyhedron representation returned by the build_* functions and accepted most other functions (split, clip, get_volume, get_moments, voxelize), the polyhedron is stored as a 3-vertex-connected, triply-linked graph, with each vertex's neighbors listed in counterclockwise order when viewed from outside the polyhedron. TODO - Each graph-vertex (g-vertex) is connected to exactly 3 other g-vertices, and + Each graph-vertex (g-vertex) is connected to exactly 3 other g-vertices; polygon- + vertices (p-vertices) are + + TODO This representation looks like poly = {'neighbors': ndarray[Px3, int], 'vertices': ndarray[Px3, float]} - where poly['neighbors'] contains + where poly['neighbors'] contains ''' diff --git a/chop/boundary.py b/adze/boundary.py similarity index 100% rename from chop/boundary.py rename to adze/boundary.py diff --git a/chop/moments.py b/adze/moments.py similarity index 100% rename from chop/moments.py rename to adze/moments.py diff --git a/chop/shapes.py b/adze/shapes.py similarity index 100% rename from chop/shapes.py rename to adze/shapes.py diff --git a/chop/split.py b/adze/split.py similarity index 100% rename from chop/split.py rename to adze/split.py diff --git a/chop/transform.py b/adze/transform.py similarity index 100% rename from chop/transform.py rename to adze/transform.py diff --git a/chop/util.py b/adze/util.py similarity index 100% rename from chop/util.py rename to adze/util.py diff --git a/chop/voxel.py b/adze/voxel.py similarity index 100% rename from chop/voxel.py rename to adze/voxel.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..b2c6582 --- /dev/null +++ b/setup.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 + +from setuptools import setup, find_packages + +setup(name='adze', + version='0.1', + description='Polyhedron clipping and antialiased voxelization', + author='Jan Petykiewicz', + author_email='anewusername@gmail.com', + url='https://mpxd.net/code/jan/adze', + keywords=[ + 'geometry', + 'geometric', + 'polyhedron', + 'voxel', + 'voxelize', + 'clip', + 'clipping', + 'split', + 'moment', + 'schlegel', + '3D', + 'boolean', + ], + classifiers=[ + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Development Status :: 4 - Beta', + 'Environment :: Other Environment', + 'Intended Audience :: Developers', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved', + 'License :: OSI Approved :: GNU Affero General Public License v3', + 'Operating System :: OS Independent', + 'Topic :: Multimedia :: Graphics', + 'Topic :: Scientific/Engineering', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + packages=find_packages(), + install_requires=[ + 'typing', + 'numpy', + ], + extras_require={ + }, + ) + diff --git a/tpy_r3d.py b/tpy_r3d.py index e31d438..988eb18 100644 --- a/tpy_r3d.py +++ b/tpy_r3d.py @@ -7,10 +7,10 @@ import numpy from numpy import sin, cos, pi from numpy.linalg import norm -from chop import (number_of_moments, get_moments, split, clip, build_tetrahedron, +from adze import (number_of_moments, get_moments, split, clip, build_tetrahedron, build_box, planes_from_tetrahedron, build_polyhedron, boundary_from_poly, voxelize) -from chop.util import check_poly +from adze.util import check_poly try: # Check if running with line_profiler @@ -547,7 +547,7 @@ if __name__ == '__main__': test_recursive_split() logger.info('voxelization') - test_voxelization() +# test_voxelization() logger.info('test_tet_tet_timing') test_tet_tet_timing()