Esempio n. 1
0
        protected virtual List <GeneralPolygon2d> make_solid(GeneralPolygon2d poly, bool bIsSupportSolid)
        {
            // always do a self-union of outer polygon. This allows Clipper to clean up many
            // problems in input polygons, eg self-intersections and other junk
            GeneralPolygon2d        gouter        = new GeneralPolygon2d(poly.Outer);
            List <GeneralPolygon2d> resolvedSolid =
                ClipperUtil.Union(gouter, gouter, MIN_AREA);

            // solid may contain overlapping holes. We need to resolve these before continuing,
            // otherwise those overlapping regions will be filled by Clipper even/odd rules
            foreach (Polygon2d hole in poly.Holes)
            {
                GeneralPolygon2d holePoly = new GeneralPolygon2d(hole);
                resolvedSolid = ClipperUtil.PolygonBoolean(resolvedSolid, holePoly, ClipperUtil.BooleanOp.Difference, MIN_AREA);
            }

            if (bIsSupportSolid == false && Thickened != null)
            {
                // Subtract away any clearance solids
                foreach (var pair in Thickened)
                {
                    if (pair.Key != poly)
                    {
                        resolvedSolid = ClipperUtil.Difference(resolvedSolid, pair.Value);
                    }
                }
            }
            return(filter_solids(resolvedSolid));
        }
Esempio n. 2
0
        virtual protected void cache_brim_polys()
        {
            combined_solid   = new List <GeneralPolygon2d>();
            combined_support = new List <GeneralPolygon2d>();
            subtract         = new List <GeneralPolygon2d>();

            Frame3f cutPlane = new Frame3f((float)layer_height * 0.5f * Vector3f.AxisY, Vector3f.AxisY);

            foreach (var so in CC.Objects.PrintMeshes)
            {
                if (so.Settings.ObjectType == PrintMeshSettings.ObjectTypes.Ignored)
                {
                    continue;
                }
                SOSectionPlane section = new SOSectionPlane(so);
                section.UpdateSection(cutPlane, CoordSpace.SceneCoords);
                List <GeneralPolygon2d> solids = section.GetSolids();

                // [TODO] should subtract holes explicitly here, like we do in slicer?

                if (so.Settings.ObjectType == PrintMeshSettings.ObjectTypes.Cavity)
                {
                    subtract = ClipperUtil.Union(solids, subtract);
                }
                else if (so.Settings.ObjectType == PrintMeshSettings.ObjectTypes.Support)
                {
                    combined_support = ClipperUtil.Union(solids, combined_support);
                }
                else if (so.Settings.ObjectType == PrintMeshSettings.ObjectTypes.Solid)
                {
                    combined_solid = ClipperUtil.Union(solids, combined_solid);
                }
            }
            if (subtract.Count > 0)
            {
                combined_solid = ClipperUtil.Difference(combined_solid, subtract);
            }

            combined_all = ClipperUtil.Union(combined_solid, combined_support);
            combined_all = CurveUtils2.FilterDegenerate(combined_all, 0.001);

            foreach (var poly in combined_all)
            {
                poly.Simplify(path_width * 0.02);
            }
        }