|
马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
以前连求曲面面积的函数都不知道,现在知道了,是UF_MODL_ask_mass_props_3d,看了那个例子后可以求一个实体的面积了,但是我想求曲面得面积,可怎么也做不到,问题到底出在哪里呢?请求高手指教,下面是我在例子的基础上写的程序,只做了一点点改动,但是结果却出现巨大差异。
extern "C" DllExport void ufusr( char *parm, int *returnCode, int rlen )
{int irc = 0;
char *message = "Select Object";
UF_UI_selection_options_t opts;
UF_UI_mask_t mask;
int response;
tag_t *object;
int unhighlight=0;
char buffer[133];
char error[133];
/* Initialize the API environment */
int errorCode = UF_initialize();
if ( 0 == errorCode )
{
/* TODO: Add your application code here */
opts.other_options = 0;
opts.reserved = NULL;
opts.num_mask_triples = 1;
opts.mask_triples = [$mask]
/* set up selectable type, subtype, solid type */
opts.mask_triples->object_type = UF_solid_type;
opts.mask_triples->object_subtype = UF_solid_face_subtype;
opts.mask_triples->solid_type = UF_UI_SEL_FEATURE_ANY_FACE;
/* set selection scope to be work part */
opts.scope = UF_UI_SEL_SCOPE_WORK_PART;
int type = 2;
int unit = 3;
int accuracy = 1;
int count = 0;
int i;
double acc_val[11] = {1,0,0,0,0,0,0,0,0,0,0};
double density = 1.0;
double massprop[47];
double massprop_stat[13];
irc = UF_UI_select_by_class(message,&opts,&response,
[$count,&object)]
/* if no error, print information about selected object */
if (!irc)
{UF_UI_open_listing_window();
sprintf(buffer,"response= %d, object tag= %d", response, object);
UF_UI_write_listing_window(buffer);
UF_MODL_ask_mass_props_3d(object,
count,
type,
unit,
density,
accuracy,
acc_val,
massprop,
massprop_stat);
for (i=0; i<47; i++)
{
sprintf(buffer,"[%d] = %f\n",i,massprop);
UF_UI_write_listing_window(buffer);
}
for(i=0;i<count;i++)
/* unhighlight selected object */
{UF_DISP_set_highlight(object,unhighlight);
}
UF_free(object);
}
else /* else get error message */
{
UF_get_fail_message(irc,error);
sprintf(buffer,"ERROR: %s\n",error);
UF_UI_write_listing_window(buffer);
}
/* Terminate the API environment */
errorCode = UF_terminate();
}
但是如果把opts.mask_triples->object_type = UF_solid_type;
opts.mask_triples->object_subtype = UF_solid_face_subtype;
opts.mask_triples->solid_type = UF_UI_SEL_FEATURE_ANY_FACE;进行一下变动就可以求实体的面积了
opts.mask_triples->object_type = UF_solid_type;
opts.mask_triples->object_subtype = 0;
opts.mask_triples->solid_type = UF_UI_SEL_FEATURE_BODY;
比较罗索,但是还是邀请高手们帮忙看一下,自己实在不知道怎么去改才可以。我的目的只想求某一个曲面得面积,而非实体的。先谢谢了! |
|