Пример #1
0
        public void InitUncertaintyManager(Variation m_variation)
        {
            variation     = m_variation;
            possibilities = CalculatePossiblities();
            int[] array = new int[variation.NumberOfFacesToMove()];
            arrayLength = array.Length;
            variations  = new List <int[]>();
            CalculatePermutation(array, ref variations, depth, array.Length);


            //Debug Part
            Console.WriteLine("Permutations: ");
            string mstring = "";

            foreach (int[] arrayElement in variations)
            {
                for (int i = 0; i < arrayElement.Length; i++)
                {
                    mstring += arrayElement[i] + " ";
                }
                mstring += "\n";
            }
            Console.WriteLine(mstring);

            //foreach (int number in arrayElement)
            //    Console.WriteLine(number);
            //Console.ReadLine();
        }
Пример #2
0
        public static Variation InitVariation(string[] filePaths, string path, string inputXmlPath)
        {
            Variation variation = new Variation("Base Variation");

            foreach (string filePath in filePaths)
            {
                string floorPath = Path.Combine(path, filePath);
                Globals.xmlDoc.Load(floorPath);

                Floor floor = new Floor(Path.GetFileName(filePath));
                variation.AddFloor(floor);
                Parser.ParseFloor(path, FileStatus.read, variation, floor);        //Hier liegt der Fehler!
                Parser.ParseFloor(inputXmlPath, FileStatus.input, floor);
                floor.InitFacesEdges();
            }
            return(variation);
        }
Пример #3
0
        /// <summary>
        /// Parse Xml.Floor into our fileformat
        /// </summary>
        /// <param name="path">The path we are reading from and into</param>
        /// <param name="fileStatus">read and write</param>
        public static void ParseFloor(string path, FileStatus fileStatus, Variation variation, Floor floor)
        {
            XmlDocument tempXmlDoc = Globals.xmlDoc;                                                                    //copy our document, so that if we save the changes it doesnt get defined

            if (fileStatus == FileStatus.input)
            {
                tempXmlDoc = Globals.xmlInput;
            }
            foreach (string objectType in Globals.objectTypes)                                                          //Iterate through all simObjs (wall, door ...)
            {
                XmlNodeList genericNodes = tempXmlDoc.SelectNodes("//floor/layer/" + objectType);
                {
                    foreach (XmlNode genericNode in genericNodes)
                    {
                        Face        tempObj    = new Face(genericNode.Attributes["id"].Value, ref variation, SetObjectType(genericNode.Attributes["id"].Value));
                        XmlNodeList pointNodes = genericNode.ChildNodes;

                        switch (fileStatus)
                        {
                        case FileStatus.read:
                        {
                            List <Vertex> vertices = new List <Vertex>();                                                   //Empty list containing the vertices of the face beeing created
                            foreach (XmlNode pointNode in pointNodes)
                            {
                                Vertex tempVertex = new Vertex();                                                          //Empty Vertex object

                                float x = float.Parse(pointNode.Attributes["x"].Value, Globals.culture);
                                float y = float.Parse(pointNode.Attributes["y"].Value, Globals.culture);

                                if (variation.FindVertex(x, y) != null)                                                       //Check if thge vertex was already created
                                {
                                    vertices.Add(variation.FindVertex(x, y));                                                 //if so, add the vertex to the list
                                }
                                else
                                {
                                    tempVertex = new Vertex(x, y);
                                    variation.AddVertex(tempVertex);
                                    vertices.Add(tempVertex);                                                         //ifnot, create a new vertex and add it to the list
                                }
                            }
                            Face testObj = new Face(genericNode.Attributes["id"].Value, ref variation, SetObjectType(genericNode.Attributes["id"].Value));
                            testObj.AddVertex(vertices);                                                                    //add the vertex list to our tempObj
                            variation.SetFacesVertices(testObj);                                                            //setup the face reference for the vertices in the globals.vertices
                            floor.AddFace(testObj);                                                                         //add the face to our floors facelist
                            break;
                        }

                        case FileStatus.write:
                        {
                            int i = 0;
                            foreach (XmlNode pointNode in pointNodes)
                            {
                                pointNode.Attributes["x"].Value = floor.GetFace(genericNode.Attributes["id"].Value).GetVertices()[i].ToVector2().X.ToString().Replace(",", ".");
                                pointNode.Attributes["y"].Value = floor.GetFace(genericNode.Attributes["id"].Value).GetVertices()[i].ToVector2().Y.ToString().Replace(",", ".");
                                i++;
                            }
                            break;
                        }

                        case FileStatus.input:
                        {
                            foreach (Face face in floor.GetFaces())
                            {
                                if (face.GetFaceName() == genericNode.Attributes["id"].Value)
                                {
                                    floor.AddFacesToMove();
                                    foreach (XmlNode pointNode in pointNodes)
                                    {
                                        if (pointNode.Attributes["Type"].Value == "Move")
                                        {
                                            float x = float.Parse(pointNode.Attributes["x"].Value, Globals.culture);
                                            float y = float.Parse(pointNode.Attributes["y"].Value, Globals.culture);
                                            face.SetMoveVector(new Vector2(x, y));
                                        }
                                        if (pointNode.Attributes["Type"].Value == "Scale")
                                        {
                                            float scaleFactor = float.Parse(pointNode.Attributes["factor"].Value, Globals.culture);
                                            face.SetScale(scaleFactor);
                                        }
                                    }
                                }
                            }
                            break;
                        }
                        }
                    }
                }
            }
            if (fileStatus == FileStatus.write)
            {
                Globals.xmlDoc.Save(Path.Combine(path + "\\" + floor.GetID()));
                Console.WriteLine("Successfully created and updated: " + path);
                //Console.ReadLine();
            }
        }
