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 NURBS-Python, 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 post-processing, such as visualization or file export.

This module works with BSpline and NURBS modules and it contains the following classes:

Inheritance Diagram

Inheritance diagram of geomdl.multi

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:

\left[{{u_{start}},{u_{start}} + \delta ,({u_{start}} + \delta ) + \delta , \ldots ,{u_{end}}} \right]

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:

\underbrace {\left[ {{u_{start}}, \ldots ,{u_{end}}} \right]}_{{n_{sample}}}

Please refer to the wiki for details on using this class member.

Getter:Gets sample size
Setter:Sets sample size
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

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 multi-curve 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 multi-curve
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:

\left[{{u_{start}},{u_{start}} + \delta ,({u_{start}} + \delta ) + \delta , \ldots ,{u_{end}}} \right]

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 grid
  • evalcolor: sets the color of the surface
  • filename: saves the plot with the input name
  • plot: controls plot window visibility. Default: True
  • animate: activates animation (if supported). Default: False
  • delta: if True, the evaluation delta of the Multi object will be used. Default: True

The cpcolor and evalcolor 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 whereas evalcolor 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. If plot 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:

\underbrace {\left[ {{u_{start}}, \ldots ,{u_{end}}} \right]}_{{n_{sample}}}

Please refer to the wiki for details on using this class member.

Getter:Gets sample size
Setter:Sets sample size
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

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 multi-surface 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 multi-surface
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:

\left[{{u_{start}},{u_{start}} + \delta ,({u_{start}} + \delta ) + \delta , \ldots ,{u_{end}}} \right]

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 u-direction.

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 and sample_size_u properties correspond to the same variable with different descriptions. Therefore, setting delta_u will also set sample_size_u.

Please refer to the wiki for details on using this class member.

Getter:Gets the delta value for the u-direction
Setter:Sets the delta value for the u-direction
Type:float
delta_v

Evaluation delta for the v-direction.

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 and sample_size_v properties correspond to the same variable with different descriptions. Therefore, setting delta_v will also set sample_size_v.

Please refer to the wiki for details on using this class member.

Getter:Gets the delta value for the v-direction
Setter:Sets the delta value for the v-direction
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 grids
  • evalcolor: sets the color of the surface
  • filename: saves the plot with the input name
  • plot: controls plot window visibility. Default: True
  • animate: activates animation (if supported). Default: False
  • colormap: sets the colormap of the surfaces
  • delta: if True, the evaluation delta of the Multi object will be used. Default: True

The cpcolor and evalcolor 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 whereas evalcolor 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. If plot 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 see VisMPL.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:

\underbrace {\left[ {{u_{start}}, \ldots ,{u_{end}}} \right]}_{{n_{sample}}}

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 u-direction.

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 u-direction
Setter:Sets sample size for the u-direction
Type:int
sample_size_v

Sample size for the v-direction.

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 v-direction
Setter:Sets sample size for the v-direction
Type:int
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

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:

The following code example illustrates the usage of these Python properties:

# Create a multi-volume 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 multi-volume
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:

\left[{{u_{start}},{u_{start}} + \delta ,({u_{start}} + \delta ) + \delta , \ldots ,{u_{end}}} \right]

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 u-direction.

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 and sample_size_u properties correspond to the same variable with different descriptions. Therefore, setting delta_u will also set sample_size_u.

Please refer to the wiki for details on using this class member.

Getter:Gets the delta value for the u-direction
Setter:Sets the delta value for the u-direction
Type:float
delta_v

Evaluation delta for the v-direction.

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 and sample_size_v properties correspond to the same variable with different descriptions. Therefore, setting delta_v will also set sample_size_v.

Please refer to the wiki for details on using this class member.

Getter:Gets the delta value for the v-direction
Setter:Sets the delta value for the v-direction
Type:float
delta_w

Evaluation delta for the w-direction.

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 and sample_size_w properties correspond to the same variable with different descriptions. Therefore, setting delta_w will also set sample_size_w.

Please refer to the wiki for details on using this class member.

Getter:Gets the delta value for the w-direction
Setter:Sets the delta value for the w-direction
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 plot
  • evalcolor: sets the color of the volume
  • filename: saves the plot with the input name
  • plot: controls plot window visibility. Default: True
  • animate: activates animation (if supported). Default: False
  • delta: if True, the evaluation delta of the Multi object will be used. Default: True
  • grid_size: grid size for voxelization. Default: (16, 16, 16)
  • use_mp: flag to activate multi-threaded voxelization. Default: False
  • num_procs: number of concurrent processes for multi-threaded voxelization. Default: 4

The cpcolor and evalcolor 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 whereas evalcolor 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. If plot 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:

\underbrace {\left[ {{u_{start}}, \ldots ,{u_{end}}} \right]}_{{n_{sample}}}

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 u-direction.

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 u-direction
Setter:Sets sample size for the u-direction
Type:int
sample_size_v

Sample size for the v-direction.

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 v-direction
Setter:Sets sample size for the v-direction
Type:int
sample_size_w

Sample size for the w-direction.

Sample size defines the number of points to evaluate. 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 w-direction
Setter:Sets sample size for the w-direction
Type:int
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