// Update neighbors to the right
 public void updateRight(Trapezoid ur, Trapezoid lr)
 {
     upperRight = ur; if (ur != null)
     {
         ur.upperLeft = this;
     }
     lowerRight = lr; if (lr != null)
     {
         lr.lowerLeft = this;
     }
 }
 // Update neighbors to the left
 public void updateLeft(Trapezoid ul, Trapezoid ll)
 {
     upperLeft = ul; if (ul != null)
     {
         ul.upperRight = this;
     }
     lowerLeft = ll; if (ll != null)
     {
         ll.lowerRight = this;
     }
 }
        public Triangulator(List <Point> polyLine)
        {
            polygons       = new List <List <Point> >();
            trapezoids     = new List <Trapezoid>();
            xMonoPoly      = new List <MonotoneMountain>();
            edgeList       = initEdges(polyLine);
            trapezoidalMap = new TrapezoidalMap();
            boundingBox    = trapezoidalMap.boundingBox(edgeList);
            queryGraph     = new QueryGraph(Sink.isink(boundingBox));

            process();
        }
示例#4
0
 // Update neighbors to the left
 public void UpdateLeft(Trapezoid ul, Trapezoid ll)
 {
     UpperLeft = ul;
     if (ul != null)
     {
         ul.UpperRight = this;
     }
     LowerLeft = ll;
     if (ll != null)
     {
         ll.LowerRight = this;
     }
 }
示例#5
0
        public Triangulator(List <Point> polyLine, float sheer)
        {
            _sheer          = sheer;
            Triangles       = new List <List <Point> >();
            Trapezoids      = new List <Trapezoid>();
            _xMonoPoly      = new List <MonotoneMountain>();
            _edgeList       = InitEdges(polyLine);
            _trapezoidalMap = new TrapezoidalMap();
            _boundingBox    = _trapezoidalMap.BoundingBox(_edgeList);
            _queryGraph     = new QueryGraph(Sink.Isink(_boundingBox));

            Process();
        }
示例#6
0
 // Update neighbors to the right
 public void UpdateRight(Trapezoid ur, Trapezoid lr)
 {
     UpperRight = ur;
     if (ur != null)
     {
         ur.UpperLeft = this;
     }
     LowerRight = lr;
     if (lr != null)
     {
         lr.LowerLeft = this;
     }
 }
示例#7
0
 public Trapezoid(Point leftPoint, Point rightPoint, Edge top, Edge bottom)
 {
     LeftPoint  = leftPoint;
     RightPoint = rightPoint;
     Top        = top;
     Bottom     = bottom;
     UpperLeft  = null;
     UpperRight = null;
     LowerLeft  = null;
     LowerRight = null;
     Inside     = true;
     Sink       = null;
 }
示例#8
0
        // Case 1: segment completely enclosed by trapezoid
        //         break trapezoid into 4 smaller trapezoids
        public Trapezoid[] Case1(Trapezoid t, Edge e)
        {
            Trapezoid[] trapezoids = new Trapezoid[4];
            trapezoids[0] = new Trapezoid(t.LeftPoint, e.P, t.Top, t.Bottom);
            trapezoids[1] = new Trapezoid(e.P, e.Q, t.Top, e);
            trapezoids[2] = new Trapezoid(e.P, e.Q, e, t.Bottom);
            trapezoids[3] = new Trapezoid(e.Q, t.RightPoint, t.Top, t.Bottom);

            trapezoids[0].UpdateLeft(t.UpperLeft, t.LowerLeft);
            trapezoids[1].UpdateLeftRight(trapezoids[0], null, trapezoids[3], null);
            trapezoids[2].UpdateLeftRight(null, trapezoids[0], null, trapezoids[3]);
            trapezoids[3].UpdateRight(t.UpperRight, t.LowerRight);

            return(trapezoids);
        }
        // Case 1: segment completely enclosed by trapezoid
        //         break trapezoid into 4 smaller trapezoids
        public Trapezoid[] case1(Trapezoid t, Edge e)
        {
            Trapezoid[] trapezoids = new Trapezoid[4];
            trapezoids[0] = new Trapezoid(t.leftPoint, e.p, t.top, t.bottom);
            trapezoids[1] = new Trapezoid(e.p, e.q, t.top, e);
            trapezoids[2] = new Trapezoid(e.p, e.q, e, t.bottom);
            trapezoids[3] = new Trapezoid(e.q, t.rightPoint, t.top, t.bottom);

            trapezoids[0].updateLeft(t.upperLeft, t.lowerLeft);
            trapezoids[1].updateLeftRight(trapezoids[0], null, trapezoids[3], null);
            trapezoids[2].updateLeftRight(null, trapezoids[0], null, trapezoids[3]);
            trapezoids[3].updateRight(t.upperRight, t.lowerRight);

            return(trapezoids);
        }
        public Trapezoid(Point leftPoint, Point rightPoint, Edge top, Edge bottom)
        {
            this.leftPoint  = leftPoint;
            this.rightPoint = rightPoint;
            this.top        = top;
            this.bottom     = bottom;
            upperLeft       = null;
            upperRight      = null;
            lowerLeft       = null;
            lowerRight      = null;
            inside          = true;
            sink            = null;

            //TODO??
            //key = hash(self)
        }
 // Update neighbors on both sides
 public void updateLeftRight(Trapezoid ul, Trapezoid ll, Trapezoid ur, Trapezoid lr)
 {
     upperLeft = ul; if (ul != null)
     {
         ul.upperRight = this;
     }
     lowerLeft = ll; if (ll != null)
     {
         ll.lowerRight = this;
     }
     upperRight = ur; if (ur != null)
     {
         ur.upperLeft = this;
     }
     lowerRight = lr; if (lr != null)
     {
         lr.lowerLeft = this;
     }
 }
