单边逃角工具源代码来了

  1     UF_initialize();
  2 
  3     double X1[3] = { 1.0,0.0,0.0 };
  4     double Y1[3] = { 0.0,1.0,0.0 };
  5     double mtx0[9];
  6     UF_MTX3_initialize(X1, Y1, mtx0);
  7     //创建矩阵
  8     tag_t Matrix0Tag = NULL_TAG;
  9     UF_CSYS_create_matrix(mtx0, &Matrix0Tag);
 10     //创建临时坐标系
 11     double P1[3] = { 0.0, 0.0, 0.0 };//直线起点
 12     tag_t Csys0Tag = NULL_TAG;
 13     UF_CSYS_create_temp_csys(P1, Matrix0Tag, &Csys0Tag);
 14 RES0:
 15     char sCue[] = "选择要逃角的面";
 16     char sTitle[] = "选择要逃角的面";
 17     int iScope = UF_UI_SEL_SCOPE_NO_CHANGE;
 18     int iResponse;
 19     tag_t tObject;
 20     tag_t tView;
 21     double adCursor[3];
 22     UF_UI_select_with_single_dialog(sCue, sTitle, iScope, init_face, NULL, &iResponse, &tObject, adCursor, &tView);
 23     if (iResponse == UF_UI_CANCEL || iResponse == UF_UI_BACK)
 24         return;
 25     else if(tObject)
 26     {
 27         tag_t body0Tag = NULL_TAG;
 28         int Type = 0;
 29         double Point[3];
 30         double Dir[3];
 31         double Box[6];
 32         double Radius[3];
 33         double RadData[3];
 34         int NormDir;
 35         UF_MODL_ask_face_data(tObject, &Type, Point, Dir, Box, Radius, RadData, &NormDir);
 36         UF_MODL_ask_face_body(tObject, &body0Tag);
 37         UF_DISP_set_highlight(tObject, 0);
 38 
 39         char sCue1[] = "选择相切边";
 40         char sTitle1[] = "选择相切边";
 41         int iScope1 = UF_UI_SEL_SCOPE_NO_CHANGE;
 42         int iResponse1;
 43         tag_t tObject1;
 44         tag_t tView1;
 45         double adCursor1[3];
 46     RES1:
 47         UF_UI_select_with_single_dialog(sCue1, sTitle1, iScope1, init_edge, NULL, &iResponse1, &tObject1, adCursor1, &tView1);
 48         if (iResponse1 == UF_UI_CANCEL || iResponse1 == UF_UI_BACK)
 49             return;
 50         UF_DISP_set_highlight(tObject1, 0);
 51 
 52         UF_EVAL_p_t evaluator;
 53         logical is_line = false;
 54         UF_EVAL_initialize(tObject1, &evaluator);
 55         UF_EVAL_is_line(evaluator, &is_line);
 56 
 57         if (is_line)
 58         {
 59             //uc1601("是直线", 1);
 60             UF_EVAL_line_t edges;
 61             UF_EVAL_ask_line(evaluator, &edges);
 62             //输入直径对话框
 63             int ijunk[2], resp, strings[] = { 290 };
 64             double djunk[] = { 20.0 };
 65             char menu[1][16] = { "逃角直径" }, user_input[1][31] = { "5" };
 66             resp = uc1613("小庆逃角工具", menu, 1, ijunk, djunk, user_input, strings);
 67             //输入两个向量获取矩阵
 68             double mtx[9];
 69             UF_MTX3_initialize(edges.unit, Dir, mtx);
 70             //创建矩阵
 71             tag_t MatrixTag = NULL_TAG;
 72             UF_CSYS_create_matrix(mtx, &MatrixTag);
 73             //创建临时坐标系
 74             tag_t CsysTag = NULL_TAG;
 75             UF_CSYS_create_temp_csys(edges.start, MatrixTag, &CsysTag);
 76             //设置WCS
 77             UF_CSYS_set_wcs(CsysTag);
 78             //设置圆柱起点
 79             double origin[3] = { 0.0,djunk[0] / 2,0.0 };
 80             //将工作坐标点转换成绝对坐标
 81             UF_CSYS_map_point(UF_CSYS_ROOT_WCS_COORDS, origin, UF_CSYS_WORK_COORDS, origin);
 82             //创建圆柱体
 83             tag_t cyltag = NULL_TAG;
 84             char heigh[25], diame[25];
 85             sprintf(heigh, "%f", edges.length);
 86             sprintf(diame, "%f", djunk[0]);
 87             UF_MODL_create_cyl1(UF_NULLSIGN, origin, heigh, diame, edges.unit, &cyltag);
 88             //特征找体
 89             tag_t cyl2tag = NULL_TAG;
 90             UF_MODL_ask_feat_body(cyltag, &cyl2tag);
 91             //设置WCS
 92             UF_CSYS_set_wcs(Csys0Tag);
 93             //设置布尔
 94             int num_result;
 95             tag_t * resul_bodies;
 96             int 状态 = UF_MODL_subtract_bodies(body0Tag, cyl2tag, &num_result, &resul_bodies);
 97             if (!状态)
 98             {
 99                 goto RES0;
100                 UF_free(resul_bodies);
101             }
102             else
103             {
104                 //多按钮模态对话框
105                 int response = 0;
106                 char title_string[] = "庆哥提示";
107                 char *sMessages = "无法进行布尔运算";
108                 UF_UI_MESSAGE_DIALOG_TYPE dialog_type =
109                     UF_UI_MESSAGE_QUESTION;//对话框类型
110                     //UF_UI_MESSAGE_ERROR;
111                 //UF_UI_MESSAGE_WARNING;
112                 //UF_UI_MESSAGE_INFORMATION;
113 
114                 UF_UI_message_buttons_s button;
115                 button.button1 = true;//控制按钮的数量
116                 button.button2 = true;//按钮好像就最多3个请自行测试
117                 button.button3 = false;
118                 button.label1 = "保留圆柱";//按钮的名字
119                 button.label2 = "删除圆柱";
120                 button.label3 = "ccc";
121                 button.response1 = 1;//按钮的返回值
122                 button.response2 = 2;
123                 button.response3 = 3;
124                 UF_UI_message_dialog(title_string, dialog_type, &sMessages, 1, 0, &button, &response);
125                 switch (response)
126                 {
127                 case 1:return; break;//显示所选按钮的名字
128                 case 2:UF_OBJ_delete_object(cyltag); break;
129                 case 3:uc1601(button.label3, 1); break;
130                 default:uc1601("未知按钮", 1); break;
131                 }
132                 return;
133             }
134             UF_EVAL_free(evaluator);//释放
135         }
136         else
137         {
138             uc1601("不是直线", 1);
139             goto RES1;
140         }
141     }
142 else
143     {
144     goto RES0;
145     }
146     UF_terminate();

 

posted @ 2020-05-02 09:19  老婆饼里有老婆  阅读(639)  评论(2编辑  收藏  举报