点击查看详细介绍

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

misnn 7年前 1538 0

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


函数结构:
UF_MODL_trace_a_ray
(
int num_bodies,
tag_t * bodies,
double origin [ 3 ],
double direction [ 3 ],
double transform [ 16 ],
int num_desired,
int * num_results,
UF_MODL_ray_hit_point_info_p_t * hit_list
)

函数说明:
在转化(可选)机构的名单火灾射线,并返回信息关于被击中每个面。舌状花是相切的内部面对,而是通过脸部不会越过不被认为是一个打击。名单包含返回的信息是它的距离从顺序光线的起源,最接近第一。来电者是负责与UF_free释放hit_list。

函数参数:
第1个参数为输入:
输入int 整数型的参数,参数的变量格式为num_bodies,那些被打机构数量

第2个参数为输入:
bodies代表参数变量,tag_t * 为输入参数类型,身体标记,是阵待击。该阵列的尺寸为num机构。

第3个参数为输入:
输入double 双精度类型的参数,参数的变量格式为origin [ 3 ],点从中射线发射。

第4个参数为输入:
输入double 双精度类型的参数,参数的变量格式为direction [ 3 ],该方向的光线被激发。

第5个参数为输入:
输入double 双精度类型的参数,参数的变量格式为transform [ 16 ],变换所需的机构转换成相同的坐标系的射线。与UF_MTX4身份初始化。只有旋转和平移是允许的。

第6个参数为输入:
输入int 整数型的参数,参数的变量格式为num_desired,命中点的最大数目所需。零请求的值返回全部命中点。

第7个参数为输出:
输出int * 整数型的参数,参数的变量格式为num_results,较高的命中率发现号

第8个参数为输出:
输出UF_MODL_ray_hit_point_info_p_t * 整数型的参数,参数的变量格式为hit_list,一个指向结构的数组,其中每个数组元素将包含有关每一击的信息。此阵列中的第一个元素将包含击中最接近的光线与元件的其它部分的来源将包含继续的距离增加的顺序分点的信息。调用者必须通过调用UF_free释放此阵。

UF_MODL_trace_a_ray函数实例代码演示:
说明:此文件包含以下外部函数支持光线追踪:UF_MODL_trace_a_ray
[quote]
#include <stdio.h>
#include <uf.h>
#include <uf_part.h>
#include <uf_defs.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)
{

char *edge_length[3] = {"5.0", "3.0", "10.0"};
char *prtnam = "trace_a_ray";
char *dia = "3.0";
char *height = "10.0";
char *cone_ht = "7.0";
char *cone_dias[2] = { "2.5","1.0" };

double cyl_dir[3] = {0.0, 0.0, 1.0};
double origin[3] = {0.0, 0.0, -5.0};
double cone_axis[3] = { 0.0,0.0,1.0};
double transform[16] = { 1.0,0.0,0.0,0.0,
0.0,1.0,0.0,0.0,
0.0,0.0,1.0,0.0,
0.0,0.0,0.0,1.0 };

double point[3] = { 2.0,-1.0,0.0 };
double raydir[3] = { 8.0,5.0,0.0 };

int hits_found;

tag_t bodies[3];
tag_t feat_tag;
tag_t part_tag;

UF_FEATURE_SIGN create = UF_NULLSIGN;
UF_MODL_ray_hit_point_info_p_t hit_list;

/* Open a new part */
UF_CALL( UF_PART_new(prtnam, METRIC, &part_tag) );

/* Create a block */
UF_CALL(UF_MODL_create_block1(create, origin, edge_length, &feat_tag));
UF_CALL(UF_MODL_ask_feat_body(feat_tag, &bodies[0]));

/* Create a cylinder */
origin[0] = 10.0;
origin[1] = 0.0;
origin[2] = 0.0;
UF_CALL(UF_MODL_create_cyl1(create, origin, height, dia, cyl_dir, &feat_tag));
UF_CALL(UF_MODL_ask_feat_body(feat_tag, &bodies[1]));

/* Create a cone */
origin[0] = 10.0;
origin[1] = 4.0;
origin[2] = -3.0;
UF_CALL(UF_MODL_create_cone1(create, origin, cone_ht, cone_dias, cone_axis,
&feat_tag));
UF_CALL(UF_MODL_ask_feat_body(feat_tag, &bodies[2])) ;

/* fire the ray on the bodies */
UF_CALL(UF_MODL_trace_a_ray( 3, bodies, point, raydir,
transform, 6, &hits_found, &hit_list ));

if ( hits_found != 4 )
printf("*** ERROR from UF_MODL_trace_a_ray ***\n");

if ( hit_list[0].hit_body != bodies[0] && hit_list[2].hit_body != bodies[2] )
printf("*** ERROR from UF_MODL_trace_a_ray ***\n");

UF_free(hit_list);

}

/*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)
请登录后发表新帖