点击查看详细介绍

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

misnn 7年前 619 0

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


函数结构:
UF_STD_import_vrml_file
(
char * filename,
UF_STD_vrml_params_p_t parameters,
int * num_errors,
int * num_warnings,
int * n_topologies,
tag_p_t * topologies
)

函数说明:
进口VRML按照指定的文件到工作的一部分参数。

函数参数:
第1个参数为输入:
输入char * 字符类型的参数,参数的变量格式为filename,文件名称输入

第2个参数为输入:
parameters代表参数变量,UF_STD_vrml_params_p_t 为输入参数类型,一个导入参数

第3个参数为输出:
输出int * 整数型的参数,参数的变量格式为num_errors,发现错误数,同时解析

第4个参数为输出:
输出int * 整数型的参数,参数的变量格式为num_warnings,发现警告数,而解析

第5个参数为输出:
输出int * 整数型的参数,参数的变量格式为n_topologies,创建新的方面拓扑数

第6个参数为输出:
topologies代表参数变量,tag_p_t * 为输出参数类型,的创建面拓扑的标签阵列。必须由调用者释放。

UF_STD_import_vrml_file函数实例代码演示:
[quote]
#include <stdio.h>
#include <uf.h>
#include <uf_std.h>
#include <uf_part.h>
#include <uf_modl.h>
#define VRML_FILENAME "vrml_test.wrl"
/*-------------------------------------------------------------*/
static int vrml_example ( void );
static int create_part ( logical populate_ug_file );
/*-------------------------------------------------------------*/
extern void ufusr( char *param, int *retcod, int param_len )
{
UF_initialize();
*retcod = vrml_example();
UF_terminate();
}
/*-------------------------------------------------------------*/
static int vrml_example( void )
{
UF_STD_vrml_params_t params;
char error_msg[133];
tag_p_t topologies;
int errors;
int warnings;
int n_topologies;
int ifail;
int indx;
ifail = create_part ( TRUE );
if (ifail == 0)
{
ifail = create_part ( FALSE );
if (ifail == 0)
{
ifail = UF_STD_set_default_vrml_params ( ¶ms );
if (ifail == 0)
{
params.hide_smooth_edges = FALSE;
params.unit_size = UF_STD_UNITS_MM;
ifail = UF_STD_import_vrml_file( VRML_FILENAME,
¶ms,
&errors,
&warnings,
&n_topologies,
&topologies );
if ( n_topologies > 0 )
{
printf("Topology tags:\n");
for (indx = 0; indx < n_topologies; indx++)
printf("%u ",topologies[indx]);
printf("\n");
}
UF_free ( topologies );
}
}
}
if ( ifail != 0 )
{
UF_get_fail_message( ifail, error_msg );
printf( "ERROR: %s\n", error_msg );
}
return 0;
}
/*-------------------------------------------------------------*/
/* Create a UG part file. If populate_ug_file is set TRUE, the
file is populated with a cylinder and two spheres. As well,
a VRML file (VRML_FILENAME) is generated from the part file.
*/
static int create_part (
logical populate_ug_file)
{
double origin[3] = { 0.0, -1.0, 0.0 };
double direction[3] = { 0.0, 1.0, 0.0 };
tag_t part;
tag_t primitive_obj_id;
int units = 2;
int ifail;
if (populate_ug_file == TRUE)
ifail = UF_PART_new("ug_generated_file", units, &part);
else
ifail = UF_PART_new("vrml_imported_file", units, &part);
if (ifail == 0 && populate_ug_file == TRUE)
{
ifail = UF_MODL_create_cyl1( UF_NULLSIGN,
origin,
"2.0",
"1.0",
direction,
&primitive_obj_id );
if (ifail == 0)
{
origin[1] = origin[1] - 0.25;
ifail = UF_MODL_create_sphere1( UF_NULLSIGN,
origin,
"1.5",
&primitive_obj_id );
if (ifail == 0)
{
origin[1] = origin[1] + 2.5;
ifail = UF_MODL_create_sphere1 ( UF_NULLSIGN,
origin,
"1.5",
&primitive_obj_id
);
if (ifail == 0)
ifail = UF_STD_create_vrml_file (
VRML_FILENAME, 1.0, UF_STD_OUTPUT_MATERIALS );
}
}
}
return ifail;
}


[/quote]

0

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