NX二次开发-算法篇-找相切面

2020-12-13 03:11

阅读:344

标签:def   stream   ace   dialog   actor   selected   play   cts   splay   

方法1:通过判断相邻面公共边的光顺性来找相切面

 1 #include  2 #include  3 #include  4 
 5 
 6     UF_initialize();
 7 
 8 
 9     //获取面的所有边
10     uf_list_p_t edge_list;
11     UF_MODL_ask_face_edges(42084, &edge_list);
12 
13     //获取链表的数量
14     int count;
15     UF_MODL_ask_list_count(edge_list, &count);
16 
17     for (int i = 0; i )
18     {
19         //获取链表里的tag
20         tag_t EdgeTag = NULL_TAG;
21         UF_MODL_ask_list_item(edge_list, i, &EdgeTag);
22 
23         //获取边的光顺性
24         logical is_smooth;
25         UF_MODL_ask_edge_smoothness(EdgeTag, 0, &is_smooth);
26 
27         if (is_smooth == true)
28         {
29             //边找面
30             uf_list_p_t face_list;
31             UF_MODL_ask_edge_faces(EdgeTag, &face_list);
32 
33             //获得链表数量
34             int face_count;
35             UF_MODL_ask_list_count(face_list, &face_count);
36             for (int j = 0; j )
37             {
38                 //获取链表里的tag
39                 tag_t FaceTag = NULL_TAG;
40                 UF_MODL_ask_list_item(face_list, j, &FaceTag);
41 
42                 //设置颜色
43                 UF_OBJ_set_color(FaceTag, 186);    
44             }
45         }
46 
47     }
48 
49 
50     UF_terminate();

技术图片

 

 

方法2:使用NXOPEN相切面方法

 1 #include  2 #include  3 #include  4 #include  5 #include  6 #include  7 #include  8 #include  9 #include 10 #include 11 #include 12 #include 13 #include 14 #include 15 #include 16 #include 17 #include 18 #include 19 #include 20 #include 21 #include 22 
23 
24         UF_initialize();
25 
26         //NXOPEN初始化
27         NXOpen::Session *theSession = NXOpen::Session::GetSession();
28         NXOpen::Part *workPart(theSession->Parts()->Work());
29         NXOpen::Part *displayPart(theSession->Parts()->Display());
30 
31         //选择面控件
32         PropertyList* FaceSelectProps = face_select0->GetProperties();
33         std::vector<:taggedobject> faces = FaceSelectProps->GetTaggedObjectVector("SelectedObjects");
34         delete FaceSelectProps;
35         FaceSelectProps = NULL;
36 
37         tag_t FaceTag = faces[0]->Tag();
38 
39         //对选中的面设置颜色
40         UF_OBJ_set_color(FaceTag, 186);
41 
42         //给入一个面
43         NXOpen::Face *face1(dynamic_cast<:face>(NXOpen::NXObjectManager::Get(FaceTag)));
44 
45         //使用NXOPEN相切面规则
46         std::vector<:face> boundaryFaces1(0);
47         NXOpen::FaceTangentRule *faceTangentRule1;
48         faceTangentRule1 = workPart->ScRuleFactory()->CreateRuleFaceTangent(face1, boundaryFaces1, 0.050000000000000003);
49         std::vector<:selectionintentrule> rules1(1);
50         rules1[0] = faceTangentRule1;
51 
52         NXOpen::ScCollector* scCollector1 = workPart->ScCollectors()->CreateCollector();
53         scCollector1->ReplaceRules(rules1, false);
54 
55         std::vector<:taggedobject> BB = scCollector1->GetObjects();
56         for (int i = 0; i )
57         {
58             UF_OBJ_set_color(BB[i]->Tag(), 1);
59         }
60 
61         UF_terminate();

技术图片

技术图片

技术图片

技术图片

NX二次开发-算法篇-找相切面

标签:def   stream   ace   dialog   actor   selected   play   cts   splay   

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


评论


亲,登录后才可以留言!