/****************************************************************************** Copyright (c) 1999 Unigraphics Solutions, Inc. Unpublished - All Rights Reserved *******************************************************************************/ /* The code creates a cone, deteermins the parameters (u,v) of a point on the conical face, and then evaluates the face at (u,v) for the position and the normal. */ #include #include #include #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); } void ufusr( char *param, int *retcod, int param_len ) { UF_MODL_SRF_VALUE_t eval_surf; char *cone_diams[] = {"5.", "2."}; char *part_name = "face"; char cone_height[] = "5."; double axis[] = {0., 0., 1.}; double box[6]; double center[3]; double cone_origin[] = {15., 2.5, 0.}; double dir[3]; double face_pnt[3]; double min_max_box[4]; double parm[2]; double point[3]; double rad; double rad_data; double radius; int deriv_request; int count; int i; int norm_dir; int rc; int sen; int type; tag_t body; tag_t cone_feat_id; tag_t face; tag_t face_id; tag_t part; uf_list_p_t face_list; UF_initialize(); UF_PART_new(part_name, UF_PART_ENGLISH, &part); /* build a cone and get the id of the conical face */ UF_CALL(UF_MODL_create_cone1(UF_NULLSIGN, cone_origin, cone_height, cone_diams, axis, &cone_feat_id)); UF_CALL(UF_MODL_create_list(&face_list)); UF_CALL(UF_MODL_ask_feat_body(cone_feat_id, &body)); UF_CALL(UF_MODL_ask_body_faces(body,&face_list)); UF_CALL(UF_MODL_ask_list_count(face_list, &count)); for(i = 0; i < count; i++) { UF_CALL(UF_MODL_ask_list_item(face_list, i, &face)); UF_CALL(UF_MODL_ask_face_data(face, &type, center, dir, box, &radius, &rad_data, &norm_dir)); if(type == UF_cone_type) { face_id = face; } } UF_CALL(UF_MODL_delete_list(&face_list)); UF_CALL(UF_MODL_ask_face_data(face_id,&type,point,dir, box,&radius,&rad,&sen)); /* return the position and parameters of the face for the given reference point. The location of the point on the face is immaterial for this example. When we evaluate the face at the resulting parm, we should get the face point back */ UF_CALL(UF_MODL_ask_face_parm(face_id,point,parm,face_pnt)); printf("face_pnt = %f %f %f\n", face_pnt[0], face_pnt[1], face_pnt[2]); /* evaluate the position and the unitized normal at parm */ deriv_request = UF_MODL_EVAL_UNIT_NORMAL rc = UF_MODL_evaluate_face(face_id, deriv_request, parm, eval_result); if ( rc != 0 ) { printf("position = %f %f %f\n",eval_surf.srf_pos[0], eval_surf.srf_pos[1], eval_surf.srf_pos[2]); printf("unitized normal = %f %f %f\n",eval_surf.unormal[0], eval_surf.unormal[1], eval_surf.unormal[2]); } UF_terminate(); }