Ejemplo n.º 1
0
        public static void GetGraphics(ToolPath toolPath, out Graphic curveGraphic, out Graphic arrowGraphic)
        {
            IList <CurveSegment> cutterCurves;
            IList <CurveSegment> rapidCurves;
            IList <CurveSegment> arrowCurves;

            toolPath.GetCurves(out cutterCurves, out rapidCurves, out arrowCurves);

            var style = new GraphicStyle {
                LineWidth = 2
            };
            Graphic cutterGraphic = Graphic.Create(style, cutterCurves.Select(c => CurvePrimitive.Create(c)).ToArray());

            style = new GraphicStyle {
                LineWidth = 1
            };
            Graphic rapidGraphic = Graphic.Create(style, rapidCurves.Select(c => CurvePrimitive.Create(c)).ToArray());

            curveGraphic = Graphic.Create(null, null, new[] { cutterGraphic, rapidGraphic });

            style = new GraphicStyle {
                LineColor = Color.Black,
                FillColor = Color.Gray,
                //  IsFlatOn = true,
                LineWidth = 1
            };
            //arrowGraphic = Graphic.Create(style, arrowCurves.Select(c => {
            //    var point = c.StartPoint;
            //    var tangent = (c.EndPoint - c.StartPoint).Direction;
            //    var frame = Frame.Create(point, tangent);
            //    return ArrowPrimitive.Create(frame, 20, 10);
            //}).ToArray());
            arrowGraphic = null;
        }
Ejemplo n.º 2
0
        public SpiralStrategy(Plane plane, ICollection <ITrimmedCurve> curves, double initialOffset, ToolPath toolPath)
        {
            this.plane         = plane;
            this.curves        = curves;
            this.toolPath      = toolPath;
            this.tool          = toolPath.CuttingTool;
            this.parameters    = toolPath.CuttingParameters;
            this.initialOffset = initialOffset;

            SurfaceEvaluation eval = plane.Evaluate(PointUV.Origin);

            centerOffset         = eval.Normal * tool.Radius;
            tip                  = -toolPath.Csys.DirZ * tool.Radius;
            closeClearanceVector = toolPath.Csys.DirZ * tool.Radius;
        }
Ejemplo n.º 3
0
        public void Regenerate()
        {
            this.Initialize();
            //           ToolPath = toolPath;
            if (IDesFace == null)
            {
                return;
            }

            ToolPath.UpdateCutterLocations();
            ToolPath = ToolPath; // make sure we have serialized
            UpdateRendering(new CancellationToken());

            DefaultToolPath = ToolPath;
            DefaultColor    = Color;

            if (ToolPathChanged != null)
            {
                ToolPathChanged(this, new EventArgs());
            }
        }
Ejemplo n.º 4
0
        public void ResetFromSelection()
        {
            if (InteractionContext.SingleSelection as ICustomObject == null)
            {
                return;
            }

            toolPathObj = FaceToolPathObject.GetWrapper((InteractionContext.SingleSelection as ICustomObject).Master);
            if (toolPathObj == null || toolPathObj.IDesFace == null)
            {
                TransportControls.IsEnabled = false;
                return;
            }

            toolPath       = toolPathObj.ToolPath;
            locations      = toolPathObj.ToolPath.CutterLocations;
            timeToLocation = new double[locations.Count];

            time              = 0;
            totalTime         = 0;
            timeToLocation[0] = 0;
            for (int i = 0; i < locations.Count - 1; i++)
            {
                double length = (locations[i + 1].Point - locations[i].Point).Magnitude;
                totalLength += length;
                double rate  = locations[i + 1].IsRapid ? toolPath.CuttingParameters.FeedRateRapid : toolPath.CuttingParameters.FeedRate;
                double dtime = length / rate;
                totalTime            += dtime;
                timeToLocation[i + 1] = totalTime;
            }
            timeToLocation = timeToLocation.Distinct().ToArray();

            SetGraphics();
            TransportControls.IsEnabled = true;
            TransportControls.Reset(this);
        }