NURBS Geometry¶
NURBS
module provides data storage and evaluation functions for rational spline geometries.
Inheritance Diagram¶
NURBS Curve¶

class
geomdl.NURBS.
Curve
(**kwargs)¶ Bases:
geomdl.BSpline.Curve
Data storage and evaluation class for nvariate NURBS (rational) curves.
The rational shapes have some minor differences between the nonrational ones. This class is designed to operate with weighted control points (Pw) as described in The NURBS Book by Piegl and Tiller. Therefore, it provides a different set of properties (i.e. getters and setters):
ctrlptsw
: 1dimensional array of weighted control pointsctrlpts
: 1dimensional array of control pointsweights
: 1dimensional array of weights
You may also use
set_ctrlpts()
function which is designed to work with all types of control points.This class provides the following properties:
order
degree
knotvector
ctrlptsw
ctrlpts
weights
delta
sample_size
bbox
vis
name
dimension
evaluator
rational
 Notes:
 Please see the
abstract.Surface()
documentation for details.  This class sets the FindSpan implementation to Linear Search by default.
 Please see the
Please refer to
ex_curve04.py
in the Examples repository for a NURBS curve example.
bbox
¶ Bounding box.
Evaluates the bounding box and returns the minimum and maximum coordinates.
Please refer to the wiki for details on using this class member.
Getter: Gets the bounding box Type: tuple

binormal
(parpos, **kwargs)¶ Evaluates the binormal vector of the curve at the given parametric position(s).
The
param
argument can be a float value for evaluation at a single parametric position
 a list of float values for evaluation at the multiple parametric positions
The return value will be in the order of the input parametric position list.
This method accepts the following keyword arguments:
normalize
: normalizes the output vector. Default value is True.
Parameters: parpos (float, list or tuple) – parametric position(s) where the evaluation will be executed Returns: an array containing “point” and “vector” pairs Return type: tuple

ctrlpts
¶ Control points (P).
Please refer to the wiki for details on using this class member.
Getter: Gets unweighted control points. Use weights
to get weights vector.Setter: Sets unweighted control points Type: list

ctrlpts_size
¶ Total number of control points.
Getter: Gets the total number of control points Type: int

ctrlptsw
¶ Weighted control points (Pw).
Weighted control points are in (x*w, y*w, z*w, w) format; where x,y,z are the coordinates and w is the weight.
Please refer to the wiki for details on using this class member.
Getter: Gets the weighted control points Setter: Sets the weighted control points

data
¶ Returns a dictionary containing all shape data.
Please refer to the wiki for details on using this class member.

degree
¶ Degree.
Please refer to the wiki for details on using this class member.
Getter: Gets the degree Setter: Sets the degree Type: int

delta
¶ Evaluation delta.
Evaluation delta corresponds to the step size while
evaluate
function iterates on the knot vector to generate curve points. Decreasing step size results in generation of more curve points. Therefore; smaller the delta value, smoother the curve.The following figure illustrates the working principles of the delta property:
Please refer to the wiki for details on using this class member.
Getter: Gets the delta value Setter: Sets the delta value Type: float

derivatives
(u, order=0, **kwargs)¶ Evaluates nth order curve derivatives at the given parameter value.
Parameters:  u (float) – parameter value
 order (int) – derivative order
Returns: a list containing up to {order}th derivative of the curve
Return type: list

dimension
¶ Spatial dimension.
Spatial dimension will be automatically estimated from the first element of the control points array.
Please refer to the wiki for details on using this class member.
Getter: Gets the spatial dimension, e.g. 2D, 3D, etc. Type: int

domain
¶ Domain.
Domain is determined using the knot vector(s).
Getter: Gets the domain

evalpts
¶ Evaluated points.
Please refer to the wiki for details on using this class member.
Getter: Gets the coordinates of the evaluated points Type: list

evaluate
(**kwargs)¶ Evaluates the curve.
The evaluated curve points are stored in :py:attr:`~evalpts` property.
 Keyword arguments:
start
: start parameterstop
: stop parameter
The
start
andstop
parameters allow evaluation of a curve segment in the range [start, stop], i.e. the curve will also be evaluated at thestop
parameter value.The following examples illustrate the usage of the keyword arguments.
# Start evaluating from u=0.2 to u=1.0 curve.evaluate(start=0.2) # Start evaluating from u=0.0 to u=0.7 curve.evaluate(stop=0.7) # Start evaluating from u=0.1 to u=0.5 curve.evaluate(start=0.1, stop=0.5) # Get the evaluated points curve_points = curve.evalpts

evaluate_list
(param_list)¶ Evaluates the curve for an input range of parameters.
Parameters: param_list (list, tuple) – list of parameters Returns: evaluated surface points at the input parameters Return type: list

evaluate_single
(param)¶ Evaluates the curve at the input parameter.
Parameters: param (float) – parameter Returns: evaluated surface point at the given parameter Return type: list

evaluator
¶ Evaluator instance.
Evaluators allow users to use different algorithms for BSpline and NURBS evaluations. Please see the documentation on
Evaluator
classes.Please refer to the wiki for details on using this class member.
Getter: Gets the current Evaluator instance Setter: Sets the Evaluator instance Type: evaluators.AbstractEvaluator

