def surf(): """ 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) theta = np.linspace(0, 2 * np.pi, len(xs.flatten())) z = np.sin(theta) ctrlpt_array = np.column_stack((xs.flatten(), ys.flatten(), z)) 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
def test_surf_control_pt_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_v = 2 surf.control_points = ctrlpt_array
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