购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008 QQ号:85585969
函数结构:
UF_MODL_ask_edge_verts
(
tag_t edge,
double point1 [ 3 ],
double point2 [ 3 ],
int * vertex_count
)
函数说明:
给定一个固力作为输入,返回的顶点(端点)边缘。边缘可以具有零个,一个或两个顶点的基础上,边给出。例如,一个圆是一个具有零顶点的边缘和线路是与两个顶点的边缘。另外,也可以创建一个圆形边缘一个顶点。一个例子是挤压三角形到气缸和然后对结果进行联合以获得身体,如图所示。当输入边缘的发生,为点1的坐标和点2是相对于发生。
函数参数:
第1个参数为输入:
edge代表参数变量,tag_t 为输入参数类型,含边顶点的对象标识符
第2个参数为输出:
输出double 双精度类型的参数,参数的变量格式为point1 [ 3 ],边的第一个端点。
第3个参数为输出:
输出double 双精度类型的参数,参数的变量格式为point2 [ 3 ],边的第二个端点。
第4个参数为输出:
输出int * 整数型的参数,参数的变量格式为vertex_count,返回端点的数量。如果只返回一个端点,它包含在'点1。
UF_MODL_ask_edge_verts函数实例代码演示:
下面的C程序得到的顶点数目在每个边缘该固体。
#include <stdio.h>
#include <uf_defs.h>
#include <uf_modl.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_object_types.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)
{
tag_t obj_id = 0;
tag_t edge_id = 0;
tag_t view;
uf_list_p_t edge_list;
uf_list_p_t face_list;
UF_UI_selection_options_t opts;
UF_UI_mask_t mask = {UF_solid_type,0,UF_UI_SEL_FEATURE_BODY};
int edge_count = 0;
int face_count = 0;
int index, vertex, response;
double p1[3]={0.0, 0.0, 0.0}, p2[3]={0.0, 0.0, 0.0}, cursor[3];
opts.num_mask_triples = 1;
opts.mask_triples = &mask;
opts.scope = UF_UI_SEL_SCOPE_WORK_PART;
response = 4;
do
{
UF_CALL(UF_UI_select_single("Select a solid body", &opts,
&response, &obj_id,
cursor, &view));
if((response == 4) || (response == 5))
{
UF_MODL_ask_body_edges(obj_id, &edge_list);
UF_MODL_ask_list_count(edge_list, &edge_count);
UF_MODL_ask_body_faces(obj_id, &face_list);
UF_MODL_ask_list_count(face_list, &face_count); for(index = 0; index < edge_count; index++)
{
printf("\nInfo for edge number: %d\n", index);
UF_MODL_ask_list_item(edge_list, index, &edge_id);
UF_MODL_ask_edge_verts(edge_id, p1, p2, &vertex);
printf("The number of vertices is: %d\n", vertex);
switch(vertex)
{
case 0:
printf("There are no vertices on this edge.\n");
break;
case 1:
printf("The X value of P1 is: %f\n", p1[0]);
printf("The Y value of P1 is: %f\n", p1[1]);
printf("The Z value of P1 is: %f\n", p1[2]);
break;
case 2:
printf("The X value of P1 is: %f\n", p1[0]);
printf("The Y value of P1 is: %f\n", p1[1]);
printf("The Z value of P1 is: %f\n", p1[2]);
printf("The X value of P2 is: %f\n", p2[0]);
printf("The Y value of P2 is: %f\n", p2[1]);
printf("The Z value of P2 is: %f\n", p2[2]);
break;
default:
break;
}
}
}
printf("Total number of faces: %d\n", face_count);
}while((response == 4) || (response ==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);
}