Esempio n. 1
0
        /* Navigation */

        /**
         * Report neighbor opposite the given vertex of simplex.
         * @param vertex a vertex of simplex
         * @param simplex we want the neighbor of this Simplex
         * @return the neighbor opposite vertex of simplex; null if none
         * @throws IllegalArgumentException if vertex is not in this Simplex
         */
        public Simplex neighborOpposite(Object vertex, Simplex simplex)
        {
            if (!simplex.contains(vertex))
            {
                throw new InvalidOperationException("Bad vertex; not in simplex");
            }

            for (Iterator it = ((Set)_neighbors.get(simplex)).iterator(); it.hasNext();)
            {
                Simplex s = (Simplex)it.next();
                for (Iterator otherIt = simplex.iterator(); otherIt.hasNext();)
                {
                    var v = otherIt.next();
                    if (v.Equals(vertex))
                    {
                        continue;
                    }
                    if (!s.contains(v))
                    {
                        s = null;
                        break;
                    }
                }

                if (s == null)
                {
                    continue;
                }

                return(s);
            }
            return(null);
        }
Esempio n. 2
0
 /**
  * Draw all the empty circles (one for each triangle) of the DT.
  */
 public void drawAllCircles()
 {
     // Loop through all triangles of the DT
     for (Iterator it = dt.iterator(); it.hasNext();)
     {
         Simplex triangle = (Simplex)it.next();
         for (Iterator otherIt = initialTriangle.iterator(); otherIt.hasNext();)
         {
             Pnt p = (Pnt)otherIt.next();
             if (triangle.contains(p))
             {
                 triangle = null;
                 break;
             }
         }
         if (triangle != null)
         {
             Pnt    c      = Pnt.circumcenter((Pnt[])triangle.toArray(new Pnt[0]));
             double radius = c.subtract((Pnt)triangle.iterator().next()).magnitude();
             draw(c, radius, null);
         }
     }
 }
		/* Navigation */

		/**
		 * Report neighbor opposite the given vertex of simplex.
		 * @param vertex a vertex of simplex
		 * @param simplex we want the neighbor of this Simplex
		 * @return the neighbor opposite vertex of simplex; null if none
		 * @throws IllegalArgumentException if vertex is not in this Simplex
		 */
		public Simplex neighborOpposite(Object vertex, Simplex simplex)
		{
			if (!simplex.contains(vertex))
				throw new InvalidOperationException("Bad vertex; not in simplex");

			for (Iterator it = ((Set)_neighbors.get(simplex)).iterator(); it.hasNext(); )
			{
				Simplex s = (Simplex)it.next();
				for (Iterator otherIt = simplex.iterator(); otherIt.hasNext(); )
				{
					var v = otherIt.next();
					if (v.Equals(vertex)) continue;
					if (!s.contains(v))
					{
						s = null;
						break;
					}
				}
				
				if (s == null)
					continue;

				return s;
			}
			return null;
		}