insert_knot
(u, **kwargs)¶ Inserts the given knot and updates the control points array and the knot vector.
 Keyword Arguments:
r
: Number of knot insertions. Default: 1
Parameters: u (float) – knot to be inserted

knotvector
¶ Knot vector.
The knot vector will be normalized to [0, 1] domain if the class is initialized with
normalize_kv=True
argument.Please refer to the wiki for details on using this class member.
Getter: Gets the knot vector Setter: Sets the knot vector Type: list

load
(file_name)¶ Loads the curve from a pickled file.
Parameters: file_name (str) – name of the file to be loaded Raises: IOError – an error occurred reading the file

name
¶ Descriptor field for storing the shape identification data, such as names, ID numbers, etc.
Please refer to the wiki for details on using this class member.
Getter: Gets the descriptor Setter: Sets the descriptor Type: str

next
()¶

normal
(parpos, **kwargs)¶ Evaluates the normal vector of the curve at the given parametric position(s).
The
param
argument can be a float value for evaluation at a single parametric position
 a list of float values for evaluation at the multiple parametric positions
The return value will be in the order of the input parametric position list.
This method accepts the following keyword arguments:
normalize
: normalizes the output vector. Default value is True.
Parameters: parpos (float, list or tuple) – parametric position(s) where the evaluation will be executed Returns: an array containing “point” and “vector” pairs Return type: tuple

order
¶ Order.
Defined as
order = degree + 1
Please refer to the wiki for details on using this class member.
Getter: Gets the order Setter: Sets the order Type: int

pdimension
¶ Parametric dimension.
Please refer to the wiki for details on using this class member.
Getter: Gets the parametric dimension Type: int

range
¶ Domain range.
Getter: Gets the range

rational
¶ Defines the rational and nonrational Bspline shapes.
Rational shapes use homogeneous coordinates which includes a weight alongside with the Cartesian coordinates. Rational Bsplines are also named as NURBS (Nonuniform rational basis spline) and nonrational Bsplines are sometimes named as NUBS (Nonuniform basis spline) or directly as Bsplines.
Please refer to the wiki for details on using this class member.
Getter: Returns True is the Bspline object is rational (NURBS) Type: bool

