码迷,mamicode.com
首页 > 其他好文 > 详细

删除鱼眼

时间:2020-04-21 13:24:14      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:manage   tag   ons   radius   oid   中国   except   pre   mask   

  1 // NX 8.5.3.3
  2 // Journal created by Administrator on Mon Apr 20 11:21:24 2020 中国标准时间
  3 //
  4 #include "C:\\all_uf.h"
  5 #include <uf_defs.h>
  6 #include <NXOpen/NXException.hxx>
  7 #include <NXOpen/Session.hxx>
  8 #include <NXOpen/BasePart.hxx>
  9 #include <NXOpen/Builder.hxx>
 10 #include <NXOpen/Expression.hxx>
 11 #include <NXOpen/ExpressionCollection.hxx>
 12 #include <NXOpen/Face.hxx>
 13 #include <NXOpen/FaceDumbRule.hxx>
 14 #include <NXOpen/Features_Brep.hxx>
 15 #include <NXOpen/Features_DeleteFaceBuilder.hxx>
 16 #include <NXOpen/Features_FeatureCollection.hxx>
 17 #include <NXOpen/NXObject.hxx>
 18 #include <NXOpen/Part.hxx>
 19 #include <NXOpen/PartCollection.hxx>
 20 #include <NXOpen/Plane.hxx>
 21 #include <NXOpen/PlaneCollection.hxx>
 22 #include <NXOpen/Preferences_PartModeling.hxx>
 23 #include <NXOpen/Preferences_PartPreferences.hxx>
 24 #include <NXOpen/Preferences_PartPreferences.hxx>
 25 #include <NXOpen/Preferences_PartVisualizationLine.hxx>
 26 #include <NXOpen/ScCollector.hxx>
 27 #include <NXOpen/ScRuleFactory.hxx>
 28 #include <NXOpen/SelectISurface.hxx>
 29 #include <NXOpen/SelectObject.hxx>
 30 #include <NXOpen/SelectionIntentRule.hxx>
 31 #include <NXOpen/Session.hxx>
 32 #include <NXOpen/TaggedObject.hxx>
 33 #include <NXOpen/Unit.hxx>
 34 #include <NXOpen/Face.hxx>
 35 #include <NXOpen/FaceTangentRule.hxx>
 36 #include <NXOpen/NXObjectManager.hxx>
 37 #include <uf_defs.h>
 38 #include <uf_ui_types.h>
 39 #include <iostream>
 40 #include <NXOpen/Session.hxx>
 41 #include <NXOpen/UI.hxx>
 42 #include <NXOpen/NXMessageBox.hxx>
 43 #include <NXOpen/Callback.hxx>
 44 #include <NXOpen/NXException.hxx>
 45 #include <NXOpen/BlockStyler_UIBlock.hxx>
 46 #include <NXOpen/BlockStyler_BlockDialog.hxx>
 47 #include <NXOpen/BlockStyler_PropertyList.hxx>
 48  #include <NXOpen/BlockStyler_Group.hxx>
 49 #include <NXOpen/BlockStyler_FaceCollector.hxx>
 50 #include <uf.h>
 51  #include <uf_obj.h>
 52 #include <NXOpen/NXObjectManager.hxx>
 53 #include <NXOpen/PartCollection.hxx>
 54 #include <NXOpen/Face.hxx>
 55 #include <NXOpen/FaceTangentRule.hxx>
 56 #include <NXOpen/ScCollectorCollection.hxx>
 57 #include <NXOpen/ScRuleFactory.hxx>
 58 using namespace NXOpen;
 59 
 60 extern "C" DllExport int ufusr_ask_unload()
 61 {
 62     return (int)Session::LibraryUnloadOptionImmediately;
 63 }
 64 
 65 static int select_filter_proc_fn(tag_t object, int type[1], void* user_data, UF_UI_selection_p_t select)
 66 {
 67     uf_list_p_t  edge_list;
 68     int edge_count = 0, Type = 0;
 69     double Point[3];
 70     double Dir[3];
 71     double Box[6];
 72     double Radius[3];
 73     double RadData[3];
 74     int NormDir;
 75     UF_MODL_ask_face_data(object, &Type, Point, Dir, Box, Radius, RadData, &NormDir);
 76     UF_MODL_ask_face_edges(object, &edge_list);
 77     UF_MODL_ask_list_count(edge_list, &edge_count);
 78     if (object == NULL)
 79     {
 80         return UF_UI_SEL_REJECT;
 81     }
 82     else if (object&&edge_count == 2&&Type==UF_cone_subtype)
 83 
 84     {
 85         return UF_UI_SEL_ACCEPT;
 86     }
 87 }
 88 
 89 static int init_proc(UF_UI_selection_p_t select, void* user_data)
 90 {
 91     int num_triples = 1;//可选类型的数量
 92     
 93     UF_UI_mask_t mask_triples[] =
 94     { UF_face_type, UF_cone_subtype, UF_UI_SEL_NOT_A_FEATURE };//可选对象类型
 95     UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, num_triples, mask_triples);
 96     if ((UF_UI_set_sel_procs(select, select_filter_proc_fn, NULL, user_data)) == 0)
 97     {
 98         return UF_UI_SEL_SUCCESS;
 99     }
100     else
101     {
102         return UF_UI_SEL_FAILURE;
103     }
104 }
105 
106 //以下是封装函数
107 static void DeleteFaces(std::vector<Face *> faces)
108 {
109     Session *theSession = Session::GetSession();
110     Part *workPart(theSession->Parts()->Work());    
111     Features::Feature *nullFeatures_Feature(NULL);
112     Features::DeleteFaceBuilder *deleteFaceB;
113     deleteFaceB = workPart->Features()->CreateDeleteFaceBuilder(nullFeatures_Feature);    
114     FaceDumbRule *faceDumbRule1;
115     faceDumbRule1 = workPart->ScRuleFactory()->CreateRuleFaceDumb(faces);
116     std::vector<SelectionIntentRule *> rules1(1);
117     rules1[0] = faceDumbRule1;
118     deleteFaceB->FaceCollector()->ReplaceRules(rules1, false);
119     NXObject *nXObject1;
120     nXObject1 = deleteFaceB->Commit();
121     deleteFaceB->Destroy();
122 }
123 
124 extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)
125 {
126     UF_initialize();
127     char sCue[] = "象选择对话框";
128     char sTitle[] = "象选择对话框";
129     int iScope = UF_UI_SEL_SCOPE_NO_CHANGE;
130     int iResponse;
131     tag_t *tObject;
132     int count = 0;
133     UF_UI_select_with_class_dialog(sCue, sTitle, iScope, init_proc, NULL, &iResponse, &count, &tObject);
134     if (count)
135     {
136         std::vector<Face *> deleteface;
137         for (int i = 0; i < count; i++)
138         {
139             NXOpen::Face *face1(dynamic_cast<NXOpen::Face *>(NXOpen::NXObjectManager::Get(tObject[i])));
140             deleteface.push_back(face1);
141         }
142         DeleteFaces(deleteface);
143     }
144     else
145     {
146         return;
147     }
148             
149 }

 

删除鱼眼

标签:manage   tag   ons   radius   oid   中国   except   pre   mask   

原文地址:https://www.cnblogs.com/liuxiaoqing1/p/12743682.html

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