Пример #1
0
        protected virtual List <LayerInfo <TFeatureInfo> > PerLayerInfoFromGCodeFile(GCodeFile gcode)
        {
            featureInfoFactory.Initialize();
            var layers = new List <LayerInfo <TFeatureInfo> >();

            LayerInfo <TFeatureInfo> currentLayer = null;
            string fillType = DefaultFillType.Label;

            foreach (var line in gcode.AllLines())
            {
                if (LineIsNewLayer(line))
                {
                    if (currentLayer != null)
                    {
                        currentLayer.AddFeatureInfo(featureInfoFactory.SwitchFeature(fillType));
                        layers.Add(currentLayer);
                    }
                    currentLayer = new LayerInfo <TFeatureInfo>(logger);
                    continue;
                }

                if (LineIsNewFeatureType(line, fillType, out var newFillType))
                {
                    currentLayer?.AddFeatureInfo(featureInfoFactory.SwitchFeature(newFillType));
                }

                featureInfoFactory.ObserveGcodeLine(line);
            }

            currentLayer?.AddFeatureInfo(featureInfoFactory.SwitchFeature(fillType));
            layers.Add(currentLayer);
            return(layers);
        }