Esempio n. 1
0
        public static List <Vertex> GetOuterContour(IReadOnlyCollection <Contour> contours,
                                                    int gridResolution)
        {
            List <Vertex> outerVertices = new List <Vertex>();

            var convexHull  = GetConvexHull(contours);
            var hullPolygon = convexHull.GetHullPolygon();

            ConcurrentBag <BinaryMap> Maps     = new ConcurrentBag <BinaryMap>();
            BinaryMapSettings         settings = new BinaryMapSettings
            {
                SizeX       = gridResolution,
                SizeY       = gridResolution,
                BoundingBox = hullPolygon.GetBounds()
            };

            for (int i = 0; i < contours.Count; i++)
            {
                BinaryMap bm = new BinaryMap(settings);
                bm.SetContour(contours.ElementAt(i).ToVector2dList());
                bm.Id = i;
                Maps.Add(bm);
            }

            BinaryMap refMap = Maps.FirstOrDefault();

            foreach (BinaryMap map in Maps)
            {
                refMap?.OR(map);
            }
            outerVertices = refMap?.GetBoundary();
            return(outerVertices);
        }
Esempio n. 2
0
        public BinaryMap(BinaryMapSettings settings)
        {
            Settings = settings;
            SizeX    = Settings.SizeX;
            SizeY    = Settings.SizeY;
            IncreaseGridSize(_increase_bounding_box);

            _binaryMap   = new int[SizeX, SizeY];
            _trackingMap = new int[SizeX, SizeY];
            Initilize();
        }