Пример #1
0
        /// <summary>
        /// Calls the Transform function for given floor. Moves and Scales all the floors faces
        /// </summary>
        /// <param name="floor"></param>
        public void Transform()
        {
            foreach (Floor floor in variation.GetFloors())
            {
                currentFloor = floor;
                foreach (Face face in currentFloor.GetFaces())            //iterate through all faces
                {
                    if (face.GetMoveVector() != new Vector2(0, 0))        //if moveVector exists
                    {
                        List <Vertex> verticesToMove = new List <Vertex>();
                        AddFaceToMove(face, ref verticesToMove);
                        List <Face> checkedFaces = new List <Face>()
                        {
                            face
                        };
                        if (face.GetObjectType() != "stair")
                        {
                            AddAttachedToMove(face, face.GetMoveVector(), checkedFaces, ref verticesToMove);                                    //find faces which need to be added to the list
                        }
                        else
                        {
                            FindStairVertices(variation.GetFloors(), floor, verticesToMove);
                        }
                        Move(face.GetMoveVector(), ref verticesToMove);
                        //verticesToMove.Clear();
                        //checkedFaces.Clear();
                    }

                    if (face.GetScale() != 0)
                    {
                        //CalculateMidpoint
                        Vector2 midPoint  = face.CalculateMidPoint();
                        int     diminuend = 0;
                        if (face.GetVertices()[0] == face.GetVertices()[face.GetVertices().Count - 1])
                        {
                            diminuend = 1;
                        }
                        //GetLongestEdge
                        for (int i = 0; i < face.GetVertices().Count - diminuend; i++)
                        {
                            Vector2 straight = face.GetVertices()[i].ToVector2() - midPoint;
                            Vector2 moveVector;
                            if (Math.Abs(straight.X) > Math.Abs(straight.Y))
                            {
                                moveVector = new Vector2(straight.X * face.GetScale(), straight.Y);
                            }
                            else
                            {
                                moveVector = new Vector2(straight.X, straight.Y * face.GetScale());
                            }
                            face.GetVertices()[i].VertexVector = midPoint + moveVector;
                        }
                    }
                }
            }
        }
Пример #2
0
 public static void ParseFloor(string path, FileStatus filestatus, Variation variation)
 {
     foreach (Floor floor in variation.GetFloors())
     {
         Parser.ParseFloor(path, filestatus, variation, floor);
     }
 }
Пример #3
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();
        }