Пример #4
0
 //Konstructors
 public Face(string name, ref Variation m_variation, string m_objectType)
 {
     faceName = name; faceID = counter++; variation = m_variation; objectType = m_objectType;
 }
Пример #5
0
        static void Main(string[] args)
        {
            string sourceDirectory = "C:\\Users\\Janik\\Source\\Repos\\myRepos\\Thesis\\projects\\baseProject";
            string path            = "C:\\Users\\Janik\\Source\\Repos\\myRepos\\Thesis\\projects\\baseProject\\project1_res\\geometry";

            string[] filePaths    = Directory.GetFiles(path, "*.floor");
            int      floorCount   = filePaths.Length;
            string   inputXMLpath = "C:\\Users\\Janik\\source\\repos\\myRepos\\Thesis\\intputXML\\input.floor";

            List <Variation> listOfVariations = new List <Variation>();

            Globals.xmlInput.Load(inputXMLpath);
            Variation variation = InitVariation(filePaths, path, inputXMLpath);

            UncertaintyManager uncertaintyManger = new UncertaintyManager(Globals.GetDepthOfUncertainty());   //add meaningful depth

            Console.WriteLine("Instantiated uncertaintymanger");
            uncertaintyManger.InitUncertaintyManager(variation);
            Console.WriteLine("initialized uncertainty Manger");
            int possibility = uncertaintyManger.GetPosibilities() - 1;

            Console.WriteLine("eachedPointOfPermutation!");

            int parallelSimulations = 0;

            while (possibility >= 0)
            {
                Console.WriteLine("Reached loop!");
                Variation   possibleVariation = ObjectExtensions.Copy(variation);
                Manipulator manipulator       = new Manipulator(possibleVariation);
                manipulator.SetModifiedMoveVectors(uncertaintyManger.GetPermutation(possibility));
                manipulator.Transform(); //HIER LIEGT DER FEHLER

                string newPath  = "C:\\Users\\Janik\\Source\\Repos\\myRepos\\Thesis\\projects\\project" + possibility;
                string rootPath = newPath.Copy();
                Directory.CreateDirectory(newPath);
                Copy(sourceDirectory, newPath);
                newPath = Path.Combine(newPath + "\\project1_res\\geometry");
                foreach (Floor floor in possibleVariation.GetFloors())
                {
                    Globals.xmlDoc.Load(Path.Combine(path + "\\" + floor.GetID()));
                    Parser.ParseFloor(newPath, FileStatus.write, possibleVariation, floor); //Hier noch ergängen, zielpfad plus object name
                }
                Console.WriteLine("Terminated one process successfully");
                ////Console.ReadLine();

                possibility--;

                var processInfo = new ProcessStartInfo("java.exe", "-jar C:\\Users\\Janik\\Desktop\\1.5.6.jar --filename=" + rootPath + "\\project1.crowdit --lastStep=" + Globals.lastStep);
                {
                    processInfo.CreateNoWindow  = false;
                    processInfo.UseShellExecute = true;
                    Console.WriteLine("SIMULATION STARTED");
                    parallelSimulations++;
                }

                Process proc;

                if ((proc = Process.Start(processInfo)) == null)
                {
                    throw new InvalidOperationException("??");
                }


                while (parallelSimulations >= 6)
                {
                    if (proc.HasExited == true)
                    {
                        parallelSimulations--;
                        proc.Close();
                    }
                    Console.WriteLine("Waiting for simulation to finish");
                }

                //proc.WaitForExit();
                //int exitCode = proc.ExitCode;
                //proc.Close();
            }
            Console.WriteLine("All floor successfully manipulated and simulated!");
            Console.ReadLine();
        }
Пример #6
0
 public Manipulator(Variation m_variation)
 {
     variation = m_variation;
 }
Пример #7
0
 public void SetCurrentVariation(Variation m_variation)
 {
     variation = m_variation;
 }