public static void doAssemblyPlanning(string dir)
        {
            state = new ProgramState();
            if (dir == "")
            {
                dir = ".";
            }
            if (serverMode)
            {
                ProgramState.Load(dir + slash + "intermediate" + slash + "ProgramState.xml", ref state);
            }
            else
            {
                ProgramState.Load(dir + slash + "bin" + slash + "intermediate" + slash + "ProgramState.xml", ref state);
            }
            LoadState();

            checkDirs();
            AssemblyGraph.RepairGraphConnections();


            //$ Adding this so that bounding box related functionalities still work
            BoundingGeometry.OrientedBoundingBoxDic = new Dictionary <TessellatedSolid, BoundingBox>();
            BoundingGeometry.BoundingCylinderDic    = new Dictionary <TessellatedSolid, BoundingCylinder>();
            BoundingGeometry.CreateOBB2(Solids);
            BoundingGeometry.CreateBoundingCylinder(Solids);

            PartitioningSolid.Partitions     = new Dictionary <TessellatedSolid, Partition[]>();
            PartitioningSolid.PartitionsAABB = new Dictionary <TessellatedSolid, PartitionAABB[]>();
            PartitioningSolid.CreatePartitions(Program.SimplifiedSolids);

            NonadjacentBlockingWithPartitioning.Run(AssemblyGraph, SolidsNoFastenerSimplified, globalDirPool);
            GraphSaving.SaveTheGraph(AssemblyGraph);
            Stabilityfunctions.GenerateReactionForceInfo(AssemblyGraph);
            var leapSearch = new LeapSearch();
            var solutions  = leapSearch.Run(AssemblyGraph, Solids, globalDirPool);

            OptimalOrientation.Run(solutions);
            var cand = new AssemblyCandidate()
            {
                Sequence = solutions
            };

            cand.SaveToDisk(state.inputDir + slash + "XML" + slash + "solution.xml");
            WorkerAllocation.Run(solutions);

            SaveState();
            if (serverMode)
            {
                state.Save(state.inputDir + slash + "intermediate" + slash + "ProgramState.xml");
            }
            else
            {
                state.Save(state.inputDir + slash + "bin" + slash + "intermediate" + slash + "ProgramState.xml");
            }
            Console.WriteLine("\n\nDone");
        }
        private static void Main(string[] args)
        {
            state = new ProgramState();
            SetInputArguments(state, args);
            LoadState();
            Solids = GetSTLs(state.inputDir);
            EnlargeTheSolid();

            AssemblyGraph = new designGraph();
            DisassemblyDirectionsWithFastener.RunGeometricReasoning(Solids);
            if (DetectFasteners)
            {
                DisassemblyDirectionsWithFastener.RunFastenerDetection(Solids, FastenersAreThreaded);
            }
            //SolidsNoFastener = Solids;
            SerializeSolidProperties();
            Console.WriteLine("\nPress enter once input parts table generated >>");


            Console.ReadLine();
            DeserializeSolidProperties();
            globalDirPool = DisassemblyDirectionsWithFastener.RunGraphGeneration(AssemblyGraph, SolidsNoFastener);
            //the second user interaction must happen here
            SaveDirections();
            var connectedGraph = false;

            while (!connectedGraph)
            {
                Console.WriteLine("\n\nPress enter once input directions generated >>");
                Console.ReadLine();
                LoadDirections();
                connectedGraph = DisassemblyDirectionsWithFastener.GraphIsConnected(AssemblyGraph);
            }


            NonadjacentBlockingWithPartitioning.Run(AssemblyGraph, SolidsNoFastenerSimplified, globalDirPool);
            GraphSaving.SaveTheGraph(AssemblyGraph);
            Stabilityfunctions.GenerateReactionForceInfo(AssemblyGraph);
            var leapSearch = new LeapSearch();
            var solutions  = leapSearch.Run(AssemblyGraph, Solids, globalDirPool);

            OptimalOrientation.Run(solutions);
            var cand = new AssemblyCandidate()
            {
                Sequence = solutions
            };

            cand.SaveToDisk(state.inputDir + "solution.xml");
            WorkerAllocation.Run(solutions);
            Console.WriteLine("\n\nDone");
            Console.ReadLine();
        }