码迷,mamicode.com
首页 > 编程语言 > 详细

NX二次开发-算法篇-判断找到两个数组里不相同的对象

时间:2019-05-31 21:10:03      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:code   src   二次开发   create   i++   ali   image   lse   个数   

  1     NX9+VS2012
  2     
  3     #include <uf.h>
  4     #include <uf_curve.h>
  5     #include <uf_modl.h>
  6     #include <vector>
  7     #include <uf_disp.h>
  8     
  9 
 10     UF_initialize();
 11 
 12     //第一步,创建5条直线
 13     UF_CURVE_line_t Coords1;
 14     Coords1.start_point[0] = 0.0;
 15     Coords1.start_point[1] = 0.0;
 16     Coords1.start_point[2] = 0.0;
 17     Coords1.end_point[0] = 20.0;
 18     Coords1.end_point[1] = 0.0;
 19     Coords1.end_point[2] = 0.0;
 20     tag_t LineTag1 = NULL_TAG;
 21     UF_CURVE_create_line(&Coords1, &LineTag1);
 22 
 23     UF_CURVE_line_t Coords2;
 24     Coords2.start_point[0] = 0.0;
 25     Coords2.start_point[1] = 10.0;
 26     Coords2.start_point[2] = 0.0;
 27     Coords2.end_point[0] = 20.0;
 28     Coords2.end_point[1] = 10.0;
 29     Coords2.end_point[2] = 0.0;
 30     tag_t LineTag2 = NULL_TAG;
 31     UF_CURVE_create_line(&Coords2, &LineTag2);
 32 
 33     UF_CURVE_line_t Coords3;
 34     Coords3.start_point[0] = 0.0;
 35     Coords3.start_point[1] = 20.0;
 36     Coords3.start_point[2] = 0.0;
 37     Coords3.end_point[0] = 20.0;
 38     Coords3.end_point[1] = 20.0;
 39     Coords3.end_point[2] = 0.0;
 40     tag_t LineTag3 = NULL_TAG;
 41     UF_CURVE_create_line(&Coords3, &LineTag3);
 42 
 43     UF_CURVE_line_t Coords4;
 44     Coords4.start_point[0] = 0.0;
 45     Coords4.start_point[1] = 30.0;
 46     Coords4.start_point[2] = 0.0;
 47     Coords4.end_point[0] = 20.0;
 48     Coords4.end_point[1] = 30.0;
 49     Coords4.end_point[2] = 0.0;
 50     tag_t LineTag4 = NULL_TAG;
 51     UF_CURVE_create_line(&Coords4, &LineTag4);
 52 
 53     UF_CURVE_line_t Coords5;
 54     Coords5.start_point[0] = 0.0;
 55     Coords5.start_point[1] = 40.0;
 56     Coords5.start_point[2] = 0.0;
 57     Coords5.end_point[0] = 20.0;
 58     Coords5.end_point[1] = 40.0;
 59     Coords5.end_point[2] = 0.0;
 60     tag_t LineTag5 = NULL_TAG;
 61     UF_CURVE_create_line(&Coords5, &LineTag5);
 62 
 63     //第二步,将5条直线分别放到两个数组里
 64 
 65     //创建vector数组
 66     std::vector<tag_t> LineCurve1;
 67     std::vector<tag_t> LineCurve2;
 68 
 69     //将5条直线添加到数组1
 70     LineCurve1.push_back(LineTag1);
 71     LineCurve1.push_back(LineTag2);
 72     LineCurve1.push_back(LineTag3);
 73     LineCurve1.push_back(LineTag4);
 74     LineCurve1.push_back(LineTag5);
 75 
 76     //将3条直线添加到数组2
 77     LineCurve2.push_back(LineTag2);
 78     LineCurve2.push_back(LineTag4);
 79     LineCurve2.push_back(LineTag5);
 80 
 81     //算法,判断找到两个数组里不相同的对象
 82     for (int i = 0; i < LineCurve1.size(); i++)
 83     {
 84         bool FindSame = false;
 85         for (int j = 0; j < LineCurve2.size(); j++)
 86         {
 87             if (LineCurve1[i] == LineCurve2[j])
 88             {
 89                 FindSame = true;
 90                 break;
 91             }
 92         }
 93         if (FindSame == false)
 94         {
 95             //将两个数组里不相同的直线进行高亮
 96             UF_DISP_set_highlight(LineCurve1[i], 1);
 97         }
 98     }
 99 
100 
101     UF_terminate();

技术图片

NX二次开发-算法篇-判断找到两个数组里不相同的对象

标签:code   src   二次开发   create   i++   ali   image   lse   个数   

原文地址:https://www.cnblogs.com/nxopen2018/p/10957429.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!