我创建一个圆柱体想用UF_FACET_facet_solid离散,在UG里运行的时候不行啊
我创建一个圆柱体想用UF_FACET_facet_solid离散,在UG里运行的时候不行啊,图里那样UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN,origin1,height1,diam1,direction1,&cyl_obj_id1));
UF_CALL(UF_MODL_ask_feat_body(cyl_obj_id1,&cylinder_obj_id1));
UF_FACET_INIT_PARAMETERS(parameters);
UF_FACET_ask_default_parameters(parameters);//参数查询
UF_FACET_facet_solid(cylinder_obj_id1,parameters,&facet_model1);//离散实体
UF_FACET_cycle_facets(facet_model1,&facet_id);//遍历离散的实体并获取其顶点
while ( facet_id!= UF_FACET_NULL_FACET_ID )
{
UF_FACET_ask_num_verts_in_facet(facet_model1, facet_id,&num_vertices_in_facet);
UF_FACET_ask_vertices_of_facet(facet_model1, facet_id,&num_verts,facet_vertices);
for (i=0;i<num_vertices_in_facet;i++ )
{
UF_UI_open_listing_window();
sprintf(msg," %g, %g, %g\n", facet_vertices, facet_vertices, facet_vertices );
UF_UI_write_listing_window(msg);
}
UF_FACET_cycle_facets(facet_model1,&facet_id);
}
我创建完圆柱体只要加一句UF_FACET函数就在UG里运行不了
帮助文档有例子,
/* This example is referenced for several of the other UF_FACET
functions.
*/
#include <stdio.h>
#include <uf.h>
#include <uf_modl.h>
#include <uf_assem.h>
#include <uf_facet.h>
static int example1( tag_t *new_faceted_model);
/*ARGSUSED*/
extern void ufusr( char *param, int *retcod, int param_len )
{
tag_t faceted_model;
UF_initialize();
*retcod = example1(&faceted_model);
UF_terminate();
}
/*--------------------------------------------------------------*/
static int example1( tag_t * new_faceted_model )
{
int ifail;
tag_t part_tag;
double corner_point;
char * edge_lengths[] = { "10", "30", "40" };
tag_t block_feature_tag;
tag_t block_tag;
tag_t faceted_model;
logical up_to_date = true;
tag_t blend_feature;
uf_list_p_tedge_list = NULL;
tag_t tag_of_solid;
int i;
tag_t * facet_models;
int n_facet_models;
UF_FACET_parameters_t faceting_params;
*new_faceted_model = NULL_TAG;
/*
First create a part in which we will initially create a
block.
*/
ifail = UF_PART_new( "uf_facet_exp1_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 );
corner_point = 0.0;
corner_point = 0.0;
corner_point = 0.0;
UF_MODL_create_block1( UF_NULLSIGN,
corner_point,
edge_lengths,
&block_feature_tag );
UF_MODL_ask_feat_body( block_feature_tag, &block_tag );
UF_FACET_INIT_PARAMETERS( &faceting_params);
UF_FACET_ask_default_parameters( &faceting_params) ;
UF_FACET_facet_solid( block_tag,
&faceting_params,
&faceted_model );
if ( faceted_model != NULL_TAG )
{
UF_FACET_ask_solid_of_model( faceted_model, &tag_of_solid );
if ( block_tag != tag_of_solid )
{
printf( "**ERR: Failed find solid from facet model\n" );
return 1;
}
UF_FACET_ask_models_of_solid( block_tag,
&n_facet_models,
&facet_models );
/*
Just check that the association between the solid and
the new faceted model has been established.
*/
for ( i=0 ; i < n_facet_models ; i++ )
{
if ( facet_models == faceted_model )
{
printf( "Faceted model is attached to solid\n" );
}
}
UF_free( facet_models );
/*
Now blend all of the edges of the block.
*/
UF_MODL_ask_body_edges( block_tag, &edge_list );
UF_MODL_create_blend( "2.0", edge_list,
0, 0, 0, 0.0,
&blend_feature );
UF_MODL_delete_list( &edge_list );
UF_MODL_update();
ifail = UF_FACET_is_model_up_to_date( faceted_model,
&up_to_date );
if ( up_to_date )
{
printf( "**ERR: Faceted model is up to date\n" );
return 1;
}
ifail = UF_FACET_ask_model_parameters( faceted_model,
&faceting_params );
/*
Set the number of sides for facets to four and use that
when refaceting the solid.
*/
faceting_params.max_facet_edges = 4;
ifail = UF_FACET_update_model( faceted_model,
&faceting_params );
if ( ifail != 0 )
{
printf( "**ERR: Failed to refacet model\n" );
return 1;
}
ifail = UF_FACET_is_model_up_to_date( faceted_model,
&up_to_date );
if (!up_to_date)
{
printf( "**ERR: Model is not up to date\n" );
return 1;
}
/*
Finally, disassociate the faceted model from
the generating solid.
*/
UF_FACET_disassoc_from_solid( faceted_model );
*new_faceted_model = faceted_model;
}
else
{
return 1;
}
return 0;
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}
蓝摩羯 发表于 2020-3-11 09:11
帮助文档有例子,
/* This example is referenced for several of the other UF_FACET
functions.
UFUN帮助文档有例子还是?
页:
[1]