#選択頂点・辺・面の拡大 def return_pointlist(pointnum): #その点と接続されている頂点の頂点番号をリストで返す(引数 頂点番号) pointlist=[] totaledgesuu=xshade.scene().active_shape().number_of_edges for i in range(totaledgesuu): if xshade.scene().active_shape().edge(i).v0==pointnum: pointlist.append(xshade.scene().active_shape().edge(i).v1) if xshade.scene().active_shape().edge(i).v1==pointnum: pointlist.append(xshade.scene().active_shape().edge(i).v0) return pointlist 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) def return_setuzokuhen(point): #頂点番号を渡すと、その頂点と接続されている辺のリストを返す henlist=[] for i in range(xshade.scene().active_shape().number_of_edges): if xshade.scene().active_shape().edge(i).v0==point or xshade.scene().active_shape().edge(i).v1==point: henlist.append(i) return henlist def return_edge_number(pointnum1,pointnum2): #頂点二つの頂点番号を与えると、その頂点で構成される辺の辺番号を返す #エラー(辺の両端のポイントでは無い)の場合は-1を返す returnnum=-1 for i in range(xshade.scene().active_shape().number_of_edges): if xshade.scene().active_shape().edge(i).v0==pointnum1 and xshade.scene().active_shape().edge(i).v1==pointnum2: returnnum=i if xshade.scene().active_shape().edge(i).v1==pointnum1 and xshade.scene().active_shape().edge(i).v0==pointnum2: returnnum=i return returnnum def return_menlist(edgenumber): #その辺を共有する面の面番号をリストで返す(引数 辺番号) menlist=[] edgevertex=[xshade.scene().active_shape().edge(edgenumber).v0,xshade.scene().active_shape().edge(edgenumber).v1] totalmenmen=xshade.scene().active_shape().number_of_faces for i in range(totalmenmen): konomen=0 temppoint=list(xshade.scene().active_shape().face(i).vertex_indices) for j in temppoint: if edgevertex[0]==j: konomen+=1 if edgevertex[1]==j: konomen+=1 if konomen==2: menlist.append(i) return menlist #選択頂点の拡大 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) #選択されている頂点と接続している頂点を追加リストにいれていく tuikalist=[] for i in activepointlist: tuikalist=tuikalist+return_pointlist(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) #重複点を整理 erase_same_num(pointlist) #その頂点と接続されている辺のリストを返す setuzokuhenlist=[] for i in pointlist: templist=return_setuzokuhen(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 #以下は辺の隣接面を選択 #選択されてる辺の辺番号リストをつくる 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+=return_menlist(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()