购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008 QQ号:85585969
函数结构:UF_CURVE_ask_spline_thru_pts( tag_t spline_tag, int * degree, int * periodicity, int * num_points, UF_CURVE_pt_slope_crvatr_t * * point_data, double * * parameters) 函数说明:
读取一个样条定义的数据结构。该定义数据回报不管花键是否与同步或其定义数据。但是,如果将返回的数据结构的常规UF_CURVE_edit_spline_thru_pts,样条曲线是从重建的输入数据。以往任何改变样条通过修改其极数据将被丢弃。如果没有存储与没有定义数据花键,错误代码将被退回。的参数的阵列的长度为非周期性NUM_POINTS曲线和(NUM_POINTS+ 1)为周期性的。
函数参数:
第1个参数为输入:
spline_tag代表参数变量,tag_t 为输入参数类型,花键要返回数据的标签
第2个参数为输出:
输出int * 整数型的参数,参数的变量格式为degree,样条曲线的程度
第3个参数为输出:
输出int * 整数型的参数,参数的变量格式为periodicity,样条曲线的周期性
第4个参数为输出:
输出int * 整数型的参数,参数的变量格式为num_points,点和参数在后面的阵列数
第5个参数为输出:
point_data代表参数变量,UF_CURVE_pt_slope_crvatr_t * * 为输出参数类型,数据定义点和斜率/曲率控制的数组。此数组必须通过它传递给AV_free被释放。
第6个参数为输出:
输出double * * 双精度类型的参数,参数的变量格式为parameters,定义样条曲线的点的参数。这是花键的定义点,这需要是单调递增一个用户指定的参数,但并不需要进行归一化,如果NULL,则默认参数将被使用。此数组需要通过调用UF_free释放。
UF_CURVE_ask_spline_thru_pts函数实例代码演示:
下面的例子需要与样条线的开口部分。该示例代码使用了选择按类功能,允许用户选择多个样条线。然后,花键查询样条直通点数据和报表打印到信息窗口。
[quote]
#include <stdio.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_object_types.h>
#include <uf_disp.h>
#include <uf_curve.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 *message = "Select Spline";
char buffer[UF_UI_MAX_STRING_LEN];
UF_UI_selection_options_t opts;
UF_UI_mask_t mask = {UF_spline_type, 0, 0};
int response, count;
tag_p_t objects;
int i,j;
int off = 0;
int slope;
int curve;
/* Ask spline parameters. */
int degree;
int periodicity;
int num_points;
double *parameters;
UF_CURVE_pt_slope_crvatr_t *point_data;
opts.other_options = 0;
opts.reserved = NULL;
opts.num_mask_triples = 1;
/* Set selection scope to be work part & occurrence. */
opts.scope = UF_UI_SEL_SCOPE_WORK_PART_AND_OCC;
opts.mask_triples = &mask;
/* if no error, print information about selected spline objects.
*/
if(!UF_CALL(UF_UI_select_by_class( message,&opts,&response,
&count,&objects )))
{
/* Opens the information window for a report on spline data. */
UF_CALL(UF_UI_open_listing_window());
sprintf(buffer,"response= %d, object count=
%d\n",response,count);
/* Fall through only if objects selected. */
if (objects != NULL)
{
/* For each spline in the array of objects, get the spline
data and print the data to the information window.
*/
for (j=0; j < count; j++)
{
/* Unhighlight selected objects. */
UF_DISP_set_highlight(objects[j],off);
/* Get the spline data. */
UF_CALL(UF_CURVE_ask_spline_thru_pts(objects[j],
°ree,
&periodicity,
&num_points,
&point_data,
¶meters));
/* Print a header that identifies the spline number. */
sprintf(buffer, "\n\n------Data for Spline %d ------\n",
j+1);
UF_UI_write_listing_window(buffer);
/*Print the degree and periodicity. A value of 0 indicates
a nonperiodic spline. A value of 1 indicates a periodic
spline.
*/
sprintf(buffer,"\nDegree is: %d\n", degree);
UF_UI_write_listing_window(buffer);
sprintf(buffer,"Periodicity is : %d\n",periodicity);
UF_UI_write_listing_window(buffer);
/* Print the parametric values of the spline. */
for(i = 0; i < num_points; i++)
{
sprintf(buffer,"parameters[%d]: %f\n",i,parameters[i]);
UF_UI_write_listing_window(buffer);
}
/* Print the spline points. */
for(i = 0; i < num_points; i++)
{
/* Print out spline data. */
sprintf(buffer,"\nPoints (%d):\n", i+1);
UF_UI_write_listing_window(buffer);
sprintf(buffer,"point_data[%d]->point[0]: %f\n",
i,point_data[i].point[0]);
UF_UI_write_listing_window(buffer);
sprintf(buffer,"point_data[%d]->point[1]: %f\n",
i,point_data[i].point[1]);
UF_UI_write_listing_window(buffer);
sprintf(buffer,"point_data[%d]->point[2]: %f\n",
i,point_data[i].point[2]);
UF_UI_write_listing_window(buffer);
/* Print out the slope type. */
slope = point_data[i].slope_type;
switch(slope)
{
case UF_CURVE_SLOPE_NONE:
sprintf(buffer, "slope type: UF_CURVE_SLOPE_NONE\n");
UF_UI_write_listing_window(buffer);
break;
case UF_CURVE_SLOPE_AUTO:
sprintf(buffer, "slope type: UF_CURVE_SLOPE_AUTO\n");
UF_UI_write_listing_window(buffer);
break;
case UF_CURVE_SLOPE_VEC:
sprintf(buffer, "slope type: UF_CURVE_SLOPE_VEC\n");
UF_UI_write_listing_window(buffer);
break;
case UF_CURVE_SLOPE_DIR:
sprintf(buffer, "slope type: UF_CURVE_SLOPE_DIR\n");
UF_UI_write_listing_window(buffer);
break;
default:
sprintf(buffer,"Unknown slope type: %d\n",slope);
UF_UI_write_listing_window(buffer);
break;
}
/* Print the slope vector coordinates. */
sprintf(buffer,"point_data[%d]->slope[0]: %f\n",
i,point_data[i].slope[0]);
UF_UI_write_listing_window(buffer);
sprintf(buffer,"point_data[%d]->slope[1]: %f\n",
i,point_data[i].slope[1]);
UF_UI_write_listing_window(buffer);
sprintf(buffer,"point_data[%d]->slope[2]: %f\n",
i,point_data[i].slope[2]);
UF_UI_write_listing_window(buffer);
/* Print out curvature type.*/
curve = point_data[i].crvatr_type;
switch(curve)
{
case UF_CURVE_CRVATR_NONE:
sprintf(buffer, "curvature type:
UF_CURVE_CRVATR_NONE\n");
UF_UI_write_listing_window(buffer);
break;
case UF_CURVE_CRVATR_AUTO_DIR:
sprintf(buffer, "curvature type:
UF_CURVE_CRVATR_AUTO_DIR\n");
UF_UI_write_listing_window(buffer);
break;
case UF_CURVE_CRVATR_VEC:
sprintf(buffer, "curvature type:
UF_CURVE_CRVATR_VEC\n");
UF_UI_write_listing_window(buffer);
break;
default:
sprintf(buffer,"Unknown curvature type: %d\n",curve);
UF_UI_write_listing_window(buffer);
break;
}
/* Print the curvature vector coordinates. */
sprintf(buffer,"point_data[%d]->crvatr[0]: %f\n",
i,point_data[i].crvatr[0]);
UF_UI_write_listing_window(buffer);
sprintf(buffer,"point_data[%d]->crvatr[1]: %f\n",
i,point_data[i].crvatr[1]);
UF_UI_write_listing_window(buffer);
sprintf(buffer,"point_data[%d]->crvatr[2]: %f\n",
i,point_data[i].crvatr[2]);
UF_UI_write_listing_window(buffer);
}
}
}
}
/* Deallocate memory for the array of spline object tags. */
UF_free(objects);
}
/*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]