Shape Containers¶
This module provides object containers for curves, surfaces and volumes. A container is a holder object that stores a collection of other objects, i.e. its elements. In NURBSPython, containers can be generated as a result of
 A geometric operation, such as splitting
 File import, e.g. reading a file or a set of files containing multiple surfaces
Additionally, they can be used for advanced postprocessing, such as visualization or file export.
This module works with BSpline
and NURBS
modules and it contains the following classes:
AbstractContainer
abstract base class for containersCurveContainer
for storing multiple curvesSurfaceContainer
for storing multiple surfacesVolumeContainer
for storing multiple volumes
Inheritance Diagram¶
Abstract Container¶

class
geomdl.multi.
AbstractContainer
(*args, **kwargs)¶ Bases:
object
Abstract class for curve and surface containers.
This class implements Python Iterator Protocol and therefore any instance of this class can be directly used in a for loop.
This class provides the following properties:

add
(element)¶ Adds shapes to the container.
The input can be a single shape, a list of shapes or a container object.
Parameters: element – shape to be added

append
(element)¶ Adds shapes to the container.
The input can be a single shape, a list of shapes or a container object.
Parameters: element – shape to be added

bbox
¶ Bounding box.
Please refer to the wiki for details on using this class member.
Getter: Gets the bounding box of all contained shapes

delta
¶ Evaluation delta (for all parametric directions).
Evaluation delta corresponds to the step size. Decreasing the step size results in evaluation of more points. Therefore; smaller the delta value, smoother the shape.
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

dimension
¶ Shape dimension.
Please refer to the wiki for details on using this class member.
Getter: Gets the dimension of the shape

evalpts
¶ Evaluated points.
Since there are multiple shapes contained in the multi objects, the evaluated points will be returned in the format of list of individual evaluated points which is also a list of Cartesian coordinates.
The following code example illustrates these details:
1 2 3 4 5 6 7 8
multi_obj = multi.SurfaceContainer() # it can also be multi.CurveContainer() # Add shapes to multi_obj via multi_obj.add() method # Then, the following loop will print all the evaluated points of the Multi object for idx, mpt in enumerate(multi_obj.evalpts): print("Shape", idx+1, "contains", len(mpt), "points. These points are:") for pt in mpt: line = ", ".join([str(p) for p in pt]) print(line)
Please refer to the wiki for details on using this class member.
Getter: Gets the evaluated points of all contained shapes

render
(**kwargs)¶ Renders plots using the visualization component.
Note
This is an abstract method and it must be implemented in the subclass.

sample_size
¶ Sample size (for all parametric directions).
Sample size defines the number of points to evaluate. 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

Curve Container¶

class
geomdl.multi.
CurveContainer
(*args, **kwargs)¶ Bases:
geomdl.multi.AbstractContainer
Container class for storing multiple curves.
This class implements Python Iterator Protocol and therefore any instance of this class can be directly used in a for loop.
This class provides the following properties:
The following code example illustrates the usage of the Python properties:
# Create a multicurve container instance mcrv = Multi.CurveContainer() # Add single or multi curves to the multi container using mcrv.add() command # Addition operator, e.g. mcrv1 + mcrv2, also works # Set the evaluation delta of the multicurve mcrv.delta = 0.05 # Get the evaluated points curve_points = mcrv.evalpts

add
(element)¶ Adds shapes to the container.
The input can be a single shape, a list of shapes or a container object.
Parameters: element – shape to be added

append
(element)¶ Adds shapes to the container.
The input can be a single shape, a list of shapes or a container object.
Parameters: element – shape to be added

bbox
¶ Bounding box.
Please refer to the wiki for details on using this class member.
Getter: Gets the bounding box of all contained shapes

delta
¶ Evaluation delta (for all parametric directions).
Evaluation delta corresponds to the step size. Decreasing the step size results in evaluation of more points. Therefore; smaller the delta value, smoother the shape.
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

dimension
¶ Shape dimension.
Please refer to the wiki for details on using this class member.
Getter: Gets the dimension of the shape

evalpts
¶ Evaluated points.
Since there are multiple shapes contained in the multi objects, the evaluated points will be returned in the format of list of individual evaluated points which is also a list of Cartesian coordinates.
The following code example illustrates these details:
1 2 3 4 5 6 7 8
multi_obj = multi.SurfaceContainer() # it can also be multi.CurveContainer() # Add shapes to multi_obj via multi_obj.add() method # Then, the following loop will print all the evaluated points of the Multi object for idx, mpt in enumerate(multi_obj.evalpts): print("Shape", idx+1, "contains", len(mpt), "points. These points are:") for pt in mpt: line = ", ".join([str(p) for p in pt]) print(line)
Please refer to the wiki for details on using this class member.
Getter: Gets the evaluated points of all contained shapes

