购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008 QQ号:85585969
函数结构:UF_CURVE_ask_curve_inflections( tag_t curve_eid, double proj_matrx [ 9 ], double range [ 2 ], int * num_infpts, double * * inf_pts) 函数说明:
通过输入计算曲面投影的拐点曲线标记,所述投影矩阵,相对范围(在百分比),其中拐点被发现。
函数参数:
第1个参数为输入:
curve_eid代表参数变量,tag_t 为输入参数类型,曲线的对象标识符
第2个参数为输入:
输入double 双精度类型的参数,参数的变量格式为proj_matrx [ 9 ],在一维数组指定的投影矩阵(凸出矩阵[9])
第3个参数为输入:
输入double 双精度类型的参数,参数的变量格式为range [ 2 ],其中拐点被搜索范围的相对范围(%)的下限和上限[0] =下限(在)范围[1] =上限(UMAX)
第4个参数为输出:
输出int * 整数型的参数,参数的变量格式为num_infpts,发现的拐点数
第5个参数为输出:
输出double * * 双精度类型的参数,参数的变量格式为inf_pts,拐点的数据。阵列的大小是inf_pts[num_infpts4]。 (inf_pts+4I)[0]= U第i个拐点的价值。 [1-3]= X,Y,第i语调的z值。该数组必须通过调用UF_free释放。
UF_CURVE_ask_curve_inflections函数实例代码演示:
在下面的示例中的代码创建了两个平面曲线和计算它们的拐点。
[quote]
#include <uf_modl.h>
#include <uf_part.h>
#include <uf_defs.h>
#include <uf_curve.h>
#include <uf.h>
#include <uf_csys.h>
#include <uf_obj.h>
#include <stdio.h>
#include <string.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 i, k, curve_cnt=0;
tag_t curve_array[2];
char newnam[UF_OBJ_NAME_LEN+1];
int num_infpts;
double range[]={0.0, 100.0}, *inf_pts;
double proj_matrx[]={ 1.0, 0.0, 0.0, 0., 1.0, 0.0,0.0, 0.0, 1.0};
int knot1_fix, knot2_fix, pole1_fix, pole2_fix;
double bc1_knots[] = {-3./8., -2./8., -1./8., 0.0, 1./8.,
2./8., 3./8., 4./8., 5./8., 6./8.,
7./8., 1.0, 9./8., 10./8., 11./8};
double bc1_poles[] = { 2.0, 0.0, 0.0, 1.0,
4.0, 0.0, 0.0, 1.0,
3.5, 2.0, 0.0, 1.0,
6.0, 6.0, 0.0, 1.0,
2.0, 3.5, 0.0, 1.0,
0.0, 4.0, 0.0, 1.0,
0.0, 2.0, 0.0, 1.0,
0.0, 0.0, 0.0, 1.0,
2.0, 0.0, 0.0, 1.0,
4.0, 0.0, 0.0, 1.0,
3.5, 2.0, 0.0, 1.0 };
double bc2_knots[] = {0.0, 0.0, 0.0, 1.0/3.0,
2.0/3.0, 1.0, 1.0, 1.0};
double bc2_poles[] = {0.0, 0.0, 1.0, 1.0,
1.0, 2.0, 1.0, 1.0,
0.625, 0.0, 0.25, 0.25,
4.0, 2.0, 1.0, 1.0,
5.0, 0.0, 1.0, 1.0 };
/* create two B-curves */
UF_CALL(UF_MODL_create_spline(11,
4,
bc1_knots,
bc1_poles,
&curve_array[0],
&knot1_fix,
&pole1_fix));
strcpy(newnam, "BCURVE_1") ;
UF_CALL(UF_OBJ_set_name(curve_array[0], newnam)) ;
curve_cnt ++;
UF_CALL(UF_MODL_create_spline(5,
3,
bc2_knots,
bc2_poles,
&curve_array[1],
&knot2_fix,
&pole2_fix));
strcpy(newnam, "BCURVE_2") ;
UF_CALL(UF_OBJ_set_name(curve_array[1], newnam)) ;
curve_cnt ++;
/* loop over each curve and compute their inflections */
for (i = 0; i < curve_cnt; i++)
{
/* used a pre-definied projection matrix and predefined curve's
range for the inflection points calculation
*/
UF_CALL(UF_CURVE_ask_curve_inflections(curve_array[i],
proj_matrx,
range,
&num_infpts,
&inf_pts));
/* free the memory taken by the inflection points */
if (num_infpts > 0)
{
printf("There are %d inflection points for curve %d\n",
num_infpts, i+1);
for(k = 0; k < (num_infpts * 4); k++)
{
printf("inf_pts[%d] = %f\n", k, inf_pts[k]);
}
UF_free(inf_pts);
}
}
}
/*ARGSUSED*/
void ufusr(char *param, int *retcode, int paramLen)
{
if (!UF_CALL(UF_initialize()))
{
do_ugopen_api();
UF_CALL(UF_terminate());
}
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}
[/quote]