![]() |
Expressions |
<<< Reading and Writing Parasolid Data | Chapters | Introduction To Model Interrogation >>> |
This chapter provides information on expressions.Expressions allow an application to supply a mathematical formula to be evaluated. The expressions are supplied in the form of strings. For example, the expression "position + vector(0.1, 0.0, 0.0)" evaluates the result of adding the vector (0.1, 0.0, 0.0) to the variable position, which should also be a vector.
Note: Expressions are calculated in double precision. |
Evaluators can be used an inputs when performing deformation using PK_FACE_change. See Section 72.4.8, “Deformation options” for more information.
PK_EXPR_sf_t is the standard form of an expression. It contains fields that specify:
The expression's overall value comes from evaluating the root expression.
The use of sub-expressions is optional. If you choose to use them, their names must begin with the prefix "sbx_" and consist of alphanumeric characters or underscore "_".Sub-expressions can be referenced by name in either the
root_expr
field or the
sub_expr_defs
field in the PK_EXPR_sf_t structure.
The use of constants are also optional and their names must begin with the prefix "c_" and consist of alphanumeric characters or underscore "_". A constant is referenced by its name in either the
root_expr
field or the
sub_expr_defs
field in the PK_EXPR_sf_t structure.
Note: Sub-expression and constant names are case-insensitive. |
See PK_EXPR_sf_t for more information.
multiply (real*real or real*vector), cross product (vector*vector) |
|
Evaluates to |
Operators have the following order of precedence:
Note: Operators listed higher in the table have higher precedence. |
Operators of equal precedence such as multiplication and division are evaluated from left to right. Parentheses may be used to force the ordering of the mathematical operations.
An expression string forms a mathematical formula consisting of identifiers combined by operators and functions. Identifiers may be:
An object referred to by an identifier, received or returned by a function can be of type bool, integer, real, vector, or PK_ENTITY or any of its sub-classes. The form of a vector is an array of three reals.
The operators are mathematical or logical and the functions are mathematical or geometric as illustrated in the following expression string example:
position + c_offset_dist * pkx_normal(c_surf, sbx_projection)
Returns a unit vector parallel to v, of the zero vector if v has zero magnitude. |
||
Returns the index-th component of the supplied vector v. The index must be 1, 2 or 3. |
||
Returns x rounded down to the nearest integer multiple of y. |
||
(PK_ENTITY_t entity, vector start, vector end) |
Evaluates the arc length of an edge or curve between the supplied start and end positions.The entity may be an edge or curve.The start and end must lie on the curve. |
|
(PK_ENTITY_t entity, vector position) |
Finds the global minimum separation between the supplied entity and position. The function returns a point on the entity that is the minimum separation distance from the position. The entity may be a body, face, edge, fin, vertex, surface, curve, or point. |
|
(PK_ENTITY_t entity, vector position, bool |
Evaluates the normal on a face or surface, at the supplied position.The entity may be a face or surface. If the entity is a face, the function evaluates on the face's surface, taking into account the face orientation. If the optional argument |
|
(PK_GEOM_t geom, vector position) |
Finds the parameter(s) of the supplied position on a curve or surface.The geom may be a curve or surface. For a curve, the parameter t is returned as the vector (t, 0, 0). For a surface, the parameters u and v are returned as the vector (u, v, 0).The position must lie on the curve or surface. |
|
(PK_GEOM_t geom, vector parameters) |
Evaluates a point on the curve or surface, at the supplied parameters.The geom may be a curve or surface. For a curve, the parameter should be supplied as the first component of the parameters vector. For a surface, the u and v parameters should be supplied as the first and second components of the parameters vector respectively. |
|
(PK_ENTITY_t entity, vector position, bool |
Evaluates the tangent on an edge, fin or curve, at the supplied position The entity may be an edge, fin or curve. If the entity is an edge or fin, the function evaluates on the edge's or fin's geometry, taking into account the edge or fin orientation. If the optional argument |
Offsets the supplied position by a distance 0.1 in the direction of the face normal at the position |
An example involving sub-expressions and constants is as follows:
This example expression offsets the position by a distance c_offset_dist in the direction of the normal of the surface with tag c_s0 at the point sbx_projection. sbx_projection is the closest point on the surface to the position. In this example, c_s0 and c_offset_dist are supplied as constants in the PK_EXPR_sf_t standard form.
<<< Reading and Writing Parasolid Data | Chapters | Introduction To Model Interrogation >>> |