public static CustomAttributeEditorWire CreateCustomAttributEditorWire(Wire model) { var wire = new CustomAttributeEditorWire(); wire.Type = "Wire"; //TODO: assign the model data to the editor wire.Id = model.Id; wire.Brace1 = model.Brace1 != null? model.Brace1.Id: ""; wire.Brace2 = model.Brace2 != null ? model.Brace2.Id : ""; wire.Material = model.Material; wire.Thicknes = model.Thicknes; return wire; }
void contours(Brush b) { model = new Wire(); model.Brace1 = brace1.Model; model.Brace2 = brace2.Model; Point3D c1 = brace1.centroid(); Point3D c2 = brace2.centroid(); /* int n = 6; // Create the data to be fitted float[] x = new float[n]; float[] y = new float[n]; Random rand = new Random(1); float xf = (float)(c2.X - c1.X)/n; float yf = (float)(c2.Y - c1.Y) / n; for (int i = 0; i < n; i++) { x[i] = (float) c1.X + (i * xf); y[i] = (float) c1.Y + (i * yf); } int upsampleFactor = 10; int nInterpolated = n * upsampleFactor; float[] xs = new float[nInterpolated]; for (int i = 0; i < nInterpolated; i++) { xs[i] = (float)i * (n - 1) / (float)(nInterpolated - 1); } CubicSpline spline = new CubicSpline(); float[] ys = spline.FitAndEval(x, y, xs, true); */ Point3DCollection contours = new Point3DCollection(); contours.Add(brace1.ToWorld(c1)); /*for (int i = 0; i < xs.Length; i++) { contours.Add(new Point3D(xs[i], ys[i], c1.Z)); }*/ contours.Add(brace2.ToWorld(c2)); this.Children.Clear(); TubeVisual3D tube = new TubeVisual3D { Diameter = 1.02, Path = contours, Fill = b }; this.Children.Add(tube); }