Ejemplo n.º 1
0
        private void AppendTravel(Vector2d startPt, Vector2d endPt)
        {
            double travelDistance = startPt.Distance(endPt);

            // a travel may require a retract, which we might want to skip
            if (ExtrudeOnShortTravels &&
                travelDistance < ShortTravelDistance)
            {
                Builder.AppendExtrude(endPt, Settings.RapidTravelSpeed);
            }
            else if (Settings.TravelLiftEnabled &&
                     travelDistance > Settings.TravelLiftDistanceThreshold)
            {
                Builder.AppendZChange(Settings.TravelLiftHeight, Settings.ZTravelSpeed, ToolpathTypes.Travel);
                Builder.AppendTravel(endPt, Settings.RapidTravelSpeed);
                Builder.AppendZChange(-Settings.TravelLiftHeight, Settings.ZTravelSpeed, ToolpathTypes.Travel);
            }
            else
            {
                Builder.AppendTravel(endPt, Settings.RapidTravelSpeed);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is the main driver of the slicing process
        /// </summary>
        protected virtual void generate_result()
        {
            // should be parameterizable? this is 45 degrees...  (is it? 45 if nozzlediam == layerheight...)
            //double fOverhangAllowance = 0.5 * settings.NozzleDiamMM;
            OverhangAllowanceMM = Settings.LayerHeightMM / Math.Tan(45 * MathUtil.Deg2Rad);


            // initialize compiler and get start nozzle position
            Compiler.Begin();

            // We need N above/below shell paths to do roof/floors, and *all* shells to do support.
            // Also we can compute shells in parallel. So we just precompute them all here.
            precompute_shells();
            int nLayers = Slices.Count;

            // Now generate paths for each layer.
            // This could be parallelized to some extent, but we have to pass per-layer paths
            // to Scheduler in layer-order. Probably better to parallelize within-layer computes.
            for (int layer_i = 0; layer_i < nLayers; ++layer_i)
            {
                BeginLayerF(layer_i);

                // make path-accumulator for this layer
                ToolpathSetBuilder paths = new ToolpathSetBuilder();

                // TODO FIX
                //paths.Initialize(Compiler.NozzlePosition);
                paths.Initialize((double)(layer_i) * Settings.LayerHeightMM * Vector3d.AxisZ);

                // layer-up (ie z-change)
                paths.AppendZChange(Settings.LayerHeightMM, Settings.ZTravelSpeed);

                // rest of code does not directly access path builder, instead if
                // sends paths to scheduler.
                SequentialScheduler2d scheduler = new SequentialScheduler2d(paths, Settings);

                // a layer can contain multiple disjoint regions. Process each separately.
                List <ShellsFillPolygon> layer_shells = LayerShells[layer_i];
                for (int si = 0; si < layer_shells.Count; si++)
                {
                    // schedule shell paths that we pre-computed
                    ShellsFillPolygon shells_gen = layer_shells[si];
                    scheduler.AppendCurveSets(shells_gen.Shells);

                    // all client to do configuration (eg change settings for example)
                    BeginShellF(shells_gen, ShellTags.Get(shells_gen));

                    // solid fill areas are inner polygons of shell fills
                    List <GeneralPolygon2d> solid_fill_regions = shells_gen.InnerPolygons;

                    // fill solid regions
                    foreach (GeneralPolygon2d solid_poly in solid_fill_regions)
                    {
                        fill_solid_region(layer_i, solid_poly, scheduler, false);
                    }
                }

                // resulting paths for this layer (Currently we are just discarding this after compiling)
                ToolpathSet layerPaths = paths.Paths;

                // compile this layer
                Compiler.AppendPaths(layerPaths);
            }

            Compiler.End();
        }