コード例 #1
0
        /// <summary>
        /// Compile this set of toolpaths and pass to assembler.
        /// Settings are optional, pass null to ignore
        /// </summary>
        public virtual void AppendPaths(ToolpathSet paths, SingleMaterialFFFSettings pathSettings)
        {
            Assembler.FlushQueues();

            SingleMaterialFFFSettings useSettings = (pathSettings == null) ? Settings : pathSettings;

            CalculateExtrusion calc = new CalculateExtrusion(paths, useSettings);

            calc.Calculate(Assembler.NozzlePosition, Assembler.ExtruderA, Assembler.InRetract);


            int path_index = 0;

            foreach (var gpath in paths)
            {
                path_index++;

                if (IsCommandToolpath(gpath))
                {
                    ProcessCommandToolpath(gpath);
                    continue;
                }

                LinearToolpath p = gpath as LinearToolpath;

                if (p[0].Position.Distance(Assembler.NozzlePosition) > 0.00001)
                {
                    throw new Exception("SingleMaterialFFFCompiler.AppendPaths: path " + path_index + ": Start of path is not same as end of previous path!");
                }

                int i = 0;
                if ((p.Type == ToolpathTypes.Travel || p.Type == ToolpathTypes.PlaneChange) && Assembler.InTravel == false)
                {
                    //Assembler.DisableFan();

                    // do retract cycle
                    if (p[0].Extrusion.x < Assembler.ExtruderA)
                    {
                        if (Assembler.InRetract)
                        {
                            throw new Exception("SingleMaterialFFFCompiler.AppendPaths: path " + path_index + ": already in retract!");
                        }
                        Assembler.BeginRetract(p[0].Position, useSettings.RetractSpeed, p[0].Extrusion.x);
                    }
                    Assembler.BeginTravel();
                }
                else if (p.Type == ToolpathTypes.Deposition)
                {
                    // end travel / retract if we are in that state
                    if (Assembler.InTravel)
                    {
                        if (Assembler.InRetract)
                        {
                            Assembler.EndRetract(p[0].Position, useSettings.RetractSpeed, p[0].Extrusion.x);
                        }
                        Assembler.EndTravel();
                        //Assembler.EnableFan();
                    }
                }

                i = 1;      // do not need to emit code for first point of path,
                            // we are already at this pos

                var currentDimensions = p[1].Dimensions;
                if (p.Type == ToolpathTypes.Deposition)
                {
                    AddFeatureTypeLabel(p.TypeModifiers);
                    AppendDimensions(currentDimensions);
                }

                for (; i < p.VertexCount; ++i)
                {
                    if (p.Type == ToolpathTypes.Deposition && !p[i].Dimensions.EpsilonEqual(currentDimensions, 1e-6))
                    {
                        currentDimensions = p[i].Dimensions;
                        AppendDimensions(p[i].Dimensions);
                    }

                    if (p.Type == ToolpathTypes.Travel)
                    {
                        Assembler.AppendMoveTo(p[i].Position, p[i].FeedRate, "Travel");
                    }
                    else if (p.Type == ToolpathTypes.PlaneChange)
                    {
                        Assembler.AppendMoveTo(p[i].Position, p[i].FeedRate, "Plane Change");
                    }
                    else
                    {
                        Assembler.AppendExtrudeTo(p[i].Position, p[i].FeedRate, p[i].Extrusion.x);
                    }
                }
            }


            Assembler.FlushQueues();
        }
