private void AddBSplineInterpolateCurve() { var selectedPoints = Points.Where(x => x.Selected).ToList(); var curve = new InterpolatingBSpline(); selectedPoints.ForEach(x => curve.AddPoint(x)); _listBox.Items.Add(curve); }
private void AddInterpolatingCurveFromIntersectingCurve() { var intersectingCurves = _listBox.Items.OfType <IntersectionCurve>().Where(x => x.Selected).ToList(); if (intersectingCurves.Count != 1) { return; } var curve = intersectingCurves[0]; var interpolating = new InterpolatingBSpline(); var points = curve.GetPoints(out var parameters); foreach (var point in points) { var drawable = new DrawablePoint(point.X, point.Y, point.Z); interpolating.AddPoint(drawable); } _listBox.Items.Remove(curve); _listBox.Items.Add(interpolating); }
private void Deserialize() { string filename = string.Empty; using (var ofd = new OpenFileDialog()) { var res = ofd.ShowDialog(); if (res != DialogResult.OK) { return; } else { filename = ofd.FileName; } } var f = _listBox.Items[0]; _listBox.Items.Clear(); _listBox.Items.Add(f); var lines = File.ReadAllLines(filename); for (int i = 0; i < lines.Length; i++) { string line = lines[i]; var spl = line.Split(' '); var expected = int.Parse(spl[1].Trim()); i++; var type = spl[0].Trim(); switch (type) { case "curveC0": for (int j = 0; j < expected; j++, i++) { var curve = new BezierCurve(lines[i]); _listBox.Items.Add(curve); curve.Points.ForEach(p => _listBox.Items.Add(p)); } break; case "curveC2": for (int j = 0; j < expected; j++, i++) { var curve = new BSplineCurve(lines[i]); _listBox.Items.Add(curve); curve.Points.ForEach(p => _listBox.Items.Add(p)); } break; case "curveInt": for (int j = 0; j < expected; j++, i++) { var curve = new InterpolatingBSpline(lines[i]); _listBox.Items.Add(curve); curve.Points.ForEach(p => _listBox.Items.Add(p)); } break; case "surfaceC0": for (int j = 0; j < expected; j++, i++) { var surf = new BasicSurface(lines[i], false); //if (surf.Name == "ucho") //{ // var surf2 = new BasicSurface(lines[i], false); // surf2.Points.ToList().ForEach(x => x.X = -x.X); // surf2.Name = "ucho2"; // _listBox.Items.Add(surf2); //} _listBox.Items.Add(surf); } break; case "tubeC0": for (int j = 0; j < expected; j++, i++) { _listBox.Items.Add(new BasicSurface(lines[i], true)); } break; case "surfaceC2": for (int j = 0; j < expected; j++, i++) { var surf = new BSplineSurface(lines[i], false); _listBox.Items.Add(surf); } break; case "tubeC2": for (int j = 0; j < expected; j++, i++) { var surf = new BSplineSurface(lines[i], true); if (surf.Name == "noga1") { //var surf2 = new BSplineSurface(lines[i], true); //surf2.Points.ToList().ForEach(x => x.X = -x.X); //surf2.Name = "noga3"; //_listBox.Items.Add(surf2); } else if (surf.Name == "noga2") { //var surf2 = new BSplineSurface(lines[i], true); //surf2.Points.ToList().ForEach(x => x.X = -x.X); //surf2.Name = "noga4"; //_listBox.Items.Add(surf2); } else { // var points = surf.Points.ToList(); // //for(int k=0;k<points.Count;k++) // //{ // // var p = points[k]; // // var p2 = points[k+2]; // // points[k + 2].Point = new Vector4(-p.X, p2.Y, p.Z, 1); // // if (k % 4 == 1) // // k += 2; // //} // var bigX = points.Where(x => x.X >0).ToList(); // foreach(var p in bigX) // { // var mirror = new Vector4(-p.X, p.Y, p.Z, 1); // var matched = points.OrderBy(x => Vector4.DistanceSquared(x.Point, mirror)).ToList(); // var best = matched.First(); // best.Point = mirror; // if (best == p) // p.X = 0; // } } _listBox.Items.Add(surf); } break; default: break; } i--; } }