示例#12
0
        // Case 4: Trapezoid contains point q, p lies outside
        //         break trapezoid into 3 smaller trapezoids
        public Trapezoid[] Case4(Trapezoid t, Edge e)
        {
            Point lp;

            if (e.P.X == t.LeftPoint.X)
            {
                lp = e.P;
            }
            else
            {
                lp = t.LeftPoint;
            }

            Trapezoid[] trapezoids = new Trapezoid[3];

            if (_cross == t.Top)
            {
                trapezoids[0]            = t.UpperLeft;
                trapezoids[0].RightPoint = e.Q;
            }
            else
            {
                trapezoids[0] = new Trapezoid(lp, e.Q, t.Top, e);
                trapezoids[0].UpdateLeft(t.UpperLeft, e.Above);
            }

            if (_bCross == t.Bottom)
            {
                trapezoids[1]            = t.LowerLeft;
                trapezoids[1].RightPoint = e.Q;
            }
            else
            {
                trapezoids[1] = new Trapezoid(lp, e.Q, e, t.Bottom);
                trapezoids[1].UpdateLeft(e.Below, t.LowerLeft);
            }

            trapezoids[2] = new Trapezoid(e.Q, t.RightPoint, t.Top, t.Bottom);
            trapezoids[2].UpdateLeftRight(trapezoids[0], trapezoids[1], t.UpperRight, t.LowerRight);

            return(trapezoids);
        }
        // Case 4: Trapezoid contains point q, p lies outside
        //         break trapezoid into 3 smaller trapezoids
        public Trapezoid[] case4(Trapezoid t, Edge e)
        {
            Point lp;

            if (e.p.x == t.leftPoint.x)
            {
                lp = e.p;
            }
            else
            {
                lp = t.leftPoint;
            }

            Trapezoid[] trapezoids = new Trapezoid[3];

            if (tCross == t.top)
            {
                trapezoids[0]            = t.upperLeft;
                trapezoids[0].rightPoint = e.q;
            }
            else
            {
                trapezoids[0] = new Trapezoid(lp, e.q, t.top, e);
                trapezoids[0].updateLeft(t.upperLeft, e.above);
            }

            if (bCross == t.bottom)
            {
                trapezoids[1]            = t.lowerLeft;
                trapezoids[1].rightPoint = e.q;
            }
            else
            {
                trapezoids[1] = new Trapezoid(lp, e.q, e, t.bottom);
                trapezoids[1].updateLeft(e.below, t.lowerLeft);
            }

            trapezoids[2] = new Trapezoid(e.q, t.rightPoint, t.top, t.bottom);
            trapezoids[2].updateLeftRight(trapezoids[0], trapezoids[1], t.upperRight, t.lowerRight);

            return(trapezoids);
        }
示例#14
0
        // Y intercept

        public Edge(Point p, Point q)
        {
            P = p;
            Q = q;

            if (q.X - p.X != 0)
            {
                Slope = (q.Y - p.Y) / (q.X - p.X);
            }
            else
            {
                Slope = 0;
            }

            B       = p.Y - (p.X * Slope);
            Above   = null;
            Below   = null;
            MPoints = new HashSet <Point>();
            MPoints.Add(p);
            MPoints.Add(q);
        }
        public Edge(Point p, Point q)
        {
            this.p = p;
            this.q = q;

            if (q.x - p.x != 0)
            {
                slope = (q.y - p.y) / (q.x - p.x);
            }
            else
            {
                slope = 0;
            }

            b       = p.y - (p.x * slope);
            above   = null;
            below   = null;
            mPoints = new List <Point>();
            mPoints.Add(p);
            mPoints.Add(q);
        }
示例#16
0
        // Y intercept

        public Edge(Point p, Point q)
        {
            P = p;
            Q = q;

            if (q.x - p.x != 0)
            {
                Slope = (q.y - p.y) / (q.x - p.x);
            }
            else
            {
                Slope = 0;
            }

            B       = p.y - (p.x * Slope);
            Above   = null;
            Below   = null;
            MPoints = new HashSet <Point>();
            MPoints.Add(p);
            MPoints.Add(q);
        }
示例#17
0
 // Update neighbors on both sides
 public void UpdateLeftRight(Trapezoid ul, Trapezoid ll, Trapezoid ur, Trapezoid lr)
 {
     UpperLeft = ul;
     if (ul != null)
     {
         ul.UpperRight = this;
     }
     LowerLeft = ll;
     if (ll != null)
     {
         ll.LowerRight = this;
     }
     UpperRight = ur;
     if (ur != null)
     {
         ur.UpperLeft = this;
     }
     LowerRight = lr;
     if (lr != null)
     {
         lr.LowerLeft = this;
     }
 }
 public Sink(Trapezoid trapezoid)
     : base(null, null)
 {
     this.trapezoid = trapezoid;
     trapezoid.sink = this;
 }
示例#19
0
 private Sink(Trapezoid trapezoid)
     : base(null, null)
 {
     Trapezoid      = trapezoid;
     trapezoid.Sink = this;
 }