/* * The layer-part creation step is the first step in creating actual useful data for 3D printing. * It takes the result of the Slice step, which is an unordered list of polygons, and makes groups of polygons, * each of these groups is called a "part", which sometimes are also known as "islands". These parts represent * isolated areas in the 2D layer with possible holes. * * Creating "parts" is an important step, as all elements in a single part should be printed before going to another part. * Every bit inside a single part can be printed without the nozzle leaving the boundery of this part. * * It's also the first step that stores the result in the "data storage" so all other steps can access it. */ static void createLayerWithParts(SliceLayer storageLayer, SlicerLayer layer, ConfigConstants.REPAIR_OVERLAPS unionAllType) { if ((unionAllType & ConfigConstants.REPAIR_OVERLAPS.REVERSE_ORIENTATION) == ConfigConstants.REPAIR_OVERLAPS.REVERSE_ORIENTATION) { for (int i = 0; i < layer.polygonList.Count; i++) { if (layer.polygonList[i].Orientation()) { layer.polygonList[i].Reverse(); } } } List <Polygons> result; if ((unionAllType & ConfigConstants.REPAIR_OVERLAPS.UNION_ALL_TOGETHER) == ConfigConstants.REPAIR_OVERLAPS.UNION_ALL_TOGETHER) { result = layer.polygonList.Offset(1000).SplitIntoParts(unionAllType != 0); } else { result = layer.polygonList.SplitIntoParts(unionAllType != 0); } for (int i = 0; i < result.Count; i++) { storageLayer.parts.Add(new SliceLayerPart()); if ((unionAllType & ConfigConstants.REPAIR_OVERLAPS.UNION_ALL_TOGETHER) == ConfigConstants.REPAIR_OVERLAPS.UNION_ALL_TOGETHER) { storageLayer.parts[i].outline.Add(result[i][0]); storageLayer.parts[i].outline = storageLayer.parts[i].outline.Offset(-1000); } else { storageLayer.parts[i].outline = result[i]; } storageLayer.parts[i].boundaryBox.calculate(storageLayer.parts[i].outline); } }
public static void createLayerParts(SliceVolumeStorage storage, Slicer slicer, ConfigConstants.REPAIR_OVERLAPS unionAllType) { for (int layerIndex = 0; layerIndex < slicer.layers.Count; layerIndex++) { storage.layers.Add(new SliceLayer()); storage.layers[layerIndex].printZ = slicer.layers[layerIndex].z; LayerPart.createLayerWithParts(storage.layers[layerIndex], slicer.layers[layerIndex], unionAllType); } }
/* * The layer-part creation step is the first step in creating actual useful data for 3D printing. * It takes the result of the Slice step, which is an unordered list of polygons, and makes groups of polygons, * each of these groups is called a "part", which sometimes are also known as "islands". These parts represent * isolated areas in the 2D layer with possible holes. * * Creating "parts" is an important step, as all elements in a single part should be printed before going to another part. * Every bit inside a single part can be printed without the nozzle leaving the boundery of this part. * * It's also the first step that stores the result in the "data storage" so all other steps can access it. */ private static void CreateLayerWithParts(SliceLayer storageLayer, SlicerLayer layer, ConfigConstants.REPAIR_OVERLAPS unionAllType) { if ((unionAllType & ConfigConstants.REPAIR_OVERLAPS.REVERSE_ORIENTATION) == ConfigConstants.REPAIR_OVERLAPS.REVERSE_ORIENTATION) { for (int i = 0; i < layer.PolygonList.Count; i++) { if (layer.PolygonList[i].Orientation()) { layer.PolygonList[i].Reverse(); } } } List <Polygons> result; if ((unionAllType & ConfigConstants.REPAIR_OVERLAPS.UNION_ALL_TOGETHER) == ConfigConstants.REPAIR_OVERLAPS.UNION_ALL_TOGETHER) { result = layer.PolygonList.Offset(1000).CreateLayerOutlines(PolygonsHelper.LayerOpperation.UnionAll); } else { result = layer.PolygonList.CreateLayerOutlines(PolygonsHelper.LayerOpperation.EvenOdd); } for (int i = 0; i < result.Count; i++) { storageLayer.parts.Add(new SliceLayerPart()); if ((unionAllType & ConfigConstants.REPAIR_OVERLAPS.UNION_ALL_TOGETHER) == ConfigConstants.REPAIR_OVERLAPS.UNION_ALL_TOGETHER) { storageLayer.parts[i].TotalOutline.Add(result[i][0]); storageLayer.parts[i].TotalOutline = storageLayer.parts[i].TotalOutline.Offset(-1000); } else { storageLayer.parts[i].TotalOutline = result[i]; } storageLayer.parts[i].BoundingBox.Calculate(storageLayer.parts[i].TotalOutline); } }