NX二开ufun函数UF_MODL_create_surf_from_cloud(使用现有点创建B曲面)

本文介绍了如何利用ufun函数UF_MODL_create_surf_from_cloud从点云数据创建B曲面。该函数允许点按任意顺序排列,只要足够定义平面。示例代码展示了如何调用此函数,设置参数如点的数量、曲面的UV度数和分区,以及处理边界角。当bnd_corners指针为NULL时,边界将默认为包含所有点的最小矩形。
摘要由CSDN通过智能技术生成

本节主要讲使用现有点创建B曲面的ufun函数UF_MODL_create_surf_from_cloud,这些点可以按任何顺序出现,但是必须有足够的点来定义平面。

先看实例效果图:

  1、函数结构

int UF_MODL_create_surf_from_cloud 

int point_cnt,
double cloud [] [3],
double csys_matrix [2] [3],
double bnd_corners [4] [3],
int U_degree,
int V_degree,
int U_patches,
int V_patches,
int corner_switch,
double * average_error,
double * max_error,
int * max_error_index,
tag_t * surface_tag

2、实例源码  

#include <stdio.h>
#include <uf.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)
{
  int             pnt_cnt = 16;
  int             u_degree = 3, v_degree = 3;
  int             u_patches = 1, v_patches = 1;
  int             corner_switch = 0;
  int             max_err_index;
  double          average_error, max_error;
  tag_t           surface_tag = NULL_TAG;

  static double   mtx[2][3] = { {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0} };
  static double   cloud_pnts[][3]=
        { { 2200.0,  548.0, 1472.0 }, { 1400.0, 1168.0, 1213.0 },
          { 1000.0,  285.0, 1377.0 }, { 1000.0, 1107.0, 1154.0 },
          { 1000.0, -254.0,  950.0 }, { 2200.0,  951.0, 1462.0 },
          { 1400.0, -353.0, 1049.0 }, { 1800.0,  605.0, 1388.0 },
          { 1400.0,  222.0, 1550.0 }, { 1800.0, -426.0, 1121.0 },
          { 2200.0,  207.0, 1750.0 }, { 1800.0, 1007.0, 1406.0 },
          { 1800.0,  259.0, 1655.0 }, { 1400.0,  649.0, 1301.0 },
          { 2200.0, -479.0, 1175.0 }, { 1000.0,  704.0, 1167.0 } };


  UF_CALL(UF_MODL_create_surf_from_cloud( pnt_cnt,
                                          cloud_pnts,
                                          mtx,
                                          NULL,
                                          u_degree,
                                          v_degree,
                                          u_patches,
                                          v_patches,
                                          corner_switch,
                                          &average_error,
                                          &max_error,
                                          &max_err_index,
                                          &surface_tag ));
}
/*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);
}

3、源码分析 

这个ufun函数,主要用来实现点列表创建B曲面, 点的顺序决定了面的U和V方向。如果指向bnd_corners的指针为NULL,则便捷为包含XY平面中的点列表的最小矩形。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

MarcoPro

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

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

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

打赏作者

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

抵扣说明:

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

余额充值