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

*******************************************************************************/
/*

The following example requires an open, blank part. The code
creates a block and hollows it. The code then changes the pierce face
for the hollow.

*/

#include <stdio.h>
#include <uf_modl.h>
#include <uf.h>
#include <uf_curve.h>
#include <uf_csys.h>
#include <uf_defs.h>
#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)
{
  tag_t block_tag, hollow_feature;
  tag_t pierce_face, new_pierce_face;
  double origin[3]={0.0,0.0,0.0};
  char *edge_lens[3]={"300.0","25.0","150.0"};
  char *thickness="0.1";
  uf_list_p_t uflist;
  /* Create a block. */
  UF_CALL(UF_MODL_create_block1(UF_NULLSIGN,
                                origin,
                                edge_lens,
                                &block_tag));
  UF_CALL(UF_MODL_ask_feat_faces(block_tag,
                                 &uflist));
  UF_CALL(UF_MODL_ask_list_item(uflist,
                                0,
                                &pierce_face));
  UF_CALL(UF_MODL_ask_list_item(uflist,
                                2,
                                &new_pierce_face));
  UF_MODL_delete_list(&uflist);
  UF_MODL_create_list(&uflist);
  UF_MODL_put_list_item(uflist,
                        pierce_face);

  /* Hollow the block */
  UF_CALL(UF_MODL_create_hollow(thickness,
                                uflist,
                                &hollow_feature));
  UF_MODL_delete_list(&uflist);
  /* Change the pierce face of the hollow. */
  if(UF_CALL(UF_MODL_redefine_replace_faces(hollow_feature,
                                            1,
                                            &new_pierce_face)))
  {
     /* error check */
  }
  /* Trigger update */
  if(UF_CALL(UF_MODL_update()))
  {
     /* error check */
  }
}
/*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);
}

