- 积分
- 0
- 注册时间
- 2012-9-18
- 仿真币
-
- 最后登录
- 1970-1-1
|
; Flac3D 5.0
; 自动链接结构单元,不多解释,用过结构单元应该明白
; w.gang.89@foxmail.com
def relink(begin_link_id)
dist_tol = 1e-2
link_id = begin_link_id
node_num = 0
node_pnt0 = nd_head
; m_pnt = null
loop while node_pnt0 # null
; node_num = node_num + 1
; m_pnt1 = get_mem(2)
; mem(m_pnt1) = m_pnt
; mem(m_pnt1+1) = node_pnt0
; m_pnt = m_pnt1
; node_pnt0 = nd_next(node_pnt0)
node_num = node_num + 1
node_pnt0 = nd_next(node_pnt0)
endloop
node_arr = get_array(node_num)
node_num = 0
node_pnt0 = nd_head
loop while node_pnt0 # null
node_num = node_num + 1
node_arr(node_num) = node_pnt0
node_pnt0 = nd_next(node_pnt0)
endloop
node_num_minus1 = node_num - 1
loop ii(1,node_num_minus1)
node_pnt1 = node_arr(ii)
node_id1 = nd_id(node_pnt1)
xxa = nd_pos(node_pnt1,2,1)
yya = nd_pos(node_pnt1,2,2)
zza = nd_pos(node_pnt1,2,3)
ii_plus1 = ii + 1
loop jj(ii_plus1,node_num)
node_pnt2 = node_arr(jj)
node_id2 = nd_id(node_pnt2)
xxb = nd_pos(node_pnt2,2,1)
yyb = nd_pos(node_pnt2,2,2)
zzb = nd_pos(node_pnt2,2,3)
node_dist = sqrt((xxa-xxb)^2+(yya-yyb)^2+(zza-zzb)^2)
if node_dist <= dist_tol then
link_pnt1 = nd_link(node_pnt1)
link_pnt2 = nd_link(node_pnt2)
if link_pnt1 = null then
link_id = link_id + 1
command
; sel set link node_tol=dist_tol
sel link id=@link_id @node_id1 target=node tgt_num=@node_id2
sel link attach xdir=rigid ydir=rigid zdir=rigid &
xrdir=rigid yrdir=rigid zrdir=rigid range id=@link_id
endcommand
else
if link_pnt2 = null then
link_id = link_id + 1
command
; sel set link node_tol=dist_tol
sel link id=@link_id @node_id2 target=node tgt_num=@node_id1
sel link attach xdir=rigid ydir=rigid zdir=rigid &
xrdir=rigid yrdir=rigid zrdir=rigid range id=@link_id
endcommand
else
if lk_type(link_pnt1) = lk_type(link_pnt2) then
; value {1,2} denotes node-to-node or node-to-zone link
temp = lk_delete(link_pnt2)
link_id = link_id + 1
command
sel link id=@link_id @node_id2 target = node tgt_num=@node_id1
sel link attach xdir=rigid ydir=rigid zdir=rigid &
xrdir=rigid yrdir=rigid zrdir=rigid range id=@link_id
endcommand
endif
endif
endif
endif
endloop
endloop
temp = lose_array(node_arr)
end
@relink(10000)
|
|