购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008 QQ号:85585969
函数结构:UF_MODL_create_spline( int nc, int kc, double knot [ ], double poles [ ], tag_t * spline_id, int * knot_fixup, int * pole_fixup) 函数说明:
创建一个样条曲线。曲线的周期性状态从继承定义数据。如果曲线上没有输入周期性的,但可以使周期性的,所得到的曲线是由C1周期性的。提示和技巧这个例程的标准NURB(非均匀有理B样条)数据作为输入。磁极是有序选自ABS的坐标和一个的四胞胎重量。作为一般原则,让所有的权重为1.0。对于结序列值:让U1,...,uorder = 0.0让upoles + 1,...,upoles +订单= 1.0这台开始4序列值到0.0,在过去四年当订单为四个序列值1.0。对于其他序列价值观,让NU = 1 /(极级+ 1)。然后将剩余的归一化序列值将是:uorder + 1 = 1NU,uorder + 2 = 2NU,...,upoles =(极顺序)NU。例如,假设我们有8极和秩序= 4,则:NU = 1 /(8-4 + 1)= 0.2和U1,...,uorder = U1,...,U4 = 0.0,upoles + 1,...,upoles +顺序= U9,...,U12 = 1.0,U5 = 2,U6 = 0.4,U7 = .6 U8 = 0.8这给了我们以下标准化,非减结序列:{0,0,0,0,2,4,.6 .8,1,1,1,1}。
函数参数:
第1个参数为输入:
输入int 整数型的参数,参数的变量格式为nc,控制顶点数(极)
第2个参数为输入:
输入int 整数型的参数,参数的变量格式为kc,订单(学位+1)
第3个参数为输入:
输入double 双精度类型的参数,参数的变量格式为knot [ ],结序列(尺寸以极+顺序,例如结[NC+ KC]
第4个参数为输入:
输入double 双精度类型的参数,参数的变量格式为poles [ ],阵列均匀控制点(WX,WY,WZ,W) - 尺寸为(4杆),例如极[NC 4]
第5个参数为输出:
spline_id代表参数变量,tag_t * 为输出参数类型,对于花键对象标识符
第6个参数为输出:
输出int * 整数型的参数,参数的变量格式为knot_fixup,结修正状态0=没有任何的修正进行1 =结固定顺序
第7个参数为输出:
输出int * 整数型的参数,参数的变量格式为pole_fixup,极修正状态0=没有任何的修正进行1=极阵列固定
UF_MODL_create_spline函数实例代码演示:
[quote]
The following C program creates a tube using a spline for the tube
path.
<img src=uf_modl_grf56.gif>
Figure Spring
#include <stdio.h>
#include <math.h>
#include <uf.h>
#include <uf_defs.h>
#include <uf_curve.h>
#include <uf_modl.h>
#include <uf_disp.h>
#define POLES 384
#define R1 2.25
#define R2 0.35
#define ANG PI/24
#define WEIGHT 1.0
#define ORDER 4
#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 *diams[2] = {"0.5", "0.0"};
int i;
int k_fixup;
int p_fixup;
tag_t spline_id;
uf_list_p_t tubelist, tubefeats;
UF_FEATURE_SIGN create = UF_NULLSIGN;
double knotseq[POLES+ORDER];
double pole_array[POLES*4];
double x,y,z,t,w = WEIGHT;
double delta_u = 1.0/((double)(POLES-ORDER+1));
for(i = 0; i < ORDER; i++) {
knotseq[i] = 0.0;
}
for(i = POLES; i < POLES + ORDER; i++) {
knotseq[i] = 1.0;
}
i = 0;
t =0.0;
while( i < POLES*4){
x = R1*cos(t) + .001;
y = R1*sin(t) + .001;
z = R2 + (R2/PI)*t;
t += ANG;
pole_array[i++] = x;
pole_array[i++] = y;
pole_array[i++] = z;
pole_array[i++] = w;
printf("%f, %f, %f, %f, %d\n",pole_array[i-4],pole_array[i-3],
pole_array[i-2],pole_array[i-1],i-4);
}
for(i = ORDER; i < POLES ; i++){
knotseq[i] = (i-ORDER+1)*delta_u;
}
printf("\nDelta u is = %f\n",delta_u);
printf("Knot Sequence values:\n");
for(i = 0; i < POLES + ORDER; i++) printf("%f\n",knotseq[i]);
if(k_fixup == 1) printf("Knot sequence was fixed.\n");
if(p_fixup == 1) printf("Pole array was fixed.\n");
UF_CALL(UF_MODL_create_spline(POLES,ORDER,knotseq,pole_array,
&spline_id,&k_fixup,&p_fixup));
UF_CALL(UF_MODL_create_list(&tubelist));
UF_CALL(UF_MODL_put_list_item(tubelist, spline_id));
UF_CALL(UF_MODL_create_tube(tubelist, diams, create,
&tubefeats));
}
/*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);
}
[/quote]