コード例 #2
0
        /// <summary>
        /// Compile this set of toolpaths and pass to assembler.
        /// Settings are optional, pass null to ignore
        /// </summary>
        public virtual void AppendPaths(ToolpathSet toolpathSet, IPrintProfileFFF profile)
        {
            Assembler.FlushQueues();

            IPrintProfileFFF useSettings = (profile == null) ? Settings : profile;

            var paths = toolpathSet.GetPaths <PrintVertex>();
            var calc  = new CalculateExtrusion <PrintVertex>(paths, useSettings);

            calc.Calculate(Assembler.NozzlePosition, Assembler.ExtruderA, Assembler.InRetract);

            int path_index = 0;

            foreach (var gpath in toolpathSet)
            {
                path_index++;

                if (IsCommandToolpath(gpath))
                {
                    ProcessCommandToolpath(gpath);
                    continue;
                }

                LinearToolpath p = gpath as LinearToolpath;

                if (p[0].Position.Distance(Assembler.NozzlePosition) > 0.00001)
                {
                    throw new Exception("SingleMaterialFFFCompiler.AppendPaths: path " + path_index + ": Start of path is not same as end of previous path!");
                }

                int i = 0;
                if (p.Type == ToolpathTypes.Travel || p.Type == ToolpathTypes.PlaneChange)
                {
                    HandleTravelAndPlaneChangePath(p, path_index, useSettings);
                }
                else if (p.Type == ToolpathTypes.Deposition)
                {
                    HandleDepositionPath(p, useSettings);
                }

                i = 1;      // do not need to emit code for first point of path,
                            // we are already at this pos

                var currentDimensions = p[1].Dimensions;

                for (; i < p.VertexCount; ++i)
                {
                    if (p.Type == ToolpathTypes.Travel)
                    {
                        Assembler.AppendMoveTo(p[i].Position, p[i].FeedRate, "Travel");
                    }
                    else if (p.Type == ToolpathTypes.PlaneChange)
                    {
                        Assembler.AppendMoveTo(p[i].Position, p[i].FeedRate, "Plane Change");
                    }
                    else
                    {
                        if (p.Type == ToolpathTypes.Deposition && !p[i].Dimensions.EpsilonEqual(currentDimensions, 1e-6))
                        {
                            currentDimensions = p[i].Dimensions;
                            AppendDimensions(p[i].Dimensions);
                        }
                        Assembler.AppendExtrudeTo(p[i].Position, p[i].FeedRate, p[i].Extrusion.x, null);
                    }
                }
            }

            /*
             * TODO: Should there be an EndTravel() call here?
             */
            HandleDepositionEnd();
            Assembler.FlushQueues();
        }
コード例 #3
0
        /// <summary>
        /// Compile this set of toolpaths and pass to assembler.
        /// Settings are optional, pass null to ignore
        /// </summary>
        public virtual void AppendPaths(ToolpathSet paths, SingleMaterialFFFSettings pathSettings)
        {
            SingleMaterialFFFSettings useSettings = (pathSettings == null) ? Settings : pathSettings;

            int path_index = 0;

            foreach (var gpath in paths)
            {
                path_index++;

                if (IsCommandToolpath(gpath))
                {
                    ProcessCommandToolpath(gpath);
                    continue;
                }

                LinearToolpath p = gpath as LinearToolpath;

                // [RMS] this doesn't work because we are doing retract inside assembler...
                //if (p[0].Position.Distance(Assembler.ToolPosition) > 0.00001)
                //	throw new Exception("SingleMaterialFFFCompiler.AppendPaths: path "
                //                    + path_index + ": Start of path is not same as end of previous path!");

                int i = 0;
                if (p.Type == ToolpathTypes.Travel || p.Type == ToolpathTypes.PlaneChange)
                {
                    // do retract cycle
                    if (Assembler.InRetract == false)
                    {
                        Assembler.BeginRetract(useSettings.RetractDistanceMM, useSettings.RetractSpeed, "Retract");
                    }
                    if (Assembler.InTravel == false)
                    {
                        Assembler.BeginTravel();
                    }
                }
                else if (p.Type == ToolpathTypes.Cut)
                {
                    if (Assembler.InTravel)
                    {
                        Assembler.EndTravel();
                    }

                    if (Assembler.InRetract)
                    {
                        Assembler.EndRetract(useSettings.RetractSpeed, "End Retract");
                    }
                }

                i = 1;      // do not need to emit code for first point of path,
                            // we are already at this pos
                for (; i < p.VertexCount; ++i)
                {
                    if (p.Type == ToolpathTypes.Travel)
                    {
                        Assembler.AppendMoveTo(p[i].Position, p[i].FeedRate, "Travel");
                    }
                    else if (p.Type == ToolpathTypes.PlaneChange)
                    {
                        Assembler.AppendMoveTo(p[i].Position, p[i].FeedRate, "Plane Change");
                    }
                    else
                    {
                        Assembler.AppendCutTo(p[i].Position, p[i].FeedRate);
                    }
                }
            }
        }