public static void doFastenerDetection(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);
            }
            SerializeSolidProperties();

            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("\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();
        }
        public static int doVerification(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();

            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);

            Console.WriteLine("\n\nChecking connectedness...");
            LoadDirections();
            if (!DisassemblyDirectionsWithFastener.GraphIsConnected(AssemblyGraph))
            {
                Console.WriteLine("\n\nFailure: Graph is not connected");
                SaveVerification("false");
                return(1);
            }

            Console.WriteLine("\n\nConnectedness verified");
            SaveState();
            if (serverMode)
            {
                state.Save(state.inputDir + slash + "intermediate" + slash + "ProgramState.xml");
                SaveVerification("true");
            }
            else
            {
                state.Save(state.inputDir + slash + "bin" + slash + "intermediate" + slash + "ProgramState.xml");
            }


            Console.WriteLine("\nDone");
            return(0);
        }
        public static void doDisassemblyDirections(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();


            AssemblyGraph.RepairGraphConnections();
            //RefreshGraphArcs ();

            //$ 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);

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

            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("\nDone");
        }