iCAx开思工具箱

标题: 【求助】UF_MODL_ask_extrusion函数的使用问题,救急!!! [打印本页]

作者: dongyoudong    时间: 2003-8-24 13:54
标题: 【求助】UF_MODL_ask_extrusion函数的使用问题,救急!!!
利用该函数查询拉伸的参数,其中许多参数需要初始化和释放操作,请教如何正确的初始化和释放操作。
函数的说明如下:
extern UFUNEXPORT int UF_MODL_ask_extrusion(
tag_t feature_obj_id ,/* <I>
                      Object tag for the extruded feature
                      */
int* num_objects ,/* <O>
                  Number of curves
                  */
tag_t** objects ,/* <OF>
                &nbspointer to an array containing the tags of the extruded curves.
                 This array must be freed by calling UF_free.
                 */
UF_MODL_SWEEP_TRIM_object_p_t* trim_ptr ,/* <OF>
                                        &nbspointer to structure for trimming data.
                                         This pointer may be returned as NULL,
                                         if trimming objects are not used.
                                         NEEDS A FREE ROUTINE
                                         */
char** taper_angle ,/* <OF>
                    Taper angle.  This must be freed by calling UF_free.
                    */
char* limits[2] ,/* <OF>
                 Limits of extrusion.  Each element of this array must be
                 freed by calling UF_free.
                 */
char* offsets[2] ,/* <OF>
                  Offsets for open strings.  Each element of this array must be
                 freed by calling UF_free.
                  */
double region_point[3] ,/* <O>
                       &nbspoint on region desired.
                        */
logical* region_specified ,/* <O>
                           True or False for region desired.
                           */
logical* solid_creation ,/* <O>
                         TRUE = a solid body.
                         */
double direction[3]  /* <O>
                     Extrusion direction
                     */
);
作者: mazhiguo    时间: 2003-8-24 19:51
函数参数进行初始化也就是在使用函数前,声明或定义变量。凡是注释中带有<OF>,使用完毕需要用UF_free()函数进行释放所占存储空间。函数的参数是被释放的参数。具体可参考清华出版的UG OPEN/API或着UG软件自带的DOCUMENT。
作者: dongyoudong    时间: 2003-8-26 14:40
但根据UGAPI说明,有的函数参数的释放并不是用UF_free,如该函数中的UF_MODL_SWEEP_TRIM_object_p_t* trim_ptr在说明中要求用 NEEDS A FREE ROUTINE 来进行释放,而且在参数的设置和释放并不是说明中的那样简单,在许多情况下对函数的执行有很大的影响,在程序中是查不出错误,但在UG下运行就不行了。
  
请各位热心的多多指教。
作者: liberty000    时间: 2003-8-26 19:24
我认为这个函数比较简单,在工程图中变量的初始化和定义更复杂。
作者: dongyoudong    时间: 2003-8-27 09:38
如果是静态的调用该函数是较简单的,但在动态实时的调用时就不一样了,会导致函数执行后UG关闭或死循环。现在不知如何的解决,请各位指教。
作者: dongyoudong    时间: 2003-8-27 09:41
现在版上人气不旺,好象几位版主也不太露面了。大家一定要救急。
作者: liberty000    时间: 2003-8-27 14:04
你把你的源代码发上来吧,这样才能有的放矢。
作者: dongyoudong    时间: 2003-8-28 09:02
void  my_tag_event_cb(UF_TAG_event_t re, tag_t tag,void *closure)
{
    
    /* Note that this function needs to call UF_initialize()
       This requirement was added in V16.
    */
    if (UF_CALL(UF_initialize())) return;
    GetNewCreateFeature();
 UF_terminate();
}//该函数由一回调函数调用
  
