Beispiel #1
0
def surf2():
    """ Generate surface for testing """
    surf = spline.Surface()
    surf.degree_u = 2
    surf.degree_v = 2
    surf.num_ctrlpts_u = 5
    surf.num_ctrlpts_v = 5

    x = np.arange(0.0, 5.0)
    y = np.arange(0.0, 5.0)

    ys, xs = np.meshgrid(x, y)

    ctrlpt_array = np.column_stack(
        (xs.flatten(), ys.flatten(), np.zeros(len(xs.flatten()))))

    surf.control_points = ctrlpt_array

    uvec = knots.generate_uniform(surf.degree_u, surf.num_ctrlpts_u)
    vvec = knots.generate_uniform(surf.degree_v, surf.num_ctrlpts_v)

    surf.knot_vector_u = uvec
    surf.knot_vector_v = vvec

    return surf
Beispiel #2
0
def test_knot_vector_v(surf):

    vvec = knots.generate_uniform(surf.degree_v, surf.num_ctrlpts_v)

    condition = np.allclose(vvec, surf.knot_vector_v)

    assert condition
Beispiel #3
0
def test_knot_vector_u(surf):

    uvec = knots.generate_uniform(surf.degree_u, surf.num_ctrlpts_u)

    condition = np.allclose(uvec, surf.knot_vector_u)

    assert condition
Beispiel #4
0
def test_generate2():
    degree = 3
    num_ctrlpts = 4

    expected = np.array([0, 0, 0, 0, 1, 1, 1, 1])

    generated = knots.generate_uniform(degree, num_ctrlpts)

    condition = np.allclose(generated, expected)

    assert condition
Beispiel #5
0
def test_generate3():
    degree = 2
    num_ctrlpts = 6

    expected = np.array([0, 0, 0, 0.25, 0.5, 0.75, 1, 1, 1])

    generated = knots.generate_uniform(degree, num_ctrlpts)

    condition = np.allclose(generated, expected)

    assert condition
Beispiel #6
0
def test_surf_knot_vector_guard_v():
    with pytest.raises(Exception):
        x = np.arange(0.0, 5.0)
        y = np.arange(0.0, 5.0)

        ys, xs = np.meshgrid(x, y)

        ctrlpt_array = np.column_stack(
            (xs.flatten(), ys.flatten(), np.zeros(len(xs.flatten()))))

        surf = spline.Surface()
        surf.degree_u = 2
        surf.degree_v = 2

        num_ctrlpts = 5

        knot_vec = knots.generate_uniform(surf.degree_v, num_ctrlpts)

        surf.knot_vector_v = knot_vec
Beispiel #7
0
import numpy as np
import nurbs
from splineDIC import knots
from splineDIC import spline

deg = 3
ncpts = 6
kv = knots.generate_uniform(deg, ncpts)

cpts = np.linspace(0.0, 4.0, ncpts)

ys, xs = np.meshgrid(cpts, cpts)
xcpts = xs.flatten()
ycpts = ys.flatten()

u = np.linspace(0, 1, 800)
uu, vv = np.meshgrid(u, u)

us = uu.flatten()
vs = vv.flatten()

uv = np.column_stack((us, vs))

surf = spline.Surface()

surf.degree_u = deg
surf.degree_v = deg

surf.num_ctrlpts_u = ncpts
surf.num_ctrlpts_v = ncpts
Beispiel #8
0
coords3d = np.column_stack((coords, np.zeros(len(coords))))

# Surface
ref_surf = spline.Surface()

ref_surf.degree_u = 2
ref_surf.degree_v = 2

num_ctrlpts = np.sqrt(len(coords)).astype('int')
ref_surf.num_ctrlpts_u = num_ctrlpts
ref_surf.num_ctrlpts_v = num_ctrlpts

ref_surf.control_points = coords3d

ref_surf.knot_vector_u = knots.generate_uniform(ref_surf.degree_u, num_ctrlpts)
ref_surf.knot_vector_v = knots.generate_uniform(ref_surf.degree_v, num_ctrlpts)


#TODO: MAKE THIS A FUNCTION
# Compute ROI and ROI uv values
# Get min and max column values from min/max reference ctrlpt node x values
min_col_index = np.min(coords[:, 0]).astype('int')
max_col_index = np.max(coords[:, 0]).astype('int')

# Get maximum column number for sub image array from ref ctrlpt node x values
colmax = (np.max(coords[:, 0]) - np.min(coords[:, 0])).astype('int')

# Get min and max column values from min/max reference ctrlpt node x values
min_row_index = np.min(coords[:, 1]).astype('int')
max_row_index = np.max(coords[:, 1]).astype('int')