|
使用acr_coords->radius进行相关操作会提示如下错误
代码如下
#include <uf.h>
#include <uf_exit.h>
#include <uf_ui.h>
#include <uf_disp.h>
#include <uf_curve.h>
#include <uf_csys.h>
#include <uf_obj.h>
#include <uf_modl.h>
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
# include <strstream>
# include <iostream>
using std::ostrstream;
using std::endl;
using std::ends;
using std::cerr;
#else
# include <strstream.h>
# include <iostream.h>
#endif
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
static int report_error( char *file, int line, char *call, int irc)
{
if (irc)
{
char
err[133],
messg[300];
UF_get_fail_message(irc, err);
sprintf(messg, "\n%s\nerror %d at line %d in %s\n%s",
err, irc, line, file, call);
printf("%s\n", messg);
strcpy(&messg[129], "...");
uc1601(messg, TRUE); /* Internal only - remove for external */
}
return(irc);
}
//设置选择的实体类型
static int init_proc( UF_UI_selection_p_t select, void *user_data )
{
int errorCode = 0;
int num_triples = 1; //选择类型 数量
UF_UI_mask_t mask_triples[]={UF_face_type,0,0,}; //定义选择类型
errorCode = UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC,num_triples, mask_triples);
if( errorCode == 0)
{
return UF_UI_SEL_SUCCESS;
}
else
{
return UF_UI_SEL_FAILURE;
}
}
char *IntToChar(int a) ; //这两个函数已定义,功能将int 和 double 转换为char
char *DoubleToChar(double a) ;
static void do_it(void)
{
char *message="提示!请选择表面。";
char *title="请选择表面";
int scope=UF_UI_SEL_SCOPE_WORK_PART;//UF_UI_SEL_SCOPE_NO_CHANGE
int response;
tag_t object_tag; //选择面的tag
tag_t point;
double cursor[3]={0.0};
tag_t view=NULL_TAG;
UF_UI_lock_ug_access (UF_UI_FROM_CUSTOM);//加锁
UF_UI_select_with_single_dialog(message,title,scope,init_proc,NULL,&response,&object_tag,cursor,&view); //选择框
UF_DISP_set_highlight(object_tag,0); //1高亮显示 0不高亮显示
UF_UI_unlock_ug_access (UF_UI_FROM_CUSTOM);//解锁
if (response==UF_UI_OBJECT_SELECTED)
{
//获得面最外边缘
int n=0;
int loops_count=0; // 封闭循环曲线数量
tag_t edge_id[2000];
uf_loop_p_t loops_list=NULL_TAG; // 边的链表
UF_CURVE_arc_p_t acr_coords= 0;
UF_MODL_ask_face_loops(object_tag,&loops_list ); //查询面上边的链表loops_list
uc1601( IntToChar(object_tag),1 ); //
UF_MODL_ask_loop_list_count(loops_list,&loops_count);//查询边的数量loops_count
uc1601( IntToChar(loops_count), 1 ); //
for (int l_i=0; l_i<loops_count; l_i++)
{
int loops_type=0; //类型
uf_list_p_t edge_list=NULL_TAG; //边缘菜单指针ID
UF_MODL_ask_loop_list_item(loops_list,l_i,&loops_type,&edge_list); // 输出loops_type及edge_list
uc1601( IntToChar(loops_type), 1 ); //
if ( 2 == loops_type ) //边界=1, 洞=2, 其他=3
{
uc1601( "有hole边界哦!", 1 ); //
int edge_count=0; //边缘数量
UF_MODL_ask_list_count ( edge_list, &edge_count );
uc1601( "接下来是edge_count!", 1 );
uc1601( IntToChar(edge_count), 1 );
for(int edge_i=0; edge_i<edge_count;edge_i++)
{
n=n+1;
//输出边的tag edge_id
UF_MODL_ask_list_item( edge_list,edge_i,&edge_id[n-1]); //n-1 是因为 数组是从0开始的
uc1601( IntToChar(edge_id[n-1]), 1 );
UF_CURVE_ask_arc_data( edge_id[n-1],acr_coords );
UF_DISP_set_highlight (edge_id[n-1],1);
uc1601( "接下来是radius!", 1 );
uc1601( DoubleToChar(acr_coords->radius), 1 );
if ( fabs( acr_coords->radius - 5.0 ) < 1.0)
{
uc1601( "到底出什么错了呢?!", 1 );
}
//从输入边缘提取曲线并返回该曲线的标识符
UF_MODL_create_curve_from_edge(edge_id[n-1],&edge_id[n-1]);
}
}
}
uc1601( "222?", 1 ); //在这之前有个2
if (n!=0)
{
//char msg[32]="";
//sprintf(msg, "%d",n);
uc1601( "接下来是n!", 1 );
uc1601( IntToChar(n),1 );
}
else
{
uc1601("UGapi提示!你选择的面没有发现边缘(比如:首尾相连的圆柱面不返回边缘)",1);
}
}
// errorCode = UF_terminate();
}
// return;
//}
void ufusr(char *param, int *retcode, int paramLen)
{
if (UF_CALL(UF_initialize())) return;
do_it();
UF_terminate();
}
int ufusr_ask_unload( void )
{
return (UF_UNLOAD_IMMEDIATELY);
}
|
|