Exemplo n.º 1
0
        private void RecurseDescendChainTreeNodes(List <CutterLocation> locations, ChainTreeNode parent)
        {
            Point initialPoint = locations.Count == 0 ? Point.Origin : locations[locations.Count - 1].Point;

            ChainTreeNode[] nodes = parent.Children.OrderBy(n => (n.OrderedCurves.First().StartPoint - initialPoint).Magnitude).ToArray();

            foreach (ChainTreeNode node in nodes)
            {
                IList <Point> points     = GetPoints(node.OrderedCurves).RemoveAdjacentDuplicates();
                Point         startPoint = points[0];
                Point         endPoint   = points[points.Count - 1];

                if (!isOnSpiral)
                {
                    locations.Add(new CutterLocation(toolPath.RestPoint(startPoint) + tip, true));
                }

                isOnSpiral = true;

                locations.Add(new CutterLocation(startPoint + closeClearanceVector + tip, true));
                locations.AddRange(points.Select(p => new CutterLocation(p + tip, false)));
                locations.Add(new CutterLocation(endPoint + closeClearanceVector + tip, true));

                RecurseDescendChainTreeNodes(locations, node);
                isOnSpiral = false;

                var endLocation = new CutterLocation(toolPath.RestPoint(locations[locations.Count - 1].Point) + tip, true);
                if (locations[locations.Count - 1].Point != endLocation.Point)
                {
                    locations.Add(endLocation);
                }
            }
        }
Exemplo n.º 2
0
        // Does the heavy lifting of creating the offsets for each spiral, from the outside in, but to not attempt to order the result
        private ChainTreeNode BuildChainTreeNodes()
        {
            var    positions = new List <IList <Point> >();
            Vector toCenter  = Direction.DirZ * tool.Radius;

            ChainTreeNode root = new ChainTreeNode(null, curves.ExtractChains().First().ToArray());  // TBD get inner loops working

            RecurseBuildChainTreeNodes(root, initialOffset, 0);
            return(root);
        }
Exemplo n.º 3
0
            public ChainTreeNode(ChainTreeNode parent, IList <ITrimmedCurve> orderedCurves)
            {
                Parent   = parent;
                Children = new List <ChainTreeNode>();
                if (parent != null) // root
                {
                    Parent.Children.Add(this);
                }

                OrderedCurves = orderedCurves;
            }
Exemplo n.º 4
0
        private void RecurseBuildChainTreeNodes(ChainTreeNode parent, double offset, int depth)
        {
            Debug.Assert(depth < 33, "Exceeded max depth");
            if (depth >= 33)
            {
                return;
            }

            ChainTreeNode[] children = parent.OrderedCurves
                                       .OffsetChainInward(plane, -offset, OffsetCornerType.Round)
                                       .ExtractChains()
                                       .Select(c => new ChainTreeNode(parent, c))
                                       .ToArray();

            foreach (ChainTreeNode node in children)
            {
                RecurseBuildChainTreeNodes(node, parameters.StepOver, ++depth);
            }
        }