Exemplo n.º 1
0
        internal void AddChild(PolyNode child)
        {
            Contract.Requires(child != null);

            var cnt = Children.Count;
            Children.Add(child);
            child.Parent = this;
            child._index = cnt;
        }
Exemplo n.º 2
0
        private void BuildResultPolytree(PolyTree polytree)
        {
            Contract.Requires(polytree != null);

            polytree.Clear();

            //add each output polygon/contour to polytree ...
            foreach (var outRec in _polyOuts)
            {
                var cnt = PointCount(outRec.Pts);
                if (cnt < 3)
                    continue;
                FixHoleLinkage(outRec);
                var pn = new PolyNode();
                polytree.AllPolys.Add(pn);
                outRec.PolyNode = pn;
                var op = outRec.Pts;
                for (var j = 0; j < cnt; j++)
                {
                    pn.Polygon.Add(op.Pt);
                    op = op.Prev;
                }
            }

            //fixup PolyNode links etc ...
            foreach (var outRec in _polyOuts.Where(outRec => outRec.PolyNode != null))
            {
                if (outRec.FirstLeft == null)
                    polytree.AddChild(outRec.PolyNode);
                else
                    outRec.FirstLeft.PolyNode.AddChild(outRec.PolyNode);
            }
        }