internal ScaffoldItem(ReadableIdentifier name, IEnumerable <Point2Dstep> points) : base(name) { _definition = points.ToArray(); constructionInitialization(); }
/// <inheritdoc/> internal override ShapeItem Load(string path, ReadableIdentifier identifier) { var lines = File.ReadAllLines(path); var points = new List <Point2Dmm>(); var pointsScale = 100.0; foreach (var line in lines) { if (line.Trim() == "") { continue; } var pointParts = line.Trim().Split('\t'); var x = double.Parse(pointParts[0]) * pointsScale; var y = double.Parse(pointParts[1]) * pointsScale; var point = new Point2Dmm(-x, -y); points.Add(point); } var shape = new ShapeItem2D(identifier, points); shape.MetricWidth = pointsScale; return(shape); }
public IEnumerable <Point2Dmm[]> Load(string path, out ReadableIdentifier identifier) { var extension = Path.GetExtension(path).ToLowerInvariant(); var name = Path.GetFileNameWithoutExtension(path); identifier = new ReadableIdentifier(name); if (_panel != null) { identifier = _panel.UnusedVersion(identifier); } if (!_loaders.ContainsKey(extension)) { ShowError("No available loader found."); return(null); } try { return(_loaders[extension].LoadPoints(path)); } catch (Exception ex) { ShowError("Loading failed with an error: " + ex.Message); return(null); } }
internal MillingShapeItemGCode(string gcode, ReadableIdentifier identifier) : base(identifier) { var parser = new GeometryCNC.GCode.Parser(gcode); _toolPath = parser.GetToolPath(); }
/// <inheritdoc/> internal override ShapeItem Load(string path, ReadableIdentifier identifier) { var lines = File.ReadAllLines(path); var points = new List <Point2Dmm>(); foreach (var line in lines) { var pointParts = sanitizeDatLine(line).Split(' '); if (pointParts.Length != 2) { //invalid line continue; } double x, y; if (!double.TryParse(pointParts[0], out x) || !double.TryParse(pointParts[1], out y)) { continue; } var point = new Point2Dmm(-x, -y); points.Add(point); } points.Add(points.First()); var shape = new ShapeItem2D(identifier, points); shape.MetricWidth = 50; return(shape); }
internal MillingWorkspaceItem(SerializationInfo info, StreamingContext context) { _positionX = info.GetInt32("_positionX"); _positionY = info.GetInt32("_positionY"); _rotationAngle = info.GetDouble("_rotationAngle"); Name = (ReadableIdentifier)info.GetValue("Name", typeof(ReadableIdentifier)); constructionInitialization(); }
/// <inheritdoc/> internal override ShapeItem Load(string path, ReadableIdentifier identifier) { var points = LoadPoints(path); var shape = new ShapeItem2D(identifier, points.FirstOrDefault()); shape.MetricWidth = pointsScale; return(shape); }
internal override ShapeItem Clone(ReadableIdentifier cloneName) { var shapeItem = new ShapeItem2D(cloneName, ShapeDefinition.ToUV()); shapeItem.MetricWidth = MetricWidth; shapeItem.RotationAngle = RotationAngle; shapeItem.MetricHeight = MetricHeight; return(shapeItem); }
internal MillingShapeItemRelief Clone(ReadableIdentifier cloneName) { var shapeItem = new MillingShapeItemRelief(cloneName, _reliefDefinition); shapeItem.MetricWidth = MetricWidth; shapeItem.RotationAngle = RotationAngle; shapeItem.MetricHeight = MetricHeight; shapeItem.MillingDepth = MillingDepth; return(shapeItem); }
internal ShapeItem(ReadableIdentifier name, IEnumerable <Point4Dmm> shapeDefinition) : base(name) { if (shapeDefinition == null) { throw new ArgumentNullException("shapeDefinition"); } _shapeDefinition = shapeDefinition.ToArray(); _useClockwiseCut = true; constructionInitialization(); }
internal MillingShapeItemRelief(ReadableIdentifier name, double[,] reliefDefinition) : base(name) { if (reliefDefinition == null) { throw new ArgumentNullException("reliefDefinition"); } _reliefDefinition = (double[, ])reliefDefinition.Clone(); _millingDepth = 1.0; constructionInitialization(); }
/// <inheritdoc/> internal override ShapeItem Load(string path, ReadableIdentifier identifier) { var formatter = new BinaryFormatter(); using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) { var definition = (ShapeDefinition4D)formatter.Deserialize(stream); var shape = new ShapeItem4D(identifier, definition.Points); shape.MetricThickness = definition.Thickness; shape.SetOriginalSize(); return(shape); } }
/// <inheritdoc/> internal override ShapeItem Load(string path, ReadableIdentifier identifier) { var lines = File.ReadAllLines(path); var dimensions = new List <double>(); foreach (var line in lines) { var parts = line.Split(' '); if (parts.Length == 0) { continue; } var dimension = double.Parse(parts[0]); dimensions.Add(dimension); } var sliceThickness = dimensions[0]; var sliceLength = dimensions[1]; var sliceCount = (int)Math.Round(dimensions[2]); //TODO even counts are now not supported sliceCount = ((sliceCount + 1) / 2) * 2; var slicePoints = new List <Point2Dmm>(); for (var i = 0; i < sliceCount; ++i) { var totalHeight = i * sliceThickness; if (i % 2 == 0) { slicePoints.Add(new Point2Dmm(0, totalHeight)); slicePoints.Add(new Point2Dmm(sliceLength, totalHeight)); } else { slicePoints.Add(new Point2Dmm(sliceLength, totalHeight)); slicePoints.Add(new Point2Dmm(0, totalHeight)); } } //this we can do only for odd slice counts slicePoints.Add(new Point2Dmm(0, 0)); slicePoints.Reverse(); var item = new ShapeItem2D(identifier, slicePoints); item.SetOriginalSize(); return(item); }
internal MillingShapeItem2D(ReadableIdentifier name, IEnumerable <Point2Dmm[]> shapeDefinition) : base(name) { if (shapeDefinition == null) { throw new ArgumentNullException("shapeDefinition"); } _shapeDefinition = preparePoints(shapeDefinition); _useClockwiseCut = true; _millingDepth = 1.0; constructionInitialization(); }
/// <inheritdoc/> internal override ShapeItem Load(string path, ReadableIdentifier identifier) { Message("Image processing, please wait."); var interpolator = new ImageInterpolator(path); var points = interpolator.InterpolatePoints(); points = ShapeFactory.Centered(points); HideMessage(); var shape = new ShapeItem2D(identifier, points); shape.MetricWidth = 50; return(shape); }
public double[,] LoadRelief(string path, out ReadableIdentifier identifier) { var imageLoader = new ImageLoader(); var map = imageLoader.LoadRelief(path); var extension = Path.GetExtension(path).ToLowerInvariant(); var name = Path.GetFileNameWithoutExtension(path); identifier = new ReadableIdentifier(name); if (_panel != null) { identifier = _panel.UnusedVersion(identifier); } return(map); }
/// <inheritdoc/> internal override ShapeItem Clone(ReadableIdentifier cloneName) { var shapeItem = new ShapeItem4D(cloneName, ShapeDefinition); shapeItem.MetricWidth = MetricWidth; shapeItem.RotationAngle = RotationAngle; shapeItem.MetricHeight = MetricHeight; shapeItem.MetricThickness = MetricThickness; shapeItem.UseClockwiseCut = UseClockwiseCut; shapeItem.UseExplicitKerf = UseExplicitKerf; shapeItem.KerfUV = KerfUV; shapeItem.KerfXY = KerfXY; shapeItem.IsUvXySwitched = IsUvXySwitched; shapeItem.SpeedAlgorithm = SpeedAlgorithm; shapeItem.FinishCutMetricMarginC2 = FinishCutMetricMarginC2; return(shapeItem); }
public MillingItem Load(string path) { var extension = Path.GetExtension(path); if (extension == ".gcode" || extension == ".nc") { var name = Path.GetFileNameWithoutExtension(path); var identifier = new ReadableIdentifier(name); if (_provider != null) { identifier = _provider.UnusedVersion(identifier); } return(new MillingShapeItemGCode(File.ReadAllText(path), identifier)); } var useHeightmap = false; if (useHeightmap) { var reliefShape = _factory.LoadRelief(path, out var name); if (reliefShape != null) { var reliefShapeItem = new MillingShapeItemRelief(name, reliefShape); reliefShapeItem.MetricHeight = 100; return(reliefShapeItem); } } else { var flatShape = _factory.Load(path, out var name); if (flatShape != null) { var shapeItem = new MillingShapeItem2D(name, flatShape); shapeItem.MetricHeight = 100; return(shapeItem); } } return(null); }
internal override ShapeItem Load(string path, ReadableIdentifier identifier) { var lines = File.ReadAllLines(path); var segmentSpeeds = new List <Speed>(); var coordinates = new List <Point2Dmm>(); coordinates.Add(new Point2Dmm(0, 0)); foreach (var line in lines) { if (line.Trim() == "") { //empty line continue; } var coords = line.Split(' '); if (coords.Length != 3) { throw new FormatException("Invalid format on line: " + line); } var coord1 = double.Parse(coords[0]); var coord2 = double.Parse(coords[1]); var speed = double.Parse(coords[2]); var lastP = coordinates.Last(); coordinates.Add(new Point2Dmm(coord1 + lastP.C1, coord2 + lastP.C2)); var deltaT = Configuration.MilimetersPerStep * Configuration.TimerFrequency / speed; segmentSpeeds.Add(Speed.FromDeltaT((int)Math.Round(deltaT))); } var item = new NativeControlItem(identifier, coordinates, segmentSpeeds); item.SetOriginalSize(); return(item); }
internal ReadableIdentifier UnusedVersion(ReadableIdentifier name) { var names = new HashSet <ReadableIdentifier>(); foreach (var child in Children) { var item = child as MillingWorkspaceItem; if (item == null) { continue; } names.Add(item.Name); } var currentVersion = name; while (names.Contains(currentVersion)) { currentVersion = currentVersion.NextVersion(); } return(currentVersion); }
internal NativeControlItem(ReadableIdentifier name, IEnumerable <Point2Dmm> shapeDefinition, IEnumerable <Speed> segmentSpeeds) : base(name, shapeDefinition.DuplicateTo4Dmm()) { SegmentSpeeds = segmentSpeeds; }
public LevelMillingItem(ReadableIdentifier name) : base(name, new[] { new[] { new Point2Dmm(0, 0), new Point2Dmm(1, 0), new Point2Dmm(1, 1), new Point2Dmm(0, 1) } }) { MillingDepth = 0; // default to z level milling }
internal MillingWorkspaceItem(ReadableIdentifier name) { Name = name; constructionInitialization(); }
internal ReadableIdentifier UnusedVersion(ReadableIdentifier identifier) { return Workspace.UnusedVersion(identifier); }
internal abstract ShapeItem Load(string path, ReadableIdentifier identifier);
public ReadableIdentifier UnusedVersion(ReadableIdentifier identifier) { return(Workspace.UnusedVersion(identifier)); }
internal PermanentMillingWorkspaceItem(ReadableIdentifier name) : base(name) { }
/// <inheritdoc/> internal override ShapeItem Clone(ReadableIdentifier cloneName) { return(new NativeControlItem(cloneName, ShapeDefinition.ToUV(), SegmentSpeeds)); }
internal MillingItem(ReadableIdentifier name) : base(name) { }
internal PointProviderItem(ReadableIdentifier name) : base(name) { }