/*=================================================================== Copyright (c) 1999 Unigraphics Solutions Corporation Unpublished - All rights reserved ===================================================================*/ /****************************************************************************** * * * DESCRIPTION - * * This program shows how to use the following Open API routines: * * * * UF_DIE_create_binder_wrap * * UF_DIE_edit_binder_wrap * * UF_DIE_ask_binder_wrap_info * * UF_DIE_free_binder_wrap_info * * * * PROGRAM DESCRIPTION - * * The following example requires an open, blank part. The code creates * * some points and a curve to be used as input. The code then creates a * * binder wrap from the points, asks for the binder wrap info, edits the * * binder wrap to be created from the curve and frees the binder wrap info. * * * * * ******************************************************************************/ #include #include #include #include #include #include #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) { UF_CURVE_pt_slope_crvatr_t point_data[17] = { { {140.276438220360, 285.207637257640, 149.060723582790}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {153.562366505600, 286.376801601100, 150.268028814650}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {166.413406797560, 282.650382405990, 150.887608217450}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {177.087657938610, 274.558460135600, 150.955981983120}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {184.132764140080, 263.167268518690, 150.762115831200}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {186.588222068670, 250.000000000000, 150.646771558180}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {184.132764163140, 236.832731540940, 150.762115830250}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {177.087657981600, 225.441539911720, 150.955981982530}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {166.413406819130, 217.349617604860, 150.887608218010}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {153.562366503040, 213.623198398650, 150.268028814480}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {140.276438217890, 214.792362743060, 149.060723582510}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {128.400374459870, 220.783289876610, 147.525624156050}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {119.583705086100, 230.764715506440, 146.122926036250}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {114.933117669780, 243.300606572350, 145.295474083350}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {114.933117670230, 256.699393430170, 145.295474083440}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {119.583705087420, 269.235284495770, 146.122926036480}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} }, { {128.400374461910, 279.216710124970, 147.525624156340}, UF_CURVE_SLOPE_NONE, {0.0000, 0.0000, 0.0000}, UF_CURVE_CRVATR_NONE, {0.0000, 0.0000, 0.0000} } }; tag_t spline_tag, point_tags[17], binder_wrap; char thick[] = {"0.25"}; int degree = 3, i; int periodicity = 1; /* closed curve */ int num_points = 17, save_def_data = 1; double *parameters = NULL; UF_DIE_binder_wrap_t ask_binder_info, binder_info; /* Create B-spline curve */ UF_CALL(UF_CURVE_create_spline_thru_pts(degree, periodicity, num_points, point_data, parameters, save_def_data, &spline_tag)); /* Create points */ for (i=0; i<17; i++) UF_CURVE_create_point(point_data[i].point, &point_tags[i]); /* Create string for input */ UF_MODL_init_string_list(&binder_info.defined_by.string.defining_string); UF_MODL_create_string_list(1, 1, &binder_info.defined_by.string.defining_string); binder_info.defined_by.string.defining_string.num = 1; binder_info.defined_by.string.defining_string.string[0] = 1; binder_info.defined_by.string.defining_string.dir[0] = 1; binder_info.defined_by.string.defining_string.id[0] = spline_tag; /* Initialize binder wrap info */ binder_info.input_type = UF_DIEENG_BOUNDARY; binder_info.material_thickness = thick; UF_MODL_ask_distance_tolerance(&binder_info.distance_tol); UF_MODL_ask_angle_tolerance(&binder_info.angle_tol); binder_info.output_sw = UF_DIEENG_BINDER_WRAP_FEATURE; /* Create binder wrap feature */ UF_CALL(UF_DIE_create_binder_wrap(&binder_info, &binder_wrap)); /* Free the string list */ UF_MODL_free_string_list(&binder_info.defined_by.string.defining_string); /* Ask binder wrap feature info */ UF_CALL(UF_DIE_ask_binder_wrap(binder_wrap, &ask_binder_info)); /* Free the binder wrap feature info */ UF_CALL(UF_DIE_free_binder_wrap(&ask_binder_info)); /* Modify binder wrap feature info to create by points */ binder_info.input_type = UF_DIEENG_POINTS; binder_info.defined_by.points.num_defining_points = 17; binder_info.defined_by.points.defining_points = point_tags; /* Edit the binder wrap feature */ UF_CALL(UF_DIE_edit_binder_wrap(binder_wrap, &binder_info)); /* Trigger an update to update the feature */ UF_MODL_update(); } /*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); }