Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Evaluates the subassemly.
        /// </summary>
        /// <param name="subassemblyNodes">The subassembly nodes - all the nodes in the combined install action.</param>
        /// <param name="optNodes">The subset of nodes that represent one of the two parts in the install step.</param>
        /// <param name="sub">The sub is the class that is then tied into the treequence.</param>
        /// <returns>System.Double.</returns>
        public double EvaluateSub(designGraph graph, HashSet <Component> subassemblyNodes, List <Component> optNodes,
                                  HashSet <int> validDirs, out SubAssembly sub)
        {
            var rest = subassemblyNodes.Where(n => !optNodes.Contains(n)).ToList();

            sub = Update(optNodes, rest);
            var connectingArcs =
                graph.arcs.Where(a => a is Connection)
                .Cast <Connection>()
                .Where(a => ((optNodes.Contains(a.To) && rest.Contains(a.From)) ||
                             (optNodes.Contains(a.From) && rest.Contains(a.To))))
                .ToList();
            var insertionDirections = InsertionDirectionsFromRemovalDirections(sub, optNodes, validDirs);
            var minDis = double.PositiveInfinity;
            var bestInstallDirection = new[] { 0.0, 0.0, 0.0 };

            foreach (var dir in insertionDirections)
            {
                var dis = DetermineDistanceToSeparateHull(sub, dir);
                if (dis >= minDis)
                {
                    continue;
                }
                minDis = dis;
                bestInstallDirection = dir;
            }
            sub.Install.InstallDirection = bestInstallDirection;
            sub.Install.InstallDistance  = minDis;
            // I need to add InstallationPoint also
            var install = new[] { rest, optNodes };

            if (EitherRefOrMovHasSeperatedSubassemblies(install, subassemblyNodes))
            {
                return(-1);
            }
            var moivingnames = sub.Install.Moving.PartNames;
            var refnames     = sub.Install.Reference.PartNames;
            var movingnodes  = subassemblyNodes.Where(n => moivingnames.Contains(n.name)).ToList();
            var refnodes     = subassemblyNodes.Where(n => refnames.Contains(n.name)).ToList();

            /////time
            sub.Install.Time = 0;
            EvaluateSubFirstThreeTime(sub, refnodes, movingnodes, minDis, out sub.Install.Time, out sub.Install.TimeSD, out sub.Secure.Time, out sub.Secure.TimeSD);
            if (sub.Install.Time < 0)
            {
                sub.Install.Time = 0.5;
            }
            ///////stability

            //assembly gravity direction is oppositve to install directon
            var Gravitydir = bestInstallDirection.multiply(-1);


            var stbility1 =
                Stabilityfunctions.EvaluateSubStability(Program.AssemblyGraph, refnodes, movingnodes, sub, Gravitydir);

            if (refnodes.Count == 1)
            {
                stbility1 = -1;
            }
            var stbility2 =
                Stabilityfunctions.EvaluateSubStability(Program.AssemblyGraph, movingnodes, refnodes, sub, Gravitydir);

            if (movingnodes.Count == 1)
            {
                stbility2 = -1;
            }
            var stbility = stbility1 + stbility2;

            sub.InternalStabilityInfo.Totalsecore = stbility;

            sub.Secure.Fasteners = ConnectingArcsFastener(connectingArcs, subassemblyNodes, optNodes);



            return(1);
        }