Listing 1. pfb Conversion Code Snippets

Load Ice Keel Node and Store as pfb file

/**  read input file(s)           **/

      i = 0;
        group = pfNewGroup();
        for (i = 0; i < num_files - 1; i++)
        {

         printf("Make keel: %s\n",files[i]);
         bot_switch = (pfSwitch*)
                  LoadKeel(files[i],limits,i);
          pfAddChild(group, bot_switch);
          printf("adding switch to group\n");
        }
        node = (pfNode *)group;


    /**  optimize input file (optional)     **/
    node = optimize(node);

    /*
     *  write output file
     */
    pfdStoreFile(node, files[num_files - 1]);

    /*
     *  indicate success
     */
    return 0;
}

Convert Ice Keel to Performer Node

/***** LOAD AND CREATE A 3D SURFACE **********/
pfSwitch *LoadKeel( const char *file_name,
                    float *limits, long numfile  )
{
/* Declare Local Variables */
   pfSwitch *root;
   pfGroup *depth_group;
   pfGroup *mag_group;
   pfLOD *lod_ptr;
   pfDCS *dcs12;
   pfGeode *ice_geode;
   pfCoord    coord;
   long lod_cols;
   long lod_rows;
   pfMaterial *material;
   long i;
   long j;
   long status;

  /* Create work space to create surface */
     arena = pfGetSharedArena();

  /* Load vertices, normals and colors */
     status = load_data(file_name);
        if( status != OK )
         {
           exit (1);
         }

  /* Create the KEEL geode */
  ice_geode = MakeKeel();

  /* Create a group to hold all Depth and
   * Magnitude Features of Surface
   */
  depth_group = pfNewGroup();
  root = pfNewSwitch();

  /* Add ice geode to group */
   magflag = 0;
   pfAddChild( depth_group, ice_geode );
   dcs12 = pfNewDCS();
   coord.xyz[PF_X] = 0.0f;
   coord.xyz[PF_Y] = 0.0f;
   coord.xyz[PF_Z] = 0.0f;
   pfAddChild( dcs12,depth_group );
   pfAddChild( dcs12,mag_group );
   pfDCSScaleXYZ( dcs12, 1.0f,1.0f,1.0f);
   pfAddChild( root,dcs12 );
   pfDelete(dcs12);

   /* Return 3D Surface Switch */
   limits[0] = -1;
   limits[1] = 1;
   limits[2] = -1;
   limits[3] = 1;
   limits[4] = 0;
   limits[5] = 0;
   limits[6] = 0;
   limits[7] = 1;
   limits[8] = 1;
   limits[9] = 1;

   return(root);
}