Inheritance: Delaunay.Utils.IDisposable
コード例 #1
0
		/**
		 * This function only removes the Halfedge from the left-right list.
		 * We cannot dispose it yet because we are still using it. 
		 * @param halfEdge
		 * 
		 */
		public void Remove (Halfedge halfEdge)
		{
			halfEdge.edgeListLeftNeighbor.edgeListRightNeighbor = halfEdge.edgeListRightNeighbor;
			halfEdge.edgeListRightNeighbor.edgeListLeftNeighbor = halfEdge.edgeListLeftNeighbor;
			halfEdge.edge = Edge.DELETED;
			halfEdge.edgeListLeftNeighbor = halfEdge.edgeListRightNeighbor = null;
		}
コード例 #2
0
		/**
		 * Insert newHalfedge to the right of lb 
		 * @param lb
		 * @param newHalfedge
		 * 
		 */
		public void Insert (Halfedge lb, Halfedge newHalfedge)
		{
			newHalfedge.edgeListLeftNeighbor = lb;
			newHalfedge.edgeListRightNeighbor = lb.edgeListRightNeighbor;
			lb.edgeListRightNeighbor.edgeListLeftNeighbor = newHalfedge;
			lb.edgeListRightNeighbor = newHalfedge;
		}
コード例 #3
0
		private Halfedge Init (Edge edge, Nullable<Side> lr)
		{
			this.edge = edge;
			leftRight = lr;
			nextInPriorityQueue = null;
			vertex = null;
			return this;
		}
コード例 #4
0
		private int Bucket (Halfedge halfEdge)
		{
			int theBucket = (int)((halfEdge.ystar - _ymin) / _deltay * _hashsize);
			if (theBucket < 0)
				theBucket = 0;
			if (theBucket >= _hashsize)
				theBucket = _hashsize - 1;
			return theBucket;
		}
コード例 #5
0
ファイル: Halfedge.cs プロジェクト: ngarside/Delaunay
 public void ReallyDispose()
 {
     edgeListLeftNeighbor = null;
     edgeListRightNeighbor = null;
     nextInPriorityQueue = null;
     edge = null;
     leftRight = null;
     vertex = null;
     _pool.Add(this);
 }
コード例 #6
0
		public void Insert (Halfedge halfEdge)
		{
			Halfedge previous, next;
			int insertionBucket = Bucket (halfEdge);
			if (insertionBucket < _minBucket) {
				_minBucket = insertionBucket;
			}
			previous = _hash [insertionBucket];
			while ((next = previous.nextInPriorityQueue) != null
			&&     (halfEdge.ystar  > next.ystar || (halfEdge.ystar == next.ystar && halfEdge.vertex.x > next.vertex.x))) {
				previous = next;
			}
			halfEdge.nextInPriorityQueue = previous.nextInPriorityQueue; 
			previous.nextInPriorityQueue = halfEdge;
			++_count;
		}
コード例 #7
0
		public void Remove (Halfedge halfEdge)
		{
			Halfedge previous;
			int removalBucket = Bucket (halfEdge);
			
			if (halfEdge.vertex != null) {
				previous = _hash [removalBucket];
				while (previous.nextInPriorityQueue != halfEdge) {
					previous = previous.nextInPriorityQueue;
				}
				previous.nextInPriorityQueue = halfEdge.nextInPriorityQueue;
				_count--;
				halfEdge.vertex = null;
				halfEdge.nextInPriorityQueue = null;
				halfEdge.Dispose ();
			}
		}
コード例 #8
0
ファイル: Vertex.cs プロジェクト: ngarside/UnityDelaunay
        /**
         * This is the only way to make a Vertex
         *
         * @param halfedge0
         * @param halfedge1
         * @return
         *
         */
        public static Vertex Intersect(Halfedge halfedge0, Halfedge halfedge1)
        {
            Edge edge0, edge1, edge;
            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 (-1.0e-10 < determinant && determinant < 1.0e-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(intersectionX, intersectionY);
        }
コード例 #9
0
		public EdgeList (float xmin, float deltax, int sqrt_nsites)
		{
			_xmin = xmin;
			_deltax = deltax;
			_hashsize = 2 * sqrt_nsites;

			_hash = new Halfedge[_hashsize];
			
			// two dummy Halfedges:
			_leftEnd = Halfedge.CreateDummy ();
			_rightEnd = Halfedge.CreateDummy ();
			_leftEnd.edgeListLeftNeighbor = null;
			_leftEnd.edgeListRightNeighbor = _rightEnd;
			_rightEnd.edgeListLeftNeighbor = _leftEnd;
			_rightEnd.edgeListRightNeighbor = null;
			_hash [0] = _leftEnd;
			_hash [_hashsize - 1] = _rightEnd;
		}
コード例 #10
0
		public void Dispose ()
		{
			Halfedge halfEdge = _leftEnd;
			Halfedge prevHe;
			while (halfEdge != _rightEnd) {
				prevHe = halfEdge;
				halfEdge = halfEdge.edgeListRightNeighbor;
				prevHe.Dispose ();
			}
			_leftEnd = null;
			_rightEnd.Dispose ();
			_rightEnd = null;

			int i;
			for (i = 0; i < _hashsize; ++i) {
				_hash [i] = null;
			}
			_hash = null;
		}
コード例 #11
0
ファイル: EdgeList.cs プロジェクト: ngarside/Delaunay
        public EdgeList(float xmin, float deltax, int sqrt_nsites)
        {
            _xmin = xmin;
            _deltax = deltax;
            _hashsize = 2 * sqrt_nsites;

            int i;
            _hash = new List<Halfedge>(_hashsize);

            while (_hash.Count < _hashsize)
            {
                _hash.Add(null);
            }

            // two dummy Halfedges:
            _leftEnd = Halfedge.CreateDummy();
            _rightEnd = Halfedge.CreateDummy();
            _leftEnd.edgeListLeftNeighbor = null;
            _leftEnd.edgeListRightNeighbor = _rightEnd;
            _rightEnd.edgeListLeftNeighbor = _leftEnd;
            _rightEnd.edgeListRightNeighbor = null;
            _hash[0] = _leftEnd;
            _hash[_hashsize - 1] = _rightEnd;
        }
コード例 #12
0
ファイル: Voronoi.cs プロジェクト: WilliamChao/nmap
		private Site FortunesAlgorithm_rightRegion (Halfedge he)
		{
			Edge edge = he.edge;
			if (edge == null) {
				return fortunesAlgorithm_bottomMostSite;
			}
			return edge.Site (SideHelper.Other ((Side)he.leftRight));
		}
コード例 #13
0
ファイル: Voronoi.cs プロジェクト: ngarside/UnityDelaunay
 Site RightRegion(Halfedge he, Site bottomMostSite)
 {
     Edge edge = he.edge;
     if (edge == null)
     {
         return bottomMostSite;
     }
     return edge.GetSite(LR.Other(he.leftRight));
 }
コード例 #14
0
 private Site FortunesAlgorithm_leftRegion(Halfedge he)
 {
     Edge edge = he.edge;
     if (edge == null) {
         return fortunesAlgorithm_bottomMostSite;
     }
     return edge.Site ((LR.Side)he.leftRight);
 }