render
(**kwargs)¶ Renders the curve using the visualization component
The visualization component must be set using
vis
property before calling this method. Keyword Arguments:
cpcolor
: sets the color of the control points polygonevalcolor
: sets the color of the curvebboxcolor
: sets the color of the bounding boxfilename
: saves the plot with the input nameplot
: controls plot window visibility. Default: Trueanimate
: activates animation (if supported). Default: Falseextras
: adds line plots to the figure. Default: None
plot
argument is useful when you would like to work on the command line without any window context. Ifplot
flag is False, this method saves the plot as an image file (.png file where possible) and disables plot window popping out. If you don’t provide a file name, the name of the image file will be pulled from the configuration class.extras
argument can be used to add extra line plots to the figure. This argument expects a list of dicts in the format described below:1 2 3 4 5 6 7 8 9 10 11 12 13 14
[ dict( # line plot 1 points=[[1, 2, 3], [4, 5, 6]], # list of points name="My line Plot 1", # name displayed on the legend color="red", # color of the line plot size=6.5 # size of the line plot ), dict( # line plot 2 points=[[7, 8, 9], [10, 11, 12]], # list of points name="My line Plot 2", # name displayed on the legend color="navy", # color of the line plot size=12.5 # size of the line plot ) ]

reset
(**kwargs)¶ Resets control points and/or evaluated points.
Keyword Arguments:
evalpts
: if True, then resets evaluated pointsctrlpts
if True, then resets control points

sample_size
¶ Sample size.
Sample size defines the number of evaluated points to generate. It also sets the
delta
property.The following figure illustrates the working principles of sample size property:
Please refer to the wiki for details on using this class member.
Getter: Gets sample size Setter: Sets sample size Type: int

save
(file_name)¶ Saves the curve as a pickled file.
Parameters: file_name (str) – name of the file to be saved Raises: IOError – an error occurred writing the file

set_ctrlpts
(ctrlpts, *args, **kwargs)¶ Sets control points and checks if the data is consistent.
This method is designed to provide a consistent way to set control points whether they are weighted or not. It directly sets the control points member of the class, and therefore it doesn’t return any values. The input will be an array of coordinates. If you are working in the 3dimensional space, then your coordinates will be an array of 3 elements representing (x, y, z) coordinates.
Parameters: ctrlpts (list) – input control points as a list of coordinates

tangent
(param, **kwargs)¶ Evaluates the tangent vector of the curve at the given parametric position(s).
The
param
argument can be a float value for evaluation at a single parametric position
 a list of float values for evaluation at the multiple parametric positions
The return value will be in the order of the input parametric position list.
This method accepts the following keyword arguments:
normalize
: normalizes the output vector. Default value is True.
Parameters: param (float, list or tuple) – parametric position(s) where the evaluation will be executed Returns: an array containing “point” and “vector” pairs Return type: tuple
NURBS Surface¶

class
geomdl.NURBS.
Surface
(**kwargs)¶ Bases:
geomdl.BSpline.Surface
Data storage and evaluation class for NURBS (rational) surfaces.
The rational shapes have some minor differences between the nonrational ones. This class is designed to operate with weighted control points (Pw) as described in The NURBS Book by Piegl and Tiller. Therefore, it provides a different set of properties (i.e. getters and setters):
ctrlptsw
: 1dimensional array of weighted control pointsctrlpts2d
: 2dimensional array of weighted control pointsctrlpts
: 1dimensional array of control pointsweights
: 1dimensional array of weights
You may also use
set_ctrlpts()
function which is designed to work with all types of control points.This class provides the following properties:
order_u
order_v
degree_u
degree_v
knotvector_u
knotvector_v
ctrlptsw
ctrlpts
weights
ctrlpts_size_u
ctrlpts_size_v
ctrlpts2d
delta
delta_u
delta_v
sample_size
sample_size_u
sample_size_v
bbox
name
dimension
vis
evaluator
tessellator
rational
trims
 Notes:
 Please see the
abstract.Surface()
documentation for details.  This class sets the FindSpan implementation to Linear Search by default.
 Please see the
Please refer to
ex_surface03.py
in the Examples repository for a NURBS surface example.
bbox
¶ Bounding box.
Evaluates the bounding box and returns the minimum and maximum coordinates.
Please refer to the wiki for details on using this class member.
Getter: Gets the bounding box Type: tuple

ctrlpts
¶ 1dimensional array of control points (P).
This property sets and gets the control points in 1D.
Getter: Gets unweighted control points. Use weights
to get weights vector.Setter: Sets unweighted control points. Type: list

ctrlpts2d
¶ 2dimensional array of control points.
The getter returns a tuple of 2D control points (weighted control points + weights if NURBS) in [u][v] format. The rows of the returned tuple correspond to vdirection and the columns correspond to udirection.
The following example can be used to traverse 2D control points:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# Create a BSpline surface surf_bs = BSpline.Surface() # Do degree, control points and knot vector assignments here # Each u includes a row of v values for u in surf_bs.ctrlpts2d: # Each row contains the coordinates of the control points for v in u: print(str(v)) # will be something like (1.0, 2.0, 3.0) # Create a NURBS surface surf_nb = NURBS.Surface() # Do degree, weighted control points and knot vector assignments here # Each u includes a row of v values for u in surf_nb.ctrlpts2d: # Each row contains the coordinates of the weighted control points for v in u: print(str(v)) # will be something like (0.5, 1.0, 1.5, 0.5)
When using NURBS.Surface class, the output of
ctrlpts2d
property could be confusing since,ctrlpts
always returns the unweighted control points, i.e.ctrlpts
property returns 3D control points all divided by the weights and you can useweights
property to access the weights vector, butctrlpts2d
returns the weighted ones plus weights as the last element. This difference is intentionally added for compatibility and interoperability purposes.To explain this situation in a simple way;
 If you need the weighted control points directly, use
ctrlpts2d
 If you need the control points and the weights separately, use
ctrlpts
andweights
Note
Please note that the setter doesn’t check for inconsistencies and using the setter is not recommended. Instead of the setter property, please use
set_ctrlpts()
function.Please refer to the wiki for details on using this class member.
Getter: Gets the control points as a 2dimensional array in [u][v] format Setter: Sets the control points as a 2dimensional array in [u][v] format Type: list  If you need the weighted control points directly, use

ctrlpts_size
¶ Total number of control points.
Getter: Gets the total number of control points Type: int

ctrlpts_size_u
¶ Number of control points for the udirection.
Please refer to the wiki for details on using this class member.
Getter: Gets number of control points for the udirection Setter: Sets number of control points for the udirection

ctrlpts_size_v
¶ Number of control points for the vdirection.
Please refer to the wiki for details on using this class member.
Getter: Gets number of control points on the vdirection Setter: Sets number of control points on the vdirection

ctrlptsw
¶ 1dimensional array of weighted control points (Pw).
Weighted control points are in (x*w, y*w, z*w, w) format; where x,y,z are the coordinates and w is the weight.
This property sets and gets the control points in 1D.
Getter: Gets weighted control points Setter: Sets weighted control points

data
¶ Returns a dictionary containing all shape data.
Please refer to the wiki for details on using this class member.

degree
¶ Degree for u and vdirections
Getter: Gets the degree Setter: Sets the degree Type: list

degree_u
¶ Degree for the udirection.
Please refer to the wiki for details on using this class member.
Getter: Gets degree for the udirection Setter: Sets degree for the udirection Type: int

degree_v
¶ Degree for the vdirection.
Please refer to the wiki for details on using this class member.
Getter: Gets degree for the vdirection Setter: Sets degree for the vdirection Type: int

delta
¶ Evaluation delta for both u and vdirections.
Evaluation delta corresponds to the step size while
evaluate()
function iterates on the knot vector to generate surface points. Decreasing step size results in generation of more surface points. Therefore; smaller the delta value, smoother the surface.Please note that
delta
andsample_size
properties correspond to the same variable with different descriptions. Therefore, settingdelta
will also setsample_size
.The following figure illustrates the working principles of the delta property:
Please refer to the wiki for details on using this class member.
Getter: Gets evaluation delta as a tuple of values corresponding to u and vdirections Setter: Sets evaluation delta for both u and vdirections Type: float

delta_u
¶ Evaluation delta for the udirection.
Evaluation delta corresponds to the step size while
evaluate()
function iterates on the knot vector to generate surface points. Decreasing step size results in generation of more surface points. Therefore; smaller the delta value, smoother the surface.Please note that
delta_u
andsample_size_u
properties correspond to the same variable with different descriptions. Therefore, settingdelta_u
will also setsample_size_u
.Please refer to the wiki for details on using this class member.
Getter: Gets evaluation delta for the udirection Setter: Sets evaluation delta for the udirection Type: float

delta_v
¶ Evaluation delta for the vdirection.
Evaluation delta corresponds to the step size while
evaluate()
function iterates on the knot vector to generate surface points. Decreasing step size results in generation of more surface points. Therefore; smaller the delta value, smoother the surface.Please note that
delta_v
andsample_size_v
properties correspond to the same variable with different descriptions. Therefore, settingdelta_v
will also setsample_size_v
.Please refer to the wiki for details on using this class member.
Getter: Gets evaluation delta for the vdirection Setter: Sets evaluation delta for the vdirection Type: float

derivatives
(u, v, order=0, **kwargs)¶ Evaluates nth order surface derivatives at the given (u, v) parameter pair.
 SKL[0][0] will be the surface point itself
 SKL[0][1] will be the 1st derivative w.r.t. v
 SKL[2][1] will be the 2nd derivative w.r.t. u and 1st derivative w.r.t. v
Parameters:  u (float) – parameter on the udirection
 v (float) – parameter on the vdirection
 order (integer) – derivative order
Returns: A list SKL, where SKL[k][l] is the derivative of the surface S(u,v) w.r.t. u k times and v l times
Return type: list

dimension
¶ Spatial dimension.
Spatial dimension will be automatically estimated from the first element of the control points array.
Please refer to the wiki for details on using this class member.
Getter: Gets the spatial dimension, e.g. 2D, 3D, etc. Type: int

domain
¶ Domain.
Domain is determined using the knot vector(s).
Getter: Gets the domain

evalpts
¶ Evaluated points.
Please refer to the wiki for details on using this class member.
Getter: Gets the coordinates of the evaluated points Type: list

evaluate
(**kwargs)¶ Evaluates the surface.
The evaluated surface points are stored in :py:attr:`~evalpts` property.
 Keyword arguments:
start_u
: start parameter on the udirectionstop_u
: stop parameter on the udirectionstart_v
: start parameter on the vdirectionstop_v
: stop parameter on the vdirection
The
start_u
,start_v
andstop_u
andstop_v
parameters allow evaluation of a surface segment in the range [start_u, stop_u][start_v, stop_v] i.e. the surface will also be evaluated at thestop_u
andstop_v
parameter values.The following examples illustrate the usage of the keyword arguments.
1 2 3 4 5 6 7 8
# Start evaluating in range u=[0, 0.7] and v=[0.1, 1] surf.evaluate(stop_u=0.7, start_v=0.1) # Start evaluating in range u=[0, 1] and v=[0.1, 0.3] surf.evaluate(start_v=0.1, stop_v=0.3) # Get the evaluated points surface_points = surf.evalpts

evaluate_list
(param_list)¶ Evaluates the surface for a given list of (u, v) parameters.
Parameters: param_list (list, tuple) – list of parameter pairs (u, v) Returns: evaluated surface point at the input parameter pairs Return type: tuple

evaluate_single
(param)¶ Evaluates the surface at the input (u, v) parameter pair.
Parameters: param (list, tuple) – parameter pair (u, v) Returns: evaluated surface point at the given parameter pair Return type: list

evaluator
¶ Evaluator instance.
Evaluators allow users to use different algorithms for BSpline and NURBS evaluations. Please see the documentation on
Evaluator
classes.Please refer to the wiki for details on using this class member.
Getter: Gets the current Evaluator instance Setter: Sets the Evaluator instance Type: evaluators.AbstractEvaluator

insert_knot
(u=None, v=None, **kwargs)¶ Inserts knot(s) in u or vdirections
If you keep a parameter assigned to
None
, there will be no knot insertion to that parametric direction. Keyword Arguments:
ru
: Number of knot insertions on the udirection. Default: 1rv
: Number of knot insertions on the vdirection. Default: 1
Parameters:  u (float) – Knot to be inserted on the udirection
 v (float) – Knot to be inserted on the vdirection

knotvector
¶ Knot vector for u and vdirections
Getter: Gets the knot vector Setter: Sets the knot vector Type: list

knotvector_u
¶ Knot vector for the udirection.
The knot vector will be normalized to [0, 1] domain if the class is initialized with
normalize_kv=True
argument.Please refer to the wiki for details on using this class member.
Getter: Gets knot vector for the udirection Setter: Sets knot vector for the udirection Type: list

knotvector_v
¶ Knot vector for the vdirection.
The knot vector will be normalized to [0, 1] domain if the class is initialized with
normalize_kv=True
argument.Please refer to the wiki for details on using this class member.
Getter: Gets knot vector for the vdirection Setter: Sets knot vector for the vdirection Type: list

load
(file_name)¶ Loads the surface from a pickled file.
Parameters: file_name (str) – name of the file to be loaded Raises: IOError – an error occurred reading the file

name
¶ Descriptor field for storing the shape identification data, such as names, ID numbers, etc.
Please refer to the wiki for details on using this class member.
Getter: Gets the descriptor Setter: Sets the descriptor Type: str

next
()¶

normal
(parpos, **kwargs)¶ Evaluates the normal vector of the surface at the given parametric position(s).
The
param
argument can be a float value for evaluation at a single parametric position
 a list of float values for evaluation at the multiple parametric positions
The parametric positions should be a pair of (u,v) values. The return value will be in the order of the input parametric position list.
This method accepts the following keyword arguments:
normalize
: normalizes the output vector. Default value is True.
Parameters: parpos (list or tuple) – parametric position(s) where the evaluation will be executed Returns: an array containing “point” and “vector” pairs Return type: tuple

order_u
¶ Order for the udirection.
Defined as
order = degree + 1
Please refer to the wiki for details on using this class member.
Getter: Gets order for the udirection Setter: Sets order for the udirection Type: int

order_v
¶ Order for the vdirection.
Defined as
order = degree + 1
Please refer to the wiki for details on using this class member.
Getter: Gets surface order for the vdirection Setter: Sets surface order for the vdirection Type: int

pdimension
¶ Parametric dimension.
Please refer to the wiki for details on using this class member.
Getter: Gets the parametric dimension Type: int

range
¶ Domain range.
Getter: Gets the range

rational
¶ Defines the rational and nonrational Bspline shapes.
Rational shapes use homogeneous coordinates which includes a weight alongside with the Cartesian coordinates. Rational Bsplines are also named as NURBS (Nonuniform rational basis spline) and nonrational Bsplines are sometimes named as NUBS (Nonuniform basis spline) or directly as Bsplines.
Please refer to the wiki for details on using this class member.
Getter: Returns True is the Bspline object is rational (NURBS) Type: bool

render
(**kwargs)¶ Renders the surface using the visualization component.
The visualization component must be set using
vis
property before calling this method. Keyword Arguments:
cpcolor
: sets the color of the control points gridevalcolor
: sets the color of the surfacetrimcolor
: sets the color of the trim curvesfilename
: saves the plot with the input nameplot
: controls plot window visibility. Default: Trueanimate
: activates animation (if supported). Default: Falseextras
: adds line plots to the figure. Default: Nonecolormap
: sets the colormap of the surface
The
plot
argument is useful when you would like to work on the command line without any window context. Ifplot
flag is False, this method saves the plot as an image file (.png file where possible) and disables plot window popping out. If you don’t provide a file name, the name of the image file will be pulled from the configuration class.extras
argument can be used to add extra line plots to the figure. This argument expects a list of dicts in the format described below:1 2 3 4 5 6 7 8 9 10 11 12 13 14
[ dict( # line plot 1 points=[[1, 2, 3], [4, 5, 6]], # list of points name="My line Plot 1", # name displayed on the legend color="red", # color of the line plot size=6.5 # size of the line plot ), dict( # line plot 2 points=[[7, 8, 9], [10, 11, 12]], # list of points name="My line Plot 2", # name displayed on the legend color="navy", # color of the line plot size=12.5 # size of the line plot ) ]
Please note that
colormap
argument can only work with visualization classes that support colormaps. As an example, please seeVisMPL.VisSurfTriangle()
class documentation. This method expects a single colormap input.

reset
(**kwargs)¶ Resets control points and/or evaluated points.
Keyword Arguments:
evalpts
: if True, then resets evaluated pointsctrlpts
if True, then resets control points

sample_size
¶ Sample size for both u and vdirections.
Sample size defines the number of surface points to generate. It also sets the
delta
property.The following figure illustrates the working principles of sample size property:
Please refer to the wiki for details on using this class member.
Getter: Gets sample size as a tuple of values corresponding to u and vdirections Setter: Sets sample size for both u and vdirections Type: int

sample_size_u
¶ Sample size for the udirection.
Sample size defines the number of surface points to generate. It also sets the
delta_u
property.Please refer to the wiki for details on using this class member.
Getter: Gets sample size for the udirection Setter: Sets sample size for the udirection Type: int

sample_size_v
¶ Sample size for the vdirection.
Sample size defines the number of surface points to generate. It also sets the
delta_v
property.Please refer to the wiki for details on using this class member.
Getter: Gets sample size for the vdirection Setter: Sets sample size for the vdirection Type: int

save
(file_name)¶ Saves the surface as a pickled file.
Parameters: file_name (str) – name of the file to be saved Raises: IOError – an error occurred writing the file

set_ctrlpts
(ctrlpts, *args, **kwargs)¶ Sets the control points and checks if the data is consistent.
This method is designed to provide a consistent way to set control points whether they are weighted or not. It directly sets the control points member of the class, and therefore it doesn’t return any values. The input will be an array of coordinates. If you are working in the 3dimensional space, then your coordinates will be an array of 3 elements representing (x, y, z) coordinates.
This method also generates 2D control points in [u][v] format which can be accessed via
ctrlpts2d
.Note
The v index varies first. That is, a row of v control points for the first u value is found first. Then, the row of v control points for the next u value.
Parameters: ctrlpts (list) – input control points as a list of coordinates

tangent
(parpos, **kwargs)¶ Evaluates the tangent vectors of the surface at the given parametric position(s).
The
param
argument can be a float value for evaluation at a single parametric position
 a list of float values for evaluation at the multiple parametric positions
The parametric positions should be a pair of (u,v) values. The return value will be in the order of the input parametric position list.
This method accepts the following keyword arguments:
normalize
: normalizes the output vector. Default value is True.
Parameters: parpos (list or tuple) – parametric position(s) where the evaluation will be executed Returns: an array containing “point” and “vector”s on u and vdirections, respectively Return type: tuple

tessellate
(**kwargs)¶ Tessellates the surface.
Keyword arguments are directly passed to the tessellation component.

tessellator
¶ Tessellation component.
Please refer to the wiki for details on using this class member.
Getter: Gets the tessellation component Setter: Sets the tessellation component

transpose
()¶ Transposes the surface by swapping u and v parametric directions.

trims
¶ Trim curves.
Trim curves are introduced to the surfaces on the parametric space. It should be an array (or list, tuple, etc.) and they are integrated to the existing visualization system.
Please refer to the wiki for details on using this class member.
Getter: Gets the array of trim curves Setter: Sets the array of trim curves

vis
¶ Visualization component.
Please refer to the wiki for details on using this class member.
Getter: Gets the visualization component Setter: Sets the visualization component Type: vis.VisAbstract

weights
¶ Weights vector.
Getter: Gets the weights vector Setter: Sets the weights vector Type: list
NURBS Volume¶

class
geomdl.NURBS.
Volume
(**kwargs)¶ Bases:
geomdl.BSpline.Volume
Data storage and evaluation class for NURBS (rational) volumes.
The rational shapes have some minor differences between the nonrational ones. This class is designed to operate with weighted control points (Pw) as described in The NURBS Book by Piegl and Tiller. Therefore, it provides a different set of properties (i.e. getters and setters):
ctrlptsw
: 1dimensional array of weighted control pointsctrlpts
: 1dimensional array of control pointsweights
: 1dimensional array of weights
This class provides the following properties:
order_u
order_v
order_w
degree_u
degree_v
degree_w
knotvector_u
knotvector_v
knotvector_w
ctrlptsw
ctrlpts
weights
ctrlpts_size_u
ctrlpts_size_v
ctrlpts_size_w
delta
delta_u
delta_v
delta_w
sample_size
sample_size_u
sample_size_v
sample_size_w
bbox
name
dimension
vis
evaluator
rational
 Notes:
 Please see the
abstract.Volume()
documentation for details.  This class sets the FindSpan implementation to Linear Search by default.
 Please see the

bbox
¶ Bounding box.
Evaluates the bounding box and returns the minimum and maximum coordinates.
Please refer to the wiki for details on using this class member.
Getter: Gets the bounding box Type: tuple

ctrlpts
¶ 1dimensional array of control points (P).
This property sets and gets the control points in 1D.
Getter: Gets unweighted control points. Use weights
to get weights vector.Setter: Sets unweighted control points. Type: list

ctrlpts_size
¶ Total number of control points.
Getter: Gets the total number of control points Type: int

ctrlpts_size_u
¶ Number of control points for the udirection.
Please refer to the wiki for details on using this class member.
Getter: Gets number of control points for the udirection Setter: Sets number of control points for the udirection

ctrlpts_size_v
¶ Number of control points for the vdirection.
Please refer to the wiki for details on using this class member.
Getter: Gets number of control points for the vdirection Setter: Sets number of control points for the vdirection

ctrlpts_size_w
¶ Number of control points for the wdirection.
Please refer to the wiki for details on using this class member.
Getter: Gets number of control points for the wdirection Setter: Sets number of control points for the wdirection

ctrlptsw
¶ 1dimensional array of weighted control points (Pw).
Weighted control points are in (x*w, y*w, z*w, w) format; where x,y,z are the coordinates and w is the weight.
This property sets and gets the control points in 1D.
Getter: Gets weighted control points Setter: Sets weighted control points

data
¶ Returns a dictionary containing all shape data.
Please refer to the wiki for details on using this class member.

degree
¶ Degree for u, v and wdirections
Getter: Gets the degree Setter: Sets the degree Type: list

degree_u
¶ Degree for the udirection.
Please refer to the wiki for details on using this class member.
Getter: Gets degree for the udirection Setter: Sets degree for the udirection Type: int

degree_v
¶ Degree for the vdirection.
Please refer to the wiki for details on using this class member.
Getter: Gets degree for the vdirection Setter: Sets degree for the vdirection Type: int

degree_w
¶ Degree for the wdirection.
Please refer to the wiki for details on using this class member.
Getter: Gets degree for the wdirection Setter: Sets degree for the wdirection Type: int

delta
¶ Evaluation delta for u, v and wdirections.
Evaluation delta corresponds to the step size while
evaluate()
function iterates on the knot vector to generate surface points. Decreasing step size results in generation of more surface points. Therefore; smaller the delta value, smoother the surface.Please note that
delta
andsample_size
properties correspond to the same variable with different descriptions. Therefore, settingdelta
will also setsample_size
.The following figure illustrates the working principles of the delta property:
Please refer to the wiki for details on using this class member.
Getter: Gets evaluation delta as a tuple of values corresponding to u, v and wdirections Setter: Sets evaluation delta for u, v and wdirections Type: float

delta_u
¶ Evaluation delta for the udirection.
Evaluation delta corresponds to the step size while
evaluate()
function iterates on the knot vector to generate surface points. Decreasing step size results in generation of more surface points. Therefore; smaller the delta value, smoother the surface.Please note that
delta_u
andsample_size_u
properties correspond to the same variable with different descriptions. Therefore, settingdelta_u
will also setsample_size_u
.Please refer to the wiki for details on using this class member.
Getter: Gets evaluation delta for the udirection Setter: Sets evaluation delta for the udirection Type: float

delta_v
¶ Evaluation delta for the vdirection.
Evaluation delta corresponds to the step size while
evaluate()
function iterates on the knot vector to generate surface points. Decreasing step size results in generation of more surface points. Therefore; smaller the delta value, smoother the surface.Please note that
delta_v
andsample_size_v
properties correspond to the same variable with different descriptions. Therefore, settingdelta_v
will also setsample_size_v
.Please refer to the wiki for details on using this class member.
Getter: Gets evaluation delta for the vdirection Setter: Sets evaluation delta for the vdirection Type: float

delta_w
¶ Evaluation delta for the wdirection.
Evaluation delta corresponds to the step size while
evaluate()
function iterates on the knot vector to generate surface points. Decreasing step size results in generation of more surface points. Therefore; smaller the delta value, smoother the surface.Please note that
delta_w
andsample_size_w
properties correspond to the same variable with different descriptions. Therefore, settingdelta_w
will also setsample_size_w
.Please refer to the wiki for details on using this class member.
Getter: Gets evaluation delta for the wdirection Setter: Sets evaluation delta for the wdirection Type: float

dimension
¶ Spatial dimension.
Spatial dimension will be automatically estimated from the first element of the control points array.
Please refer to the wiki for details on using this class member.
Getter: Gets the spatial dimension, e.g. 2D, 3D, etc. Type: int

domain
¶ Domain.
Domain is determined using the knot vector(s).
Getter: Gets the domain

evalpts
¶ Evaluated points.
Please refer to the wiki for details on using this class member.
Getter: Gets the coordinates of the evaluated points Type: list

evaluate
(**kwargs)¶ Evaluates the volume.
The evaluated points are stored in :py:attr:`~evalpts` property.
 Keyword arguments:
start_u
: start parameter on the udirectionstop_u
: stop parameter on the udirectionstart_v
: start parameter on the vdirectionstop_v
: stop parameter on the vdirectionstart_w
: start parameter on the wdirectionstop_w
: stop parameter on the wdirection

evaluate_list
(param_list)¶ Evaluates the volume for a given list of (u, v, w) parameters.
Parameters: param_list (list, tuple) – list of parameters in format (u, v, w) Returns: evaluated surface point at the input parameter pairs Return type: tuple

evaluate_single
(param)¶ Evaluates the volume at the input (u, v, w) parameter.
Parameters: param (list, tuple) – parameter (u, v, w) Returns: evaluated surface point at the given parameter pair Return type: list

evaluator
¶ Evaluator instance.
Evaluators allow users to use different algorithms for BSpline and NURBS evaluations. Please see the documentation on
Evaluator
classes.Please refer to the wiki for details on using this class member.
Getter: Gets the current Evaluator instance Setter: Sets the Evaluator instance Type: evaluators.AbstractEvaluator

knotvector
¶ Knot vector for u, v and wdirections
Getter: Gets the knot vector Setter: Sets the knot vector Type: list

knotvector_u
¶ Knot vector for the udirection.
The knot vector will be normalized to [0, 1] domain if the class is initialized with
normalize_kv=True
argument.Please refer to the wiki for details on using this class member.
Getter: Gets knot vector for the udirection Setter: Sets knot vector for the udirection Type: list

knotvector_v
¶ Knot vector for the vdirection.
The knot vector will be normalized to [0, 1] domain if the class is initialized with
normalize_kv=True
argument.Please refer to the wiki for details on using this class member.
Getter: Gets knot vector for the vdirection Setter: Sets knot vector for the vdirection Type: list

knotvector_w
¶ Knot vector for the wdirection.
The knot vector will be normalized to [0, 1] domain if the class is initialized with
normalize_kv=True
argument.Please refer to the wiki for details on using this class member.
Getter: Gets knot vector for the wdirection Setter: Sets knot vector for the wdirection Type: list

load
(file_name)¶ Loads the volume from a pickled file.
Parameters: file_name (str) – name of the file to be loaded Raises: IOError – an error occurred reading the file

name
¶ Descriptor field for storing the shape identification data, such as names, ID numbers, etc.
Please refer to the wiki for details on using this class member.
Getter: Gets the descriptor Setter: Sets the descriptor Type: str

next
()¶

order_u
¶ Order for the udirection.
Defined as
order = degree + 1
Please refer to the wiki for details on using this class member.
Getter: Gets the surface order for udirection Setter: Sets the surface order for udirection Type: int

order_v
¶ Order for the vdirection.
Defined as
order = degree + 1
Please refer to the wiki for details on using this class member.
Getter: Gets the surface order for vdirection Setter: Sets the surface order for vdirection Type: int

order_w
¶ Order for the wdirection.
Defined as
order = degree + 1
Please refer to the wiki for details on using this class member.
Getter: Gets the surface order for vdirection Setter: Sets the surface order for vdirection Type: int

pdimension
¶ Parametric dimension.
Please refer to the wiki for details on using this class member.
Getter: Gets the parametric dimension Type: int

range
¶ Domain range.
Getter: Gets the range

rational
¶ Defines the rational and nonrational Bspline shapes.
Rational shapes use homogeneous coordinates which includes a weight alongside with the Cartesian coordinates. Rational Bsplines are also named as NURBS (Nonuniform rational basis spline) and nonrational Bsplines are sometimes named as NUBS (Nonuniform basis spline) or directly as Bsplines.
Please refer to the wiki for details on using this class member.
Getter: Returns True is the Bspline object is rational (NURBS) Type: bool

render
(**kwargs)¶ Renders the volume using the visualization component.
The visualization component must be set using
vis
property before calling this method. Keyword Arguments:
cpcolor
: sets the color of the control pointsevalcolor
: sets the color of the volumefilename
: saves the plot with the input nameplot
: controls plot window visibility. Default: Trueanimate
: activates animation (if supported). Default: Falsegrid_size
: grid size for voxelization. Default: (16, 16, 16)use_mp
: flag to activate multithreaded voxelization. Default: Falsenum_procs
: number of concurrent processes for multithreaded voxelization. Default: 4
The
plot
argument is useful when you would like to work on the command line without any window context. Ifplot
flag is False, this method saves the plot as an image file (.png file where possible) and disables plot window popping out. If you don’t provide a file name, the name of the image file will be pulled from the configuration class.extras
argument can be used to add extra line plots to the figure. This argument expects a list of dicts in the format described below:1 2 3 4 5 6 7 8 9 10 11 12 13 14
[ dict( # line plot 1 points=[[1, 2, 3], [4, 5, 6]], # list of points name="My line Plot 1", # name displayed on the legend color="red", # color of the line plot size=6.5 # size of the line plot ), dict( # line plot 2 points=[[7, 8, 9], [10, 11, 12]], # list of points name="My line Plot 2", # name displayed on the legend color="navy", # color of the line plot size=12.5 # size of the line plot ) ]

reset
(**kwargs)¶ Resets control points and/or evaluated points.
Keyword Arguments:
evalpts
: if True, then resets the evaluated pointsctrlpts
if True, then resets the control points

sample_size
¶ Sample size for both u and vdirections.
Sample size defines the number of surface points to generate. It also sets the
delta
property.The following figure illustrates the working principles of sample size property:
Please refer to the wiki for details on using this class member.
Getter: Gets sample size as a tuple of values corresponding to u, v and wdirections Setter: Sets sample size value for both u, v and wdirections Type: int

sample_size_u
¶ Sample size for the udirection.
Sample size defines the number of evaluated points to generate. It also sets the
delta_u
property.Please refer to the wiki for details on using this class member.
Getter: Gets sample size for the udirection Setter: Sets sample size for the udirection Type: int

sample_size_v
¶ Sample size for the vdirection.
Sample size defines the number of evaluated points to generate. It also sets the
delta_v
property.Please refer to the wiki for details on using this class member.
Getter: Gets sample size for the vdirection Setter: Sets sample size for the vdirection Type: int

sample_size_w
¶ Sample size for the wdirection.
Sample size defines the number of evaluated points to generate. It also sets the
delta_w
property.Please refer to the wiki for details on using this class member.
Getter: Gets sample size for the wdirection Setter: Sets sample size for the wdirection Type: int

save
(file_name)¶ Saves the volume as a pickled file.
Parameters: file_name (str) – name of the file to be saved Raises: IOError – an error occurred writing the file

set_ctrlpts
(ctrlpts, *args, **kwargs)¶ Sets the control points and checks if the data is consistent.
This method is designed to provide a consistent way to set control points whether they are weighted or not. It directly sets the control points member of the class, and therefore it doesn’t return any values. The input will be an array of coordinates. If you are working in the 3dimensional space, then your coordinates will be an array of 3 elements representing (x, y, z) coordinates.
Parameters:  ctrlpts (list) – input control points as a list of coordinates
 args (tuple[int, int, int]) – number of control points corresponding to each parametric dimension

vis
¶ Visualization component.
Please refer to the wiki for details on using this class member.
Getter: Gets the visualization component Setter: Sets the visualization component Type: vis.VisAbstract

weights
¶ Weights vector.
Getter: Gets the weights vector Setter: Sets the weights vector Type: list