void GetNewCreateFeature()
{
  
  int index=0;
  int irc=0,irc2=0;
  int enttype;
  tag_t feat1=0;  
  
  tag_t feat3;
  char *feat_type;
  enttype = UF_feature_type;
  
  UF_MODL_edge_blend_data_p_t filletdata;
         filletdata=new UF_MODL_edge_blend_data_s;
  /*int num_objects=0;
  tag_t* objects[255];
  UF_MODL_SWEEP_TRIM_object_p_t trim_ptr;
  trim_ptr=new UF_MODL_SWEEP_TRIM_object_s;
  char* taper_angle[1];
  char* limits[2];
  char* offsets[2];
  double region_point[3];
  logical region_specified;
  logical solid_creation;
  double direction[3];*/
  
  do
  {
    irc=UF_OBJ_cycle_objs_in_part(part_tag ,enttype , [$feat1)]
    if(feat1 == NULL_TAG) break;
  feat3=feat1;
  ++index;
    
  }while(feat1);
   if(count!=index)
  {
  
  
  irc=UF_MODL_ask_feat_type(feat3,[$feat_type)]
  
  if (irc==0)
  {
      
    /*if (strcmp(feat_type,"SWP104")==0)
    {
      
      
      
        irc2=UF_MODL_ask_extrusion(feat3,&num_objects, objects, &trim_ptr,  
        taper_angle, limits,  offsets, region_point, [$region_specified,&solid_creation,direction)]
      
        if (irc2==0)
        {
          uc1601("irc2=0", TRUE);
          UF_UI_open_listing_window();
          sprintf(buffer,"\n %d    %d    %s\n",irc2,num_objects,feat_type );
          UF_UI_write_listing_window(buffer);
          count=index;
          //UF_UI_close_listing_window();
          uc1601("增加了新特征", TRUE);
        }
      
      uc1601(limits[0], TRUE);
      uc1601(limits[1], TRUE);
      delete(trim_ptr);
      
    }*/
     
  
    if (strcmp(feat_type,"BLEND")==0)
    {
             uc1601("irc1=0", TRUE);
  
      irc2=UF_MODL_ask_edge_blend (feat3, filletdata );
      if (irc2==0) {
  
    uc1601("irc2=0", TRUE);
  
        int irc;       
  UF_MODL_blend_edge_p_t edgetagdata;
  tag_t edgetag;
  char *blendrad;
  double p1[3]={0.0, 0.0, 0.0};
  UF_MODL_blend_edge_p_t blendedge_data;
  char buffer[UF_UI_MAX_STRING_LEN+1];
  blendedge_data=filletdata->edge_data;
  UF_CURVE_line_p_t line_coords;  
  line_coords=new UF_CURVE_line_s;
  edgetagdata=filletdata->edge_data;
  edgetag=edgetagdata->edge;
  blendrad=filletdata->blend_radius;
  
  irc=UF_CURVE_ask_line_data (edgetag,line_coords );//要得到edge的参数需要用line函数,直接用边不行。
  
    
//特征数和计数的次数相等语句的放置位置比较重要,原因待查。
  count=index;
  
  p1[0]=(line_coords->start_point[0]+line_coords->end_point[0])/2.0;
  p1[1]=(line_coords->start_point[1]+line_coords->end_point[1])/2.0;
  p1[2]=(line_coords->start_point[2]+line_coords->end_point[2])/2.0;
  
  UF_UI_open_listing_window();
  sprintf(buffer, "\n  %d  The X value of P1 is: %f %f %f  feature is of type   %s  %u\n",
             irc,p1[0],p1[1],p1[2],filletdata->blend_radius,edgetag);//%dfilletdata->number_edges %s%d    %d,edgetag,edgetagdata->number_points);
  UF_UI_write_listing_window(buffer);
  
      
      }
    
    }
  UF_free(feat_type);
  
  }
  
   }
  UF_free(filletdata);//该函数的放置位置很难确定
   //uc1601("irc2=0", TRUE);
}
  
因为试来试去,所以有点乱,代码中有两个,一个是拉伸(拉伸被去除了),另一个是倒圆。




欢迎光临 iCAx开思工具箱 (https://t.icax.org/) Powered by Discuz! X3.3