protected virtual List <GeneralPolygon2d> filter_solids(List <GeneralPolygon2d> solids) { if (MIN_AREA > 0) { return(CurveUtils2.FilterDegenerate(solids, MIN_AREA)); } else { return(solids); } }
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); } }
virtual public void PreRender() { if (in_shutdown()) { return; } if (parameters_dirty) { // offset List <GeneralPolygon2d> offset = ClipperUtil.RoundOffset(combined_all, offset_distance); // aggressively simplify after round offset... foreach (var poly in offset) { poly.Simplify(path_width); } // subtract initial and add tiny gap so these don't get merged by slicer if (SubtractSolids) { offset = ClipperUtil.Difference(offset, combined_solid); offset = ClipperUtil.MiterOffset(offset, -path_width * 0.1); } offset = CurveUtils2.FilterDegenerate(offset, 0.001); foreach (var poly in offset) { poly.Simplify(path_width * 0.02); } DMesh3 mesh = new DMesh3(); MeshEditor editor = new MeshEditor(mesh); foreach (var poly in offset) { TriangulatedPolygonGenerator polygen = new TriangulatedPolygonGenerator() { Polygon = poly }; editor.AppendMesh(polygen.Generate().MakeDMesh()); } MeshTransforms.ConvertZUpToYUp(mesh); if (mesh.TriangleCount > 0) { MeshExtrudeMesh extrude = new MeshExtrudeMesh(mesh); extrude.ExtrudedPositionF = (v, n, vid) => { return(v + Layers * layer_height * Vector3d.AxisY); }; extrude.Extrude(); MeshTransforms.Translate(mesh, -mesh.CachedBounds.Min.y * Vector3d.AxisY); } PreviewSO.ReplaceMesh(mesh, true); //Vector3d translate = scene_bounds.Point(1, -1, 1); //translate.x += spiral.Bounds.Width + PathWidth; //Frame3f sceneF = Frame3f.Identity.Translated((Vector3f)translate); //PreviewSO.SetLocalFrame(sceneF, CoordSpace.SceneCoords); parameters_dirty = false; } }