Spline Surface#

class SplineSurface(orders, knots_u=None, knots_v=None, control_points=None)[source]#

Bases: Module

The bivariate B-Spline surface model class.

A bivariate B-spline surface is a parametric surface defined as the tensor product of two univariate B-spline curves:

\[S(x, y) = \sum_{i,j=1}^{n_x, n_y} B_{i,k}(x) B_{j,s}(y) C_{i,j}, \quad x \in [x_1, x_m], y \in [y_1, y_l]\]

where:

  • \(C_{i,j} \in \mathbb{R}^2\) are the control points. These fixed points influence the shape of the surface but are not generally interpolated, except at the boundaries under certain knot multiplicities.

  • \(B_{i,k}(x)\) and \(B_{j,s}(y)\) are the B-spline basis functions defined over two orthogonal directions, with orders \(k\) and \(s\), respectively.

  • \(X = \{ x_1, x_2, \dots, x_m \}\) and \(Y = \{ y_1, y_2, \dots, y_l \}\) are the non-decreasing knot vectors along the two directions.

Initialization of the SplineSurface class.

Parameters:
  • orders (list[int]) – The orders of the spline along each parametric direction. Each order defines the degree of the corresponding basis as degree = order - 1.

  • knots_u (torch.Tensor | dict) – The knots of the spline along the first direction. For details on valid formats and initialization modes, see the Spline class. Default is None.

  • knots_v (torch.Tensor | dict) – The knots of the spline along the second direction. For details on valid formats and initialization modes, see the Spline class. Default is None.

  • control_points (torch.Tensor) – The control points defining the surface geometry. It must be a two-dimensional tensor of shape [len(knots_u) - orders[0], len(knots_v) - orders[1]]. If None, they are initialized as learnable parameters with zero values. Default is None.

Raises:
  • ValueError – If orders is not a list of integers.

  • ValueError – If knots_u is neither a torch.Tensor nor a dictionary, when provided.

  • ValueError – If knots_v is neither a torch.Tensor nor a dictionary, when provided.

  • ValueError – If control_points is not a torch.Tensor, when provided.

  • ValueError – If orders is not a list of two elements.

  • ValueError – If knots_u, knots_v, and control_points are all None.

forward(x)[source]#

Forward pass for the SplineSurface model.

Parameters:

x (torch.Tensor | LabelTensor) – The input tensor.

Returns:

The output tensor.

Return type:

torch.Tensor

property knots#

The knots of the univariate splines defining the spline surface.

Returns:

The knots.

Return type:

tuple(torch.Tensor, torch.Tensor)

property control_points#

The control points of the spline.

Returns:

The control points.

Return type:

torch.Tensor