public iterator ( ) : global::java.util.Iterator | ||
Результат | global::java.util.Iterator |
/** * 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; }
/* Modification */ /** * Update by replacing one set of Simplices with another. * Both sets of simplices must fill the same "hole" in the * Triangulation. * @param oldSet set of Simplices to be replaced * @param newSet set of replacement Simplices */ public void update(Set oldSet, Set newSet) { // Collect all simplices neighboring the oldSet Set allNeighbors = new HashSet(); for (Iterator it = oldSet.iterator(); it.hasNext(); ) allNeighbors.addAll((Set)_neighbors.get((Simplex)it.next())); // Delete the oldSet for (Iterator it = oldSet.iterator(); it.hasNext(); ) { Simplex simplex = (Simplex)it.next(); for (Iterator otherIt = ((Set)_neighbors.get(simplex)).iterator(); otherIt.hasNext(); ) ((Set)_neighbors.get(otherIt.next())).remove(simplex); _neighbors.remove(simplex); allNeighbors.remove(simplex); } // Include the newSet simplices as possible neighbors allNeighbors.addAll(newSet); // Create entries for the simplices in the newSet for (Iterator it = newSet.iterator(); it.hasNext(); ) _neighbors.put((Simplex)it.next(), new HashSet()); // Update all the neighbors info for (Iterator it = newSet.iterator(); it.hasNext(); ) { Simplex s1 = (Simplex)it.next(); for (Iterator otherIt = allNeighbors.iterator(); otherIt.hasNext(); ) { Simplex s2 = (Simplex)otherIt.next(); if (!s1.isNeighbor(s2)) continue; ((Set)_neighbors.get(s1)).add(s2); ((Set)_neighbors.get(s2)).add(s1); } } }