******************************************************************************
Copyright (c) 1999 - 2001 Unigraphics Solutions, Inc.
Unpublished - All Rights Reserved
*******************************************************************************/
/*
This example requires an open part. The code creates a unit block
and a 4-sided polygon which is extruded and unioned to the bottom
of the block.
*/
#include <stdlib.h>
#include <stdio.h>
#include <uf_curve.h>
#include <math.h>
#include <uf_modl.h>
#include <uf.h>
#define EPSILON (double)1.0e-7
#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)
{
int obj_cnt;
char *offsets[2] = {"0.0", "0.0"};
UF_FEATURE_SIGN mode_sign = UF_NULLSIGN;
int i, num;
uf_list_p_t face_list;
double corner_pt[3] = { 0.0, 0.0, 2.0 };
char *edges_len[3] = { "1", "1", "1" };
char *limits[2]={ "0", "1" };
char *taper_angle="0.0";
tag_t blk_eid, face;
tag_t line1, line2, line3, line4;
tag_t line5, line6, line7, line8;
tag_t *objects;
tag_t generators[12];
double pt1[3],face_dir[3],dir[3];
UF_CURVE_line_t sline1, sline2, sline3, sline4;
UF_CURVE_line_t sline5, sline6, sline7, sline8;
uf_list_p_t objects_list;
uf_list_p_t features_list;
int count;
pt1[0]=0.5;
pt1[1]=0.5;
pt1[2]=0.0;
/* line#1 */
sline1.start_point[0] = 0.0;
sline1.start_point[1] = 0.0;
sline1.start_point[2] = 0.0;
sline1.end_point[0] = 0.0;
sline1.end_point[1] = 1.0;
sline1.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&sline1,&line1));
/* line#2 */
sline2.start_point[0] = 0.0;
sline2.start_point[1] = 1.0;
sline2.start_point[2] = 0.0;
sline2.end_point[0] = 2.5;
sline2.end_point[1] = 3.5;
sline2.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&sline2,&line2));
/* line#3 */
sline3.start_point[0] = 2.5;
sline3.start_point[1] = 3.5;
sline3.start_point[2] = 0.0;
sline3.end_point[0] = 1.0;
sline3.end_point[1] = 0.0;
sline3.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&sline3,&line3));
/* line#4 */
sline4.start_point[0] = 1.0;
sline4.start_point[1] = 0.0;
sline4.start_point[2] = 0.0;
sline4.end_point[0] = 0.0;
sline4.end_point[1] = 0.0;
sline4.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&sline4,&line4));
/* line#5 */
sline5.start_point[0] = 3;
sline5.start_point[1] = 3;
sline5.start_point[2] = 0.0;
sline5.end_point[0] = 3;
sline5.end_point[1] = 6;
sline5.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&sline5,&line5));
/* line#6 */
sline6.start_point[0] = 3;
sline6.start_point[1] = 6;
sline6.start_point[2] = 0.0;
sline6.end_point[0] = 5;
sline6.end_point[1] = 6;
sline6.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&sline6,&line6));
/* line#7 */
sline7.start_point[0] = 5;
sline7.start_point[1] = 6;
sline7.start_point[2] = 0.0;
sline7.end_point[0] = 4;
sline7.end_point[1] = 3;
sline7.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&sline7,&line7));
/* line#8 */
sline8.start_point[0] = 4;
sline8.start_point[1] = 3;
sline8.start_point[2] = 0.0;
sline8.end_point[0] = 3;
sline8.end_point[1] = 3;
sline8.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&sline8,&line8));
/* line 4 */
generators[0] = line1;
generators[1] = line2;
generators[2] = line3;
generators[3] = line4;
generators[4] = line5;
generators[5] = line6;
generators[6] = line7;
generators[7] = line8;
dir[0]=0.0; dir[1]=0.0; dir[2]=1.0;
UF_MODL_create_list(&objects_list);
count=8;
for(i = 0; i < count; i++) {
UF_MODL_put_list_item(objects_list, generators);
}
UF_MODL_create_extruded(objects_list,taper_angle,limits,offsets,dir,mode_sign,&features_list);
/*
UF_MODL_create_extrusion(&generators[0], 8, NULL,
taper_angle,limits,offsets,
pt1, false,true, dir,
mode_sign,&objects,&obj_cnt);
UF_free(objects);
*/
}
/*ARGSUSED*/
void ufusr(char *param, int *retcode, int param_len)
{
if (!UF_CALL(UF_initialize()))
{
do_ugopen_api();
UF_CALL(UF_terminate());
}
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
} |