iCAx开思工具箱

标题: 【求助】各位帮我看看这个程序吧,急死人了! [打印本页]

作者: suye007    时间: 2004-6-26 17:08
标题: 【求助】各位帮我看看这个程序吧,急死人了!
我想使用UIStlyer建立了一个按钮,点击按钮后出现selection class的对话框,然后使用鼠标选择work part中的几条样条曲线,OK之后调用through curves函数生成曲面,可程序编译链接都没有错误,就是生成不了曲面,各位大大帮帮忙看看了,我调了两天也不知问题出在哪里了
其实就是使用了两个函数:UF_UI_select_with_class_dialog( );UF_MODL_create_thru_curves ( );可能是我给函数的赋值不争取吧?不过第一个函数调用我想没有问题,因为selection class的对话框是可以显示出来的。下面就是我使用uistlyer建立的按钮的回调函数代码:
int CHANGE_action_0_act_cb ( int dialog_id,
              void * client_data,
              UF_STYLER_item_value_type_p_t callback_data)
{
   char cue[] = "Select Curves";
     char title[] = "SELECTION";
     int response, count;
     tag_p_t objects;
  
   //B_surface的各项参数
   UF_STRING_t  s_section,s_spine;
  
   int patch=2;//B-spline
  
   int alignment=1;//Parameter alignment
  
   double value[ 6 ]={0,0,0,0,0,0};//Data for alignment method
  
   int vdegree;//Degree of surface in V direction;0 < vdegree <= (s_section.num-1)
  
   int vstatus=0;//Open Surface
  
   int body_type=0;//Sheet
  
   UF_FEATURE_SIGN  boolean=UF_NULLSIGN;//create new target solid
  
     double  tol[ 3 ]={0.001,0.001,0.001};//Tolerances
  
   tag_t  c_face_id[ 2 ];//[0] = first section string;[1] = last section string
  
     int  c_flag[ 2 ]={0,0};
  
   tag_t body_obj_id=NULL_TAG;
  
      /* Make sure User Function is available. */   
if(UF_UI_select_with_class_dialog(
           cue, title, UF_UI_SEL_SCOPE_WORK_PART,
           NULL, NULL, &response, &count, &objects) == 0)
     {
     UF_MODL_create_string_list(count,count,[$s_section)]
     s_section.num=count;
     for(int j=0;j<count;j++)
     {
       s_section.string[j]=1;
       s_section.dir[j]=1;
       s_section.id[j]=objects[j];
     }
  
     s_spine.num=0;
  
     c_face_id[0]=objects[0];
     c_face_id[1]=objects[count-1];
  
     if(count<=1)
       return -1;
     else if(count==2)
       vdegree=1;
     else if(count==3)
       vdegree=2;
     else
       vdegree=3;
           
          if (response == UF_UI_OK)
          {
              for (i=0; i<count; i++)
              {
                  
                  UF_DISP_set_highlight(objects, 0);
              }
        UF_MODL_create_thru_curves (
                                         &s_section,  
                                         &s_spine,  
                                         &patch,  
                                         &alignment,  
                                         value,  
                                         &vdegree,  
                                         &vstatus,  
                                         &body_type,  
                                         boolean,  
                                         tol,  
                                         c_face_id,  
                                         c_flag,  
                                         [$body_obj_id )]
        UF_MODL_free_string_list([$s_section)]
              UF_free(objects);
          }
     }
  
      UF_terminate ();
  
}
作者: 深夜摔键盘    时间: 2004-6-27 00:37
   s_section->num=count; ----------------从这里开始出错!内存越界。
      for(int j=0;j<count;j++)  
      {  
        s_section->string[j]=26;  
        s_section->dir[j]=1;  
        s_section->id[j]=objects[j];  
      }  
            
      c_face_id[ 0 ]=objects[0];  
  
  s_section应该是一个结构体指针,这个指针只做了声明,没有为其开辟内存空间,所以 s_section->num是没有意义的!其他错误没看出来
作者: suye007    时间: 2004-7-1 12:00
感谢深夜摔键盘老兄:
的确是有这个错误!不过还是没有结果。我跟踪了一下,估计还是UF_MODL_create_thru_curves ( )这个函数赋值有问题。




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