/****************************************************************************** Copyright (c) 1999 Unigraphics Solutions, Inc. Unpublished - All Rights Reserved *******************************************************************************/ #include #include #include #include #include #define VRML_FILENAME "vrml_test.wrl" /*-------------------------------------------------------------*/ static int vrml_example ( void ); static int create_part ( logical populate_ug_file ); /*-------------------------------------------------------------*/ extern void ufusr( char *param, int *retcod, int param_len ) { UF_initialize(); *retcod = vrml_example(); UF_terminate(); } /*-------------------------------------------------------------*/ static int vrml_example( void ) { UF_STD_vrml_params_t params; char error_msg[133]; tag_p_t topologies; int errors; int warnings; int n_topologies; int ifail; int indx; ifail = create_part ( TRUE ); if (ifail == 0) { ifail = create_part ( FALSE ); if (ifail == 0) { ifail = UF_STD_set_default_vrml_params ( ¶ms ); if (ifail == 0) { params.hide_smooth_edges = FALSE; params.unit_size = UF_STD_UNITS_MM; ifail = UF_STD_import_vrml_file( VRML_FILENAME, ¶ms, &errors, &warnings, &n_topologies, &topologies ); if ( n_topologies > 0 ) { printf("Topology tags:\n"); for (indx = 0; indx < n_topologies; indx++) printf("%u ",topologies[indx]); printf("\n"); } UF_free ( topologies ); } } } if ( ifail != 0 ) { UF_get_fail_message( ifail, error_msg ); printf( "ERROR: %s\n", error_msg ); } return 0; } /*-------------------------------------------------------------*/ /* Create a UG part file. If populate_ug_file is set TRUE, the file is populated with a cylinder and two spheres. As well, a VRML file (VRML_FILENAME) is generated from the part file. */ static int create_part ( logical populate_ug_file) { double origin[3] = { 0.0, -1.0, 0.0 }; double direction[3] = { 0.0, 1.0, 0.0 }; tag_t part; tag_t primitive_obj_id; int units = 2; int ifail; if (populate_ug_file == TRUE) ifail = UF_PART_new("ug_generated_file", units, &part); else ifail = UF_PART_new("vrml_imported_file", units, &part); if (ifail == 0 && populate_ug_file == TRUE) { ifail = UF_MODL_create_cyl1( UF_NULLSIGN, origin, "2.0", "1.0", direction, &primitive_obj_id ); if (ifail == 0) { origin[1] = origin[1] - 0.25; ifail = UF_MODL_create_sphere1( UF_NULLSIGN, origin, "1.5", &primitive_obj_id ); if (ifail == 0) { origin[1] = origin[1] + 2.5; ifail = UF_MODL_create_sphere1 ( UF_NULLSIGN, origin, "1.5", &primitive_obj_id ); if (ifail == 0) ifail = UF_STD_create_vrml_file ( VRML_FILENAME, 1.0, UF_STD_OUTPUT_MATERIALS ); } } } return ifail; }