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.6.tar.gz
(287.2 kB
view details)
Built Distribution
File details
Details for the file subdivision_hole_filler-1.0.6.tar.gz
.
File metadata
- Download URL: subdivision_hole_filler-1.0.6.tar.gz
- Upload date:
- Size: 287.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66f5245ccd7c593a305cd7313fd4e9498a6fc777c34e10288bfd2077f9f3b5c3 |
|
MD5 | ee05472451ba4a2ace169e20f5dacbe8 |
|
BLAKE2b-256 | 9a29993e888d93f906d7e181fb17763eda3ce96948cc57ee321f10ddd29459ec |
File details
Details for the file subdivision_hole_filler-1.0.6-py3-none-any.whl
.
File metadata
- Download URL: subdivision_hole_filler-1.0.6-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d243e8f3bd2d7288691be1fbc7e89069a494300817bc7b1df0facb9a54988e0 |
|
MD5 | 3d9fcd97f8fd91d0a7e8051867d585a0 |
|
BLAKE2b-256 | 48ccbb683b91a394b84630e6fa8981e46a99e8fcad6401991ff83c4df7c45bda |