render
(**kwargs)¶ Renders the curves.
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 surfacefilename
: saves the plot with the input nameplot
: controls plot window visibility. Default: Trueanimate
: activates animation (if supported). Default: Falsedelta
: if True, the evaluation delta of the Multi object will be used. Default: True
The
cpcolor
andevalcolor
arguments can be a string or a list of strings corresponding to the color values. Both arguments are processed separately, e.g.cpcolor
can be a string whereasevalcolor
can be a list or a tuple, or vice versa. A single string value sets the color to the same value. List input allows customization over the color values. If none provided, a random color will be selected.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.

sample_size
¶ Sample size (for all parametric directions).
Sample size defines the number of points to evaluate. 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

Surface Container¶

class
geomdl.multi.
SurfaceContainer
(*args, **kwargs)¶ Bases:
geomdl.multi.AbstractContainer
Container class for storing multiple surfaces.
This class implements Python Iterator Protocol and therefore any instance of this class can be directly used in a for loop.
This class provides the following properties:
The following code example illustrates the usage of these Python properties:
# Create a multisurface container instance msurf = Multi.SurfaceContainer() # Add single or multi surfaces to the multi container using msurf.add() command # Addition operator, e.g. msurf1 + msurf2, also works # Set the evaluation delta of the multisurface msurf.delta = 0.05 # Get the evaluated points surface_points = msurf.evalpts

add
(element)¶ Adds shapes to the container.
The input can be a single shape, a list of shapes or a container object.
Parameters: element – shape to be added

append
(element)¶ Adds shapes to the container.
The input can be a single shape, a list of shapes or a container object.
Parameters: element – shape to be added

bbox
¶ Bounding box.
Please refer to the wiki for details on using this class member.
Getter: Gets the bounding box of all contained shapes

delta
¶ Evaluation delta (for all parametric directions).
Evaluation delta corresponds to the step size. Decreasing the step size results in evaluation of more points. Therefore; smaller the delta value, smoother the shape.
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

delta_u
¶ Evaluation delta for the udirection.
Evaluation delta corresponds to the step size. Decreasing the step size results in evaluation of more points. Therefore; smaller the delta, smoother the shape.
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 the delta value for the udirection Setter: Sets the delta value for the udirection Type: float

delta_v
¶ Evaluation delta for the vdirection.
Evaluation delta corresponds to the step size. Decreasing the step size results in evaluation of more points. Therefore; smaller the delta, smoother the shape.
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 the delta value for the vdirection Setter: Sets the delta value for the vdirection Type: float

dimension
¶ Shape dimension.
Please refer to the wiki for details on using this class member.
Getter: Gets the dimension of the shape

evalpts
¶ Evaluated points.
Since there are multiple shapes contained in the multi objects, the evaluated points will be returned in the format of list of individual evaluated points which is also a list of Cartesian coordinates.
The following code example illustrates these details:
1 2 3 4 5 6 7 8
multi_obj = multi.SurfaceContainer() # it can also be multi.CurveContainer() # Add shapes to multi_obj via multi_obj.add() method # Then, the following loop will print all the evaluated points of the Multi object for idx, mpt in enumerate(multi_obj.evalpts): print("Shape", idx+1, "contains", len(mpt), "points. These points are:") for pt in mpt: line = ", ".join([str(p) for p in pt]) print(line)
Please refer to the wiki for details on using this class member.
Getter: Gets the evaluated points of all contained shapes

render
(**kwargs)¶ Renders the surfaces.
The visualization component must be set using
vis
property before calling this method. Keyword Arguments:
cpcolor
: sets the color of the control points gridsevalcolor
: sets the color of the surfacefilename
: saves the plot with the input nameplot
: controls plot window visibility. Default: Trueanimate
: activates animation (if supported). Default: Falsecolormap
: sets the colormap of the surfacesdelta
: if True, the evaluation delta of the Multi object will be used. Default: True
The
cpcolor
andevalcolor
arguments can be a string or a list of strings corresponding to the color values. Both arguments are processed separately, e.g.cpcolor
can be a string whereasevalcolor
can be a list or a tuple, or vice versa. A single string value sets the color to the same value. List input allows customization over the color values. If none provided, a random color will be selected.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.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 multiple colormap inputs as a list or tuple, preferable the input list size is the same as the number of surfaces contained in the class. In the case of number of surfaces is bigger than number of input colormaps, this method will automatically assign a random color for the remaining surfaces.

