Example #1
0
        public MazeConstructor(Bitmap bitmap, MazeConstructorPreference preference)
        {
            this.preference = preference;

            Thresholding(bitmap);
            Repeir();

            ShapeDetector shapeDetector = new ShapeDetector(StepRepair, preference);

            StepDestroyShape = shapeDetector.ConvertedSource;

            LineDetector lineDetector = new LineDetector(StepDestroyShape, preference);

            StepGeometry = lineDetector.StepGeometry;

            try
            {
                LineMerger lineMerger = new LineMerger(lineDetector.VerticalLines, lineDetector.HorizontalLines, preference);
                StepMaze      = lineMerger.LastStep;
                IsMazeCorrect = CheckIsMazeCorrect();
            }
            catch
            {
                StepMaze = new bool[1, 1];
            }
        }
Example #2
0
        private void SetImages()
        {
            MazeConstructorPreference preference      = new MazeConstructorPreference(Thresholding, RepeirIteration, MinimalShapeSize, LineThicknes, FieldLenght);
            MazeConstructor           mazeConstructor = new MazeConstructor(bitmap, preference);

            maze = mazeConstructor.IsMazeCorrect ? mazeConstructor.StepMaze : null;

            AcceptImageButton.IsEnabled = mazeConstructor.IsMazeCorrect;

            ImageConstructor imageConstructor = new MazeImageConstructor(mazeConstructor.StepMaze, 3);

            Photo1.Source = imageConstructor.ImageSource;

            imageConstructor = new ImageConstructor(mazeConstructor.StepThresholding);
            Photo2.Source    = imageConstructor.ImageSource;

            imageConstructor = new ImageConstructor(mazeConstructor.StepRepair);
            Photo3.Source    = imageConstructor.ImageSource;

            imageConstructor = new ImageConstructor(mazeConstructor.StepDestroyShape);
            Photo4.Source    = imageConstructor.ImageSource;

            imageConstructor = new ImageConstructor(mazeConstructor.StepGeometry);
            Photo5.Source    = imageConstructor.ImageSource;
        }
Example #3
0
        public LineMerger(List <Line> verticalLines, List <Line> horizontalLines, MazeConstructorPreference preference)
        {
            this.preference      = preference;
            this.verticalLines   = new List <Line>(verticalLines);
            this.horizontalLines = new List <Line>(horizontalLines);

            GenerateMaze();
        }
Example #4
0
        public ShapeDetector(bool[,] source, MazeConstructorPreference preference)
        {
            this.preference = preference;

            height = source.GetLength(0);
            width  = source.GetLength(1);

            ConvertedSource = (bool[, ])source.Clone();

            markedField = new bool[height, width];
            queue       = new Point[source.Length];

            DeleteDisturbingShape();
        }
Example #5
0
        public LineDetector(bool[,] source, MazeConstructorPreference preference)
        {
            this.preference = preference;

            height = source.GetLength(0);
            width  = source.GetLength(1);

            currentSource = (bool[, ])source.Clone();
            ReadVerticalLines();

            currentSource = (bool[, ])source.Clone();
            ReadHorizontalLines();

            GenerateMaze();
        }