/******************************************************************************
             Copyright (c) 1999 Unigraphics Solutions, Inc.
                       Unpublished - All Rights Reserved

*******************************************************************************/
/* You must open a blank part before you execute this example code.*/
#include <stdio.h>
#include <uf_curve.h>
#include <uf.h>
#define  NUMBER_POINTS  5
#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
static int report( char *file, int line, char *call, int irc)
{
    if (irc)
    {
        char    messg[133];
        printf("%s, line %d:  %s\n", file, line, call);
        (UF_get_fail_message(irc, messg)) ?
            printf("    returned a %d\n", irc) :
            printf("    returned error %d:  %s\n", irc, messg);
    }
    return(irc);
}
static void do_ugopen_api(void)
{
  /* B-spline parameters  */
  int degree = 3;
  int periodicity = 0;
  int num_points = NUMBER_POINTS;
  /* Point/slope curve attribute array */
  UF_CURVE_pt_slope_crvatr_t point_data[NUMBER_POINTS];
  /* Arrays of user's defining point data */
  double parameters[NUMBER_POINTS] = {0.00,  0.17,  0.32,  0.45,
1.29};
  double points[3*NUMBER_POINTS] = {1.1000,  0.5320,  2.0000,
                                    1.5240,  0.6789,  2.3000,
                                    2.0000,  0.9000,  3.5956,
                                    2.3456,  1.3456,  3.7890,
                                    3.1000,  2.4567,  3.3214};
  int slopeTypes[NUMBER_POINTS] = {UF_CURVE_SLOPE_DIR,
                                   UF_CURVE_SLOPE_AUTO,
                                   UF_CURVE_SLOPE_NONE,
                                   UF_CURVE_SLOPE_DIR,
                                   UF_CURVE_SLOPE_VEC};
  double slopeVecs[3*NUMBER_POINTS] = {1.2300,  5.0506,  4.0360,
                                       0.0000,  0.0000,  0.0000,
                                       0.0000,  0.0000,  0.0000,
                                       0.5000,  1.0000,  0.5000,
                                       1.0000, -2.0000,  1.0000};
  int crvatrTypes[NUMBER_POINTS] = {UF_CURVE_CRVATR_NONE,
                                    UF_CURVE_CRVATR_AUTO_DIR,
                                    UF_CURVE_CRVATR_NONE,
                                    UF_CURVE_CRVATR_VEC,
                                    UF_CURVE_CRVATR_VEC};
  double crvatrVecs[3*NUMBER_POINTS] = {0.0000,  0.0000,  0.0000,
                                     1.0000,  2.5780,  5.6700,
                                     0.0000,  0.0000,  0.0000,
                                     1.0000,  -1.0000,  1.0000,
                                    -1.0000,  -1.0000,  -1.0000};
  int i, save_def_data = 1;
  tag_t spline_tag;
  for (i= 0;   i<NUMBER_POINTS;   i++)
  {
    point_data[i].point[0] = points[3*i];
    point_data[i].point[1] = points[3*i+1];
    point_data[i].point[2] = points[3*i+2];
    point_data[i].slope_type = slopeTypes[i];
    point_data[i].slope[0] = slopeVecs[3*i];
    point_data[i].slope[1] = slopeVecs[3*i+1];
    point_data[i].slope[2] = slopeVecs[3*i+2];
    point_data[i].crvatr_type = crvatrTypes[i];
    point_data[i].crvatr[0] = crvatrVecs[3*i];
    point_data[i].crvatr[1] = crvatrVecs[3*i+1];
    point_data[i].crvatr[2] = crvatrVecs[3*i+2];
  }
  /* Create B-spline curve */
  UF_CALL(UF_CURVE_create_spline_thru_pts(degree,
                                          periodicity,
                                          num_points,
                                          point_data,
                                          parameters,
                                          save_def_data,
                                          &spline_tag));
}
/*ARGSUSED*/
void ufusr(char *param, int *retcode, int paramLen)
{
    if (!UF_CALL(UF_initialize()))
    {
        do_ugopen_api();
        UF_CALL(UF_terminate());
    }
}
int ufusr_ask_unload(void)
{
    return (UF_UNLOAD_IMMEDIATELY);
}

Return:
         Return code:
    return (UF_UNLOAD_IMMEDIATELY);
}


