/****************************************************************************** Copyright (c) 1999 Unigraphics Solutions, Inc. Unpublished - All Rights Reserved *******************************************************************************/ /* The UF_SUBDIV_ISOCLINE type inputs a body, any faces which should be excluded, a smart object vector, and the string value of the angle expression; and splits faces along the isocline curves. Afterwards, all faces that were applied can be classified as steep or flat relative to the specified direction and angle. This example program creates a simple sphere and uses it to create and edit subdiv isocline feature. */ #include #include #include #include #include #include #include #include /* ARGSUSED */ extern void ufusr (char *param, int *retcod, int param_len) { double sphere_origin[3]={0,1,0}; char *sphere_length = "2"; char *angle_str = "20.0"; /* Expression string */ char message[133]; char *part_name="sample"; char *feat_type; char *subdiv_feat_type = "SUBDIVIDE_ISOCLINE"; int units=2, err; int scope=0, close_mode=1; tag_t part_tag, sphere_tag, subdiv_tag; UF_SUBDIV_type_t subdiv_type; UF_SUBDIV_data_structures_u subdiv_structure; UF_SUBDIV_data_structures_u ask_subdiv_struct; UF_SUBDIV_isocline_t isocline_data; UF_SUBDIV_isocline_p_t isocline_data_ptr; /* Initialize UG/Open API and open a new part */ UF_initialize (); UF_PART_new (part_name, units, &part_tag); /* Create a sphere */ UF_MODL_create_sphere1 (UF_NULLSIGN, sphere_origin, sphere_length, &sphere_tag); /* Set up the structures to define a subdiv feature with a method type of isocline. */ memset ((void *)&isocline_data, (int)0, (size_t)1*sizeof(UF_SUBDIV_isocline_t)); isocline_data.body_tag = sphere_tag; isocline_data.excluded_faces = NULL; isocline_data.face_count = 0; isocline_data.direction = NULL_TAG; /* 0,0,1 WCS */ isocline_data.angle_str = angle_str; subdiv_structure.subdiv_type1 = &isocline_data; /* Create an isocline subdiv feature */ err = UF_SUBDIV_create (UF_SUBDIV_ISOCLINE, &subdiv_structure, &subdiv_tag); if (err) { UF_get_fail_message (err, message); UF_UI_write_listing_window ("Error in UF_SUBDIV_create:"); UF_UI_write_listing_window (message); } /* Edit the subdiv isocline like we did not already have the defining data */ UF_MODL_ask_feat_type (subdiv_tag, &feat_type); if (strcmp (feat_type, subdiv_feat_type) == 0) { /* Find the type of subdiv */ err = UF_SUBDIV_ask_type (subdiv_tag, &subdiv_type); if (err) { UF_get_fail_message (err, message); UF_UI_write_listing_window ("Error in UF_SUBDIV_ask_type:"); UF_UI_write_listing_window (message); } /* Or, get the subdiv type and parms together */ err = UF_SUBDIV_ask_parms (subdiv_tag, &subdiv_type, &ask_subdiv_struct); if (err) { UF_get_fail_message (err, message); UF_UI_write_listing_window ("Error in UF_SUBDIV_ask_parms:"); UF_UI_write_listing_window (message); } switch (subdiv_type) { case UF_SUBDIV_ISOCLINE: { char *new_angle_str = "30.0"; isocline_data_ptr = ask_subdiv_struct.subdiv_type1; isocline_data_ptr->angle_str = new_angle_str; break; } default: break; } /* Edit the feature to the new definition */ err = UF_SUBDIV_edit (subdiv_type, &ask_subdiv_struct, subdiv_tag); if (err) { UF_get_fail_message (err, message); UF_UI_write_listing_window ("Error in UF_SUBDIV_edit:"); UF_UI_write_listing_window (message); } /* Cleanup */ err = UF_SUBDIV_free (subdiv_type, &ask_subdiv_struct); if (err) { UF_get_fail_message (err, message); UF_UI_write_listing_window ("Error in UF_SUBDIV_free:"); UF_UI_write_listing_window (message); } } /* Save and close the part. */ UF_PART_save (); UF_PART_close (part_tag, scope, close_mode); UF_terminate (); }