public void ReallyDispose(VoronoiManager manager) { edgeListLeftNeighbor = null; edgeListRightNeighbor = null; nextInPriorityQueue = null; edge = null; leftRight = null; vertex = null; manager.Release(this); }
public Voronoi(VoronoiManager manager, List <Vector2f> points, Rectf plotBounds, int lloydIterations) { this.manager = manager; sites = new SiteList(manager); weigthDistributor = new Random(); Init(points, plotBounds); if (lloydIterations > 0) { LloydRelaxation(lloydIterations); } }
private static Vertex Create(VoronoiManager manager, float x, float y) { if (float.IsNaN(x) || float.IsNaN(y)) { return(VERTEX_AT_INFINITY); } var result = manager.ObtainVertex(); result.Init(x, y); return(result); }
/* * This is the only way to make a Vertex * * @param halfedge0 * @param halfedge1 * @return * */ public static Vertex Intersect(VoronoiManager manager, Halfedge halfedge0, Halfedge halfedge1) { Edge edge, edge0, edge1; Halfedge halfedge; float determinant, intersectionX, intersectionY; bool rightOfSite; edge0 = halfedge0.edge; edge1 = halfedge1.edge; if (edge0 == null || edge1 == null) { return(null); } if (edge0.RightSite == edge1.RightSite) { return(null); } determinant = edge0.a * edge1.b - edge0.b * edge1.a; if (Math.Abs(determinant) < 1E-10) { // The edges are parallel return(null); } intersectionX = (edge0.c * edge1.b - edge1.c * edge0.b) / determinant; intersectionY = (edge1.c * edge0.a - edge0.c * edge1.a) / determinant; if (Voronoi.CompareByYThenX(edge0.RightSite, edge1.RightSite) < 0) { halfedge = halfedge0; edge = edge0; } else { halfedge = halfedge1; edge = edge1; } rightOfSite = intersectionX >= edge.RightSite.x; if ((rightOfSite && halfedge.leftRight == LR.LEFT) || (!rightOfSite && halfedge.leftRight == LR.RIGHT)) { return(null); } return(Vertex.Create(manager, intersectionX, intersectionY)); }
public void Dispose(VoronoiManager manager) { if (edgeListLeftNeighbor != null || edgeListRightNeighbor != null) { // still in EdgeList return; } if (nextInPriorityQueue != null) { // still in PriorityQueue return; } edge = null; leftRight = null; vertex = null; manager.Release(this); }
public SiteList(VoronoiManager manager) { this.manager = manager; sorted = false; }
public static Halfedge Create(VoronoiManager manager, Edge edge, LR lr) { return(manager.ObtainHalfedge().Init(edge, lr)); }
public static Halfedge CreateDummy(VoronoiManager manager) { return(manager.ObtainHalfedge().Init(null, null)); }
public HalfedgePriorityQueue(VoronoiManager manager, float ymin, float deltaY, int sqrtSitesNb) { this.manager = manager; Init(ymin, deltaY, sqrtSitesNb); }
public void Dispose(VoronoiManager manager) { coord = Vector2f.zero; manager.Release(this); }