public static void CompositeCurveMeshing(Model model) { MainWindow.SetDisplayMode(model, displayType.Shaded); CompositeCurve outer = new CompositeCurve(); outer.CurveList.Add(new Line(0, 0, 10, 0)); outer.CurveList.Add(new Line(10, 0, 10, 6)); outer.CurveList.Add(new Line(10, 6, 0, 6)); outer.CurveList.Add(new Line(0, 6, 0, 0)); CompositeCurve inner1 = new CompositeCurve(); inner1.CurveList.Add(new Line(2, 2, 6, 2)); inner1.CurveList.Add(new Line(6, 2, 2, 3)); inner1.CurveList.Add(new Line(2, 3, 2, 2)); CompositeCurve inner2 = new CompositeCurve(); inner2.CurveList.Add(new Circle(8, 4, 0, 1)); CompositeCurve inner3 = new CompositeCurve(); inner3.CurveList.Add(new Circle(6, 4, 0, .75)); Region reg = new Region(outer, inner1, inner2, inner3); Mesh m = UtilityEx.Triangulate(reg, .15); model.Entities.Add(m, Color.Salmon); }
private void delaunayToolStripMenuItem_Click(object sender, EventArgs e) { int rows = 100; int cols = 100; Point3D[] points = new Point3D[rows * cols]; int min = -2; int max = 2; int minxy = -1000; int maxxy = 1000; Random random = new Random(); int index = 0; for (int i = 0; i < rows; ++i) { for (int j = 0; j < cols; ++j) { points[index] = new Point3D(random.Next(minxy, maxxy), random.Next(minxy, maxxy), random.Next(min, max)); index++; } } Mesh tin = UtilityEx.Triangulate(points, Mesh.natureType.RichSmooth); if (tin != null) { model1.Entities.Add(tin, Color.YellowGreen); } }
public static void TerrainTriangulation(Model model) { MainWindow.SetBackgroundStyleAndColor(model); int sideCount = 100; int len = sideCount * sideCount; Point3D[] pts = new Point3D[len]; Random rand = new Random(3); for (int j = 0; j < sideCount; j++) { for (int i = 0; i < sideCount; i++) { double x = rand.NextDouble() * sideCount; double y = rand.NextDouble() * sideCount; double z = 0; double _x = x / 2 - 15; double _y = y / 2 - 15; double den = Math.Sqrt(_x * _x + _y * _y); if (den != 0) { z = 10 * Math.Sin(Math.Sqrt(_x * _x + _y * _y)) / den; } int R = (int)(255 * (z + 2) / 12); int B = (int)(2.55 * y); Utility.LimitRange <int>(0, ref R, 255); Utility.LimitRange <int>(0, ref B, 255); PointRGB pt = new PointRGB(x, y, z, (byte)R, 255, (byte)B); pts[i + j * sideCount] = pt; } } Mesh m = UtilityEx.Triangulate(pts); model.Entities.Add(m); Plane pln = new Plane(new Point3D(0, 20, 20), new Vector3D(20, -30, 10)); PlanarEntity pe = new PlanarEntity(pln, 25); model.Entities.Add(pe, Color.Magenta); ICurve[] curves = m.Section(pln, 0); foreach (Entity ent in curves) { model.Entities.Add(ent); } }
void MakeFemMeshSample() { Line l1 = new Line(0, 0, 100, 0); Line l2 = new Line(100, 0, 100, 30); Line l3 = new Line(100, 30, 80, 30); Arc a1 = new Arc(80, 50, 0, 20, Utility.DegToRad(180), Utility.DegToRad(270)); Line l4 = new Line(60, 50, 60, 80); Line l5 = new Line(60, 80, 30, 80); Line l6 = new Line(30, 80, 30, 31); Arc a2 = new Arc(29, 31, 0, 1, Utility.DegToRad(270), Utility.DegToRad(360)); Line l7 = new Line(29, 30, 26, 30); Arc a3 = new Arc(26, 31, 0, 1, Utility.DegToRad(180), Utility.DegToRad(270)); Line l8 = new Line(25, 31, 25, 80); Line l9 = new Line(25, 80, 15, 80); Line l10 = new Line(15, 80, 15, 31); Arc a4 = new Arc(14, 31, 0, 1, Utility.DegToRad(270), Utility.DegToRad(360)); Line l11 = new Line(14, 30, 11, 30); Arc a5 = new Arc(11, 31, 0, 1, Utility.DegToRad(180), Utility.DegToRad(270)); Line l12 = new Line(10, 31, 10, 80); Line l13 = new Line(10, 80, 0, 80); Line l14 = new Line(0, 80, 0, 0); Circle c1 = new Circle(20, 15, 0, 5); Circle c2 = new Circle(35, 15, 0, 5); Circle c3 = new Circle(50, 15, 0, 5); Circle c4 = new Circle(65, 15, 0, 5); devDept.Eyeshot.Entities.Region reg = new devDept.Eyeshot.Entities.Region(new ICurve[] { new CompositeCurve(l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, a1, a2, a3, a4, a5), c1, c2, c3, c4 }, Plane.XY); Mesh m = UtilityEx.Triangulate(reg, 3); Material copper = Material.Copper; copper.ElementThickness = 6; copper.ElementType = elementType.PlaneStress; FemMesh fMesh = m.ConvertToFemMesh(copper, true); fMesh.FixAll(new Point3D(0, 0), new Point3D(100, 0), .1); fMesh.SetForce(new Point3D(0, 70), new Point3D(50, 70), .1, new Vector3D(-1, 0, 0)); model1.Entities.Add(fMesh); model1.Invalidate(); Solver s1 = new Solver(fMesh); model1.DoWork(s1); model1.Invalidate(); fMesh.PlotMode = FemMesh.plotType.U; fMesh.NodalAverages = true; fMesh.ComputePlot(model1, model1.ActiveViewport.Legends[0]); model1.ZoomFit(); }
protected override void OnContentRendered(EventArgs e) { // defines and add a circle Circle c1 = new Circle(0, 0, 0, 8); // regen with our own tolerance c1.Regen(0.05); // defines and adds a rect LinearPath r1 = new LinearPath(3, 3); r1.Translate(1, -5, 0); // creates an array of points ... Point3D[] points = new Point3D[100]; // ... and fills it for (int y = 0; y < 10; y++) { for (int x = 0; x < 10; x++) { Point3D p = new Point3D(x, y, 0); points[x + y * 10] = p; // adds the point also to the master entity array model1.Entities.Add(new devDept.Eyeshot.Entities.Point(p), System.Drawing.Color.Black); } } // creates an internal constraint Arc a1 = new Arc(0, 0, 0, 5, Utility.DegToRad(120), Utility.DegToRad(220)); a1.Regen(0.05); List <Segment3D> segments = new List <Segment3D>(); for (int i = 0; i < a1.Vertices.Length - 1; i++) { segments.Add(new Segment3D(a1.Vertices[i], a1.Vertices[i + 1])); } // computes triangulation and fill the Mesh entity Mesh m = UtilityEx.Triangulate(c1.Vertices, new Point3D[][] { r1.Vertices }, points, segments); model1.Entities.Add(c1, System.Drawing.Color.Red); model1.Entities.Add(r1, System.Drawing.Color.Blue); model1.Entities.Add(a1, System.Drawing.Color.Green); m.EdgeStyle = Mesh.edgeStyleType.Free; // moves the mesh up m.Translate(0, 0, 5); // adds the mesh to the master entity array model1.Entities.Add(m, System.Drawing.Color.RoyalBlue); // sets the shaded display mode model1.DisplayMode = displayType.Shaded; // fits the model in the viewport model1.ZoomFit(); // sets trimetric view model1.SetView(viewType.Trimetric); // hides origin symbol model1.GetOriginSymbol().Visible = false; //refresh the viewport model1.Invalidate(); base.OnContentRendered(e); }