示例#1
0
        /// <summary>
        /// update dynamic cutpoint of 2 adjacent edges
        /// </summary>
        /// <param name="p"></param>
        static void UpdateNewEdgeCut(Vertex p)
        {
            OutsideEdgeLine e0 = p.E0;
            OutsideEdgeLine e1 = p.E1;

            Vector2f tmp_e0_q = e0._newDynamicMidPoint + e0.GetOriginalEdgeVector();
            Vector2f tmp_e1_p = e1._newDynamicMidPoint - e1.GetOriginalEdgeVector();

            if (MyMath.FindCutPoint(e0._newDynamicMidPoint, tmp_e0_q, e1._newDynamicMidPoint, tmp_e1_p, out Vector2f cutpoint))
            {
                p.SetNewXY(cutpoint.X, cutpoint.Y);
            }
            else
            {
                //pararell edges
            }
        }
示例#2
0
        internal void CreateEdges()
        {
            int             lim = flattenPoints.Count - 1;
            Vertex          p = null, q = null;
            OutsideEdgeLine edgeLine = null;

            _edges = new List <OutsideEdgeLine>();
            //
            for (int i = 0; i < lim; ++i)
            {
                //in order ...
                p = flattenPoints[i];
                q = flattenPoints[i + 1];
                if ((edgeLine = EdgeLine.FindCommonOutsideEdge(p, q)) != null)
                {
                    //from p point to q
                    //so ...
                    //edgeLine is outwardEdge for p.
                    //edgeLine is inwardEdge for q.
                    //p.OutwardEdge = q.InwardEdge = edgeLine;
                    _edges.Add(edgeLine);
                }
                else
                {
                    //?
                }
            }
            //close
            p = flattenPoints[lim];
            q = flattenPoints[0];

            if ((edgeLine = EdgeLine.FindCommonOutsideEdge(p, q)) != null)
            {
                //from p point to q
                //so ...
                //edgeLine is outwardEdge for p.
                //edgeLine is inwardEdge for q.
                //p.OutwardEdge = q.InwardEdge = edgeLine;
                _edges.Add(edgeLine);
            }
            else
            {
                //not found
            }
        }