NX二开ufun函数UF_MODL_ask_bsurf (获取B平面信息)

这个ufun函数用来返回与输入面或正文(带单面)标记关联的B表面数据 。

实例返回截图如下:

实例创建的曲面如下:

1、函数结构

int UF_MODL_ask_bsurf(tag_t face,UF_MODL_bsurface_p_t bsurf)

2、实例源码


#include <stdio.h>
#include <stdlib.h>
#include <uf.h>
#include <uf_part.h>
#include <uf_defs.h>
#include <uf_modl.h>


#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    *prtnam = "create_bsurf"; 

  /* Points for B-surface  */
  double points[16][3] = { 3.5, 2.5, 0.0,
			   4.0, 2.6, 0.2,
			   4.5, 2.6, 0.2,
			   5.0, 2.5, 0.0,
			   3.3, 3.0, 0.2,
			   4.1, 3.2, 0.3, 
			   4.5, 3.2, 0.3,
			   5.0, 3.0, 0.2,
			   3.0, 3.5, 0.2,
			   3.8, 3.6, 0.3,
			   4.5, 3.6, 0.3,
			   5.0, 3.5, 0.2,
			   2.6, 4.0, 0.0,
			   3.3, 4.0, 0.2,
			   4.5, 4.0, 0.2,
			   5.0, 4.0, 0.0 };	

  int create_mode = 1;
  int u_closed_status = 0;
  int v_closed_status = 0;
  int u_degree = 3;
  int v_degree = 3;
  int num_rows = 4;
  int pts_per_row[4] = {4, 4, 4, 4};
    
  int ii, jj, kk, indx;
        
  tag_t   part_tag;
  tag_t   bsurf_obj_id = NULL_TAG;

  UF_MODL_bsurf_row_info_t *pts_info_per_row; /* pts info for each row */
  UF_MODL_bsurface_t   bsurf;


  /* Open a new part */
  UF_CALL( UF_PART_new(prtnam, METRIC, &part_tag) );

  pts_info_per_row = ( UF_MODL_bsurf_row_info_t *)malloc( num_rows *
                       sizeof(UF_MODL_bsurf_row_info_t) );
   
  /* allocate and load point and other information for each row of points */
  indx = 0;
  for (ii=0; ii<num_rows; ii++)
  {
    pts_info_per_row[ii].num_points = pts_per_row[ii];  /* can vary */
    pts_info_per_row[ii].points = (double *)malloc( pts_per_row[ii] * 3 *
                                   sizeof(double) );
      
    pts_info_per_row[ii].weight = (double *)malloc( pts_per_row[ii] * 
                                   sizeof(double) );
               
    /* load up point and weight info */
    for (jj=0, kk = 0; kk<pts_per_row[ii]; kk++, jj+=3, indx++)
    {
      pts_info_per_row[ii].points[jj] = points[indx][0];
      pts_info_per_row[ii].points[jj+1] = points[indx][1];
      pts_info_per_row[ii].points[jj+2] = points[indx][2];
      pts_info_per_row[ii].weight[kk] = 1.0;
    
    }
  }
  
  /* create B-surface */
  UF_CALL(UF_MODL_create_bsurf_thru_pts( create_mode, u_closed_status, 
                                         v_closed_status, u_degree, 
                                         v_degree, num_rows, pts_info_per_row,
	                                 &bsurf_obj_id));
	           
  if ( bsurf_obj_id == NULL_TAG )
    printf("*** ERROR CREATING B-SURFACE ***\n");

  /* free allocated memory */
  for (ii=0; ii<num_rows; ii++)
  {
    free(pts_info_per_row[ii].points);
    free(pts_info_per_row[ii].weight);
  }
  
  free(pts_info_per_row);
    
    
  /* ask the B-surface information */
  UF_CALL(UF_MODL_ask_bsurf( bsurf_obj_id, &bsurf ));
  
  /* validate the surface */
  if ( (bsurf.order_u != u_degree+1) || (bsurf.order_v != v_degree+1) )
    printf("*** ERROR ASKING B-SURFACE ***\n");
  
  UF_CALL(UF_MODL_free_bsurf_data(&bsurf));


} 

/*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);
}

1、创建B平面UF_MODL_create_bsurf_thru_pts

2、获取B平面信息UF_MODL_ask_bsurf

3、释放B平面信息UF_MODL_free_bsurf_data

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

MarcoPro

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

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

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

打赏作者

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

抵扣说明:

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

余额充值