You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
here's a snlite ( a bit unstable, that's why it has an iteration limit) for now..
""">in verts_in vout verts_out vout faces_out s"""importsverchokfromsverchok.utils.modules.vertex_utilsimportnp_faces_normalsasnormalsfromsverchok.utils.modules.geom_utilsimportccw_angle, pt_in_triangledeftriangulate_version_one(verts, normal=None):
# print(verts)iflen(verts) <3: return [[]]
iflen(verts) ==3: return [[0, 1, 2]]
# [ ] first we filter out any consecutive colinear verts# current_verts, unused_vertex_indices = filter_consecutive_colinear_verts(verts)# [ ] are verts coplanar ? if not -> return [[]]# [ ] are any edges intersecting? (verts on edges, vers on other verts) -> return [[]]normal=normals(np.array([verts]))[0] #... # normal or get_normal(verts)index_list=list(range(len(verts)))
new_index_list= []
iterations=0max_iterations=len(verts)**2while(len(index_list) >3):
ifiterations>max_iterations:
#print("ending early")breakforiinrange(len(list(index_list))-1):
ifi+1>=len(index_list):
#print('index too high')break#else:# print(len(index_list), i+1)idx_1=index_list[i+1]
idx_0=index_list[i]
idx_2=index_list[i-1]
v0=np.array(verts[idx_0])
v1=np.array(verts[idx_1])
v2=np.array(verts[idx_2])
# is angle reflexive? ( not an ear )ifccw_angle(v1-v0, v2-v0, normal) >np.pi:
continueforpt_iinindex_list:
# exclude points in this triangle from next checkifpt_iin {idx_0, idx_1, idx_2}: continue# does it contain any other verts?point=verts[pt_i]
# print('here')ifpt_in_triangle(point, v0, v1, v2):
breaknew_index_list.append([idx_0, idx_1, idx_2])
index_list.remove(idx_0)
break# print(new_index_list)iterations+=1iflen(index_list) ==3:
breaknew_index_list.append(index_list)
returnnew_index_listforvertsinverts_in:
# print(verts)faces=triangulate_version_one(verts)
verts_out.append(verts)
faces_out.append(faces)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
here's a snlite ( a bit unstable, that's why it has an iteration limit) for now..
Beta Was this translation helpful? Give feedback.
All reactions