patch

patch attaches the four edges of one face to the four sides of a surface and projects the face onto the surface.

Syntax

patch imin jmin kmin imax jmax kmax surface

The first six numbers are a region, as for lin. The region must be one face. surface is the number of a surface that sd defines.

What it does

patch works for a surface with four sides: rule2d, rule3d, crule3d, swept, blend4, and r3dc when its turn is under 360 degrees. The geometry chapter numbers the sides. A face has four corner vertices and four edges, and the surface has four corners, where its sides meet. James tries the eight ways to lay the face’s corners on the surface’s corners (the four rotations of the loop of corners, each way round) and keeps the one that moves the four corner vertices the least, measured as the sum of the four distances from the vertices, as step 1 left them or as an earlier command of step 2 moved them, to the surface’s corners. A tie goes to the first of the eight, which are tried in the order of the four rotations one way round and then the four the other way.

James then puts the four corner vertices on the surface’s corners and attaches each edge of the face to the side that joins its two corners, as edge attaches one. The face is projected onto the surface as sf projects a face. A node of the face counts the surface as one of the surfaces it is held to, so a fourth surface on one node is E0803 as for sf. Because the mapping depends on where the corners stand, put the face’s corners near the corners of the surface that you want them at; a block whose corners lie far from the surface can map the wrong way.

A face that has deleted elements is accepted.

When James applies it

The IR stores patch for steps 2 and 9: the edges are attached at step 2, with the other edge commands, and the face is projected at step 9. The face’s vertices are projected at step 3, and the nodes of its edges are held to the surface at step 6, through the edges’ stretches of the sides, exactly as for sf on a face. patch is legal only in the Part phase. James refuses it in the Control and Merge phases (E0412).

Rules James adds

  • A region that is not a face is an error (E0802). The message names what the region is: a vertex, an edge or a block.
  • A surface number that nothing defines is an error (E0800).
  • A surface that does not have four sides is an error that the engine reports when it reaches the step, with exit status 2: patch names surface #0, a plane, which has no four sides in this version of James. A plane, a cylinder, a sphere, a revolved curve, a pipe, a blend3 and the other kinds with fewer than four sides are refused so. The count starts at 0 in the order of definition, so the first sd is surface #0 whatever number it carries.
  • A side of no length, such as a ruling between two curve ends that meet, is refused as edge refuses it, with a line that names patch. A sector of a spherical cap built as an r3dc whose generatrix starts on the axis is the usual case: its side at that end is a single point, so patch stops with the single-point error and cannot attach it. Attach such a face’s edges with cur or cure on curves that curd makes with sdedge from the sides that have length, or leave it unpatched.

Diagnostics

  • E0802: the region is not a face.
  • E0800: the surface number is not defined.
  • E0803: a node would carry more than three surfaces.
  • E0102: a reduced index lies outside the part.
  • E0106: a range of the region is written high to low.

Example

The script tests/golden/057-rule2d-patch/input.tg, which make test runs:

c A ruled surface between two 2D curves (rule2d): curve 1 in the plane y = 0
c and curve 2 in the plane y = 2, paired by relative arc length. The top face
c of a slab is attached to the surface's four sides and projected onto it by
c patch, so the face's corners sit at the curves' ends and its edges follow
c the two curves and the two rulings between them. The slab starts below
c the surface, whose ends touch z = 0.
ld 1 lp2 0 0 1 0.5 2 0;
ld 2 lp2 0 1 1 1.2 2 1;
sd 1 rule2d 0 1 2 2;
block 1 3 5;1 3 5;1 2;0 1 2 0 1 2 -1 0.8
patch 1 1 2 3 3 2 1
endpart
merge
neutral
write

The rule2d joins curve 1 in the plane y = 0 to curve 2 in the plane y = 2. The block’s top face is the face 1 1 2 3 3 2. James attaches its four edges to the surface’s four sides: the two curves and the two lines that join their ends. The face’s corners go to the curve ends, and the face lies on the surface. The case writes 50 nodes and 16 elements.

A region that is not a face is refused. The script tests/corpus/068-patch-not-face-rejected/input.tg, which make test runs:

sd 1 plan 0 0 0 0 0 1
block 1 2 3;1 2 3;1 2 3; 0 1 2; 0 1 2; 0 1 2;
patch 1 1 1 3 3 3 1
endpart

The region 1 1 1 3 3 3 spans every index, so it is a block. James prints this and exits with 1, as tests/corpus/068-patch-not-face-rejected/expected.diag.txt holds:

input.tg:3:7: error [E0802]: patch region must be a face, got block
james: 1 error, 0 warnings

See also

  • edge: attaches one edge to one side.
  • sf: projects a face onto a surface, without attaching its edges.
  • sd: defines the surfaces, and the geometry chapter says which have four sides.
  • Compatibility: the commands James refuses.

James 0.8.0.

This site uses Just the Docs, a documentation theme for Jekyll.