-------------------------------------------
 The SubjectTools -> Create Orig Surface menu
 item starts a two-part background process to
 create the left and right hemisphere cortical
 surfaces
-------------------------------------------
This "surf" program is run twice with two
different color targets on the same input 3D
volume (filled/ COR dir, or filled.mgz), which
can be either 256^3 or 512^3.

Each run connects the vertices of the faces of
the voxels of a specified color into a continuous
mesh.  If there are multiple disconnected volumes
of a single color, there will be multiple
disconnected output surfaces for one input color.

This program can be used to generate more than
two surfaces if the input volume has more than
two colors in it.

 input3D: $SUBJECTS_DIR/$name/mri/filled[.mgz]

 outsurf: $SUBJECTS_DIR/$name/surf/rh.orig
 outsurf: $SUBJECTS_DIR/$name/surf/lh.orig

The binary format of the orig output surfaces can
be quad short or quad float:

  Quad Surface File Format (short vtx coords):
    -------------- header ---------------------
      3-byte magic number (16777215)
      3-byte int vertex count (~150,000)
      3-byte int face count (~150,000)
    ---------- vertex positions ---------------
      [vertex triples are implicitly numbered]
      2-byte int vertex x-position (mm x 100)
      2-byte int vertex y-position (mm x 100)
      2-byte int vertex z-position (mm x 100)
      ... [x,y,z triples up to vertex count]
    ---- vertex numbers around each face ------
      [faces are implicitly numbered]
      [vtx nums here are implicit ones above]
      [num each face ordered CCW from outside]
      corner1 corner2 corner3 corner4
      ... [quadruples up to face count]
    -------------------------------------------

  New Quad Surface File Format (float vtx coord):
    -------------- header ---------------------
      3-byte magic number (16777213)
      3-byte int vertex count (~150,000)
      3-byte int face count (~150,000)
    ---------- vertex positions ---------------
      [vertex triples are implicitly numbered]
      4-byte float vertex x-position (mm)
      4-byte float vertex y-position (mm)
      4-byte float vertex z-position (mm)
      ... [x,y,z triples up to vertex count]
    ---- vertex numbers around each face ------
      [faces are implicitly numbered]
      [vtx nums here are implicit ones above]
      [num each face ordered CCW from outside]
      corner1 corner2 corner3 corner4
      ... [quadruples up to face count]
    -------------------------------------------

ASCII Export of Surface Geometry

The command line program "paint" with option
"-dump" can be used to export surface vertex,
face, and normal data to ASCII:

  paint -dump vtx   <name> <hemi> <surfsuff>
  paint -dump norm  <name> <hemi> <surfsuff>
  paint -dump neigh <name> <hemi> <surfsuff>
  paint -dump thick <name> <hemi> <surfsuff>
  paint -dump pvtx  <name> <hemi> <surfsuff> <patchsuff>
  paint -dump lnorm <name> <hemi> <surfsuff> <labelinf>

In each case, the output is an ASCII file (with
one initial comment line), and a single
tab-separated line of numbers for each uniquely
numbered surface vertex:

   vtx   => <hemi>.<surf>.vtx   => vtxnum  x  y  z
   norm  => <hemi>.<surf>.norm  => vtxnum nx ny nz
   neigh => <hemi>.<surf>.neigh => vtxnum n1 n2 n3 ..
   thick => <hemi>.<surf>.thick => vtxnum thickness
   pvtx  => <hemi>.<surf>.pvtx  => vtxnum  x  y  z
   lnorm => <hemi>.<labinfix>.lnorm => vtxnum nx ny nz

The first four options are for folded (or
inflated, sphere) surfaces.  The fifth is for a
patch (typically a flattened subset of a full
surface) and the last is for dumping the surface
normals of a label.

The surface normals are not saved in the surface
files and are only computed after the surface has
been read in.

N.B.: all ASCII output files are written into
the surf subdirectory of the current subject:

  $SUBJECTS_DIR/<name>/surf

