Skip to content

Skeleton with Holes #13

@bvessels

Description

@bvessels

Edited for clarity:
I have a polygon (array of Vector2s) and an array of polygons that represent interior holes. After I create the PolygonWithHoles2 instance using the outermost polygon, I then use the AddHole method for each of the holes. I would expect an interior skeleton generated using the PolygonWithHoles2 instance to respect the previously added holes. However, the resulting skeleton remains the same as though no holes had been added at all. I've attached images demonstrating this (Input polygons/holes depicted in red, generated lines depicted in pink). How do you create a skeleton with interior holes? Below is my code:

`
////Get the instance to the offset algorithm.
var instance = PolygonOffset2.Instance;

        var polygon = new Polygon2<EIK>(args.Lines.First().Points.Select(p => new Point2d(p.X, p.Y)).ToArray());
        if (polygon.IsClockWise) {
            args.Lines.First().Points.Reverse();
            polygon = new Polygon2<EIK>(args.Lines.First().Points.Select(p => new Point2d(p.X, p.Y)).ToArray());
        }

        var polygonWithHoles = new PolygonWithHoles2<EIK>(polygon);
        foreach (var hole in args.Lines.Skip(1)) {
            var polygonHole = new Polygon2<EIK>(hole.Points.Select(p => new Point2d(p.X, p.Y)).ToArray());

            if (polygonHole.IsCounterClockWise) {
                hole.Points.Reverse();
                polygonHole = new Polygon2<EIK>(hole.Points.Select(p => new Point2d(p.X, p.Y)).ToArray());
            }
            polygonWithHoles.AddHole(polygonHole);
        }

        //The skeleton is return as a array of segments.
        var skeleton = new List<Segment2d>();
        instance.CheckInput = true;
        instance.CreateInteriorSkeleton(polygonWithHoles, false, skeleton);

        foreach (var segment in skeleton) {
            Utils.AddToBmp(bmp, new Vector2[] { 
                new Vector2((float)segment.A.x, (float)segment.A.y), 
                new Vector2((float)segment.B.x, (float)segment.B.y) 
            }, Color.HotPink);

WEIRD_Ring
Square_Ring
Polyline

        }

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions