#選択頂点・辺・面の拡大 #アルゴリズム変更(20100131) #面の向きバラバラでも動作するか?(面の拡大で) def return_henlist(face): #面番号から面を構成する辺の番号を返す #前後にsetup_winged_edgeとclean_winged_edgeが必要 tempvlist=xshade.scene().active_shape().face(face).vertex_indices henlist=[] for i in tempvlist: tempf=xshade.scene().active_shape().eccwfv(face,i,False) henlist.append(tempf) return henlist def erase_same_num(list1): #リスト内に同じ値が重複する場合は一つに減らす関数 例[1,1,1,3,3,4]→[1,3,4] list1.sort() nagasa=len(list1) if nagasa>1: kesu=[] for i in range(nagasa-1): if list1[i]==list1[i+1]: kesu.append(list1[i]) kesukaisuu=len(kesu) if kesukaisuu>0: for i in kesu: list1.remove(i) #選択頂点の拡大 xscene=xshade.scene() ashape=xshade.scene().active_shape() if xshade.scene().selection_mode==2 and xshade.scene().is_modify_mode==True and xshade.scene().active_shape().type==7: #選択されている頂点のリストを作成 activepointlist=[] for i in range(xshade.scene().active_shape().total_number_of_control_points): if xshade.scene().active_shape().vertex(i).active_order>0: activepointlist.append(i) vvlist=[]#頂点と接続している頂点のリストを頂点番号順に格納したリスト for i in range(ashape.total_number_of_control_points): vvlist.append([]) for i in range(ashape.number_of_edges): vv0=ashape.edge(i).v0 vv1=ashape.edge(i).v1 tempvl=vvlist[vv0] tempvl.append(vv1) vvlist[vv0]=tempvl tempvl=vvlist[vv1] tempvl.append(vv0) vvlist[vv1]=tempvl #選択されている頂点と接続している頂点を追加リストにいれていく tuikalist=[] for i in activepointlist: tuikalist=tuikalist+vvlist[i] #追加ポイントの重複点を整理した後、追加ポイントをアクティブにしていく # erase_same_num(tuikalist) for i in tuikalist: xshade.scene().active_shape().vertex(i).active=True #選択辺の拡大 if xshade.scene().selection_mode==1 and xshade.scene().is_modify_mode==True and xshade.scene().active_shape().type==7: #選択されている辺のリスト作成 activeedgelist=[] for i in range(xshade.scene().active_shape().number_of_edges): if xshade.scene().active_shape().edge(i).active_order>0: activeedgelist.append(i) #辺のリストから辺の頂点リストを作成 pointlist=[] for i in activeedgelist: pointlist.append(xshade.scene().active_shape().edge(i).v0) pointlist.append(xshade.scene().active_shape().edge(i).v1) velist=[]#頂点と接続されている辺のリストを頂点番号順に格納したリスト for i in range(ashape.total_number_of_control_points): velist.append([]) for i in range(ashape.number_of_edges): vv0=ashape.edge(i).v0 vv1=ashape.edge(i).v1 tempel=velist[vv0] tempel.append(i) velist[vv0]=tempel tempel=velist[vv1] tempel.append(i) velist[vv1]=tempel #重複点を整理 # erase_same_num(pointlist) #その頂点と接続されている辺のリストを返す setuzokuhenlist=[] for i in pointlist: templist=velist[i] for j in templist: setuzokuhenlist.append(j) #接続辺の整理 # erase_same_num(setuzokuhenlist) #接続辺を選択状態に for i in setuzokuhenlist: xshade.scene().active_shape().edge(i).active=True #選択面の拡大 if xshade.scene().selection_mode==0 and xshade.scene().is_modify_mode==True and xshade.scene().active_shape().type==7: #選択モードを辺モードに変更 xshade.scene().selection_mode=1 #以下は辺の隣接面を選択 eflist=[] #辺の隣接面リストを辺番号順に格納したもの for i in range(ashape.number_of_edges): eflist.append([]) #面の向きを統一 ashape.adjust_face_direction() ashape.setup_winged_edge() for i in range(ashape.number_of_faces): henlist=return_henlist(i) for gg in henlist: tempefl=eflist[gg] tempefl.append(i) eflist[gg]=tempefl ashape.clean_winged_edge() #選択されてる辺の辺番号リストをつくる totaledge=xshade.scene().active_shape().number_of_edges activeedgelist=[] for i in range(totaledge): if xshade.scene().active_shape().edge(i).active_order>0: activeedgelist.append(i) #辺番号リストから、隣接面リストを作成し、重複分を消す menlist=[] for i in activeedgelist: menlist+=eflist[i] # erase_same_num(menlist) #面選択モードに移行し、面を選択 xshade.scene().selection_mode=0 for i in menlist: xshade.scene().active_shape().face(i).active=True if xshade.scene().is_modify_mode==True: xshade.scene().exit_modify_mode() xshade.scene().enter_modify_mode() #画面の更新 xshade.scene().update_figure_window()