Example #1
0
        public static void PolyTreeToPolygons(PolyTree polytree, List<List<IntPoint>> polygons)
        {
            Contract.Requires(polytree != null);
            Contract.Requires(polygons != null);

            polygons.Clear();
            InternalHelpers.AddPolyNodeToPolygons(polytree, polygons);
        }
Example #2
0
        public bool Execute(ClipType clipType, PolyTree polytree, PolyFillType subjFillType = PolyFillType.EvenOdd, PolyFillType clipFillType = PolyFillType.EvenOdd)
        {
            if (_executeLocked)
                return false;
            _executeLocked = true;

            _subjFillType = subjFillType;
            _clipFillType = clipFillType;
            _clipType = clipType;
            _usingPolyTree = true;
            var succeeded = ExecuteInternal();

            //build the return polygons ...
            if (succeeded)
                BuildResultPolytree(polytree);

            _executeLocked = false;
            return succeeded;
        }
Example #3
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);
            }
        }