点击查看详细介绍

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

misnn 8年前 738 0

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


函数结构:
UF_FACET_add_facet_to_model
(
tag_t model,
int num_vertices,
double vertices [ ] [ 3 ],
double normals [ ] [ 3 ],
int adjacent_facet_ids [ ],
int * new_facet_id
)

函数说明:
添加一个面一个面的模型。在“adjacent_facet_ids”阵包含在新的小面的每个边缘的面编号。值UF_FACET_NULL_FACET_ID意味着新的即边缘刻面不进行邻近任何现有的方面。 注意使相邻小面必须包含对应的边缘到,在新的面,并且如果它们不那么错误是返回,不会创建任何方面。此功能可以返回错误代码UF_FACET_err_zero_facets_produced时提供的多边形与相邻的重复顶点。

函数参数:
第1个参数为输入:
model代表参数变量,tag_t 为输入参数类型,模型以该水龙头要被添加

第2个参数为输入:
输入int 整数型的参数,参数的变量格式为num_vertices,顶点中的新的方面的数量

第3个参数为输入:
输入double 双精度类型的参数,参数的变量格式为vertices [ ] [ 3 ],新面的顶点。三个这种说法双重的每个元素代表一个三维空间(X,Y,Z)位置。

第4个参数为输入:
输入double 双精度类型的参数,参数的变量格式为normals [ ] [ 3 ],顶点法线新方面。如果此被指定为NULL,则小面正常将被计算并用于所有的新面顶点的三个这种说法双重的每个元素表示一个3维空间(X,Y,Z)的法线向量。

第5个参数为输入:
输入int 整数型的参数,参数的变量格式为adjacent_facet_ids [ ],与其相邻的在其每个边缘的新的方面的事实。如果没有相邻小面的边缘,然后UF_FACET_NULL_FACET_ID应该为该边缘被指定。

第6个参数为输出:
输出int * 整数型的参数,参数的变量格式为new_facet_id,新面创建的ID

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