Accessors in C_Shape_Edit
A number of Alpha_1 objects have "sub-parts" (or slots) that may be accessed
either through the designation of member names or by indexing.
Member access expressions are of the form:
<object>.<member_name>
While object indexing expressions take the form:
<object>[<integer_expression>]
Such expressions may be concatenated into a list (see examples below).
More formally the relevant part of the shape_edit command language grammar
is:
object: T_IDENTIFIER | object access_list
access: '.' T_IDENTIFIER | '[' expr ']'
access_list: access | access_list access
Notes
-
Member names are the ones that are given when objects are printed by c_shape_edit
(these are not necessarily the same as the names given to members of the
corresponding C++ objects).
-
Indexing is always zero based.
-
Use of accessors on the left hand side of assignment statements (i.e.,
modification operations) is not currently implemented.
-
Only a limited number of accessors have been implemented thus far. This
number will be expanded shortly.
Examples
Here are some examples to try:
foo : pt(1,2);
foo.x;
foo[0]; # Same as above.
foo.y;
foo[1]; # Same as above.
foo.z; # Will give an error.
foo.w; # Will give an error.
fooArc : arcEndCenterEnd( pt(0,2), pt(0,1), pt(1,1) );
fooArc.radius;
fooArc.center;
unitcircle.ctlpoly;
unitcircle.kv;
unitcircle.kv[5];
unitsphere; # Is a shell.
unitsphere[0]; # Gives surface in shell.
unitsphere[0].ctlmesh; # Gives control mesh.
unitsphere[0].ctlmesh[1]; # Gives a row of control mesh.
unitsphere[0].ctlmesh[1][2]; # Gives a point of control mesh.
unitsphere[0].ctlmesh[1][2].w; # Gives a coordinate of point.
unitsphere[0].ctlmesh[1][2][3]; # Same as above.
Table of Accessors
Points
-
Members:
-
x, y, z, w
-
Indexing:
-
A point's coordinates may be accessed by indexing.
-
Notes:
-
An error results if the specified coordinate doesn't exist.
Vectors
-
Members:
-
x, y, z
-
Indexing:
-
A vector's coordinates may be accessed by indexing.
-
Notes:
-
An error results if the specified coordinate doesn't exist.
Lines
-
Members:
-
point, direction
-
Indexing:
-
None.
Bounding Boxes
-
Members:
-
minPt, maxPt
-
Indexing:
-
0 - Returns the minPt of the axis-aligned bounding box
-
1 - Returns the maxPt of the axis-aligned bounding box
Arcs
-
Members:
-
radius, center, start, end, normal
-
Indexing:
-
None.
Circles
-
Members:
-
radius, center, normal
-
Indexing:
-
None.
Curves
-
Members:
-
order, endcond, kv, ctlpoly
-
Indexing:
-
None.
Surfaces
-
Members:
-
uorder, vorder, uendcond, vendcond, ukv, vkv, ctlmesh
-
Indexing:
-
None.
Groups
-
Members:
-
None.
-
Indexing:
-
Indexing gives the objects in the group.
Shells
-
Members:
-
None.
-
Indexing:
-
Indexing gives the surfaces in the shell.
Arrays
-
Members:
-
None.
-
Indexing:
-
Indexing gives the objects in the array.
Matrix Objects
Matrix objects include curve control polygons, surface control
meshes, and knot vectors. There is no access of matrix objects
by member name designation; only indexing is allowed.
Indexing for matrix objects works as follows:
-
Curve control polygon:
-
One level of indexing gives a control point.
-
Two levels of indexing gives a coordinate of a control point.
-
Surface control mesh:
-
One level of indexing gives a row of the control mesh.
-
Two levels of indexing gives a control point.
-
Three levels of indexing gives a coordinate of a control point.
-
Knot vector:
-
One level of indexing gives a knot value.
a1-web@gr.cs.utah.edu