点击查看详细介绍

UF_CURVE_ask_trim() 函数的参数解释说明、函数详细用法,以及实例代码演示

misnn 7年前 817 0

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


函数结构:
UF_CURVE_ask_trim
(
tag_t trim_feature,
UF_CURVE_trim_p_t trim_info
)

函数说明:
检索关联修剪曲线功能的当前参数。

函数参数:
第1个参数为输入:
trim_feature代表参数变量,tag_t 为输入参数类型,修剪曲线特征的参数是要检索

第2个参数为输出:
trim_info代表参数变量,UF_CURVE_trim_p_t 为输出参数类型,信息定义装饰曲线特性电流参数,调用方应免费在此结构中,通过调用UF_CURVE_free_trim分配的内存

UF_CURVE_ask_trim函数实例代码演示:
CLASS UFCUST
[quote]
#include <stdio.h>
#include <uf.h>
#include <uf_curve.h>
#include <uf_modl.h>
#include <uf_part.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 error,trim_string[1],trim_dir[1],bound_string[1],bound_dir[1];
tag_t lines[3],trim_curve_feat,datum,part_tag;
double plane_origin[3],plane_norm[3];
UF_CURVE_line_t line_coords;
UF_CURVE_trim_t trim_curve_info,out_trim_curve_info;
UF_CURVE_trim_mult_t out_info;
char *prtnam = "curve_trim";

UF_CALL( UF_PART_new(prtnam, METRIC, &part_tag) );

/*
Create three lines and a datum plane.
*/
line_coords.start_point[0] = 0.0; line_coords.end_point[0] = 20.0;
line_coords.start_point[1] = 0.0; line_coords.end_point[1] = 10.0;
line_coords.start_point[2] = 0.0; line_coords.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&line_coords,&lines[0]));

line_coords.start_point[0] = 20.0; line_coords.end_point[0] = 30.0;
line_coords.start_point[1] = 10.0; line_coords.end_point[1] = 0.0;
line_coords.start_point[2] = 0.0; line_coords.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&line_coords,&lines[1]));

line_coords.start_point[0] = -5.0; line_coords.end_point[0] = 35.0;
line_coords.start_point[1] = 5.0; line_coords.end_point[1] = 5.0;
line_coords.start_point[2] = 0.0; line_coords.end_point[2] = 0.0;
UF_CALL(UF_CURVE_create_line(&line_coords,&lines[2]));

plane_origin[0] = 15.0; plane_origin[1] = 0.0; plane_origin[2] = 0.0;
plane_norm[0] = 1.0; plane_norm[1] = 0.0; plane_norm[2] = 0.0;
UF_CALL(UF_MODL_create_fixed_dplane(plane_origin,plane_norm,&datum));

/*
Fill in arrays to be used in string definition.
*/
trim_string[0] = 2; trim_dir[0] = 1;

/*
Fill in trim curve structure information to trim the first line
to the second line as a bounding string.
*/
trim_curve_info.string_to_trim.num = 1;
trim_curve_info.string_to_trim.string = trim_string;
trim_curve_info.string_to_trim.dir = trim_dir;
trim_curve_info.string_to_trim.id = lines;

trim_curve_info.spline_extend_opt = UF_CURVE_EXTEND_NATURAL;
trim_curve_info.trim_type = UF_CURVE_TRIM_TO_ONE_BOUND;
UF_MODL_ask_distance_tolerance(&trim_curve_info.tolerances[0]);
UF_MODL_ask_angle_tolerance(&trim_curve_info.tolerances[1]);

/*
Fill in arrays to be used in bound definition.
*/
bound_string[0] = 1; bound_dir[0] = 1;

/*
Fill in bounding information.
*/
trim_curve_info.trim_to.one_bound.string_trim_extend_end = UF_CURVE_TRIM_EXTEND_START;

trim_curve_info.trim_to.one_bound.bound.string.num = 1;
trim_curve_info.trim_to.one_bound.bound.string.string = bound_string;
trim_curve_info.trim_to.one_bound.bound.string.dir = bound_dir;
trim_curve_info.trim_to.one_bound.bound.string.id = &lines[2];
trim_curve_info.trim_to.one_bound.bound.use_suggested = FALSE;
trim_curve_info.trim_to.one_bound.view = (UF_MODL_vector_p_t)(void *)0;

trim_curve_info.trim_to.one_bound.bound.object = NULL_TAG;
trim_curve_info.trim_to.one_bound.trim_bound = TRUE;

/*
Create the trim curve feature.
*/
error = UF_CURVE_create_trim(&trim_curve_info, &out_info, &trim_curve_feat);

if (error == UF_CURVE_TRIM_MULT_PTS)
{
printf("Multiple intersections found\n");

/*
Use first intersection point as suggested point.
*/
trim_curve_info.trim_to.one_bound.bound.use_suggested = TRUE;
trim_curve_info.trim_to.one_bound.bound.suggested_point[0] = out_info.bound1_pts[0];
trim_curve_info.trim_to.one_bound.bound.suggested_point[1] = out_info.bound1_pts[1];
trim_curve_info.trim_to.one_bound.bound.suggested_point[2] = out_info.bound1_pts[2];

if (out_info.bound1_pts)
{
UF_free(out_info.bound1_pts);
}

if (out_info.bound2_pts)
{
UF_free(out_info.bound2_pts);
}

UF_CALL(UF_CURVE_create_trim(&trim_curve_info, &out_info, &trim_curve_feat));
}

printf("Trim curve feature created\n");

/*
Ask the parameters of the trim curve feature just created.
*/
UF_CALL(UF_CURVE_ask_trim(trim_curve_feat, &out_trim_curve_info));

printf("Trim curve feature parameters retrieved\n");

/*
Transfer some of the retrieved parameters to the trim curve
information structure.
Reset other information in the structure so that the first line
will now be trimmed so that the portion of the line outside the
bounding string and the datum plane will be trimmed away.
*/
trim_curve_info.string_to_trim = out_trim_curve_info.string_to_trim;
trim_curve_info.trim_type = UF_CURVE_TRIM_TO_TWO_BOUND;
trim_curve_info.trim_to.two_bound.string_extend_end = UF_CURVE_TRIM_EXTEND_START;
trim_curve_info.trim_to.two_bound.string_trim_option = UF_CURVE_TRIM_OUTSIDE;
trim_curve_info.trim_to.two_bound.bound1.string =
out_trim_curve_info.trim_to.one_bound.bound.string;
trim_curve_info.trim_to.two_bound.bound1.object = NULL_TAG;
trim_curve_info.trim_to.two_bound.bound2.string.num = 0;
trim_curve_info.trim_to.two_bound.bound2.object = datum;
trim_curve_info.trim_to.two_bound.bound2.use_suggested = FALSE;
trim_curve_info.trim_to.two_bound.view = (UF_MODL_vector_p_t)(void *)0;
trim_curve_info.trim_to.two_bound.trim_bound = TRUE;

/*
Edit the trim curve feature.
*/
UF_CALL(UF_CURVE_edit_trim(trim_curve_feat, &trim_curve_info));

/*
Update the model.
*/
UF_CALL(UF_MODL_update());

printf("Trim curve feature edited, and model updated\n");

/*
Free the retrieved information.
*/
UF_CALL(UF_CURVE_free_trim(&out_trim_curve_info));

printf("Trim curve feature information freed, and example completed.\n");

}

/*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]

0

最新回复 (0)
请登录后发表新帖