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):
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
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 + 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.3.tar.gz
(284.8 kB
view hashes)
Built Distribution
Close
Hashes for subdivision_hole_filler-1.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bf3dc3d07734b28a23eafc2befaa171dead2feb2b2bd54547ee469a21c294aa |
|
MD5 | 81001d6958a702d24b2b012cdc8a1702 |
|
BLAKE2b-256 | 6f35756a8de5e1cb68d041d08975856bf49f243f6b1a5ff9e209b7633f5f9b74 |
Close
Hashes for subdivision_hole_filler-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6044b1034f2a9a850ffcdb4ceb83095ffbc84088bc618095e3550fa6c87cbf46 |
|
MD5 | 7d4fece081875d928267e86d6fdf38b0 |
|
BLAKE2b-256 | 634c18b70662e836201cf498acfb84e4ca9d85dcfab2ab3ab8c686e1890cf8d7 |