最近做了一个设置CAM程序边界的小工具,分享一下经验(官方的代码在文章末尾处),以下均以修剪边界曲线为例。


以下为官方提供的源码:
/***************************** Include Files **********************************/
#include <stdlib.h>
#include <uf.h>
#include <uf_obj.h>
#include <uf_object_types.h>
#include <uf_part.h>
#include <uf_ui.h>
#include <uf_ui_ont.h>
#include <uf_cambnd.h>
#include <uf_cam.h>
#include <uf_object_types.h>
#include <uf_disp.h>
#define MAX_BND 20
/*******************************************************************/
static UF_CAMBND_boundary_data_p_t create_and_init_bnd_data
(
UF_CAM_boundary_type_t type,
int plane_type,
double *origin,
double *matrix,
UF_CAM_material_side_t material_side,
int ignore_holes,
int ignore_islands,
int ignore_chamfers,
UF_CAMBND_app_data_p_t app_data
);
static UF_CAMBND_app_data_p_t create_and_init_bnd_app_data(void);
static int init_proc1(UF_UI_selection_p_t select, void *user_data);
static int init_proc2(UF_UI_selection_p_t select, void *user_data);
/*******************************************************************/
static void do_cambnd_api(void)
{
UF_CAMBND_boundary_data_p_t bnd_data, bnd_data_list[MAX_BND];
UF_CAMBND_app_data_p_t app_data_list[MAX_BND];
tag_t part_tag, *objects, entity_list[MAX_BND];
int i, j, object_count, part_count, part_item_count;
int type, subtype;
UF_CAMBND_boundary_t *part_bnd_list;
UF_CAMBND_item_t *part_item_list;
/* Get the displayed part. */
part_tag = UF_PART_ask_display_part( );
if( part_tag != null_tag )
{
/* Get the highlighted/selected objects from Navigation Tool. */
UF_UI_ONT_ask_selected_nodes( &object_count, &objects );
if (object_count > 0)
{
tag_t eid, view;
double cursor[3], origin[3], matrix[9];
int entity_count, response;
char cue_face[] = "Select faces";
char cue_edge[] = "Select edges";
char title[] = "Boundary Selection";
entity_count = 0;
/* Allow the user to select faces. */
while (TRUE)
{
UF_UI_select_with_single_dialog(cue_face, title,
UF_UI_SEL_SCOPE_NO_CHANGE, init_proc1, NULL,
&response, &eid, cursor, &view);
if (response == UF_UI_OBJECT_SELECTED)
{
entity_list[entity_count] = eid;
/* Allocate the memory for the boundary data of an item without app data. */
364



被折叠的 条评论
为什么被折叠?



