点击查看详细介绍

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

misnn 9年前 802 0

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


函数结构:
UF_FACET_model_edits_done
(
tag_t model
)

函数说明:
指示编辑到指定方位模式现已完成。这使得该系统删除该临时数据结构,它创建以方便编辑。这个函数应该经过被称为程序已完成编辑操作的序列(除在一个面模型创建和更新)。注意,如果该例程不叫然后无妨的结果,比其它该方案将消耗更多的内存比是必要的。

函数参数:
第1个参数为输入:
model代表参数变量,tag_t 为输入参数类型,我们已完成编辑模式。

UF_FACET_model_edits_done函数实例代码演示:
这个示例程序创建一个四面体的面模型。 它然后检查模型中的边缘的邻接和凸。最后,它会从四面体一个方面,并增加了另一三个方面的顶点,其中在四面体的内部向上推使得有在所得模型三凹边。 它即可查询并打印所有模型边缘的凸度。
[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)
请登录后发表新帖