Skip to main content

A python package to fill N-sided holes using combined subdivision schemes, based on Catmull-Clark subdivison.

Project description

Filler for N-sided holes

GitHub release (with filter) Upload Python Package PyPI - Version PyPI - Downloads GitHub License

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.7.tar.gz (287.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

subdivision_hole_filler-1.0.7-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file subdivision_hole_filler-1.0.7.tar.gz.

File metadata

  • Download URL: subdivision_hole_filler-1.0.7.tar.gz
  • Upload date:
  • Size: 287.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for subdivision_hole_filler-1.0.7.tar.gz
Algorithm Hash digest
SHA256 310e2de14767a11e7cc44ae6cc027f296f44a83a25ca3c3955e88290a1116f61
MD5 f90346c81bb7dd139f66c4fcf08b2404
BLAKE2b-256 13cb0361c37aeb54207853fb99625db7076ff427d64aec3672b53831a9d46a5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for subdivision_hole_filler-1.0.7.tar.gz:

Publisher: python-publish.yml on huang-lihao/subdivision-hole-filler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file subdivision_hole_filler-1.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for subdivision_hole_filler-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7ca8e6359631c7702c83385fece1ea113f7e3aad2f344b44066b89063e04d991
MD5 6f81e14465e8e057882df08b89e7a15b
BLAKE2b-256 0484f5a6974927d9cf9153bbbd2f9cf6e64bf2dfbcd948fddde742a10911969f

See more details on using hashes here.

Provenance

The following attestation bundles were made for subdivision_hole_filler-1.0.7-py3-none-any.whl:

Publisher: python-publish.yml on huang-lihao/subdivision-hole-filler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page