|
马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
double max(double ox)
{
double xc;
xc = ceil(ox)-ox;
if(xc>0)
{
return ceil(ox);
}
else if(xc=-0)
{
printf("%f",ox);
return ox;
}
else
{
return ox;
}
}
double min(double sx)
{
double xf;
xf = floor(sx)-sx;
if(xf<0)
{
return floor(sx);
}
else if(xf=-0)
{
printf("%f",sx);
return sx;
}
else
{
return sx;
}
}
static int UF_UI_sel_init(UF_UI_selection_p_t select, void *user_data)
{
UF_UI_mask_t mask_triples[]={UF_solid_type,0,0};
if(UF_CALL(UF_UI_set_sel_mask(select,UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC,1,mask_triples))==0)
{
return(UF_UI_SEL_SUCCESS);
}
else
{
return(UF_UI_SEL_FAILURE);
}
}
static void do_ugopen_api()
{
tag_t object,view;
tag_t csys=NULL;
char cue[] = "select object to get the dimensions";
int scope = UF_UI_SEL_SCOPE_WORK_PART;
int response;
double x0,y0,z0,x1,y1,z1;
double cursor[3];
double min_corner[3];
double directions[3][3];
double distances[3];
UF_UI_select_with_single_dialog(cue,"select the object",scope, UF_UI_sel_init, NULL, &response, &object, cursor, &view );
if (response == UF_UI_OBJECT_SELECTED || response == UF_UI_OBJECT_SELECTED_BY_NAME)
{
UF_DISP_set_highlight(object,1);//顯示高亮
UF_MODL_ask_bounding_box_exact(object,csys,min_corner,directions,distances);
//將最大點設為向上取整
x1 = max(distances[0]);
y1 = max(distances[1]);
z1 = max(distances[2]);
char msg3[80];
sprintf(msg3,"dis:\n (x = %.3f,y = %.3f,z = %.3f\n)",distances[0],distances[1],distances[2]);
uc1601(msg3,1);
//將最小點設為向下取整
x0 = min(min_corner[0]);
y0 = min(min_corner[1]);
z0 = min(min_corner[2]);
char msg4[80];
sprintf(msg4,"org_min:\n (x = %.3f,y = %.3f,z = %.3f\n)",min_corner[0],min_corner[1],min_corner[2]);
uc1601(msg4,1);
char msg8[80];
sprintf(msg8,"now_min:\n (x = %.3f,y = %.3f,z = %.3f\n)",x1,y1,z1);
uc1601(msg8,1);
char msg9[80];
sprintf(msg9,"floor min:\n (x = %.3f,y = %.3f,z = %.3f\n)",x0,y0,z0);
uc1601(msg9,1);
UF_DISP_set_highlight(object,0);//高亮退出
UF_FEATURE_SIGN sign=UF_NULLSIGN;
double corner_pt[3]={x0,y0,z0};
char len[80],wid[80],hei[80];
sprintf_s(len,"%f",x1);
sprintf_s(wid,"%f",y1);
sprintf_s(hei,"%f",z1);
char * edge_len[3]={len,wid,hei};
tag_t blkid=NULL_TAG;
UF_MODL_create_block1(sign,corner_pt,edge_len,&blkid);
}
}
extern DllExport void ufsta( char *param, int *returnCode, int rlen )
{
/* Initialize the API environment */
if( UF_CALL(UF_initialize()) )
{
/* Failed to initialize */
return;
}
/* TODO: Add your application code here */
do_ugopen_api();
/* Terminate the API environment */
UF_CALL(UF_terminate());
}
extern int ufusr_ask_unload( void )
{
return( UF_UNLOAD_IMMEDIATELY );
}
我偵測一個最小值x=0的物件
但是最小點總是變成x=-1
請問究竟是怎麼回事
|
|