示例#1
0
        public virtual void HandleDepositionPath(LinearToolpath path, SingleMaterialFFFSettings useSettings)
        {
            // end travel / retract if we are in that state
            if (Assembler.InTravel)
            {
                if (Assembler.InRetract)
                {
                    Assembler.EndRetract(path[0].Position, useSettings.RetractSpeed, path[0].Extrusion.x);
                }
                Assembler.EndTravel();
                Assembler.EnableFan();
            }

            AddFeatureTypeLabel(path.FillType);
            AppendDimensions(path.Start.Dimensions);
        }
        /// <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

                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.AppendExtrudeTo(p[i].Position, p[i].FeedRate, p[i].Extrusion.x);
                    }
                }
            }


            Assembler.FlushQueues();
        }