Exemplo n.º 1
0
        public Bahn Bahnplanung(List <Voxel> voxelList, int layerIndex)
        {
            /*
             * Teilen der gesamten Voxelliste in Randvoxel und Rest, damit unterschiedliche Bahnen geplant werden können
             * splitList[0] enthält Schichtränder
             * splitList[1] enthält alle anderen Voxel
             */
            List <List <Voxel> > splitList = new List <List <Voxel> >(SplitVoxelList(voxelList));

            /*
             * Erstelle zwei Graphen : Randvoxel-Graph und Restvoxel-Graph
             * False und True zeigen hier jeweils nur an ob es sich bei den Verarbeitungsschritten um
             * Infillvoxel handelt oder nicht, wegen der Nachbarschaftskontrolle
             */
            Graph_ randGraph = new Graph_(VoxelToGraph(splitList[0], false));
            Graph_ restGraph = new Graph_(VoxelToGraph(splitList[1], true));

            // Erstellen der Druckfolgen
            Druckfolge initialRand = new Druckfolge();
            Druckfolge initialRest = new Druckfolge();

            Druckfolge _2optRand = new Druckfolge();
            Druckfolge _2optRest = new Druckfolge();

            Druckfolge optimizedRand = new Druckfolge(0.0);
            Druckfolge optimizedRest = new Druckfolge(0.0);


            /*
             * Da nur lokale Optima bestimmt werden, werden mehrere Durchläufe erzeugt, von denen das Beste ausgewählt wird.
             */
            for (int NNRUNS = 0; NNRUNS < ANZAHL_NNRUNS; NNRUNS++)
            {
                Random randomizer    = new Random();
                int    startNodeRand = (randomizer.Next(0, randGraph.GetGraph().Count - 1));
                int    startNodeRest = (randomizer.Next(0, restGraph.GetGraph().Count - 1));
                // Generieren einer NN-Tour mit random Startknoten
                initialRand = NearestNeighbor(randGraph.DeepCopy(), startNodeRand);
                initialRest = NearestNeighbor(restGraph.DeepCopy(), startNodeRest);

                // Verbesserung der initialen Lösung durch 2-opt
                _2optRand = _2Opt(initialRand, randGraph.DeepCopy(), false);
                _2optRest = _2Opt(initialRest, restGraph.DeepCopy(), true);

                //Behalten des besten lokalen Optimums
                if (_2optRand.GetGesamtkosten() < optimizedRand.GetGesamtkosten())
                {
                    optimizedRand = _2optRand.DeepCopy();
                }
                if (_2optRest.GetGesamtkosten() < optimizedRest.GetGesamtkosten())
                {
                    optimizedRest = _2optRest.DeepCopy();
                }
            }

            Bahn bahn = new Bahn(splitList, randGraph, restGraph, optimizedRand, optimizedRest, layerIndex);

            return(bahn);
        }
Exemplo n.º 2
0
 //Setter
 public void SetBahn(Bahn bahn)
 {
     m_splitList     = bahn.m_splitList;
     m_randGraph     = bahn.m_randGraph;
     m_restGraph     = bahn.m_restGraph;
     m_optimizedRand = bahn.m_optimizedRand;
     m_optimizedRest = bahn.m_optimizedRest;
     m_layerIndex    = bahn.m_layerIndex;
 }
        static void Main(string[] args)
        {
            /*
             * Konstanten
             */
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            string inputFile                 = @"Galgen.txt";
            int    randBreite                = 3;
            string currentPath               = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
            string path                      = currentPath + "\\";
            string fileName                  = @"Bahnplanung.txt";
            int    infillDensity             = 20;
            string infillType                = "3DInfill"; //3DInfill oder HexInfill oder LineInfill oder Line3DInfill
            int    offset                    = 0;          //für LineInfill
            double robotGeschwindigkeit      = 30.0;
            double extrusionsGeschwindigkeit = 36.0;

            /*
             * Konstanten
             */

            Console.WriteLine("Lese Modell ein...");
            Voxelmodell v = Input(path + inputFile);

            Console.WriteLine("Modell eingelesen!");

            Console.WriteLine("Verbreitere Rand...");
            v.randVerbreiterung(randBreite);
            Console.WriteLine("Rand verbreitert!");

            Console.WriteLine("Füge das Infill ein...");
            v.InsertInfill(infillDensity, infillType, offset);
            Console.WriteLine("Infill eingefügt!");

            Console.WriteLine("Plane die Bahn...");
            Bahn bahn = new Bahn();

            if (File.Exists(path + fileName))
            {
                File.Delete(path + fileName);
            }
            for (int i = 0; i < v.getSchichtenAnzahl(); i++)
            {
                Console.WriteLine("Plane die Bahn für Schicht " + i + "/" + v.getSchichtenAnzahl());
                bahn.Bahnplanung(v.getListeAtIndex(i), robotGeschwindigkeit, extrusionsGeschwindigkeit, path, fileName, (i + 1));
            }
            Console.WriteLine("Bahn geplant!");
        }