public AddRegion ( double x, double y, int id ) : void | ||
x | double | X coordinate of the hole. |
y | double | Y coordinate of the hole. |
id | int | The region id. |
리턴 | void |
/// <summary> /// Rebuild the input geometry. /// </summary> private InputGeometry Rebuild() { InputGeometry geometry = new InputGeometry(mesh.vertices.Count); foreach (var vertex in mesh.vertices.Values) { geometry.AddPoint(vertex.x, vertex.y, vertex.mark); } foreach (var segment in mesh.subsegs.Values) { geometry.AddSegment(segment.P0, segment.P1, segment.Boundary); } foreach (var hole in mesh.holes) { geometry.AddHole(hole.x, hole.y); } foreach (var region in mesh.regions) { geometry.AddRegion(region.point.x, region.point.y, region.id); } return geometry; }
public override InputGeometry Generate(double param0, double param1, double param2) { // Number of points on the outer circle int n = GetParamValueInt(0, param0); int count, npoints; double radius = GetParamValueInt(1, param1); // Step size on the outer circle double h = 2 * Math.PI * radius / n; // Current radius and step size double r, dphi; InputGeometry input = new InputGeometry(n + 1); // Inner cirlce (radius = 1) r = 1; npoints = (int)(2 * Math.PI * r / h); dphi = 2 * Math.PI / npoints; for (int i = 0; i < npoints; i++) { input.AddPoint(r * Math.Cos(i * dphi), r * Math.Sin(i * dphi), 1); input.AddSegment(i, (i + 1) % npoints, 1); } count = input.Count; // Center cirlce r = (radius + 1) / 2.0; npoints = (int)(2 * Math.PI * r / h); dphi = 2 * Math.PI / npoints; for (int i = 0; i < npoints; i++) { input.AddPoint(r * Math.Cos(i * dphi), r * Math.Sin(i * dphi), 2); input.AddSegment(count + i, count + (i + 1) % npoints, 2); } count = input.Count; // Outer cirlce r = radius; npoints = (int)(2 * Math.PI * r / h); dphi = 2 * Math.PI / npoints; for (int i = 0; i < npoints; i++) { input.AddPoint(r * Math.Cos(i * dphi), r * Math.Sin(i * dphi), 3); input.AddSegment(count + i, count + (i + 1) % npoints, 3); } input.AddHole(0, 0); // Regions: |++++++|++++++|---| // r 1 0 input.AddRegion((r + 3.0) / 4.0, 0, 1); input.AddRegion((3 * r + 1.0) / 4.0, 0, 2); return input; }