/** * Place a new point site into the DT. * @param site the new Pnt * @return set of all new triangles created */ public Set delaunayPlace(Pnt site) { Set newTriangles = new HashSet(); Set oldTriangles = new HashSet(); Set doneSet = new HashSet(); LinkedList waitingQ = new LinkedList(); // Locate containing triangle if (debug) Console.WriteLine("Locate"); Simplex triangle = locate(site); // Give up if no containing triangle or if site is already in DT var triangle_null = triangle == null; if (triangle_null || triangle.contains(site)) return newTriangles; // Find Delaunay cavity (those triangles with site in their circumcircles) if (debug) Console.WriteLine("Cavity"); waitingQ.add(triangle); while (!waitingQ.isEmpty()) { triangle = (Simplex) waitingQ.removeFirst(); if (site.vsCircumcircle((Pnt[]) triangle.toArray(new Pnt[0])) == 1) continue; oldTriangles.add(triangle); Iterator it = this.neighbors(triangle).iterator(); for (; it.hasNext();) { Simplex tri = (Simplex) it.next(); if (doneSet.contains(tri)) continue; doneSet.add(tri); waitingQ.add(tri); } } // Create the new triangles if (debug) Console.WriteLine("Create"); for (Iterator it = Simplex.boundary(oldTriangles).iterator(); it.hasNext();) { Set facet = (Set) it.next(); facet.add(site); newTriangles.add(new Simplex(facet)); } // Replace old triangles with new triangles if (debug) Console.WriteLine("Update"); this.update(oldTriangles, newTriangles); // Update mostRecent triangle if (!newTriangles.isEmpty()) mostRecent = (Simplex) newTriangles.iterator().next(); return newTriangles; }
public static bool test() { Set<?> s = new HashSet<Object>(); return s.isEmpty(); }