Пример #1
0
    def iteration(pts):
        mask, pts, repeating = unique_points(pts)
        n = len(pts)
        all_pts = pts + invert_points(pts)
        voronoi_verts, _, voronoi_faces = voronoi_bounded(all_pts,
                    bound_mode = bound_mode,
                    clip = clip,
                    draw_bounds = True,
                    draw_hangs = True,
                    make_faces = True,
                    ordered_faces = True,
                    max_sides = 20)
        centers = []
        for face in voronoi_faces[:n]:
            face_verts = np.array([voronoi_verts[i] for i in face])
            new_pt = weighted_center(face_verts, weight_field)
            centers.append(tuple(new_pt))

        result = []
        i = 0
        j = 0
        for is_unique in mask:
            if is_unique:
                result.append(centers[i])
                i += 1
            else:
                result.append(repeating[j])
                j += 1
        return result
Пример #2
0
 def iteration(pts):
     diagram = SphericalVoronoi(pts, radius=radius, center=np.array(center))
     diagram.sort_vertices_of_regions()
     centers = []
     for region in diagram.regions:
         verts = np.array([diagram.vertices[i] for i in region])
         new_vert = weighted_center(verts, weight_field)
         centers.append(tuple(new_vert))
     return centers
Пример #3
0
 def iteration(pts):
     all_pts = pts + project_solid_normals(shell, pts, thickness)
     diagram = Voronoi(all_pts)
     centers = []
     for site_idx in range(len(pts)):
         region_idx = diagram.point_region[site_idx]
         region = diagram.regions[region_idx]
         region_verts = np.array([diagram.vertices[i] for i in region])
         center = weighted_center(region_verts, weight_field)
         centers.append(tuple(center))
     return centers
Пример #4
0
    def iteration(pts):
        n = len(pts)
        all_pts = pts
        for pt in pts:
            if solid.isInside(Base.Vector(pt), tolerance, False):
                all_pts.append(invert(pt))

        diagram = Voronoi(all_pts)
        centers = []
        for site_idx in range(n):
            region_idx = diagram.point_region[site_idx]
            region = diagram.regions[region_idx]
            region_verts = np.array([diagram.vertices[i] for i in region])
            center = weighted_center(region_verts, weight_field)
            centers.append(tuple(center))
        return centers
Пример #5
0
    def iteration(pts):
        n = len(pts)
        all_pts = pts + invert(pts)
        diagram = Voronoi(all_pts)
        vertices = restrict(diagram.vertices)
        centers = []
        for site_idx in range(n):
            region_idx = diagram.point_region[site_idx]
            region = diagram.regions[region_idx]

            if -1 in region:
                site = pts[site_idx]
                centers.append(site)
                continue

            region_verts = np.array([vertices[i] for i in region])
            center = weighted_center(region_verts, weight_field)
            centers.append(tuple(center))
        return centers
Пример #6
0
    def iteration(points):
        n = len(points)

        normals = calc_bvh_normals(bvh, points)
        k = 0.5*thickness
        points = np.array(points)
        plus_points = points + k*normals
        minus_points = points - k*normals
        all_points = points.tolist() + plus_points.tolist() + minus_points.tolist()

        diagram = Voronoi(all_points)
        centers = []
        for site_idx in range(n):
            region_idx = diagram.point_region[site_idx]
            region = diagram.regions[region_idx]
            region_verts = np.array([diagram.vertices[i] for i in region])
            center = weighted_center(region_verts, weight_field)
            centers.append(tuple(center))
        return centers
Пример #7
0
    def iteration(points):
        n = len(points)

        all_points = points[:]
        k = 0.5 * thickness
        for p in points:
            p = Vector(p)
            loc, normal, index, distance = bvh.find_nearest(p)
            if distance <= epsilon:
                p1 = p + k * normal
                all_points.append(tuple(p1))

        diagram = Voronoi(all_points)
        centers = []
        for site_idx in range(n):
            region_idx = diagram.point_region[site_idx]
            region = diagram.regions[region_idx]
            region_verts = np.array([diagram.vertices[i] for i in region])
            center = weighted_center(region_verts, weight_field)
            centers.append(tuple(center))
        return centers