예제 #1
0
		/* 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);
				}
			}
		}