def get_delaunay_triangulation(verts_in): pt_list = [Site(pt[0], pt[1]) for pt in verts_in] res = computeDelaunayTriangulation(pt_list) polys_in = [tri for tri in res if -1 not in tri] #all faces hase normals -Z, should be reversed polys_in = [pol[::-1] for pol in polys_in] edges_in = pols_edges([polys_in], unique_edges=True)[0] return edges_in, polys_in
def delaunay_triangulatrion(samples_u, samples_v, us_list, vs_list, u_coeff, v_coeff, epsilon): #if delaunay_2d_cdt is None: # Pure-python implementation points_uv = [ Site(u * u_coeff, v * v_coeff) for u, v in zip(us_list, vs_list) ] faces = computeDelaunayTriangulation(points_uv) return faces
def process(self): points_in = [] if not ('Polygons' in self.outputs and self.outputs['Polygons'].is_linked): return if 'Vertices' in self.inputs and self.inputs['Vertices'].is_linked: points_in = SvGetSocketAnyType(self, self.inputs['Vertices']) tris_out = [] for obj in points_in: pt_list = [Site(pt[0], pt[1]) for pt in obj] res = computeDelaunayTriangulation(pt_list) tris_out.append([tri for tri in res if -1 not in tri]) if 'Polygons' in self.outputs and self.outputs['Polygons'].is_linked: SvSetSocketAnyType(self, 'Polygons', tris_out)
def process(self): if not self.inputs['Vertices'].is_linked: return if not self.outputs['Polygons'].is_linked: return tris_out = [] points_in = [] points_in = self.inputs['Vertices'].sv_get() for obj in points_in: pt_list = [Site(pt[0], pt[1]) for pt in obj] res = computeDelaunayTriangulation(pt_list) tris_out.append([tri for tri in res if -1 not in tri]) self.outputs['Polygons'].sv_set(tris_out)
def delaunay_triangulatrion(samples_u, samples_v, us_list, vs_list, u_coeff, v_coeff, epsilon): if delaunay_2d_cdt is None: # Pure-python implementation points_uv = [ Site(u * u_coeff, v * v_coeff) for u, v in zip(us_list, vs_list) ] faces = computeDelaunayTriangulation(points_uv) return faces else: points_scaled = [(u * u_coeff, v * v_coeff) for u, v in zip(us_list, vs_list)] INNER = 1 # delaunay_2d_cdt function wont' work if we do not provide neither edges nor faces. # So let's just construct the outer faces of the rectangular grid # (indices in `edges' depend on the fact that in `adaptive_subdivide` we # add randomly generated points to the end of us_list/vs_list). edges = make_outer_edges(samples_v, samples_u) vert_coords, edges, faces, orig_verts, orig_edges, orig_faces = delaunay_2d_cdt( points_scaled, edges, [], INNER, epsilon) return faces