购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008 QQ号:85585969
函数结构:
UF_MODL_ask_bounding_box
(
tag_t object,
double bounding_box [ 6 ]
)
函数说明:
返回线框和实体类型对象的边界框。线框对象包括直线,圆弧,样条曲线和圆锥曲线。稳健型对象包括机构,面和边。边框值在绝对返回根据其中对象坐标值存在于部分文件。如果调用此函数的出现,边框基本几何体被转化为装配空间。这个可能会导致被返回为大于边界框预期。这种情况发生的情况下,当构成部件的轴被转化,使得它们不与的轴线对准装配坐标系。注意,箱返回好处加快了精度。返回框将包含给定的实体,它通常会接近到最小边界框,但这不被保证。此功能可能无法返回正确的信息,当身体有被修剪或者是布尔操作的结果。在这些例UF_MODL_ask_extreme可用于获得正确的边界框的尺寸。
函数参数:
第1个参数为输入:
object代表参数变量,tag_t 为输入参数类型,对象的对象标识符问边框。
第2个参数为输出:
输出double 双精度类型的参数,参数的变量格式为bounding_box [ 6 ],边界对象框。 [0] - 最小x值[1] - 最小y值[2] - 最小的z值[3] - 最大x值[4] - 最大的y值[5] - 最大的z值
UF_MODL_ask_bounding_box函数实例代码演示:
下面的示例创建bound.prt它使用要求边框的功能。该代码创建了一个弧线,然后要求其边界框。
#include <stdio.h>
#include <uf.h>
#include <uf_part.h>
#include <uf_curve.h>
#include <uf_modl.h>
#include <uf_csys.h>
#include <uf_defs.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 *part_name = "bound";
tag_t part, arc_id, wcs_tag;
double box[6];
UF_CURVE_arc_t arc_coords; /* Fill out the data structure */
arc_coords.start_angle = 0.0;
arc_coords.end_angle = 270.0 * DEGRA;
arc_coords.arc_center[0] = 0.0;
arc_coords.arc_center[1] = 0.0;
arc_coords.arc_center[2] = 1.0;
arc_coords.radius = 2.0;
UF_PART_new(part_name, UF_PART_ENGLISH, &part);
UF_CSYS_ask_wcs( &wcs_tag );
UF_CSYS_ask_matrix_of_object( wcs_tag,&arc_coords.matrix_tag );
/* Create arc */
UF_CURVE_create_arc(&arc_coords,&arc_id);
/* Ask bounding box of arc */
UF_MODL_ask_bounding_box(arc_id,box);
/* Print bounding box values */
printf("\nMinimum x value: %f\n", box[0]);
printf("Maximum x value: %f\n", box[3]);
printf("Minimum y value: %f\n", box[1]);
printf("Maximum y value: %f\n", box[4]);
printf("Minimum z value: %f\n", box[2]);
printf("Maximum z value: %f\n", box[5]);
}
/*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);
}