NX二开ufun函数UF_MODL_ask_body_boundaries(获取边界信息)

返回实体/片体的边界信息:边界数量、边Tag。

从实例返回的信息来看,可以返回曲面的边界,实体的边不算边界。

1、函数结构: 

int UF_MODL_ask_body_boundaries
(tag_t body_tag,
int * num_boundaries,
int * * num_edges,
tag_t * * edge_tags)

2、概述

返回工作表主体的边界边数,每个边界中的边数以及每个边界中边的标记 。

数组num_edges的大小由找到的边界数量确定 (例如,包括孔的边界)。数组中的每个元素都 包含相应边界中的边数。该阵列edge_tags的尺寸足够大,以包含的所有标签中的所有边界所有边。

 3、实例源码

#include <stdlib.h>
#include <stdio.h>
#include <uf.h>
#include <uf_disp.h>
#include <uf_modl.h>
#include <uf_ui.h>
#include <uf_object_types.h>
static void get_body_type(tag_t body);
#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)
{
  char buffer[UF_UI_MAX_STRING_LEN+1];
  double cursor[3];
  int err = 0, response =2;
  int num_bnd=0, *num_edges, i, count=0;
  UF_UI_selection_options_t opts;
  UF_UI_mask_t mask = {UF_solid_type,0,UF_UI_SEL_FEATURE_BODY};
  tag_t body, view, *edge_tags;
  opts.num_mask_triples = 1;
  opts.mask_triples = &mask;
  opts.scope = UF_UI_SEL_SCOPE_WORK_PART;

  UF_UI_open_listing_window();
  response = 4;
  do
  {
  err = UF_UI_select_single("Select a solid body", &opts,
                            &response, &body,
                            cursor, &view);
  if((response == 4) || (response == 5))
  {
    get_body_type(body);
  }
  if(!err && response !=1 && response !=2)
  {/* If there's no error and response is not CANCEL or BACK */

UF_CALL(UF_MODL_ask_body_boundaries(body,&num_bnd,&num_edges,&edge_tags));
    if(num_bnd != 0)
    {
      for(i = 0; i < num_bnd; i++)
      {
        sprintf(buffer, "num_edges[%d] = %d\n", i, num_edges[i]);
        UF_UI_write_listing_window(buffer);
        count += num_edges[i];
      }
      sprintf(buffer,"\nThe total number of edges is: %d\n\n",count);
      UF_UI_write_listing_window(buffer);
      for(i = 0; i < count; i++)
      {
        sprintf(buffer, "edge_tags[%d] = %d\n", i, edge_tags[i]);
        UF_UI_write_listing_window(buffer);
      }
      UF_free(edge_tags);
      UF_free(num_edges);
      count = 0;
    }
    else
    {
      sprintf(buffer,"The number of boundaries was: %d\n",num_bnd);
      UF_UI_write_listing_window(buffer);
    }
  }
  UF_CALL(UF_DISP_set_highlight(body,0));
  }while((response == 4) || (response == 5));
}
/*ARGSUSED*/
void ufusr(char *param, int *retcode, int param_len)
{
  if (!UF_CALL(UF_initialize()))
  {
    do_ugopen_api();
    UF_CALL(UF_terminate());
  }
}
int ufusr_ask_unload(void)
{
  return (UF_UNLOAD_IMMEDIATELY);
}
static void get_body_type(tag_t body)
{
  int err, type;
  char err_msg[MAX_LINE_SIZE+1];
  char buffer[UF_UI_MAX_STRING_LEN+1];
  err = UF_MODL_ask_body_type(body,&type);
  if(err)
  {
    UF_get_fail_message(err,err_msg);
    sprintf(buffer, "ERROR in ask body type: %s\n", err_msg);
    UF_UI_write_listing_window(buffer);
  }
  else
  {
    switch(type)
    {
      case UF_MODL_SOLID_BODY:
        UF_UI_write_listing_window("\nThis is a solid body.\n");
        break;
      case UF_MODL_SHEET_BODY:
        UF_UI_write_listing_window("\nThis is a sheet body.\n");
        break;
      case 0:
        UF_UI_write_listing_window("\nThis was not a solid or sheet body.\n");
        break;
      default:
        UF_UI_write_listing_window("\nUnacceptable input, terminating...\n");
        break;
    }
  }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MarcoPro

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值