点击查看详细介绍

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

misnn 7年前 786 0

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


函数结构:
UF_FACET_cycle_facets
(
tag_t model,
int * facet_id
)

函数说明:
遍历一个面模型方面。在循环使用开始代码UF_FACET_NULL_FACET_ID并且这也被返回当有在模型中没有进一步的方面。注意,虽然“facet_id”是整数,但不保证该“facet_id+1”是一个有效身份证面。

函数参数:
第1个参数为输入:
model代表参数变量,tag_t 为输入参数类型,多面模型中循环。

第2个参数为输入:
输入int * 整数型的参数,参数的变量格式为facet_id,输入模型中的当前小面的编号。传递UF_FACET_NULL_FACET_ID开始循环。上输出模型中的下一个小面的ID,如果没有更多的小面,则返回UF_FACET_NULL_FACET_ID。

UF_FACET_cycle_facets函数实例代码演示:
这个示例程序创建一个四面体的面模型。 它然后检查模型中的边缘的邻接和凸。最后,它会从四面体一个方面,并增加了另一三个方面的顶点,其中在四面体的内部向上推使得有在所得模型三凹边。 它即可查询并打印所有模型边缘的凸度。
[quote]
#include <stdio.h>
#include <uf.h>
#include <uf_modl.h>
#include <uf_assem.h>
#include <uf_facet.h>
/*--------------------------------------------------------------*/
/*ARGSUSED*/
extern void ufusr( char *param, int *retcod, int param_len )
{
UF_initialize();
*retcod = example2();
UF_terminate();
}
/*--------------------------------------------------------------*/
static int example2( void )
{
int ifail;
tag_t part_tag;
int i;
tag_t new_model;
double facet_vertices[30][3];
double facet_normals[30][3];
int adjacencies[30];
int facets[7];
int edge;
int adjacent_facets[3];
int facet_id;
int edge_in_adjacent_facet;
int num_facets_in_model;
logical model_convexity;
/*
First create a part in which we will initially create a
block.
*/
ifail = UF_PART_new( "uf_facet_exp2_test_part",
1 /* MM */,
&part_tag ); /* 1 = mm */
if ( ifail != 0 )
{
printf( "**ERR: Failed to create new part ifail %d\n",
ifail );
return 1;
}
ifail = UF_ASSEM_set_work_part( part_tag );
UF_FACET_create_model( part_tag, &new_model );
facet_vertices[0][0] = 0.0;
facet_vertices[0][1] = 0.0;
facet_vertices[0][2] = 0.0;

facet_vertices[1][0] = 0.03;
facet_vertices[1][1] = 0.05;
facet_vertices[1][2] = 0.0;
facet_vertices[2][0] = 0.060;
facet_vertices[2][1] = 0.0;
facet_vertices[2][2] = 0.0;
adjacencies[0] = UF_FACET_NULL_FACET_ID;
adjacencies[1] = UF_FACET_NULL_FACET_ID;
adjacencies[2] = UF_FACET_NULL_FACET_ID;
UF_FACET_add_facet_to_model( new_model,
3,
facet_vertices,
NULL,
adjacencies,
facets+0 );
facet_vertices[0][0] = 0.0;
facet_vertices[0][1] = 0.0;
facet_vertices[0][2] = 0.0;

facet_vertices[1][0] = 0.060;
facet_vertices[1][1] = 0.0;
facet_vertices[1][2] = 0.0;
facet_vertices[2][0] = 0.03;
facet_vertices[2][1] = 0.03;
facet_vertices[2][2] = 0.05;
adjacencies[0] = facets[0];
UF_FACET_add_facet_to_model( new_model,
3,
facet_vertices,
NULL,
adjacencies,
facets+1 );
facet_vertices[0][0] = 0.060;
facet_vertices[0][1] = 0.0;
facet_vertices[0][2] = 0.0;
facet_vertices[1][0] = 0.03;
facet_vertices[1][1] = 0.05;
facet_vertices[1][2] = 0.0;
facet_vertices[2][0] = 0.03;
facet_vertices[2][1] = 0.03;
facet_vertices[2][2] = 0.05;
adjacencies[0] = facets[0];
adjacencies[1] = UF_FACET_NULL_FACET_ID;
adjacencies[2] = facets[1];
UF_FACET_add_facet_to_model( new_model,
3,
facet_vertices,
NULL,
adjacencies,
facets+2 );
facet_vertices[0][0] = 0.03;
facet_vertices[0][1] = 0.05;
facet_vertices[0][2] = 0.0;
facet_vertices[1][0] = 0.0;
facet_vertices[1][1] = 0.0;
facet_vertices[1][2] = 0.0;

facet_vertices[2][0] = 0.03;
facet_vertices[2][1] = 0.03;
facet_vertices[2][2] = 0.05;
adjacencies[0] = facets[0];
adjacencies[1] = facets[1];
adjacencies[2] = facets[2];
UF_FACET_add_facet_to_model( new_model,
3,
facet_vertices,
NULL,
adjacencies,
facets+3 );
facet_id = UF_FACET_NULL_FACET_ID;
UF_FACET_cycle_facets( new_model, &facet_id );
while ( facet_id != UF_FACET_NULL_FACET_ID )
{
for ( edge = 0; edge < 3; edge++ )
{
UF_FACET_ask_adjacent_facet( new_model,
facet_id,
edge,
&adjacent_facets[edge],
&edge_in_adjacent_facet );
}
printf( "facet index: %d\n", facet_id );

printf( "\tadjacent_facets: [%d,%d,%d]\n",
adjacent_facets[0],
adjacent_facets[1],
adjacent_facets[2] );
UF_FACET_cycle_facets( new_model, &facet_id );
}
UF_FACET_is_model_convex( new_model, &model_convexity );
printf( "Model %s convex\n",
(model_convexity) ? "IS" : "IS NOT" );
/*
Now create a facet topology containing some concave
edges, to get this delete the first facet in the tetrahedron
and replace it with three facets the shared vertex of which
is towards the top vertex of the tetrahedron.
*/
UF_FACET_del_facet_from_model( new_model, facets[0] );
facet_vertices[0][0] = 0.060;
facet_vertices[0][1] = 0.0;
facet_vertices[0][2] = 0.0;
facet_vertices[1][0] = 0.0;
facet_vertices[1][1] = 0.0;
facet_vertices[1][2] = 0.0;
facet_vertices[2][0] = 0.02;
facet_vertices[2][1] = 0.02;
facet_vertices[2][2] = 0.01;
adjacencies[0] = facets[1];
adjacencies[1] = UF_FACET_NULL_FACET_ID;
adjacencies[2] = UF_FACET_NULL_FACET_ID;
UF_FACET_add_facet_to_model( new_model,
3,
facet_vertices,
NULL,
adjacencies,
facets+5 );
facet_vertices[0][0] = 0.03;
facet_vertices[0][1] = 0.05;
facet_vertices[0][2] = 0.0;
facet_vertices[1][0] = 0.060;
facet_vertices[1][1] = 0.0;
facet_vertices[1][2] = 0.0;
facet_vertices[2][0] = 0.02;
facet_vertices[2][1] = 0.02;
facet_vertices[2][2] = 0.01;
adjacencies[0] = facets[2];
adjacencies[1] = facets[5];
adjacencies[2] = UF_FACET_NULL_FACET_ID;
UF_FACET_add_facet_to_model( new_model,
3,
facet_vertices,
NULL,
adjacencies,
facets+6 );
facet_vertices[0][0] = 0.0;
facet_vertices[0][1] = 0.0;
facet_vertices[0][2] = 0.0;

facet_vertices[1][0] = 0.03;
facet_vertices[1][1] = 0.05;
facet_vertices[1][2] = 0.0;
facet_vertices[2][0] = 0.02;
facet_vertices[2][1] = 0.02;
facet_vertices[2][2] = 0.01;
adjacencies[0] = facets[3];
adjacencies[1] = facets[6];
adjacencies[2] = facets[5];
UF_FACET_add_facet_to_model( new_model,
3,
facet_vertices,
NULL,
adjacencies,
facets+7 );
UF_FACET_model_edits_done( new_model );
/*
Now look at the edge convexity again.
*/
printf( "Edge convexity for %u\n", new_model );
facet_id = UF_FACET_NULL_FACET_ID;
UF_FACET_cycle_facets( new_model, &facet_id );
while ( facet_id != UF_FACET_NULL_FACET_ID )
{
int verts_in_facet;
UF_FACET_ask_num_verts_in_facet( new_model,
facet_id,
&verts_in_facet );
/*
For each vertex print the vertex coordinates and the
vertex normal.
*/
UF_FACET_ask_vertices_of_facet( new_model,
facet_id,
&verts_in_facet,
facet_vertices );
UF_FACET_ask_normals_of_facet( new_model,
facet_id,
&verts_in_facet,
facet_normals );
for ( i=0 ; i < verts_in_facet ; i++ )
{
printf( " Vertex %d: (%g, %g, %g)\n",
i, facet_vertices[i][0],
facet_vertices[i][1],
facet_vertices[i][2] );
printf( " Normal %d (%g, %g, %g)\n",
i, facet_normals[i][0],
facet_normals[i][1],
facet_normals[i][2] );
}
for ( i=0 ; i < verts_in_facet ; i++ )
{
int convexity;
UF_FACET_ask_edge_convexity( new_model,
facet_id,
i,
&convexity );
printf( " Facet %d: Edge %d: %s\n", facet_id, i,
(convexity == UF_FACET_IS_CONVEX) ?
"IS CONVEX" :
(convexity == UF_FACET_IS_CONCAVE) ?
"IS CONCAVE" :
"CONVEXITY IS NOT DETERMINED"
);
/*
Now check that the convexity of the corresponding
edge in the adjacent facet is consistent.
*/
{
int adjacent_facet_id;
int adj_convexity;
UF_FACET_ask_adjacent_facet( new_model,
facet_id,
i,
&adjacent_facet_id,
&edge_in_adjacent_facet
);

UF_FACET_ask_edge_convexity( new_model,
adjacent_facet_id,
edge_in_adjacent_facet,
&adj_convexity );
if ( convexity != adj_convexity )
{
printf( " **ERR: Edge convexity wrong\n" );
}
}
}
UF_FACET_cycle_facets( new_model, &facet_id );
}
UF_FACET_ask_n_facets_in_model(new_model, &num_facets_in_model);
printf( "There are %d facets in the final model\n",
num_facets_in_model );
UF_FACET_is_model_convex( new_model, &model_convexity );
printf( "Model %s convex\n",
(model_convexity) ? "IS" : "IS NOT" );
return 0;
}



[/quote]

0

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