Exemplo n.º 1
0
        static void generate_stacked_polygon(SingleMaterialFFFCompiler compiler,
                                             SingleMaterialFFFSettings settings)
        {
            int NLayers = 10;

            for (int layer_i = 0; layer_i < NLayers; ++layer_i)
            {
                // create data structures for organizing this layer
                ToolpathSetBuilder    layer_builder = new ToolpathSetBuilder();
                SequentialScheduler2d scheduler     = new SequentialScheduler2d(layer_builder, settings);
                if (layer_i == 0)
                {
                    scheduler.SpeedHint = SchedulerSpeedHint.Careful;
                }

                // initialize layer
                layer_builder.Initialize(compiler.NozzlePosition);

                // layer-up
                layer_builder.AppendZChange(settings.LayerHeightMM, settings.ZTravelSpeed);

                // schedule a circle
                FillPolygon2d circle_poly = new FillPolygon2d(Polygon2d.MakeCircle(25.0f, 64));
                circle_poly.TypeFlags = FillTypeFlags.OuterPerimeter;
                scheduler.AppendPolygon2d(circle_poly);

                // pass paths to compiler
                compiler.AppendPaths(layer_builder.Paths, settings);
            }
        }
Exemplo n.º 2
0
        static void generate_stacked_wavy_circle(SingleMaterialFFFCompiler compiler,
                                                 SingleMaterialFFFSettings settings)
        {
            double height    = 20.0;                                   // mm
            int    NLayers   = (int)(height / settings.LayerHeightMM); // 20mm
            int    NSteps    = 128;
            double radius    = 15.0;
            double frequency = 6;
            double scale     = 5.0;

            for (int layer_i = 0; layer_i < NLayers; ++layer_i)
            {
                // create data structures for organizing this layer
                ToolpathSetBuilder    layer_builder = new ToolpathSetBuilder();
                SequentialScheduler2d scheduler     = new SequentialScheduler2d(layer_builder, settings);
                if (layer_i == 0)
                {
                    scheduler.SpeedHint = SchedulerSpeedHint.Careful;
                }

                // initialize and layer-up
                layer_builder.Initialize(compiler.NozzlePosition);
                layer_builder.AppendZChange(settings.LayerHeightMM, settings.ZTravelSpeed);

                // start with circle
                FillPolygon2d circle_poly = new FillPolygon2d(Polygon2d.MakeCircle(radius, NSteps));

                // apply a wave deformation to circle, with wave height increasing with Z
                double layer_scale = MathUtil.Lerp(0, scale, (double)layer_i / (double)NLayers);
                for (int i = 0; i < NSteps; ++i)
                {
                    Vector2d v     = circle_poly[i];
                    double   angle = Math.Atan2(v.y, v.x);
                    double   r     = v.Length;
                    r += layer_scale * Math.Sin(frequency * angle);
                    circle_poly[i] = r * v.Normalized;
                }

                circle_poly.TypeFlags = FillTypeFlags.OuterPerimeter;
                scheduler.AppendPolygon2d(circle_poly);

                // pass paths to compiler
                compiler.AppendPaths(layer_builder.Paths, settings);
            }
        }