Пример #1
0
        private static Point[] GetChainAtV(double v, FaceToolPath toolPath)
        {
#if false
            return(GetChainAtV(v, p => true));
#else
            return(GetChainAtVWhere(v, p => {
                if (!toolPath.Face.ContainsParam(p))
                {
                    return false;
                }

                ToolEvaluation eval = Evaluate(p, toolPath);
                Face[] adjacentFaces = toolPath.Face.Edges
                                       .Where(e => e.Faces.Count == 2 && e.GetAngle() < 0) // TBD handle surface bodies correctly
                                       .Select(e => toolPath.Face.GetAdjacentFace(e))
                                       .Where(f => f != null)
                                       .ToArray();

                foreach (Face adjacentFace in adjacentFaces)
                {
                    if ((eval.CenterPoint - adjacentFace.Geometry.ProjectPoint(eval.CenterPoint).Point).MagnitudeSquared() < Math.Pow(toolPath.CuttingTool.Radius, 2))
                    {
                        return false;
                    }
                }

                return true;
            }, toolPath));
#endif
        }
Пример #2
0
        private static ToolEvaluation Evaluate(PointUV pointUV, FaceToolPath toolPath)
        {
            SurfaceEvaluation eval          = toolPath.Surface.Evaluate(pointUV);
            Point             surfacePoint  = eval.Point;
            Direction         surfaceNormal = toolPath.IsNormalFlipped ? -eval.Normal : eval.Normal;

            return(new ToolEvaluation(surfacePoint + toolPath.CuttingTool.Radius * surfaceNormal, surfacePoint, surfaceNormal));
        }
Пример #3
0
        // static Create method follows the API convention and parent should be first argument
        public static FaceToolPathObject Create(IDesignFace desFace, FaceToolPath toolPath, Color color)
        {
            Debug.Assert(desFace == null || desFace.Master.Shape == toolPath.Face);
            FaceToolPathObject toolPathObj = null;

            WriteBlock.ExecuteTask("New toolpath", () => toolPathObj = new FaceToolPathObject(desFace, toolPath, color));
            toolPathObj.Initialize();

            //    IList<CutterLocation> cutterLocations;
            //    toolPath.TryGetCutterLocations(out cutterLocations);
            //    toolPathObj.cutterLocations = cutterLocations;
            return(toolPathObj);
        }
Пример #4
0
        public static CutterLocation[] GetCutterLocations(FaceToolPath toolPath)
        {
            var    CutterLocations = new List <CutterLocation>();
            Vector tip             = -toolPath.Csys.DirZ * toolPath.CuttingTool.Radius;

            foreach (IList <Point> points in GetChains(toolPath))
            {
                //      CutterLocations.Add(new CutterLocation(toolPath.RestPoint(points[0]) + tip, true));
                CutterLocations.AddRange(points.Select(p => new CutterLocation(p + tip, false)));
                CutterLocations.Add(new CutterLocation(toolPath.RestPoint(points[points.Count - 1]) + tip, true));
            }

            return(CutterLocations.ToArray());
        }
Пример #5
0
        // creates a new custom object and a wrapper for it
        protected FaceToolPathObject(IDesignFace iDesFace, FaceToolPath toolPath, Color color)
            : base(Window.ActiveWindow.Scene as Part)
        {
            this.toolPath = toolPath;
            this.iDesFace = iDesFace;
            this.color    = color;

            if (iDesFace != null)
            {
                IDesFace = iDesFace;
                iDesFace.KeepAlive(true);
            }

            allUVPaths.Add(this);
        }
Пример #6
0
        public static CutterLocation[] GetCutterLocations(FaceToolPath toolPath)
        {
            Debug.Assert(toolPath.Face.Loops.Where(l => l.IsOuter).Count() == 1);
            ITrimmedCurve[] curves = toolPath.Face.Loops.Where(l => l.IsOuter).First().Edges.ToArray();

            Plane plane = toolPath.Face.Geometry as Plane;

            if (plane == null)
            {
                throw new NotImplementedException();
            }

            SpiralStrategy strategy = new SpiralStrategy(plane, curves, toolPath.CuttingTool.Radius, toolPath);

            return(strategy.GetSpiralCuttingLocations());
        }
Пример #7
0
        private static IList <IList <Point> > GetChains(FaceToolPath toolPath)
        {
            var positions = new List <IList <Point> >();

            var points = new List <Point>();
            int count  = Count(toolPath);

            for (int i = 0; i < count; i++)
            {
                double v = count < 2 ? (toolPath.StartV + toolPath.EndV) / 2 : toolPath.StartV + (double)i / (count - 1) * (toolPath.EndV - toolPath.StartV);
                points = GetChainAtV(v, toolPath).ToList();
                if (points.Count < 1)
                {
                    continue;
                }

                positions.Add(points);
            }

            return(positions);
        }
Пример #8
0
        private static IList <IList <Point> > GetChains(FaceToolPath toolPath)
        {
            var positions = new List <IList <Point> >();

            var points = new List <Point>();

            var box   = toolPath.Face.GetBoundingBox(Matrix.Identity);
            var count = box.Size.Z / toolPath.CuttingParameters.StepOver;

            for (int i = 0; i < count; i++)
            {
                var z       = i * toolPath.CuttingParameters.StepOver;
                var plane   = Plane.Create(Frame.Create(Point.Create(0, 0, z), Direction.DirZ));
                var section = toolPath.Face.Geometry.IntersectSurface(plane);

                foreach (var iTrimmedCurve in section.Curves)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        foreach (var offsetCurve in iTrimmedCurve.Offset(plane, j * toolPath.CuttingParameters.StepOver))
                        {
                            points.AddRange(iTrimmedCurve.TessellateCurve(toolPath.CuttingParameters.Increment));
                        }
                    }
                }

                if (points.Count < 1)
                {
                    continue;
                }

                positions.Add(points);
            }

            return(positions);
        }
Пример #9
0
 private static int Count(FaceToolPath toolPath)
 {
     return((int)Math.Ceiling(toolPath.MaxLength / toolPath.CuttingParameters.StepOver));
 }
Пример #10
0
        private static Point[] GetChainAtVWhere(double v, Func <PointUV, bool> condition, FaceToolPath toolPath)
        {
            List <Point> points = new List <Point>();

            double u = toolPath.StartU;

            while (u <= toolPath.EndU)
            {
                PointUV pointUV;
                if (!toolPath.Surface.TryOffsetParam(PointUV.Create(u, v), DirectionUV.DirU, toolPath.CuttingParameters.Increment, out pointUV))
                {
                    break;
                }

                u = pointUV.U;

                if (!condition(pointUV))
                {
                    continue;
                }

                ToolEvaluation eval = Evaluate(pointUV, toolPath);
                points.Add(eval.CenterPoint);
            }

            return(points.ToArray());
        }