Compatibility and Conversion¶
This module contains conversion operations related to control points, such as flipping arrays and adding weights.
Function Reference¶

geomdl.compatibility.
combine_ctrlpts_weights
(ctrlpts, weights=None)¶ Multiplies control points by the weights to generate weighted control points.
This function is dimension agnostic, i.e. control points can be in any dimension but weights should be 1D.
The
weights
function parameter can be set to None to let the function generate a weights vector composed of 1.0 values. This feature can be used to convert BSpline basis to NURBS basis.Parameters:  ctrlpts (list, tuple) – unweighted control points
 weights (list, tuple or None) – weights vector; if set to None, a weights vector of 1.0s will be automatically generated
Returns: weighted control points
Return type: list

geomdl.compatibility.
flip_ctrlpts
(ctrlpts, size_u, size_v)¶ Flips a list of 1dimensional control points from vrow order to urow order.
urow order: each row corresponds to a list of u values
vrow order: each row corresponds to a list of v values
Parameters:  ctrlpts (list, tuple) – control points in vrow order
 size_u (int) – size in udirection
 size_v (int) – size in vdirection
Returns: control points in urow order
Return type: list

geomdl.compatibility.
flip_ctrlpts2d
(ctrlpts2d, size_u=0, size_v=0)¶ Flips a list of surface 2D control points from [u][v] to [v][u] order.
Parameters:  ctrlpts2d (list, tuple) – 2D control points
 size_u (int) – size in Udirection (row length)
 size_v (int) – size in Vdirection (column length)
Returns: flipped 2D control points
Return type: list

geomdl.compatibility.
flip_ctrlpts2d_file
(file_in='', file_out='ctrlpts_flip.txt')¶ Flips u and v directions of a 2D control points file and saves flipped coordinates to a file.
Parameters:  file_in (str) – name of the input file (to be read)
 file_out (str) – name of the output file (to be saved)
Raises: IOError – an error occurred reading or writing the file

geomdl.compatibility.
flip_ctrlpts_u
(ctrlpts, size_u, size_v)¶ Flips a list of 1dimensional control points from urow order to vrow order.
urow order: each row corresponds to a list of u values
vrow order: each row corresponds to a list of v values
Parameters:  ctrlpts (list, tuple) – control points in urow order
 size_u (int) – size in udirection
 size_v (int) – size in vdirection
Returns: control points in vrow order
Return type: list

geomdl.compatibility.
generate_ctrlpts2d_weights
(ctrlpts2d)¶ Generates unweighted control points from weighted ones in 2D.
This function
 Takes in 2D control points list whose coordinates are organized like (x*w, y*w, z*w, w)
 Converts the input control points list into (x, y, z, w) format
 Returns the result
Parameters: ctrlpts2d (list) – 2D control points (P) Returns: 2D weighted control points (Pw) Return type: list

geomdl.compatibility.
generate_ctrlpts2d_weights_file
(file_in='', file_out='ctrlpts_weights.txt')¶ Generates unweighted control points from weighted ones in 2D.
 Takes in 2D control points list whose coordinates are organized like (x*w, y*w, z*w, w)
 Converts the input control points list into (x, y, z, w) format
 Saves the result to a file
Parameters:  file_in (str) – name of the input file (to be read)
 file_out (str) – name of the output file (to be saved)
Raises: IOError – an error occurred reading or writing the file

geomdl.compatibility.
generate_ctrlpts_weights
(ctrlpts)¶ Generates unweighted control points from weighted ones in 1D.
This function
 Takes in 1D control points list whose coordinates are organized in (x*w, y*w, z*w, w) format
 Converts the input control points list into (x, y, z, w) format
 Returns the result
Parameters: ctrlpts (list) – 1D control points (P) Returns: 1D weighted control points (Pw) Return type: list

geomdl.compatibility.
generate_ctrlptsw
(ctrlpts)¶ Generates weighted control points from unweighted ones in 1D.
This function
 Takes in a 1D control points list whose coordinates are organized in (x, y, z, w) format
 converts into (x*w, y*w, z*w, w) format
 Returns the result
Parameters: ctrlpts (list) – 1D control points (P) Returns: 1D weighted control points (Pw) Return type: list

geomdl.compatibility.
generate_ctrlptsw2d
(ctrlpts2d)¶ Generates weighted control points from unweighted ones in 2D.
This function
 Takes in a 2D control points list whose coordinates are organized in (x, y, z, w) format
 converts into (x*w, y*w, z*w, w) format
 Returns the result
Therefore, the returned list could be a direct input of the NURBS.Surface class.
Parameters: ctrlpts2d (list) – 2D control points (P) Returns: 2D weighted control points (Pw) Return type: list

geomdl.compatibility.
generate_ctrlptsw2d_file
(file_in='', file_out='ctrlptsw.txt')¶ Generates weighted control points from unweighted ones in 2D.
This function
 Takes in a 2D control points file whose coordinates are organized in (x, y, z, w) format
 Converts into (x*w, y*w, z*w, w) format
 Saves the result to a file
Therefore, the resultant file could be a direct input of the NURBS.Surface class.
Parameters:  file_in (str) – name of the input file (to be read)
 file_out (str) – name of the output file (to be saved)
Raises: IOError – an error occurred reading or writing the file

geomdl.compatibility.
separate_ctrlpts_weights
(ctrlptsw)¶ Divides weighted control points by weights to generate unweighted control points and weights vector.
This function is dimension agnostic, i.e. control points can be in any dimension but the last element of the array should indicate the weight.
Parameters: ctrlptsw (list, tuple) – weighted control points Returns: unweighted control points and weights vector Return type: list