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
digraph inheritancec18657e075 { bgcolor=transparent; rankdir=LR; ratio=compress; size="8.0, 12.0"; "geomdl.evaluators.AbstractEvaluator" [URL="#geomdl.evaluators.AbstractEvaluator",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 implementations of fundamental spline algorithms, such as evaluate and derivative."]; "geomdl.evaluators.CurveEvaluator" [URL="#geomdl.evaluators.CurveEvaluator",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="Sequential curve evaluation algorithms."]; "geomdl.evaluators.AbstractEvaluator" -> "geomdl.evaluators.CurveEvaluator" [arrowsize=0.5,style="setlinewidth(0.5)"]; "geomdl.evaluators.CurveEvaluator2" [URL="#geomdl.evaluators.CurveEvaluator2",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="Sequential curve evaluation algorithms (alternative)."]; "geomdl.evaluators.CurveEvaluator" -> "geomdl.evaluators.CurveEvaluator2" [arrowsize=0.5,style="setlinewidth(0.5)"]; "geomdl.evaluators.CurveEvaluatorRational" [URL="#geomdl.evaluators.CurveEvaluatorRational",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="Sequential rational curve evaluation algorithms."]; "geomdl.evaluators.CurveEvaluator" -> "geomdl.evaluators.CurveEvaluatorRational" [arrowsize=0.5,style="setlinewidth(0.5)"]; "geomdl.evaluators.SurfaceEvaluator" [URL="#geomdl.evaluators.SurfaceEvaluator",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="Sequential surface evaluation algorithms."]; "geomdl.evaluators.AbstractEvaluator" -> "geomdl.evaluators.SurfaceEvaluator" [arrowsize=0.5,style="setlinewidth(0.5)"]; "geomdl.evaluators.SurfaceEvaluator2" [URL="#geomdl.evaluators.SurfaceEvaluator2",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="Sequential surface evaluation algorithms (alternative)."]; "geomdl.evaluators.SurfaceEvaluator" -> "geomdl.evaluators.SurfaceEvaluator2" [arrowsize=0.5,style="setlinewidth(0.5)"]; "geomdl.evaluators.SurfaceEvaluatorRational" [URL="#geomdl.evaluators.SurfaceEvaluatorRational",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="Sequential rational surface evaluation algorithms."]; "geomdl.evaluators.SurfaceEvaluator" -> "geomdl.evaluators.SurfaceEvaluatorRational" [arrowsize=0.5,style="setlinewidth(0.5)"]; "geomdl.evaluators.VolumeEvaluator" [URL="#geomdl.evaluators.VolumeEvaluator",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="Sequential volume evaluation algorithms."]; "geomdl.evaluators.AbstractEvaluator" -> "geomdl.evaluators.VolumeEvaluator" [arrowsize=0.5,style="setlinewidth(0.5)"]; "geomdl.evaluators.VolumeEvaluatorRational" [URL="#geomdl.evaluators.VolumeEvaluatorRational",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="Sequential rational volume evaluation algorithms."]; "geomdl.evaluators.VolumeEvaluator" -> "geomdl.evaluators.VolumeEvaluatorRational" [arrowsize=0.5,style="setlinewidth(0.5)"]; }Abstract Base
- class geomdl.evaluators.AbstractEvaluator(**kwargs)
Bases:
objectAbstract base class for implementations of fundamental spline algorithms, such as evaluate and derivative.
Abstract Methods:
evaluateis used for computation of the complete spline shapederivative_singleis used for computation of derivatives at a single parametric coordinate
Please note that this class requires the keyword argument
find_span_functo be set to a valid find_span function implementation. Please seehelpersmodule for details.- abstractmethod 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
- abstractmethod 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
- property name
Evaluator name.
- Getter:
Gets the name of the evaluator
- Type:
str
Curve Evaluators
- class geomdl.evaluators.CurveEvaluator(**kwargs)
Bases:
AbstractEvaluatorSequential 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_funckeyword 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
- property name
Evaluator name.
- Getter:
Gets the name of the evaluator
- Type:
str
- class geomdl.evaluators.CurveEvaluatorRational(**kwargs)
Bases:
CurveEvaluatorSequential 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_funckeyword 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
- property name
Evaluator name.
- Getter:
Gets the name of the evaluator
- Type:
str
- class geomdl.evaluators.CurveEvaluator2(**kwargs)
Bases:
CurveEvaluatorSequential 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_funckeyword 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
- property name
Evaluator name.
- Getter:
Gets the name of the evaluator
- Type:
str
Surface Evaluators
- class geomdl.evaluators.SurfaceEvaluator(**kwargs)
Bases:
AbstractEvaluatorSequential 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_funckeyword 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
- property name
Evaluator name.
- Getter:
Gets the name of the evaluator
- Type:
str
- class geomdl.evaluators.SurfaceEvaluatorRational(**kwargs)
Bases:
SurfaceEvaluatorSequential 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_funckeyword 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
- property name
Evaluator name.
- Getter:
Gets the name of the evaluator
- Type:
str
- class geomdl.evaluators.SurfaceEvaluator2(**kwargs)
Bases:
SurfaceEvaluatorSequential 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_funckeyword 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
- property name
Evaluator name.
- Getter:
Gets the name of the evaluator
- Type:
str
Volume Evaluators
- class geomdl.evaluators.VolumeEvaluator(**kwargs)
Bases:
AbstractEvaluatorSequential volume evaluation algorithms.
Please note that knot vector span finding function may be changed by setting
find_span_funckeyword 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
- property name
Evaluator name.
- Getter:
Gets the name of the evaluator
- Type:
str
- class geomdl.evaluators.VolumeEvaluatorRational(**kwargs)
Bases:
VolumeEvaluatorSequential rational volume evaluation algorithms.
Please note that knot vector span finding function may be changed by setting
find_span_funckeyword 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
- property name
Evaluator name.
- Getter:
Gets the name of the evaluator
- Type:
str