Ejemplo n.º 1
0
 public virtual void Process(PrintLayerData layerData, ToolpathSet layerPaths)
 {
     foreach (var post in Posts)
     {
         post.Process(layerData, layerPaths);
     }
 }
Ejemplo n.º 2
0
        private LayerCache build_cache(PrintLayerData layerData)
        {
            LayerCache cache = new LayerCache();

            cache.SupportAreas      = ClipperUtil.MiterOffset(layerData.SupportAreas, layerData.Settings.Machine.NozzleDiamMM);
            cache.SupportAreaBounds = new AxisAlignedBox2d[cache.SupportAreas.Count];
            cache.AllSupportBounds  = AxisAlignedBox2d.Empty;
            for (int i = 0; i < cache.SupportAreas.Count; ++i)
            {
                cache.SupportAreaBounds[i] = cache.SupportAreas[i].Bounds;
                cache.AllSupportBounds.Contain(cache.SupportAreaBounds[i]);
            }

            return(cache);
        }
Ejemplo n.º 3
0
        public virtual void Process(PrintLayerData layerData, ToolpathSet layerPaths)
        {
            if (layerData.PreviousLayer == null)
            {
                return;
            }
            if (layerData.PreviousLayer.SupportAreas == null || layerData.PreviousLayer.SupportAreas.Count == 0)
            {
                return;
            }

            LayerCache cache = build_cache(layerData.PreviousLayer);

            Func <Vector3d, Vector3d> ZOffsetF = (v) =>
            {
                return(new Vector3d(v.x, v.y, v.z + ZOffsetMM));
            };

            foreach (var toolpath in layerPaths)
            {
                LinearToolpath tp = toolpath as LinearToolpath;
                if (tp == null)
                {
                    continue;
                }
                if (!tp.FillType.IsPart())
                {
                    continue;
                }

                int N = tp.VertexCount;
                //for ( int i = 0; i < N; ++i ) {
                for (int i = 1; i < N - 1; ++i)
                {       // start and end cannot be modified!
                    PrintVertex v = tp[i];
                    if (is_over_support(v.Position.xy, ref cache))
                    {
                        v.Position = ZOffsetF(v.Position);
                        tp.UpdateVertex(i, v);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        protected virtual void fill_bridge_region_decompose(GeneralPolygon2d poly, IFillPathScheduler2d scheduler, PrintLayerData layer_data)
        {
            poly.Simplify(0.1, 0.01, true);
            TriangulatedPolygonGenerator generator = new TriangulatedPolygonGenerator()
            {
                Polygon = poly, Subdivisions = 16
            };
            DMesh3 mesh = generator.Generate().MakeDMesh();
            //Util.WriteDebugMesh(mesh, "/Users/rms/scratch/bridgemesh.obj");


            //List<Polygon2d> polys = decompose_mesh_recursive(mesh);
            List <Polygon2d> polys = decompose_cluster_up(mesh);

            Util.WriteDebugMesh(mesh, "/Users/rms/scratch/bridgemesh_reduce.obj");

            double spacing = Settings.BridgeFillPathSpacingMM();

            foreach (Polygon2d polypart in polys)
            {
                Box2d    box   = polypart.MinimalBoundingBox(0.00001);
                Vector2d axis  = (box.Extent.x > box.Extent.y) ? box.AxisY : box.AxisX;
                double   angle = Math.Atan2(axis.y, axis.x) * MathUtil.Rad2Deg;

                GeneralPolygon2d gp = new GeneralPolygon2d(polypart);

                ShellsFillPolygon shells_fill = new ShellsFillPolygon(gp);
                shells_fill.PathSpacing            = Settings.SolidFillPathSpacingMM();
                shells_fill.ToolWidth              = Settings.Machine.NozzleDiamMM;
                shells_fill.Layers                 = 1;
                shells_fill.InsetFromInputPolygonX = 0.25;
                shells_fill.ShellType              = ShellsFillPolygon.ShellTypes.BridgeShell;
                shells_fill.FilterSelfOverlaps     = false;
                shells_fill.Compute();
                scheduler.AppendCurveSets(shells_fill.GetFillCurves());
                var fillPolys = shells_fill.InnerPolygons;

                double offset = Settings.Machine.NozzleDiamMM * Settings.SolidFillBorderOverlapX;
                fillPolys = ClipperUtil.MiterOffset(fillPolys, offset);

                foreach (var fp in fillPolys)
                {
                    BridgeLinesFillPolygon fill_gen = new BridgeLinesFillPolygon(fp)
                    {
                        InsetFromInputPolygon = false,
                        PathSpacing           = spacing,
                        ToolWidth             = Settings.Machine.NozzleDiamMM,
                        AngleDeg = angle,
                    };
                    fill_gen.Compute();
                    scheduler.AppendCurveSets(fill_gen.GetFillCurves());
                }
            }

            // fit bbox to try to find fill angle that has shortest spans
            //Box2d box = poly.Outer.MinimalBoundingBox(0.00001);
            //Vector2d axis = (box.Extent.x > box.Extent.y) ? box.AxisY : box.AxisX;
            //double angle = Math.Atan2(axis.y, axis.x) * MathUtil.Rad2Deg;

            // [RMS] should we do something like this?
            //if (Settings.SolidFillBorderOverlapX > 0) {
            //	double offset = Settings.Machine.NozzleDiamMM * Settings.SolidFillBorderOverlapX;
            //	fillPolys = ClipperUtil.MiterOffset(fillPolys, offset);
            //}
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Fill a bridge region. Goal is to use shortest paths possible.
 /// So, instead of just using fixed angle, we fit bounding box and
 /// use the shorter axis.
 /// </summary>
 protected override void fill_bridge_region(GeneralPolygon2d poly, IFillPathScheduler2d scheduler, PrintLayerData layer_data)
 {
     base.fill_bridge_region(poly, scheduler, layer_data);
     //fill_bridge_region_decompose(poly, scheduler, layer_data);
 }
Ejemplo n.º 6
0
 public void PrintLayerCompleted(PrintLayerData printLayerData)
 {
     throw new NotImplementedException();
 }