// file: $USFS/class/polygon/v1.0/polygon_load_0.cc
//

// isip include files
//
#include "polygon.h"
#include "polygon_constants.h"

// method: load_cc
//
// arguments:
//  int_4 coordinate: (input) coordinate data for a vertex of the polygon
//
// return:
//  a logical_1 value indicating the status
//
// this method loads vertex coordinate data one at a time
//
logical_1 Polygon::load_cc(int_4 coordinate_a) {

  // check the end of the polygon
  //
  if (coordinate_a == POLYGON_END_POLYGON) {

    // compute the actual number of vertices
    //
    num_vertices_d = num_vertices_d / 2;
  }
  else {

    // declare memory for a temporary buffer
    //
    int_4* tmp_buf = new int_4[num_vertices_d + 1];

    for (int_4 i = 0; i< num_vertices_d; i++) {
      tmp_buf[i] = vertices_d[i];
    }
    tmp_buf[num_vertices_d] = coordinate_a;
    num_vertices_d++;

    // update the array of vertices coordinates
    //
    if (vertices_d != (int_4*)NULL) {
      delete [] vertices_d;
    }
    vertices_d = tmp_buf;    
  }
			   
  // exit gracefully
  //
  return ISIP_TRUE;
}
