Exemple #1
0
 public void Case1(Sink sink, Edge edge, Trapezoid[] tList)
 {
     YNode yNode = new YNode(edge, Sink.Isink(tList[1]), Sink.Isink(tList[2]));
     XNode qNode = new XNode(edge.Q, yNode, Sink.Isink(tList[3]));
     XNode pNode = new XNode(edge.P, Sink.Isink(tList[0]), qNode);
     Replace(sink, pNode);
 }
        // Case 2: Trapezoid contains point p, q lies outside
        //         break trapezoid into 3 smaller trapezoids
        public Trapezoid[] Case2(Trapezoid t, Edge e)
        {
            Point rp;
            if (e.Q.X == t.RightPoint.X)
                rp = e.Q;
            else
                rp = t.RightPoint;

            Trapezoid[] trapezoids = new Trapezoid[3];
            trapezoids[0] = new Trapezoid(t.LeftPoint, e.P, t.Top, t.Bottom);
            trapezoids[1] = new Trapezoid(e.P, rp, t.Top, e);
            trapezoids[2] = new Trapezoid(e.P, rp, e, t.Bottom);

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

            _bCross = t.Bottom;
            _cross = t.Top;

            e.Above = trapezoids[1];
            e.Below = trapezoids[2];

            return trapezoids;
        }
Exemple #3
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;
 }
Exemple #4
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;
 }
Exemple #5
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;
 }
Exemple #6
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;
 }
Exemple #7
0
 public Trapezoid(Point leftPoint, Point rightPoint, Edge top, Edge bottom)
 {
     this.LeftPoint  = leftPoint;
     this.RightPoint = rightPoint;
     this.Top        = top;
     this.Bottom     = bottom;
     this.UpperLeft  = null;
     this.UpperRight = null;
     this.LowerLeft  = null;
     this.LowerRight = null;
     this.Inside     = true;
     this.Sink       = null;
 }
Exemple #8
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;
     }
 }
Exemple #9
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;
     }
 }
Exemple #10
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();
        }
Exemple #11
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;
 }
Exemple #12
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);
        }
Exemple #13
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 3: Trapezoid is bisected
        public Trapezoid[] Case3(Trapezoid t, Edge e)
        {
            Point lp;
            if (e.P.X == t.LeftPoint.X)
                lp = e.P;
            else
                lp = t.LeftPoint;

            Point rp;
            if (e.Q.X == t.RightPoint.X)
                rp = e.Q;
            else
                rp = t.RightPoint;

            Trapezoid[] trapezoids = new Trapezoid[2];

            if (_cross == t.Top)
            {
                trapezoids[0] = t.UpperLeft;
                trapezoids[0].UpdateRight(t.UpperRight, null);
                trapezoids[0].RightPoint = rp;
            }
            else
            {
                trapezoids[0] = new Trapezoid(lp, rp, t.Top, e);
                trapezoids[0].UpdateLeftRight(t.UpperLeft, e.Above, t.UpperRight, null);
            }

            if (_bCross == t.Bottom)
            {
                trapezoids[1] = t.LowerLeft;
                trapezoids[1].UpdateRight(null, t.LowerRight);
                trapezoids[1].RightPoint = rp;
            }
            else
            {
                trapezoids[1] = new Trapezoid(lp, rp, e, t.Bottom);
                trapezoids[1].UpdateLeftRight(e.Below, t.LowerLeft, null, t.LowerRight);
            }

            _bCross = t.Bottom;
            _cross = t.Top;

            e.Above = trapezoids[0];
            e.Below = trapezoids[1];

            return trapezoids;
        }
        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);
        }
Exemple #16
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);
        }
Exemple #17
0
        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);
        }
Exemple #18
0
        public Edge(Point p, Point q)
        {
            this.P = p;
            this.Q = q;

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

            this.B       = p.Y - (p.X * this.Slope);
            this.Above   = null;
            this.Below   = null;
            this.MPoints = new HashSet <Point>();
            this.MPoints.Add(p);
            this.MPoints.Add(q);
        }
Exemple #19
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;
     }
 }
Exemple #20
0
 public void Case3(Sink sink, Edge edge, Trapezoid[] tList)
 {
     YNode yNode = new YNode(edge, Sink.Isink(tList[0]), Sink.Isink(tList[1]));
     Replace(sink, yNode);
 }
Exemple #21
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;
        }