Geometry Base
abstract module provides base classes for parametric curves, surfaces and volumes contained in this library and
therefore, it provides an easy way to extend the library in the most proper way.
Inheritance Diagram
digraph inheritance921cb686ed { bgcolor=transparent; rankdir=LR; ratio=compress; size="8.0, 12.0"; "geomdl.abstract.Curve" [URL="#geomdl.abstract.Curve",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract base class for defining spline curves."]; "geomdl.abstract.SplineGeometry" -> "geomdl.abstract.Curve" [arrowsize=0.5,style="setlinewidth(0.5)"]; "geomdl.abstract.GeomdlBase" [URL="#geomdl.abstract.GeomdlBase",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract base class for defining geomdl objects."]; "geomdl.abstract.Geometry" [URL="#geomdl.abstract.Geometry",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract base class for defining geometry objects."]; "geomdl.abstract.GeomdlBase" -> "geomdl.abstract.Geometry" [arrowsize=0.5,style="setlinewidth(0.5)"]; "geomdl.abstract.SplineGeometry" [URL="#geomdl.abstract.SplineGeometry",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract base class for defining spline geometry objects."]; "geomdl.abstract.Geometry" -> "geomdl.abstract.SplineGeometry" [arrowsize=0.5,style="setlinewidth(0.5)"]; "geomdl.abstract.Surface" [URL="#geomdl.abstract.Surface",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract base class for defining spline surfaces."]; "geomdl.abstract.SplineGeometry" -> "geomdl.abstract.Surface" [arrowsize=0.5,style="setlinewidth(0.5)"]; "geomdl.abstract.Volume" [URL="#geomdl.abstract.Volume",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract base class for defining spline volumes."]; "geomdl.abstract.SplineGeometry" -> "geomdl.abstract.Volume" [arrowsize=0.5,style="setlinewidth(0.5)"]; }Abstract Curve
- class geomdl.abstract.Curve(**kwargs)
Bases:
SplineGeometryAbstract base class for defining spline curves.
Curve ABC is inherited from abc.ABCMeta class which is included in Python standard library by default. Due to differences between Python 2 and 3 on defining a metaclass, the compatibility module
sixis employed. Usingsixto set metaclass allows users to use the abstract classes in a correct way.The abstract base classes in this module are implemented using a feature called Python Properties. This feature allows users to use some of the functions as if they are class fields. You can also consider properties as a pythonic way to set getters and setters. You will see “getter” and “setter” descriptions on the documentation of these properties.
The Curve ABC allows users to set the FindSpan function to be used in evaluations with
find_span_funckeyword as an input to the class constructor. NURBS-Python includes a binary and a linear search variation of the FindSpan function in thehelpersmodule. You may also implement and use your own FindSpan function. Please see thehelpersmodule for details.Code segment below illustrates a possible implementation of Curve abstract base class:
1from geomdl import abstract 2 3class MyCurveClass(abstract.Curve): 4 def __init__(self, **kwargs): 5 super(MyCurveClass, self).__init__(**kwargs) 6 # Add your constructor code here 7 8 def evaluate(self, **kwargs): 9 # Implement this function 10 pass 11 12 def evaluate_single(self, uv): 13 # Implement this function 14 pass 15 16 def evaluate_list(self, uv_list): 17 # Implement this function 18 pass 19 20 def derivatives(self, u, v, order, **kwargs): 21 # Implement this function 22 pass
The properties and functions defined in the abstract base class will be automatically available in the subclasses.
Keyword Arguments:
id: object ID (as integer)precision: number of decimal places to round to. Default: 18normalize_kv: if True, knot vector(s) will be normalized to [0,1] domain. Default: Truefind_span_func: default knot span finding algorithm. Default:helpers.find_span_linear()
- property 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
- property cpsize
Number of control points in all parametric directions.
Note
This is an expert property for getting and setting control point size(s) of the geometry.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the number of control points
- Setter:
Sets the number of control points
- Type:
list
- property ctrlpts
Control points.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the control points
- Setter:
Sets the control points
- Type:
list
- property ctrlpts_size
Total number of control points.
- Getter:
Gets the total number of control points
- Type:
int
- property data
Returns a dict which contains the geometry data.
Please refer to the wiki for details on using this class member.
- property degree
Degree.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the degree
- Setter:
Sets the degree
- Type:
int
- property delta
Evaluation delta.
Evaluation delta corresponds to the step size while
evaluatefunction 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:
![\left[{{u_{start}},{u_{start}} + \delta ,({u_{start}} + \delta ) + \delta , \ldots ,{u_{end}}} \right]](_images/math/c9b9017a2c9a6e040e642f5fb0769f6e340d9639.png)
Please refer to the wiki for details on using this class member.
- Getter:
Gets the delta value
- Setter:
Sets the delta value
- Type:
float
- abstractmethod derivatives(u, order, **kwargs)
Evaluates the derivatives of the curve at parameter u.
Note
This is an abstract method and it must be implemented in the subclass.
- Parameters:
u (float) – parameter (u)
order (int) – derivative order
- property 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
- property domain
Domain.
Domain is determined using the knot vector(s).
- Getter:
Gets the domain
- property 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
- abstractmethod evaluate(**kwargs)
Evaluates the curve.
Note
This is an abstract method and it must be implemented in the subclass.
- abstractmethod evaluate_list(param_list)
Evaluates the curve for an input range of parameters.
Note
This is an abstract method and it must be implemented in the subclass.
- Parameters:
param_list – array of parameters
- abstractmethod evaluate_single(param)
Evaluates the curve at the given parameter.
Note
This is an abstract method and it must be implemented in the subclass.
- Parameters:
param – parameter (u)
- property evaluator
Evaluator instance.
Evaluators allow users to use different algorithms for B-Spline and NURBS evaluations. Please see the documentation on
Evaluatorclasses.Please refer to the wiki for details on using this class member.
- Getter:
Gets the current Evaluator instance
- Setter:
Sets the Evaluator instance
- Type:
- property id
Object ID (as an integer).
Please refer to the wiki for details on using this class member.
- Getter:
Gets the object ID
- Setter:
Sets the object ID
- Type:
int
- property knotvector
Knot vector.
The knot vector will be normalized to [0, 1] domain if the class is initialized with
normalize_kv=Trueargument.Please refer to the wiki for details on using this class member.
- Getter:
Gets the knot vector
- Setter:
Sets the knot vector
- Type:
list
- property name
Object name (as a string)
Please refer to the wiki for details on using this class member.
- Getter:
Gets the object name
- Setter:
Sets the object name
- Type:
str
- property opt
Dictionary for storing custom data in the current geometry object.
optis a wrapper to a dict in key => value format, where key is string, value is any Python object. You can useoptproperty to store custom data inside the geometry object. For instance:geom.opt = ["face_id", 4] # creates "face_id" key and sets its value to an integer geom.opt = ["contents", "data values"] # creates "face_id" key and sets its value to a string print(geom.opt) # will print: {'face_id': 4, 'contents': 'data values'} del geom.opt # deletes the contents of the hash map print(geom.opt) # will print: {} geom.opt = ["body_id", 1] # creates "body_id" key and sets its value to 1 geom.opt = ["body_id", 12] # changes the value of "body_id" to 12 print(geom.opt) # will print: {'body_id': 12} geom.opt = ["body_id", None] # deletes "body_id" print(geom.opt) # will print: {}
Please refer to the wiki for details on using this class member.
- Getter:
Gets the dict
- Setter:
Adds key and value pair to the dict
- Deleter:
Deletes the contents of the dict
- opt_get(value)
Safely query for the value from the
optproperty.- Parameters:
value (str) – a key in the
optproperty- Returns:
the corresponding value, if the key exists.
None, otherwise.
- property order
Order.
Defined as
order = degree + 1Please refer to the wiki for details on using this class member.
- Getter:
Gets the order
- Setter:
Sets the order
- Type:
int
- property pdimension
Parametric dimension.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the parametric dimension
- Type:
int
- property range
Domain range.
- Getter:
Gets the range
- property rational
Defines the rational and non-rational B-spline shapes.
Rational shapes use homogeneous coordinates which includes a weight alongside with the Cartesian coordinates. Rational B-splines are also named as NURBS (Non-uniform rational basis spline) and non-rational B-splines are sometimes named as NUBS (Non-uniform basis spline) or directly as B-splines.
Please refer to the wiki for details on using this class member.
- Getter:
Returns True is the B-spline object is rational (NURBS)
- Type:
bool
- render(**kwargs)
Renders the curve using the visualization component
The visualization component must be set using
visproperty 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
plotargument is useful when you would like to work on the command line without any window context. Ifplotflag 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.extrasargument 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 dict( # line plot 1 3 points=[[1, 2, 3], [4, 5, 6]], # list of points 4 name="My line Plot 1", # name displayed on the legend 5 color="red", # color of the line plot 6 size=6.5 # size of the line plot 7 ), 8 dict( # line plot 2 9 points=[[7, 8, 9], [10, 11, 12]], # list of points 10 name="My line Plot 2", # name displayed on the legend 11 color="navy", # color of the line plot 12 size=12.5 # size of the line plot 13 ) 14]
- Returns:
the figure object
- reset(**kwargs)
Resets control points and/or evaluated points.
- Keyword Arguments:
evalpts: if True, then resets evaluated pointsctrlptsif True, then resets control points
- reverse()
Reverses the curve
- property sample_size
Sample size.
Sample size defines the number of evaluated points to generate. It also sets the
deltaproperty.The following figure illustrates the working principles of sample size property:
![\underbrace {\left[ {{u_{start}}, \ldots ,{u_{end}}} \right]}_{{n_{sample}}}](_images/math/1c947ab28078413a0019013d581041db4c6d1d66.png)
Please refer to the wiki for details on using this class member.
- Getter:
Gets sample size
- Setter:
Sets sample size
- Type:
int
- 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 3-dimensional 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
- property type
Geometry type
Please refer to the wiki for details on using this class member.
- Getter:
Gets the geometry type
- Type:
str
Abstract Surface
- class geomdl.abstract.Surface(**kwargs)
Bases:
SplineGeometryAbstract base class for defining spline surfaces.
Surface ABC is inherited from abc.ABCMeta class which is included in Python standard library by default. Due to differences between Python 2 and 3 on defining a metaclass, the compatibility module
sixis employed. Usingsixto set metaclass allows users to use the abstract classes in a correct way.The abstract base classes in this module are implemented using a feature called Python Properties. This feature allows users to use some of the functions as if they are class fields. You can also consider properties as a pythonic way to set getters and setters. You will see “getter” and “setter” descriptions on the documentation of these properties.
The Surface ABC allows users to set the FindSpan function to be used in evaluations with
find_span_funckeyword as an input to the class constructor. NURBS-Python includes a binary and a linear search variation of the FindSpan function in thehelpersmodule. You may also implement and use your own FindSpan function. Please see thehelpersmodule for details.Code segment below illustrates a possible implementation of Surface abstract base class:
1from geomdl import abstract 2 3class MySurfaceClass(abstract.Surface): 4 def __init__(self, **kwargs): 5 super(MySurfaceClass, self).__init__(**kwargs) 6 # Add your constructor code here 7 8 def evaluate(self, **kwargs): 9 # Implement this function 10 pass 11 12 def evaluate_single(self, uv): 13 # Implement this function 14 pass 15 16 def evaluate_list(self, uv_list): 17 # Implement this function 18 pass 19 20 def derivatives(self, u, v, order, **kwargs): 21 # Implement this function 22 pass
The properties and functions defined in the abstract base class will be automatically available in the subclasses.
Keyword Arguments:
id: object ID (as integer)precision: number of decimal places to round to. Default: 18normalize_kv: if True, knot vector(s) will be normalized to [0,1] domain. Default: Truefind_span_func: default knot span finding algorithm. Default:helpers.find_span_linear()
- add_trim(trim)
Adds a trim to the surface.
A trim is a 2-dimensional curve defined on the parametric domain of the surface. Therefore, x-coordinate of the trimming curve corresponds to u parametric direction of the surfaceand y-coordinate of the trimming curve corresponds to v parametric direction of the surface.
trimsuses this method to add trims to the surface.- Parameters:
trim (abstract.Geometry) – surface trimming curve
- property 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
- property cpsize
Number of control points in all parametric directions.
Note
This is an expert property for getting and setting control point size(s) of the geometry.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the number of control points
- Setter:
Sets the number of control points
- Type:
list
- property ctrlpts
1-dimensional array of control points.
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.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the control points
- Setter:
Sets the control points
- Type:
list
- property ctrlpts_size
Total number of control points.
- Getter:
Gets the total number of control points
- Type:
int
- property ctrlpts_size_u
Number of control points for the u-direction.
Please refer to the wiki for details on using this class member.
- Getter:
Gets number of control points for the u-direction
- Setter:
Sets number of control points for the u-direction
- property ctrlpts_size_v
Number of control points for the v-direction.
Please refer to the wiki for details on using this class member.
- Getter:
Gets number of control points on the v-direction
- Setter:
Sets number of control points on the v-direction
- property data
Returns a dict which contains the geometry data.
Please refer to the wiki for details on using this class member.
- property degree
Degree for u- and v-directions
- Getter:
Gets the degree
- Setter:
Sets the degree
- Type:
list
- property degree_u
Degree for the u-direction.
Please refer to the wiki for details on using this class member.
- Getter:
Gets degree for the u-direction
- Setter:
Sets degree for the u-direction
- Type:
int
- property degree_v
Degree for the v-direction.
Please refer to the wiki for details on using this class member.
- Getter:
Gets degree for the v-direction
- Setter:
Sets degree for the v-direction
- Type:
int
- property delta
Evaluation delta for both u- and v-directions.
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
deltaandsample_sizeproperties correspond to the same variable with different descriptions. Therefore, settingdeltawill also setsample_size.The following figure illustrates the working principles of the delta property:
![\left[{{u_{0}},{u_{start}} + \delta ,({u_{start}} + \delta ) + \delta , \ldots ,{u_{end}}} \right]](_images/math/d90992cf111e89755554d5ef75a43c97c8c29739.png)
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 v-directions
- Setter:
Sets evaluation delta for both u- and v-directions
- Type:
float
- property delta_u
Evaluation delta for the u-direction.
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_uandsample_size_uproperties correspond to the same variable with different descriptions. Therefore, settingdelta_uwill also setsample_size_u.Please refer to the wiki for details on using this class member.
- Getter:
Gets evaluation delta for the u-direction
- Setter:
Sets evaluation delta for the u-direction
- Type:
float
- property delta_v
Evaluation delta for the v-direction.
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_vandsample_size_vproperties correspond to the same variable with different descriptions. Therefore, settingdelta_vwill also setsample_size_v.Please refer to the wiki for details on using this class member.
- Getter:
Gets evaluation delta for the v-direction
- Setter:
Sets evaluation delta for the v-direction
- Type:
float
- abstractmethod derivatives(u, v, order, **kwargs)
Evaluates the derivatives of the parametric surface at parameter (u, v).
Note
This is an abstract method and it must be implemented in the subclass.
- Parameters:
u (float) – parameter on the u-direction
v (float) – parameter on the v-direction
order (int) – derivative order
- property 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
- property domain
Domain.
Domain is determined using the knot vector(s).
- Getter:
Gets the domain
- property 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
- abstractmethod evaluate(**kwargs)
Evaluates the parametric surface.
Note
This is an abstract method and it must be implemented in the subclass.
- abstractmethod evaluate_list(param_list)
Evaluates the parametric surface for an input range of (u, v) parameters.
Note
This is an abstract method and it must be implemented in the subclass.
- Parameters:
param_list – array of parameters (u, v)
- abstractmethod evaluate_single(param)
Evaluates the parametric surface at the given (u, v) parameter.
Note
This is an abstract method and it must be implemented in the subclass.
- Parameters:
param – parameter (u, v)
- property evaluator
Evaluator instance.
Evaluators allow users to use different algorithms for B-Spline and NURBS evaluations. Please see the documentation on
Evaluatorclasses.Please refer to the wiki for details on using this class member.
- Getter:
Gets the current Evaluator instance
- Setter:
Sets the Evaluator instance
- Type:
- property faces
Faces (triangles, quads, etc.) generated by the tessellation operation.
If the tessellation component is set to None, the result will be an empty list.
- Getter:
Gets the faces
- property id
Object ID (as an integer).
Please refer to the wiki for details on using this class member.
- Getter:
Gets the object ID
- Setter:
Sets the object ID
- Type:
int
- property knotvector
Knot vector for u- and v-directions
- Getter:
Gets the knot vector
- Setter:
Sets the knot vector
- Type:
list
- property knotvector_u
Knot vector for the u-direction.
The knot vector will be normalized to [0, 1] domain if the class is initialized with
normalize_kv=Trueargument.Please refer to the wiki for details on using this class member.
- Getter:
Gets knot vector for the u-direction
- Setter:
Sets knot vector for the u-direction
- Type:
list
- property knotvector_v
Knot vector for the v-direction.
The knot vector will be normalized to [0, 1] domain if the class is initialized with
normalize_kv=Trueargument.Please refer to the wiki for details on using this class member.
- Getter:
Gets knot vector for the v-direction
- Setter:
Sets knot vector for the v-direction
- Type:
list
- property name
Object name (as a string)
Please refer to the wiki for details on using this class member.
- Getter:
Gets the object name
- Setter:
Sets the object name
- Type:
str
- property opt
Dictionary for storing custom data in the current geometry object.
optis a wrapper to a dict in key => value format, where key is string, value is any Python object. You can useoptproperty to store custom data inside the geometry object. For instance:geom.opt = ["face_id", 4] # creates "face_id" key and sets its value to an integer geom.opt = ["contents", "data values"] # creates "face_id" key and sets its value to a string print(geom.opt) # will print: {'face_id': 4, 'contents': 'data values'} del geom.opt # deletes the contents of the hash map print(geom.opt) # will print: {} geom.opt = ["body_id", 1] # creates "body_id" key and sets its value to 1 geom.opt = ["body_id", 12] # changes the value of "body_id" to 12 print(geom.opt) # will print: {'body_id': 12} geom.opt = ["body_id", None] # deletes "body_id" print(geom.opt) # will print: {}
Please refer to the wiki for details on using this class member.
- Getter:
Gets the dict
- Setter:
Adds key and value pair to the dict
- Deleter:
Deletes the contents of the dict
- opt_get(value)
Safely query for the value from the
optproperty.- Parameters:
value (str) – a key in the
optproperty- Returns:
the corresponding value, if the key exists.
None, otherwise.
- property order_u
Order for the u-direction.
Defined as
order = degree + 1Please refer to the wiki for details on using this class member.
- Getter:
Gets order for the u-direction
- Setter:
Sets order for the u-direction
- Type:
int
- property order_v
Order for the v-direction.
Defined as
order = degree + 1Please refer to the wiki for details on using this class member.
- Getter:
Gets surface order for the v-direction
- Setter:
Sets surface order for the v-direction
- Type:
int
- property pdimension
Parametric dimension.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the parametric dimension
- Type:
int
- property range
Domain range.
- Getter:
Gets the range
- property rational
Defines the rational and non-rational B-spline shapes.
Rational shapes use homogeneous coordinates which includes a weight alongside with the Cartesian coordinates. Rational B-splines are also named as NURBS (Non-uniform rational basis spline) and non-rational B-splines are sometimes named as NUBS (Non-uniform basis spline) or directly as B-splines.
Please refer to the wiki for details on using this class member.
- Getter:
Returns True is the B-spline object is rational (NURBS)
- Type:
bool
- render(**kwargs)
Renders the surface using the visualization component.
The visualization component must be set using
visproperty 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
plotargument is useful when you would like to work on the command line without any window context. Ifplotflag 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.extrasargument 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 dict( # line plot 1 3 points=[[1, 2, 3], [4, 5, 6]], # list of points 4 name="My line Plot 1", # name displayed on the legend 5 color="red", # color of the line plot 6 size=6.5 # size of the line plot 7 ), 8 dict( # line plot 2 9 points=[[7, 8, 9], [10, 11, 12]], # list of points 10 name="My line Plot 2", # name displayed on the legend 11 color="navy", # color of the line plot 12 size=12.5 # size of the line plot 13 ) 14]
Please note that
colormapargument can only work with visualization classes that support colormaps. As an example, please seeVisMPL.VisSurfTriangle()class documentation. This method expects a single colormap input.- Returns:
the figure object
- reset(**kwargs)
Resets control points and/or evaluated points.
- Keyword Arguments:
evalpts: if True, then resets evaluated pointsctrlptsif True, then resets control points
- property sample_size
Sample size for both u- and v-directions.
Sample size defines the number of surface points to generate. It also sets the
deltaproperty.The following figure illustrates the working principles of sample size property:
![\underbrace {\left[ {{u_{start}}, \ldots ,{u_{end}}} \right]}_{{n_{sample}}}](_images/math/1c947ab28078413a0019013d581041db4c6d1d66.png)
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 v-directions
- Setter:
Sets sample size for both u- and v-directions
- Type:
int
- property sample_size_u
Sample size for the u-direction.
Sample size defines the number of surface points to generate. It also sets the
delta_uproperty.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
- property sample_size_v
Sample size for the v-direction.
Sample size defines the number of surface points to generate. It also sets the
delta_vproperty.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
- 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 3-dimensional space, then your coordinates will be an array of 3 elements representing (x, y, z) coordinates.
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
args (tuple[int, int]) – number of control points corresponding to each parametric dimension
- tessellate(**kwargs)
Tessellates the surface.
Keyword arguments are directly passed to the tessellation component.
- property 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
- property trims
Curves for trimming the surface.
Surface trims are 2-dimensional curves which are introduced on the parametric space of the surfaces. Trim curves can be a spline curve, an analytic curve or a 2-dimensional freeform shape. To visualize the trimmed surfaces, you need to use a tessellator that supports trimming. The following code snippet illustrates changing the default surface tessellator to the trimmed surface tessellator,
tessellate.TrimTessellate.1from geomdl import tessellate 2 3# Assuming that "surf" variable stores the surface instance 4surf.tessellator = tessellate.TrimTessellate()
In addition, using trims initialization argument of the visualization classes, trim curves can be visualized together with their underlying surfaces. Please refer to the visualization configuration class initialization arguments for more details.
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
- property type
Geometry type
Please refer to the wiki for details on using this class member.
- Getter:
Gets the geometry type
- Type:
str
- property vertices
Vertices generated by the tessellation operation.
If the tessellation component is set to None, the result will be an empty list.
- Getter:
Gets the vertices
Abstract Volume
- class geomdl.abstract.Volume(**kwargs)
Bases:
SplineGeometryAbstract base class for defining spline volumes.
Volume ABC is inherited from abc.ABCMeta class which is included in Python standard library by default. Due to differences between Python 2 and 3 on defining a metaclass, the compatibility module
sixis employed. Usingsixto set metaclass allows users to use the abstract classes in a correct way.The abstract base classes in this module are implemented using a feature called Python Properties. This feature allows users to use some of the functions as if they are class fields. You can also consider properties as a pythonic way to set getters and setters. You will see “getter” and “setter” descriptions on the documentation of these properties.
The Volume ABC allows users to set the FindSpan function to be used in evaluations with
find_span_funckeyword as an input to the class constructor. NURBS-Python includes a binary and a linear search variation of the FindSpan function in thehelpersmodule. You may also implement and use your own FindSpan function. Please see thehelpersmodule for details.Code segment below illustrates a possible implementation of Volume abstract base class:
1from geomdl import abstract 2 3class MyVolumeClass(abstract.Volume): 4 def __init__(self, **kwargs): 5 super(MyVolumeClass, self).__init__(**kwargs) 6 # Add your constructor code here 7 8 def evaluate(self, **kwargs): 9 # Implement this function 10 pass 11 12 def evaluate_single(self, uvw): 13 # Implement this function 14 pass 15 16 def evaluate_list(self, uvw_list): 17 # Implement this function 18 pass
The properties and functions defined in the abstract base class will be automatically available in the subclasses.
Keyword Arguments:
id: object ID (as integer)precision: number of decimal places to round to. Default: 18normalize_kv: if True, knot vector(s) will be normalized to [0,1] domain. Default: Truefind_span_func: default knot span finding algorithm. Default:helpers.find_span_linear()
- add_trim(trim)
Adds a trim to the volume.
trimsuses this method to add trims to the volume.- Parameters:
trim (abstract.Surface) – trimming surface
- property 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
- property cpsize
Number of control points in all parametric directions.
Note
This is an expert property for getting and setting control point size(s) of the geometry.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the number of control points
- Setter:
Sets the number of control points
- Type:
list
- property ctrlpts
1-dimensional array of control points.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the control points
- Setter:
Sets the control points
- Type:
list
- property ctrlpts_size
Total number of control points.
- Getter:
Gets the total number of control points
- Type:
int
- property ctrlpts_size_u
Number of control points for the u-direction.
Please refer to the wiki for details on using this class member.
- Getter:
Gets number of control points for the u-direction
- Setter:
Sets number of control points for the u-direction
- property ctrlpts_size_v
Number of control points for the v-direction.
Please refer to the wiki for details on using this class member.
- Getter:
Gets number of control points for the v-direction
- Setter:
Sets number of control points for the v-direction
- property ctrlpts_size_w
Number of control points for the w-direction.
Please refer to the wiki for details on using this class member.
- Getter:
Gets number of control points for the w-direction
- Setter:
Sets number of control points for the w-direction
- property data
Returns a dict which contains the geometry data.
Please refer to the wiki for details on using this class member.
- property degree
Degree for u-, v- and w-directions
- Getter:
Gets the degree
- Setter:
Sets the degree
- Type:
list
- property degree_u
Degree for the u-direction.
Please refer to the wiki for details on using this class member.
- Getter:
Gets degree for the u-direction
- Setter:
Sets degree for the u-direction
- Type:
int
- property degree_v
Degree for the v-direction.
Please refer to the wiki for details on using this class member.
- Getter:
Gets degree for the v-direction
- Setter:
Sets degree for the v-direction
- Type:
int
- property degree_w
Degree for the w-direction.
Please refer to the wiki for details on using this class member.
- Getter:
Gets degree for the w-direction
- Setter:
Sets degree for the w-direction
- Type:
int
- property delta
Evaluation delta for u-, v- and w-directions.
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
deltaandsample_sizeproperties correspond to the same variable with different descriptions. Therefore, settingdeltawill also setsample_size.The following figure illustrates the working principles of the delta property:
![\left[{{u_{0}},{u_{start}} + \delta ,({u_{start}} + \delta ) + \delta , \ldots ,{u_{end}}} \right]](_images/math/d90992cf111e89755554d5ef75a43c97c8c29739.png)
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 w-directions
- Setter:
Sets evaluation delta for u-, v- and w-directions
- Type:
float
- property delta_u
Evaluation delta for the u-direction.
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_uandsample_size_uproperties correspond to the same variable with different descriptions. Therefore, settingdelta_uwill also setsample_size_u.Please refer to the wiki for details on using this class member.
- Getter:
Gets evaluation delta for the u-direction
- Setter:
Sets evaluation delta for the u-direction
- Type:
float
- property delta_v
Evaluation delta for the v-direction.
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_vandsample_size_vproperties correspond to the same variable with different descriptions. Therefore, settingdelta_vwill also setsample_size_v.Please refer to the wiki for details on using this class member.
- Getter:
Gets evaluation delta for the v-direction
- Setter:
Sets evaluation delta for the v-direction
- Type:
float
- property delta_w
Evaluation delta for the w-direction.
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_wandsample_size_wproperties correspond to the same variable with different descriptions. Therefore, settingdelta_wwill also setsample_size_w.Please refer to the wiki for details on using this class member.
- Getter:
Gets evaluation delta for the w-direction
- Setter:
Sets evaluation delta for the w-direction
- Type:
float
- property 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
- property domain
Domain.
Domain is determined using the knot vector(s).
- Getter:
Gets the domain
- property 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
- abstractmethod evaluate(**kwargs)
Evaluates the parametric volume.
Note
This is an abstract method and it must be implemented in the subclass.
- abstractmethod evaluate_list(param_list)
Evaluates the parametric volume for an input range of (u, v, w) parameter pairs.
Note
This is an abstract method and it must be implemented in the subclass.
- Parameters:
param_list – array of parameter pairs (u, v, w)
- abstractmethod evaluate_single(param)
Evaluates the parametric surface at the given (u, v, w) parameter.
Note
This is an abstract method and it must be implemented in the subclass.
- Parameters:
param – parameter pair (u, v, w)
- property evaluator
Evaluator instance.
Evaluators allow users to use different algorithms for B-Spline and NURBS evaluations. Please see the documentation on
Evaluatorclasses.Please refer to the wiki for details on using this class member.
- Getter:
Gets the current Evaluator instance
- Setter:
Sets the Evaluator instance
- Type:
- property id
Object ID (as an integer).
Please refer to the wiki for details on using this class member.
- Getter:
Gets the object ID
- Setter:
Sets the object ID
- Type:
int
- property knotvector
Knot vector for u-, v- and w-directions
- Getter:
Gets the knot vector
- Setter:
Sets the knot vector
- Type:
list
- property knotvector_u
Knot vector for the u-direction.
The knot vector will be normalized to [0, 1] domain if the class is initialized with
normalize_kv=Trueargument.Please refer to the wiki for details on using this class member.
- Getter:
Gets knot vector for the u-direction
- Setter:
Sets knot vector for the u-direction
- Type:
list
- property knotvector_v
Knot vector for the v-direction.
The knot vector will be normalized to [0, 1] domain if the class is initialized with
normalize_kv=Trueargument.Please refer to the wiki for details on using this class member.
- Getter:
Gets knot vector for the v-direction
- Setter:
Sets knot vector for the v-direction
- Type:
list
- property knotvector_w
Knot vector for the w-direction.
The knot vector will be normalized to [0, 1] domain if the class is initialized with
normalize_kv=Trueargument.Please refer to the wiki for details on using this class member.
- Getter:
Gets knot vector for the w-direction
- Setter:
Sets knot vector for the w-direction
- Type:
list
- property name
Object name (as a string)
Please refer to the wiki for details on using this class member.
- Getter:
Gets the object name
- Setter:
Sets the object name
- Type:
str
- property opt
Dictionary for storing custom data in the current geometry object.
optis a wrapper to a dict in key => value format, where key is string, value is any Python object. You can useoptproperty to store custom data inside the geometry object. For instance:geom.opt = ["face_id", 4] # creates "face_id" key and sets its value to an integer geom.opt = ["contents", "data values"] # creates "face_id" key and sets its value to a string print(geom.opt) # will print: {'face_id': 4, 'contents': 'data values'} del geom.opt # deletes the contents of the hash map print(geom.opt) # will print: {} geom.opt = ["body_id", 1] # creates "body_id" key and sets its value to 1 geom.opt = ["body_id", 12] # changes the value of "body_id" to 12 print(geom.opt) # will print: {'body_id': 12} geom.opt = ["body_id", None] # deletes "body_id" print(geom.opt) # will print: {}
Please refer to the wiki for details on using this class member.
- Getter:
Gets the dict
- Setter:
Adds key and value pair to the dict
- Deleter:
Deletes the contents of the dict
- opt_get(value)
Safely query for the value from the
optproperty.- Parameters:
value (str) – a key in the
optproperty- Returns:
the corresponding value, if the key exists.
None, otherwise.
- property order_u
Order for the u-direction.
Defined as
order = degree + 1Please refer to the wiki for details on using this class member.
- Getter:
Gets the surface order for u-direction
- Setter:
Sets the surface order for u-direction
- Type:
int
- property order_v
Order for the v-direction.
Defined as
order = degree + 1Please refer to the wiki for details on using this class member.
- Getter:
Gets the surface order for v-direction
- Setter:
Sets the surface order for v-direction
- Type:
int
- property order_w
Order for the w-direction.
Defined as
order = degree + 1Please refer to the wiki for details on using this class member.
- Getter:
Gets the surface order for v-direction
- Setter:
Sets the surface order for v-direction
- Type:
int
- property pdimension
Parametric dimension.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the parametric dimension
- Type:
int
- property range
Domain range.
- Getter:
Gets the range
- property rational
Defines the rational and non-rational B-spline shapes.
Rational shapes use homogeneous coordinates which includes a weight alongside with the Cartesian coordinates. Rational B-splines are also named as NURBS (Non-uniform rational basis spline) and non-rational B-splines are sometimes named as NUBS (Non-uniform basis spline) or directly as B-splines.
Please refer to the wiki for details on using this class member.
- Getter:
Returns True is the B-spline object is rational (NURBS)
- Type:
bool
- render(**kwargs)
Renders the volume using the visualization component.
The visualization component must be set using
visproperty 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: (8, 8, 8)use_cubes: use cube voxels instead of cuboid ones. Default: Falsenum_procs: number of concurrent processes for voxelization. Default: 1
The
plotargument is useful when you would like to work on the command line without any window context. Ifplotflag 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.extrasargument 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 dict( # line plot 1 3 points=[[1, 2, 3], [4, 5, 6]], # list of points 4 name="My line Plot 1", # name displayed on the legend 5 color="red", # color of the line plot 6 size=6.5 # size of the line plot 7 ), 8 dict( # line plot 2 9 points=[[7, 8, 9], [10, 11, 12]], # list of points 10 name="My line Plot 2", # name displayed on the legend 11 color="navy", # color of the line plot 12 size=12.5 # size of the line plot 13 ) 14]
- Returns:
the figure object
- reset(**kwargs)
Resets control points and/or evaluated points.
- Keyword Arguments:
evalpts: if True, then resets evaluated pointsctrlptsif True, then resets control points
- property sample_size
Sample size for both u- and v-directions.
Sample size defines the number of surface points to generate. It also sets the
deltaproperty.The following figure illustrates the working principles of sample size property:
![\underbrace {\left[ {{u_{start}}, \ldots ,{u_{end}}} \right]}_{{n_{sample}}}](_images/math/1c947ab28078413a0019013d581041db4c6d1d66.png)
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 w-directions
- Setter:
Sets sample size value for both u-, v- and w-directions
- Type:
int
- property sample_size_u
Sample size for the u-direction.
Sample size defines the number of evaluated points to generate. It also sets the
delta_uproperty.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
- property sample_size_v
Sample size for the v-direction.
Sample size defines the number of evaluated points to generate. It also sets the
delta_vproperty.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
- property sample_size_w
Sample size for the w-direction.
Sample size defines the number of evaluated points to generate. It also sets the
delta_wproperty.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
- 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 3-dimensional 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
- property trims
Trimming surfaces.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the array of trim surfaces
- Setter:
Sets the array of trim surfaces
- property type
Geometry type
Please refer to the wiki for details on using this class member.
- Getter:
Gets the geometry type
- Type:
str
Low Level API
The following classes provide the low level API for the geometry abstract base.
Geometry abstract base class can be used for implementation of any geometry object, whereas
SplineGeometry abstract base class is designed specifically for spline geometries, including basis splines.
- class geomdl.abstract.GeomdlBase(**kwargs)
Bases:
objectAbstract base class for defining geomdl objects.
This class provides the following properties:
Keyword Arguments:
id: object ID (as integer)precision: number of decimal places to round to. Default: 18
- property dimension
Spatial dimension.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the spatial dimension, e.g. 2D, 3D, etc.
- Type:
int
- property id
Object ID (as an integer).
Please refer to the wiki for details on using this class member.
- Getter:
Gets the object ID
- Setter:
Sets the object ID
- Type:
int
- property name
Object name (as a string)
Please refer to the wiki for details on using this class member.
- Getter:
Gets the object name
- Setter:
Sets the object name
- Type:
str
- property opt
Dictionary for storing custom data in the current geometry object.
optis a wrapper to a dict in key => value format, where key is string, value is any Python object. You can useoptproperty to store custom data inside the geometry object. For instance:geom.opt = ["face_id", 4] # creates "face_id" key and sets its value to an integer geom.opt = ["contents", "data values"] # creates "face_id" key and sets its value to a string print(geom.opt) # will print: {'face_id': 4, 'contents': 'data values'} del geom.opt # deletes the contents of the hash map print(geom.opt) # will print: {} geom.opt = ["body_id", 1] # creates "body_id" key and sets its value to 1 geom.opt = ["body_id", 12] # changes the value of "body_id" to 12 print(geom.opt) # will print: {'body_id': 12} geom.opt = ["body_id", None] # deletes "body_id" print(geom.opt) # will print: {}
Please refer to the wiki for details on using this class member.
- Getter:
Gets the dict
- Setter:
Adds key and value pair to the dict
- Deleter:
Deletes the contents of the dict
- class geomdl.abstract.Geometry(**kwargs)
Bases:
GeomdlBaseAbstract base class for defining geometry objects.
This class provides the following properties:
Keyword Arguments:
id: object ID (as integer)precision: number of decimal places to round to. Default: 18
- property dimension
Spatial dimension.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the spatial dimension, e.g. 2D, 3D, etc.
- Type:
int
- property 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
- abstractmethod evaluate(**kwargs)
Abstract method for the implementation of evaluation algorithm.
Note
This is an abstract method and it must be implemented in the subclass.
- property id
Object ID (as an integer).
Please refer to the wiki for details on using this class member.
- Getter:
Gets the object ID
- Setter:
Sets the object ID
- Type:
int
- property name
Object name (as a string)
Please refer to the wiki for details on using this class member.
- Getter:
Gets the object name
- Setter:
Sets the object name
- Type:
str
- property opt
Dictionary for storing custom data in the current geometry object.
optis a wrapper to a dict in key => value format, where key is string, value is any Python object. You can useoptproperty to store custom data inside the geometry object. For instance:geom.opt = ["face_id", 4] # creates "face_id" key and sets its value to an integer geom.opt = ["contents", "data values"] # creates "face_id" key and sets its value to a string print(geom.opt) # will print: {'face_id': 4, 'contents': 'data values'} del geom.opt # deletes the contents of the hash map print(geom.opt) # will print: {} geom.opt = ["body_id", 1] # creates "body_id" key and sets its value to 1 geom.opt = ["body_id", 12] # changes the value of "body_id" to 12 print(geom.opt) # will print: {'body_id': 12} geom.opt = ["body_id", None] # deletes "body_id" print(geom.opt) # will print: {}
Please refer to the wiki for details on using this class member.
- Getter:
Gets the dict
- Setter:
Adds key and value pair to the dict
- Deleter:
Deletes the contents of the dict
- class geomdl.abstract.SplineGeometry(**kwargs)
Bases:
GeometryAbstract base class for defining spline geometry objects.
This class provides the following properties:
Keyword Arguments:
id: object ID (as integer)precision: number of decimal places to round to. Default: 18normalize_kv: if True, knot vector(s) will be normalized to [0,1] domain. Default: Truefind_span_func: default knot span finding algorithm. Default:helpers.find_span_linear()
- property 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
- property cpsize
Number of control points in all parametric directions.
Note
This is an expert property for getting and setting control point size(s) of the geometry.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the number of control points
- Setter:
Sets the number of control points
- Type:
list
- property ctrlpts
Control points.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the control points
- Setter:
Sets the control points
- Type:
list
- property ctrlpts_size
Total number of control points.
- Getter:
Gets the total number of control points
- Type:
int
- property degree
Degree
Note
This is an expert property for getting and setting the degree(s) of the geometry.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the degree
- Setter:
Sets the degree
- Type:
list
- property 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
- property domain
Domain.
Domain is determined using the knot vector(s).
- Getter:
Gets the domain
- property 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
- abstractmethod evaluate(**kwargs)
Abstract method for the implementation of evaluation algorithm.
Note
This is an abstract method and it must be implemented in the subclass.
- property evaluator
Evaluator instance.
Evaluators allow users to use different algorithms for B-Spline and NURBS evaluations. Please see the documentation on
Evaluatorclasses.Please refer to the wiki for details on using this class member.
- Getter:
Gets the current Evaluator instance
- Setter:
Sets the Evaluator instance
- Type:
- property id
Object ID (as an integer).
Please refer to the wiki for details on using this class member.
- Getter:
Gets the object ID
- Setter:
Sets the object ID
- Type:
int
- property knotvector
Knot vector
Note
This is an expert property for getting and setting the knot vector(s) of the geometry.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the knot vector
- Setter:
Sets the knot vector
- Type:
list
- property name
Object name (as a string)
Please refer to the wiki for details on using this class member.
- Getter:
Gets the object name
- Setter:
Sets the object name
- Type:
str
- property opt
Dictionary for storing custom data in the current geometry object.
optis a wrapper to a dict in key => value format, where key is string, value is any Python object. You can useoptproperty to store custom data inside the geometry object. For instance:geom.opt = ["face_id", 4] # creates "face_id" key and sets its value to an integer geom.opt = ["contents", "data values"] # creates "face_id" key and sets its value to a string print(geom.opt) # will print: {'face_id': 4, 'contents': 'data values'} del geom.opt # deletes the contents of the hash map print(geom.opt) # will print: {} geom.opt = ["body_id", 1] # creates "body_id" key and sets its value to 1 geom.opt = ["body_id", 12] # changes the value of "body_id" to 12 print(geom.opt) # will print: {'body_id': 12} geom.opt = ["body_id", None] # deletes "body_id" print(geom.opt) # will print: {}
Please refer to the wiki for details on using this class member.
- Getter:
Gets the dict
- Setter:
Adds key and value pair to the dict
- Deleter:
Deletes the contents of the dict
- opt_get(value)
Safely query for the value from the
optproperty.- Parameters:
value (str) – a key in the
optproperty- Returns:
the corresponding value, if the key exists.
None, otherwise.
- property pdimension
Parametric dimension.
Please refer to the wiki for details on using this class member.
- Getter:
Gets the parametric dimension
- Type:
int
- property range
Domain range.
- Getter:
Gets the range
- property rational
Defines the rational and non-rational B-spline shapes.
Rational shapes use homogeneous coordinates which includes a weight alongside with the Cartesian coordinates. Rational B-splines are also named as NURBS (Non-uniform rational basis spline) and non-rational B-splines are sometimes named as NUBS (Non-uniform basis spline) or directly as B-splines.
Please refer to the wiki for details on using this class member.
- Getter:
Returns True is the B-spline object is rational (NURBS)
- Type:
bool
- abstractmethod render(**kwargs)
Abstract method for spline rendering and visualization.
Note
This is an abstract method and it must be implemented in the subclass.
- 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 3-dimensional space, then your coordinates will be an array of 3 elements representing (x, y, z) coordinates.
- Keyword Arguments:
array_init: initializes the control points array in the instancearray_check_for: defines the types for input validationcallback: defines the callback function for processing input pointsdimension: defines the spatial dimension of the input points
- Parameters:
ctrlpts (list) – input control points as a list of coordinates
args (tuple) – number of control points corresponding to each parametric dimension
- property type
Geometry type
Please refer to the wiki for details on using this class member.
- Getter:
Gets the geometry type
- Type:
str