/*===========================================================================

        Copyright (c) 1998,1999,2000  Unigraphics Solutions Corporation
                     Unpublished - All rights reserved

===========================================================================*/
/***************************************************************************/
/*
 *  Description
 *    This function is a small sample program that demonstrates
 *    the invocation of UF_MODL_create_boss, UF_MODL_create_rect_pad,
 *    and UF_MODL_create_rect_pocket.  It is placed
 *    directly in our UFUN documentation starting with the
 *    include statements.
 *
 *
 ****************************************************************************/


#include <stdio.h>
#include <uf.h>
#include <uf_defs.h>
#include <uf_modl.h>
#include <uf_modl_primitives.h>
#include <uf_part.h>

/* ARGSUSED */
void ufusr(char *param, int *retcod, int param_len)
{
    int          ifail=0;
    int          units=1; /*1=metric, 2=english*/
    char         error_message[MAX_LINE_SIZE + 1];
    char *       prtnam = "cre_fea_by_dtm_tst";
    char *       blk_edg_len[3] = {"50", "60", "70"};
    char *       pad_size[3]={"5","6","5.5"};
    char *       pock_len[3]={"6.2","6.3","6.4"};
    char *       boss_diam="5";
    char *       boss_height="6";
    char *       boss_ang="10";
    char *       pad_corner="1";
    char *       pad_ang="10";
    char *       pock_corner="3";
    char *       pock_floor=".1";
    char *       pock_ang="5";
    tag_t        blk_tag;
    tag_t        targ_tag=NULL_TAG;
    tag_t        plane_tag;
    tag_t        boss_tag;
    tag_t        pad_tag;
    tag_t        pock_tag;
    tag_t        part_tag;
    double       blk_corner[3] = {0,0,0};
    double       planepnt[3]={0,0,0};
    double       planedir[3]={1,0,0};
    double       boss_loc[3]={0,45,65};
    double       boss_dir[3]={-1,0,0};
    double       pad_loc[3]={0,45,15};
    double       pad_dir[3]={-1,0,0};
    double       pad_x_dir[3]={0,0,-1};
    double       pock_loc[3]={0,45,35};
    double       pock_dir[3]={1,0,0};
    double       pock_x_dir[3]={0,0,-1};

    ifail = UF_initialize();

    if( !ifail )
    {
        /* Create new part. */
        ifail = UF_PART_new( prtnam, units, &part_tag );
    }

    if( !ifail )
    {
        /* Create block. */
        ifail = UF_MODL_create_block( UF_NULLSIGN, targ_tag,
                                      blk_corner, blk_edg_len,
                                      &blk_tag );
    }

    if( !ifail )
    {
        /* Create fixed datum plane. */
        ifail = UF_MODL_create_fixed_dplane( planepnt, planedir,
                                             &plane_tag );
    }

    if( !ifail )
    {
        /* Create Boss */
        ifail = UF_MODL_create_boss( boss_loc, boss_dir, boss_diam,
                                     boss_height, boss_ang, plane_tag,
                                     &boss_tag );
    }

    if( !ifail )
    {
        /* Create Pad */
        ifail = UF_MODL_create_rect_pad( pad_loc, pad_dir, pad_x_dir,
                                         pad_size, pad_corner, pad_ang,
                                         plane_tag, &pad_tag);
    }

    if( !ifail )
    {
        /* Create Pocket */
        ifail = UF_MODL_create_rect_pocket( pock_loc, pock_dir,
                                            pock_x_dir,pock_len,
                                            pock_corner, pock_floor,
                                            pock_ang, plane_tag, &pock_tag);
    }

    printf( "UF_MODL_cre_fea_by_dtm sample " );
    if( ifail )
    {
        ifail = UF_get_fail_message( ifail, error_message );
        printf( "fails.\nError is: %s\n", error_message );
    }
    else
        printf( "is successful.\n" );

    ifail = UF_terminate();

}

