""" 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, capable of holding multiple unconnected possibly non-convex components. To convert from a boundary representation, use poly = build_polyhedron(vertex_list, face_list) To convert back to a boundary representation, use list_of_boundaries = boundary_from_poly(poly) vertex_list_0 = list_of_boundaries[0]['vertices'] face_list_0 = list_of_boundaries[0]['faces'] Basic operations include plane = (normal_vector, signed_distance_to_origin) same_side_as_normal, other_side = split(poly, plane) same_side_as_normal = clip(poly, plane) volume = get_volume(poly) 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 edge coordinates: x_planes = numpy.linspace(-5, 5, 100) y_planes = numpy.linspace(-10, 10, 5) z_planes = [-3, 0, 1, 2, 3] voxel_weights = voxelize(poly, [x_planes, y_planes, z_planes], order=0) Helper functions include poly = build_box(box_corners) poly = build_tetrahedron(vertices) plane_list = planes_from_box(box_corners) plane_list = planes_from_tetrahedron(vertices) n = number_of_moments(order=3) -------------------------- ### Internal Representation: The Schlegel Diagram adze represents 3D shapes (polyhedra) using a specialized graph called a Schlegel diagram. This format is designed for high-performance geometric calculations. #### Key Features: - **Exactly Three Neighbors:** Every vertex in the graph is connected to exactly three other vertices. This "3-regular" property makes algorithms for clipping and splitting shapes much simpler and more robust. - **Ordered Adjacency:** For each vertex, the three neighbors are listed in counter-clockwise order when viewed from outside the shape. This order defines the "orientation" of the shape's surfaces. - **Handling Complex Corners:** In real-world shapes, a corner (vertex) might have more than three edges meeting (e.g., the tip of a pyramid). adze handles this by creating multiple "copy" vertices at the same physical location, each handling part of the original corner's connectivity. #### Data Structure: Shapes are stored as a dictionary containing two NumPy arrays: - `poly['vertices']`: An `[N x 3]` array of float coordinates (X, Y, Z). - `poly['neighbors']`: An `[N x 3]` array of integer indices. `poly['neighbors'][i, :]` contains the indices of the 3 vertices connected to vertex `i`. """ from .util import ( poly_t as poly_t, plane_t as plane_t, AdzeError as AdzeError, ) from .split import ( split as split, clip as clip, ) from .moments import ( get_volume as get_volume, get_moments as get_moments, number_of_moments as number_of_moments, ) from .boundary import ( build_polyhedron as build_polyhedron, boundary_from_poly as boundary_from_poly, ) from .shapes import ( build_tetrahedron as build_tetrahedron, build_box as build_box, planes_from_tetrahedron as planes_from_tetrahedron, planes_from_box as planes_from_box, ) from .voxel import voxelize as voxelize __author__ = 'Jan Petykiewicz' __version__ = '0.2'