Geometry
Surfaces and curves are the shapes a part is fitted to. This chapter describes the surface kinds James defines with sd, the two-dimensional curves of ld and lcc that some surfaces are built from, and the three-dimensional curves of curd that edges are attached to. Geometry is defined in any phase and referred to by number.
How geometry is defined and used
You define a surface, a 2D curve or a 3D curve with a number. The definition is legal in the Control, Part and Merge phases, so a script may put all its geometry first or define a shape just before the part that needs it. Defining geometry changes no mesh. It adds a row to a table, and a later command uses the row.
- A surface is referred to by its number or its name.
sfandsfiproject onto surfaces.sdreads a surface number forsds. - A 2D curve is referred to by its number.
sdreads it for the surfaces of revolution. - A 3D curve is referred to by its number.
cur,curf,cureandcursread it.
A surface, a 2D curve and a 3D curve each have their own table, so surface 1, 2D curve 1 and 3D curve 1 are three different things.
A surface is always Cartesian, even when the part that uses it is a cylinder part. James converts around each projection.
Geometry is built from these commands: sd, ld, lcc and curd.
Surfaces
sd defines a surface by number. James builds six kinds.
| Kind | Parameters, in order | What it is |
|---|---|---|
plan | x0 y0 z0 xn yn zn | The plane through the point (x0, y0, z0), normal to the vector (xn, yn, zn). |
cy | x0 y0 z0 xn yn zn radius | The infinite cylinder about the axis through the point along the vector, with the given radius. cyli is another spelling. |
sp | x0 y0 z0 radius | The sphere about the point. sphe is another spelling. |
cone | x0 y0 z0 xn yn zn radius angle | The infinite cone about the axis through the point along the vector. radius is the cone’s radius at the point and angle is its half-angle in degrees. |
crx, cry, crz | curve | The 2D curve with that number, revolved about the x, y or z axis. |
sds | surface_1 surface_2 ... ; | The union of earlier surfaces. |
The parameters are the ones sd takes, in the same order. The rest of this section says what each one means.
- A plane’s vector is its normal. It may have any length, because James normalizes it. A vector of zero length is an error.
- A cylinder’s vector is the direction of its axis. The vector
0 0 5is as good as0 0 1. The radius must be positive (E1005). - A sphere’s radius must be positive (E1005).
- A cone’s vector is the direction of its axis. A radius of 0 puts the apex at the point. The radius may not be negative (E1007). The angle lies strictly between -90 and 90 and is not 0 (E1006). The cone is the whole algebraic cone, both nappes.
- A revolved curve uses the global origin as the curve’s origin and the named axis as the curve’s local z direction. A curve is bounded by the circles that its two ends sweep, so a node beyond an end projects onto that rim.
- A composite from
sdsis projected onto every member, and a node keeps the nearest result. Its members may have gaps or overlaps. Every member must be an earlier surface (E1000). The list is a plain list of numbers. The colon shorthand1:3is E0104.
A node projected onto a surface moves to the nearest point of the surface. The shaping chapter explains projection.
The script examples/lens.tg, which make test runs, uses a cylinder and two spheres:
c A lens: one block part, its top and bottom faces projected onto two
c spheres and its four sides onto a cylinder, so the square block becomes a
c round biconvex lens 0.6 thick at the rim and 1.67 at the centre.
c 245 nodes, 144 elements.
c
c james lens.tg --format exodus -o lens.exo
sd 1 cyli 0 0 0 0 0 1 2
sd 2 sphe 0 0 3.164 4
sd 3 sphe 0 0 -3.164 4
block 1 7;1 7;1 5;-1.4 1.4;-1.4 1.4;-0.6 0.6;
sfi -1 -2;;;sd 1
sfi ;-1 -2;;sd 1
sfi ;;-1;sd 2
sfi ;;-2;sd 3
endpart
merge
write
The two spheres have radius 4 and their centres lie on the z axis, 3.164 above and below the origin. The spheres cut the cylinder of radius 2 at z = 0.3 and z = -0.3. The sphere centred above shapes the bottom face and the one centred below shapes the top face, so the lens is 0.6 thick at the rim and 1.67 at the centre. The four sfi commands project the sides of the block onto the cylinder and its top and bottom onto the spheres. James writes 245 nodes and 144 elements.
Redefining and naming
A surface number that you define again replaces the surface, and James does not warn. A number below 1 is E0104. James keeps the parameter %nextsrf: the highest surface number defined so far plus one.
A surface may have a name, written before the number. A name holds a letter and no spaces (E1008). Only its first eight characters count, and case is ignored. A name that you give to several surfaces makes a composite of them for any command that refers to that name. The script tests/corpus/139-sfi-name-composite/input.tg:
sd bowl 3 sp 0 0 0 1
sd BOWL 1 sp 3 0 0 1
sd 2 sp 6 0 0 1
block 1 3;1 3;1 3;0.5 1.5;0 1;0 1;
sfi -1;;; sd bowl
sfi -2;;; sd Bowl
endpart
The first two spheres share the name bowl, in lower and upper case. A sfi that refers to bowl or to Bowl gets a composite of the first two spheres. The IR holds that composite as a fourth surface, with the two spheres as members. The third sphere has no name and is not in it.
2D curves
A 2D curve lives in a local plane with the coordinates x and z. It is not in the mesh’s coordinate system until a surface of revolution places it. A revolving surface reads x as the distance from the axis and z as the position along it.
ld
ld builds one curve from a chain of segments. Each segment starts where the one before it ended.
ld number lp2 x z [x z ...] ; lar x_end z_end radius ;
lp2draws straight lines through its points. A first point that is not where the chain ended gets a line to it first. A single point sets the start of the chain when nothing precedes it, and a chain that never gets past that point is E1002.lardraws a circular arc from where the chain ended to(x_end, z_end). The arc is the short one. A positive radius turns counter-clockwise and a negative radius turns clockwise.
The chord rule governs lar: the radius must be at least half the length of the chord from the start to the end (E1003). A radius of exactly half the chord is a semicircle, and its sign chooses the direction.
A curve holds at most 256 segments. Any other segment type is refused: a type James knows of is E1009 and a word that is no segment type is E0104 in place of the first segment. After a complete segment such a word ends the ld, and James reports it as not recognized (E0105).
lcc
lcc makes concentric arcs. It takes a centre, a begin angle and an end angle in degrees, and a list of radii. Each radius is one curve.
The curves are numbered from one above the highest 2D curve number defined so far. The script tests/corpus/181-lcc-three-arcs/input.tg:
c lcc makes three concentric arcs, numbered 1 to 3
lcc 0 0 0 90 1 2 3;
The angles run from 0 to 90 degrees about the origin, so each curve is a quarter circle. The IR holds three 2D curves, numbered 1, 2 and 3, each with one arc. A curve that ld defined before the lcc moves the numbering up: after ld 1 an lcc with two radii makes curves 2 and 3.
An arc turns clockwise when the begin angle is larger than the end angle, and nothing wraps through 360 degrees. A negative radius reflects the arc through the centre. A span of zero is an arc of no length, and the engine refuses it with exit code 2.
Revolving a curve
crx, cry and crz revolve a defined curve about the x, y or z axis. The curve must exist when sd is read (E1001). The script tests/corpus/122-sd-crx-accept/input.tg:
ld 1 lp2 0 0 1 1;
sd 1 crx 1
The ld defines curve 1 as one line from (0, 0) to (1, 1). The sd revolves it about the x axis as surface 1, which is a cone. The IR holds the curve with one lp2 segment and the surface with kind crx, which refers to the curve.
3D curves
curd defines a 3D curve by number. A 3D curve moves nothing by itself. The commands cur, curf, cure and curs attach an edge to it. A curve that cur names may be defined by a curd later in the same part, before the part ends. A curve number that is never defined is E0601.
James builds two types.
lp3is a polyline through its points, in order.csp3is a cubic spline through its points. Its parameter runs by unit steps between points.
curd number lp3 x y z [ x y z ... ] ;
curd number csp3 option [ end_value ... ] x y z [ x y z ... ] ;
A curve has at least two points (E0602). A loop needs at least three points; two are refused when the curve is built (exit 2). The count of coordinates is a multiple of three (E0605). A transformation operator may follow the point list, as in tr.
csp3 takes an option first. The word loop closes the spline into a smooth loop and takes no end value. Otherwise the option is two digits, one for each end of the curve.
| Digit | Condition at that end | Values that follow the option |
|---|---|---|
0 | natural: second derivative zero | none |
1 | a derivative vector | three reals |
2 | matches the first end of another curve | a curve number and a magnitude |
3 | matches the last end of another curve | a curve number and a magnitude |
The values of the first digit come before those of the second. A match takes the unit tangent of the other curve at its named end and scales it by the magnitude. The other curve must be defined before this one (E0601). A wrong option or a wrong number of end values is E0606.
A curd holds one group, lp3 or csp3. A second group on the same command is E0608. The script tests/corpus/138-curd-second-group-rejected/input.tg:
curd 1 lp3 0 0 0 1 1 1; lp3 2 2 2 3 3 3;
curd 2 lp3 0 0 0 1 1 1;;
James prints the message in tests/corpus/138-curd-second-group-rejected/expected.diag.txt:
input.tg:1:25: error [E0608]: curd carries more than one type group; this version of James accepts one
james: 1 error, 0 warnings
Extra semicolons after a point list are ignored, and a transformation word on the same line as the last ; belongs to the curd. The script tests/corpus/153-curd-stray-semicolon-trans/input.tg:
curd 1 lp3 0 0 0 1 1 1 2 2 2;;
curd 2 lp3 0 0 0 1 1 1 2 2 2; ; mx 1;
curd 3 lp3 0 0 0 1 1 1;
; mx 1;
block 1 2;1 2;1 2;0 1;0 1;0 1;
endpart
The three curves are polylines. Curve 1 ends in two semicolons. Curve 2 has a stray ;, then mx 1 on the same line, which the IR holds as a transformation row. Curve 3 has two points, and its mx 1 is on the next line after a ;. The IR holds three curves and two transformation rows, and the part is unaffected.
What James refuses
- A surface kind that James knows of and does not build, such as
tsorxcy, is E1004. A word that is no surface kind at all, such astorus, is E0104. - A 2D segment that James knows of and does not build is E1009. A word that is no segment is E0104 in place of the first segment, and E0105 after a complete one, because it ends the
ld. - A 3D curve type that James knows of and does not build is E0603. A word that is no curve type is E0104.
The compatibility chapter says which milestone adds more kinds.