sfepy.mesh.bspline module

class sfepy.mesh.bspline.BSpline(degree=3, is_cyclic=False, ncp=0)[source]

B-spline curve representation

approximate(coors, ncp=None, knot_type=’clamped’, knots=None, alpha=0.5, do_eval=False, do_param_correction=False)[source]

Approximate set of points by the B-spline curve.

Parameters:
coors : array

The coordinates of the approximated points.

ncp : int

The number of control points.

knot_type : str

The knot vector type.

knots : array

The knot vector.

alpha : float
The parameter vector distribution:

1.0 = chordal 0.5 = centripetal

do_eval : bool

Evaluate the curve coordinates?

do_param_correction : bool

Perform parametric corrections to improve the approximation?

static basis_function_dg(degree, t, knots, n)[source]

B-spline basis functions.

Parameters:
degree : int

The degree of the spline function.

t : array

The parametric vector.

knots : array

The knot vector.

n : int

The number of intervals.

Returns:
bfun : array

The spline basis function evaluated for given values.

static basis_function_dg0(t, knots, n)[source]

Basis function: degree = 0

Parameters:
t : array

The parametric vector.

knots : array

The knot vector.

n : int

The number of intervals.

Returns:
bfun : array

The spline basis function evaluated for given values.

draw(ret_ax=False, ax=None, color=’r’, cp_id=True)[source]

Draw B-spline curve.

Parameters:
ret_ax : bool

Return an axes object?

ax : axes object

The axes to which will be drawn.

color : str

Line color.

cp_id : bool

If True, label control points.

draw_basis()[source]

Draw B-spline curve.

eval(t=None, cp_coors=None)[source]

Evaluate the coordinates of the bpsline curve.

Parameters:
t : array

The parameter vector of the B-spline.

cp_coors : array

The coordinates of the control points.

eval_basis(t=None, return_val=False)[source]

Evaluate the basis of the bpsline.

Parameters:
t : array

The parameter vector of the B-spline.

get_control_points()[source]

Get the B-spline control points.

Returns:
coors : array

The coordinates of control points.

get_knot_vector()[source]

Return the knot vector.

Returns:
knots : array

The knot vector.

insert_knot(new)[source]

Insert a new knot into the knot vector.

Parameters:
new : float

The new knot value.

make_knot_vector(knot_type=’clamped’, knot_data=None, knot_range=(0.0, 1.0))[source]

Create a knot vector of the requested type.

Parameters:
knot_type : str

The knot vector type: clamped/cyclic/userdef.

knot_data :

The extra knot data.

set_approx_points(coors)[source]

Set the coordinates of approximated points.

Parameters:
coors : array

The coordinates of approximated points.

set_control_points(coors, cyclic_form=False)[source]

Set the B-spline control points.

Parameters:
coors : array

The coordinates of unique control points.

cyclic_form : bool

Are the control points in the cyclic form?

set_knot_vector(knots)[source]

Set the knot vector.

Parameters:
knots : array

The knot vector.

set_param(t)[source]

Set the B-spline parametric vector.

Parameters:
t : array

The parameter vector of the B-spline.

set_param_n(n=100, knot_range=(0.0, 1.0))[source]

Generate the B-spline parametric vector using the number of steps.

Parameters:
n : array

The number of steps in the B-spline parametric vector.

class sfepy.mesh.bspline.BSplineSurf(degree=(3, 3), is_cyclic=(False, False))[source]

B-spline surface representation

approximate(coors, ncp, do_eval=False)[source]

Approximate set of points by the B-spline surface.

Parameters:
coors : array

The coordinates of the approximated points.

ncp : tuple of int

The number of control points.

draw(ret_ax=False, ax=None)[source]

Draw B-spline surface.

Parameters:
ret_ax : bool

Return an axes object?

ax : axes object

The axes to which will be drawn.

eval(t=(None, None), cp_coors=None)[source]

Evaluate the coordinates of the bpsline curve.

Parameters:
t : tuple of array

The parametric vector of the B-splines.

cp_coors : array

The coordinates of the control points.

get_control_points()[source]

Get the B-spline surface control points.

Returns:
coors : array

The coordinates of control points.

make_knot_vector(knot_type=(‘clamped’, ’clamped’), knot_data=(None, None))[source]

Create a knot vector of the requested type.

Parameters:
knot_type : tuple of str

The knot vector types.

knot_data : tuple of ANY

The extra knot data.

set_approx_points(coors)[source]

Set the coordinates of approximated points.

Parameters:
coors : array

The coordinates of approximated points.

set_control_points(coors, cyclic_form=False)[source]

Set the B-spline control points.

Parameters:
coors : array

The coordinates of unique control points.

cyclic_form : bool

Are the control points in the cyclic form?

set_param_n(n=(100, 100))[source]

Generate the B-spline parametric vector using the number of steps.

Parameters:
n : tuple of array

The number of steps in the B-spline parametric vectors.

write_control_polygon_vtk(filename, float_format=’%.6f’)[source]

Write the control polygon to VTK file.

Parameters:
filename: str

Name of the VTK file.

float_format: str

Float formating.

write_surface_vtk(filename, float_format=’%.6f’)[source]

Write the spline surface to VTK file.

Parameters:
filename: str

Name of the VTK file.

float_format: str

Float formating.

sfepy.mesh.bspline.approximation_example()[source]

The example of using BSplineSurf for approximation of the surface given by the set of points.

sfepy.mesh.bspline.get_2d_points(is3d=False)[source]

Returns the set of points.

Parameters:
is3d : bool

3D coordinates?

sfepy.mesh.bspline.main(argv)[source]
sfepy.mesh.bspline.simple_example()[source]

The example of using B-spline class.

sfepy.mesh.bspline.to_ndarray(a)[source]