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


      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();

  • 相关阅读:
    http请求类型简介
    关于PLSQL连接报错:ORA-12154:TNS:无法解析指定的连接标识符
    JDK8的安装与配置
    今天新装tomcat遇到黑窗口(startup.bat)启动乱码问题解决!!!
    一个简单的工厂模式(一个接口,多个实现,通过调用条件的不同,分别去调用符合的实现)
    数组(复习)
    java选择结构、循环结构(复习)
    java常用的数据类型,变量和常量,运算符(复习)
    java输入输出,书写规范,运行原理,跨平台原理(复习)
    JAVA基础入门(JDK、eclipse下载安装)
  • 原文地址:https://www.cnblogs.com/nxopen2018/p/10957429.html
Copyright © 2020-2023  润新知