Evaluators¶
Evaluators allow users to change the evaluation algorithms that are used to evaluate curves, surfaces and volumes, take derivatives and more. All geometry classes set an evaluator by default. Users may switch between the evaluation algorithms at runtime. It is also possible to implement different algorithms (e.g. T-splines) or extend existing ones.
How to Use¶
All geometry classes come with a default specialized evaluator
class, the algorithms are generally different for
rational and non-rational geometries. The evaluator class instance can be accessed and/or updated using evaluator
property. For instance, the following code snippet changes the evaluator of a B-Spline curve.
from geomdl import BSpline
from geomdl import evaluators
crv = BSpline.Curve()
cevaltr = evaluators.CurveEvaluator2()
crv.evaluator = cevaltr
# Curve "evaluate" method will use CurveEvaluator2.evaluate() method
crv.evaluate()
# Get evaluated points
curve_points = crv.evalpts
Implementing Evaluators¶
All evaluators should be extended from evaluators.AbstractEvaluator
abstract base class. This class provides
a point evaluation and a derivative computation methods. Both methods take a data input which contains the geometry
data as a dict object (refer to BSpline.Surface.data
property as an example). The derivative computation
method also takes additional arguments, such as the parametric position and the derivative order.
Inheritance Diagram¶
Abstract Base¶
-
class
geomdl.evaluators.
AbstractEvaluator
(**kwargs)¶ Bases:
object
Abstract base class for implementations of fundamental spline algorithms, such as evaluate and derivative.
Abstract Methods:
evaluate
is used for computation of the complete spline shapederivative_single
is used for computation of derivatives at a single parametric coordinate
Please note that this class requires the keyword argument
find_span_func
to be set to a valid find_span function implementation. Please seehelpers
module for details.-
derivatives
(datadict, parpos, deriv_order=0, **kwargs)¶ Abstract method for evaluation of the n-th order derivatives at the input parametric position.
Note
This is an abstract method and it must be implemented in the subclass.
Parameters: - datadict (dict) – data dictionary containing the necessary variables
- parpos (list, tuple) – parametric position where the derivatives will be computed
- deriv_order (int) – derivative order; to get the i-th derivative
-
evaluate
(datadict, **kwargs)¶ Abstract method for evaluation of points on the spline geometry.
Note
This is an abstract method and it must be implemented in the subclass.
Parameters: datadict (dict) – data dictionary containing the necessary variables
-
name
¶ Evaluator name.
Getter: Gets the name of the evaluator Type: str
Curve Evaluators¶
-
class
geomdl.evaluators.
CurveEvaluator
(**kwargs)¶ Bases:
geomdl.evaluators.AbstractEvaluator
Sequential curve evaluation algorithms.
This evaluator implements the following algorithms from The NURBS Book:
- Algorithm A3.1: CurvePoint
- Algorithm A3.2: CurveDerivsAlg1
Please note that knot vector span finding function may be changed by setting
find_span_func
keyword argument during the initialization. By default, this function is set tohelpers.find_span_linear()
. Please see Helpers Module Documentation for more details.-
derivatives
(datadict, parpos, deriv_order=0, **kwargs)¶ Evaluates the n-th order derivatives at the input parametric position.
Parameters: - datadict (dict) – data dictionary containing the necessary variables
- parpos (list, tuple) – parametric position where the derivatives will be computed
- deriv_order (int) – derivative order; to get the i-th derivative
Returns: evaluated derivatives
Return type: list
-
evaluate
(datadict, **kwargs)¶ Evaluates the curve.
- Keyword Arguments:
start
: starting parametric position for evaluationstop
: ending parametric position for evaluation
Parameters: datadict (dict) – data dictionary containing the necessary variables Returns: evaluated points Return type: list
-
name
¶ Evaluator name.
Getter: Gets the name of the evaluator Type: str
-
class
geomdl.evaluators.
CurveEvaluatorRational
(**kwargs)¶ Bases:
geomdl.evaluators.CurveEvaluator
Sequential rational curve evaluation algorithms.
This evaluator implements the following algorithms from The NURBS Book:
- Algorithm A3.1: CurvePoint
- Algorithm A4.2: RatCurveDerivs
Please note that knot vector span finding function may be changed by setting
find_span_func
keyword argument during the initialization. By default, this function is set tohelpers.find_span_linear()
. Please see Helpers Module Documentation for more details.-
derivatives
(datadict, parpos, deriv_order=0, **kwargs)¶ Evaluates the n-th order derivatives at the input parametric position.
Parameters: - datadict (dict) – data dictionary containing the necessary variables
- parpos (list, tuple) – parametric position where the derivatives will be computed
- deriv_order (int) – derivative order; to get the i-th derivative
Returns: evaluated derivatives
Return type: list
-
evaluate
(datadict, **kwargs)¶ Evaluates the rational curve.
- Keyword Arguments:
start
: starting parametric position for evaluationstop
: ending parametric position for evaluation
Parameters: datadict (dict) – data dictionary containing the necessary variables Returns: evaluated points Return type: list
-
name
¶ Evaluator name.
Getter: Gets the name of the evaluator Type: str
-
class
geomdl.evaluators.
CurveEvaluator2
(**kwargs)¶ Bases:
geomdl.evaluators.CurveEvaluator
Sequential curve evaluation algorithms (alternative).
This evaluator implements the following algorithms from The NURBS Book:
- Algorithm A3.1: CurvePoint
- Algorithm A3.3: CurveDerivCpts
- Algorithm A3.4: CurveDerivsAlg2
Please note that knot vector span finding function may be changed by setting
find_span_func
keyword argument during the initialization. By default, this function is set tohelpers.find_span_linear()
. Please see Helpers Module Documentation for more details.-
derivatives
(datadict, parpos, deriv_order=0, **kwargs)¶ Evaluates the n-th order derivatives at the input parametric position.
Parameters: - datadict (dict) – data dictionary containing the necessary variables
- parpos (list, tuple) – parametric position where the derivatives will be computed
- deriv_order (int) – derivative order; to get the i-th derivative
Returns: evaluated derivatives
Return type: list
-
evaluate
(datadict, **kwargs)¶ Evaluates the curve.
- Keyword Arguments:
start
: starting parametric position for evaluationstop
: ending parametric position for evaluation
Parameters: datadict (dict) – data dictionary containing the necessary variables Returns: evaluated points Return type: list
-
name
¶ Evaluator name.
Getter: Gets the name of the evaluator Type: str
Surface Evaluators¶
-
class
geomdl.evaluators.
SurfaceEvaluator
(**kwargs)¶ Bases:
geomdl.evaluators.AbstractEvaluator
Sequential surface evaluation algorithms.
This evaluator implements the following algorithms from The NURBS Book:
- Algorithm A3.5: SurfacePoint
- Algorithm A3.6: SurfaceDerivsAlg1
Please note that knot vector span finding function may be changed by setting
find_span_func
keyword argument during the initialization. By default, this function is set tohelpers.find_span_linear()
. Please see Helpers Module Documentation for more details.-
derivatives
(datadict, parpos, deriv_order=0, **kwargs)¶ Evaluates the n-th order derivatives at the input parametric position.
Parameters: - datadict (dict) – data dictionary containing the necessary variables
- parpos (list, tuple) – parametric position where the derivatives will be computed
- deriv_order (int) – derivative order; to get the i-th derivative
Returns: evaluated derivatives
Return type: list
-
evaluate
(datadict, **kwargs)¶ Evaluates the surface.
- Keyword Arguments:
start
: starting parametric position for evaluationstop
: ending parametric position for evaluation
Parameters: datadict (dict) – data dictionary containing the necessary variables Returns: evaluated points Return type: list
-
name
¶ Evaluator name.
Getter: Gets the name of the evaluator Type: str
-
class
geomdl.evaluators.
SurfaceEvaluatorRational
(**kwargs)¶ Bases:
geomdl.evaluators.SurfaceEvaluator
Sequential rational surface evaluation algorithms.
This evaluator implements the following algorithms from The NURBS Book:
- Algorithm A4.3: SurfacePoint
- Algorithm A4.4: RatSurfaceDerivs
Please note that knot vector span finding function may be changed by setting
find_span_func
keyword argument during the initialization. By default, this function is set tohelpers.find_span_linear()
. Please see Helpers Module Documentation for more details.-
derivatives
(datadict, parpos, deriv_order=0, **kwargs)¶ Evaluates the n-th order derivatives at the input parametric position.
Parameters: - datadict (dict) – data dictionary containing the necessary variables
- parpos (list, tuple) – parametric position where the derivatives will be computed
- deriv_order (int) – derivative order; to get the i-th derivative
Returns: evaluated derivatives
Return type: list
-
evaluate
(datadict, **kwargs)¶ Evaluates the rational surface.
- Keyword Arguments:
start
: starting parametric position for evaluationstop
: ending parametric position for evaluation
Parameters: datadict (dict) – data dictionary containing the necessary variables Returns: evaluated points Return type: list
-
name
¶ Evaluator name.
Getter: Gets the name of the evaluator Type: str
-
class
geomdl.evaluators.
SurfaceEvaluator2
(**kwargs)¶ Bases:
geomdl.evaluators.SurfaceEvaluator
Sequential surface evaluation algorithms (alternative).
This evaluator implements the following algorithms from The NURBS Book:
- Algorithm A3.5: SurfacePoint
- Algorithm A3.7: SurfaceDerivCpts
- Algorithm A3.8: SurfaceDerivsAlg2
Please note that knot vector span finding function may be changed by setting
find_span_func
keyword argument during the initialization. By default, this function is set tohelpers.find_span_linear()
. Please see Helpers Module Documentation for more details.-
derivatives
(datadict, parpos, deriv_order=0, **kwargs)¶ Evaluates the n-th order derivatives at the input parametric position.
Parameters: - datadict (dict) – data dictionary containing the necessary variables
- parpos (list, tuple) – parametric position where the derivatives will be computed
- deriv_order (int) – derivative order; to get the i-th derivative
Returns: evaluated derivatives
Return type: list
-
evaluate
(datadict, **kwargs)¶ Evaluates the surface.
- Keyword Arguments:
start
: starting parametric position for evaluationstop
: ending parametric position for evaluation
Parameters: datadict (dict) – data dictionary containing the necessary variables Returns: evaluated points Return type: list
-
name
¶ Evaluator name.
Getter: Gets the name of the evaluator Type: str
Volume Evaluators¶
-
class
geomdl.evaluators.
VolumeEvaluator
(**kwargs)¶ Bases:
geomdl.evaluators.AbstractEvaluator
Sequential volume evaluation algorithms.
Please note that knot vector span finding function may be changed by setting
find_span_func
keyword argument during the initialization. By default, this function is set tohelpers.find_span_linear()
. Please see Helpers Module Documentation for more details.-
derivatives
(datadict, parpos, deriv_order=0, **kwargs)¶ Evaluates the n-th order derivatives at the input parametric position.
Parameters: - datadict (dict) – data dictionary containing the necessary variables
- parpos (list, tuple) – parametric position where the derivatives will be computed
- deriv_order (int) – derivative order; to get the i-th derivative
Returns: evaluated derivatives
Return type: list
-
evaluate
(datadict, **kwargs)¶ Evaluates the volume.
- Keyword Arguments:
start
: starting parametric position for evaluationstop
: ending parametric position for evaluation
Parameters: datadict (dict) – data dictionary containing the necessary variables Returns: evaluated points Return type: list
-
name
¶ Evaluator name.
Getter: Gets the name of the evaluator Type: str
-
-
class
geomdl.evaluators.
VolumeEvaluatorRational
(**kwargs)¶ Bases:
geomdl.evaluators.VolumeEvaluator
Sequential rational volume evaluation algorithms.
Please note that knot vector span finding function may be changed by setting
find_span_func
keyword argument during the initialization. By default, this function is set tohelpers.find_span_linear()
. Please see Helpers Module Documentation for more details.-
derivatives
(datadict, parpos, deriv_order=0, **kwargs)¶ Evaluates the n-th order derivatives at the input parametric position.
Parameters: - datadict (dict) – data dictionary containing the necessary variables
- parpos (list, tuple) – parametric position where the derivatives will be computed
- deriv_order (int) – derivative order; to get the i-th derivative
Returns: evaluated derivatives
Return type: list
-
evaluate
(datadict, **kwargs)¶ Evaluates the rational volume.
- Keyword Arguments:
start
: starting parametric position for evaluationstop
: ending parametric position for evaluation
Parameters: datadict (dict) – data dictionary containing the necessary variables Returns: evaluated points Return type: list
-
name
¶ Evaluator name.
Getter: Gets the name of the evaluator Type: str
-