------------------------------
    SurfLab, Univ. Of Florida
          BezierViewer 
          Data Format

Updated Feb. 13th 2003
by Xiaobin Wu
------------------------------

1. Data format:
   The data file contains segments, each segment represents one patch.

   At the the beginning of each segment, there is a number 
   indicating the patch type, then a block of patch data should follow.

   * Patch type:
     1:    polyhedron
     3:    triangular patch
     4:    tensor-product patch with same degree in both directions.
     5:    general tensor-product patch
     8:    rational Bezier tensor-product
     9:    PN triangle patches
    10:    PN quads patches

   * Patch Data:
     -- For polyhedron, the patch data should contain:
        Vnum Fnum
        v0x v0y v0z
        v1x v1y v1z
        ..
        v(n-1)x v(n-1)y v(n-1)z
        3 f1v1 f1v2 f1v3   (OR: 4 f1v1 f1v2 f1v3 f1v4)
        ...
        3 fmv1 fmv2 fmv3    ( vertices are indices from [0, n-1], not [1,n])

      
     -- For tensor product patches,  it should contain:
        degu degv (or type 3 and 4, only degu)

        Then the x y z value of the control points.
        The control points are sorted using row-major order of following matrix
           with size ( rows= degu+1) x (columns= degv+1) :

           p11       p12    .... p1(degv+1)
           p21       p22    .... p2(degv+1)
            ..       ..     ....    ..
        p(degu+1)1 p(degu+1)1 .. p(degu+1)(degv+1)

       i.e. p11 p12 ... p1(degv+1) p21 ... p2(degv+1) .... 
	        p(degu+1)1 ... p(degu+1)(degv+1)
    
     -- For  triangle Bezier patches, it should contain:
         deg
         then the the x y z value of the (deg+2)*(deg+1)/2 control points.
         the order of a cubic patch is , for instance, the following:
                 9
                7 8
               4 5 6
              0 1 2 3

         the patch data then is 
             p0 p1 p2p p3 ... p9

     -- For PN triangle patches, it should contain:
         deg Ndeg
         then the control points
         then the normals arranged at the same order as the control points.
 
     -- For PN quads, it should contain:
         degu degv Ndegu Ndegv
         then the control points
         then the normals arranged at the same order


2. Example files(in data/) :

   -- simple data  
     tensor product patches: 
          hex.bv hex2.bv tp2x1.bv tp3x3.bv
     triangular patches: 
          tri1.bv tri2.bv 
     rational patches: 
          rat1.bv tor.bv sphear.bv
   -- utal teapot
     teapot.bv teapot2.bv tpt_grp.bv
   -- polyhedra data
     cube.bv closedcone.bv hand.bv tetra.bv
   -- mixed data
     tp_poly.bv
   -- group data
     tpt_grp.bv tridat.cube
   -- g2 patchs
     plm.icosa.260  plm.tw.700  plm.oct.100 cubeg2 twg2.bv cubeg2.bv
   
