A python package to fill N-sided holes using combined subdivision schemes, based on Catmull-Clark subdivison.
Project description
Filler for N-sided holes
A python package to fill N-sided holes using combined subdivision schemes, based on Catmull-Clark subdivison.
See Levin, Adi. “Filling N-sided Holes Using Combined Subdivision Schemes.” (2000).
Install
Use PyPI to install subdivision-hole-filler:
pip install subdivision-hole-filler
Usage
Run the following script to fill a hole.
import numpy as np
from subdivision_hole_filler import Boundary, NsidedHoleFiller
r = 1
R = 1
boundaries = [None, None, None, None, None, None]
for d in range(3):
def coord(u: float, d=d):
phi = (1.0 - u / 2.0) * np.pi / 2.0
x = r * np.cos(phi)
y = r * np.sin(phi)
z = r + R
c = np.zeros(3)
c[d] = z
c[(d + 1) % 3] = x
c[(d + 2) % 3] = y
return c
def deriv(u: float, d=d):
vec = np.zeros(3)
vec[d] = -1
return np.array(vec)
bd = Boundary()
bd.coord = coord # A function of parametric coord `u` in [0.0, 2.0], which defines the coordinate of a point on the boundary
bd.deriv = deriv # A function of parametric coord `u` in [0.0, 2.0], which defines the cross boundary derivative of a point on the boundary, poining to the inside
boundaries[d*2] = bd
for d in range(3):
bd = Boundary()
def coord(u: float, d=d):
phi = (1.0 - u / 2.0) * np.pi / 2.0
x = R + r - R * np.cos(phi)
y = R + r - R * np.sin(phi)
z = 0
c = np.zeros(3)
c[d] = z
c[(d + 1) % 3] = x
c[(d + 2) % 3] = y
return c
bd.coord = coord
def deriv(u: float, d=d):
vec = np.zeros(3)
vec[d] = 1
return np.array(vec)
bd.deriv = deriv
boundaries[(d + 1) % 3 * 2 + 1] = bd
filler = NsidedHoleFiller(boundaries)
center_point = np.array([r, r, r])
filler.gen_initial_mesh(center_point)
for iteration in range(3):
filler.cmc_subdiv_for_1step(iteration=iteration)
Here is the ouput.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
subdivision_hole_filler-1.0.1.tar.gz
(284.3 kB
view hashes)
Built Distribution
Close
Hashes for subdivision_hole_filler-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa9380bd4927c9aa6d25d4daca55e0ea1ce6b7fe3a69286b24cdaca08ffb09c8 |
|
MD5 | 9c62b9398d9907f71c61ae0d31ef6afe |
|
BLAKE2b-256 | 90a7311530148c66b7f79c465da0c18f2490554d7ea161a2ca19f370b6786510 |
Close
Hashes for subdivision_hole_filler-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b796aae3fc2a6eeb47c7881c4ed8a312b6b3186d3705a5e2c64c16fb8e1ddc58 |
|
MD5 | 6f8d48f7e9dec4946bb42356b4bfb0b8 |
|
BLAKE2b-256 | 04558b63e45f62a99269b5ef80c73364f331e4292b4bea875b4a725302ae3cb1 |