sample_size
¶ Sample size (for all parametric directions).
Sample size defines the number of points to evaluate. 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

sample_size_u
¶ Sample size for the udirection.
Sample size defines the number of points to evaluate. 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

Volume Container¶

class
geomdl.multi.
VolumeContainer
(*args, **kwargs)¶ Bases:
geomdl.multi.SurfaceContainer
Container class for storing multiple volumes.
This class implements Python Iterator Protocol and therefore any instance of this class can be directly used in a for loop.
This class provides the following properties:
dimension
evalpts
bbox
vis
delta
delta_u
delta_v
delta_w
sample_size
sample_size_u
sample_size_v
sample_size_w
The following code example illustrates the usage of these Python properties:
# Create a multivolume container instance mvol = Multi.VolumeContainer() # Add single or multi volumes to the multi container using mvol.add() command # Addition operator, e.g. mvol1 + mvol2, also works # Set the evaluation delta of the multivolume mvol.delta = 0.05 # Get the evaluated points volume_points = mvol.evalpts

add
(element)¶ Adds shapes to the container.
The input can be a single shape, a list of shapes or a container object.
Parameters: element – shape to be added

append
(element)¶ Adds shapes to the container.
The input can be a single shape, a list of shapes or a container object.
Parameters: element – shape to be added

bbox
¶ Bounding box.
Please refer to the wiki for details on using this class member.
Getter: Gets the bounding box of all contained shapes

delta
¶ Evaluation delta (for all parametric directions).
Evaluation delta corresponds to the step size. Decreasing the step size results in evaluation of more points. Therefore; smaller the delta value, smoother the shape.
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

delta_u
¶ Evaluation delta for the udirection.
Evaluation delta corresponds to the step size. Decreasing the step size results in evaluation of more points. Therefore; smaller the delta, smoother the shape.
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 the delta value for the udirection Setter: Sets the delta value for the udirection Type: float

delta_v
¶ Evaluation delta for the vdirection.
Evaluation delta corresponds to the step size. Decreasing the step size results in evaluation of more points. Therefore; smaller the delta, smoother the shape.
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 the delta value for the vdirection Setter: Sets the delta value for the vdirection Type: float

delta_w
¶ Evaluation delta for the wdirection.
Evaluation delta corresponds to the step size. Decreasing the step size results in evaluation of more points. Therefore; smaller the delta, smoother the shape.
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 the delta value for the wdirection Setter: Sets the delta value for the wdirection Type: float

dimension
¶ Shape dimension.
Please refer to the wiki for details on using this class member.
Getter: Gets the dimension of the shape

evalpts
¶ Evaluated points.
Since there are multiple shapes contained in the multi objects, the evaluated points will be returned in the format of list of individual evaluated points which is also a list of Cartesian coordinates.
The following code example illustrates these details:
1 2 3 4 5 6 7 8
multi_obj = multi.SurfaceContainer() # it can also be multi.CurveContainer() # Add shapes to multi_obj via multi_obj.add() method # Then, the following loop will print all the evaluated points of the Multi object for idx, mpt in enumerate(multi_obj.evalpts): print("Shape", idx+1, "contains", len(mpt), "points. These points are:") for pt in mpt: line = ", ".join([str(p) for p in pt]) print(line)
Please refer to the wiki for details on using this class member.
Getter: Gets the evaluated points of all contained shapes

render
(**kwargs)¶ Renders the volumes.
The visualization component must be set using
vis
property before calling this method. Keyword Arguments:
cpcolor
: sets the color of the control points plotevalcolor
: sets the color of the volumefilename
: saves the plot with the input nameplot
: controls plot window visibility. Default: Trueanimate
: activates animation (if supported). Default: Falsedelta
: if True, the evaluation delta of the Multi object will be used. Default: Truegrid_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
cpcolor
andevalcolor
arguments can be a string or a list of strings corresponding to the color values. Both arguments are processed separately, e.g.cpcolor
can be a string whereasevalcolor
can be a list or a tuple, or vice versa. A single string value sets the color to the same value. List input allows customization over the color values. If none provided, a random color will be selected.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.

sample_size
¶ Sample size (for all parametric directions).
Sample size defines the number of points to evaluate. 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

sample_size_u
¶ Sample size for the udirection.
Sample size defines the number of points to evaluate. 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 points to evaluate. 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