public override void SetVertex(IList <PrecisedVertex> vertices, PrecisedVertex newVertex, int index) { if (index == 0) { if (newVertex.Z < vertices[vertices.Count - 1].Z) { vertices[0] = newVertex; } } else { if (newVertex.Z > vertices[0].Z) { vertices[vertices.Count - 1] = newVertex; } } double len = vertices[0].DistanceTo(vertices[vertices.Count - 1]); double step = len / vertices.Count; double vx = (vertices[vertices.Count - 1].X - vertices[0].X) / (vertices.Count - 1); double vy = (vertices[vertices.Count - 1].Y - vertices[0].Y) / (vertices.Count - 1); double vz = (vertices[vertices.Count - 1].Z - vertices[0].Z) / (vertices.Count - 1); PrecisedVertex vec = new PrecisedVertex(vx, vy, vz); for (int i = 1; i < vertices.Count - 1; i++) { vertices[i] = vertices[i - 1] + vec; } }
static PrecisedVertex AddNewPillarToEnd(double Inc, bool isFirst, ref PrecisedVertex[] data, ref PrecisedVertex[] P1, ref PrecisedVertex[] P2) { double x, y, z, ax, ay, az, l; if (isFirst) { List <PrecisedVertex> Buf; l = Math.Sqrt((data[0].X - P1[0].X) * (data[0].X - P1[0].X) + (data[0].Y - P1[0].Y) * (data[0].Y - P1[0].Y) + (data[0].Z - P1[0].Z) * (data[0].Z - P1[0].Z)); ax = (data[0].X - P1[0].X) * Inc / l; ay = (data[0].Y - P1[0].Y) * Inc / l; az = (data[0].Z - P1[0].Z) * Inc / l; x = data[0].X + ax / 3; y = data[0].Y + ay / 3; z = data[0].Z + az / 3; Buf = new List <PrecisedVertex>(P2); Buf.Insert(0, new PrecisedVertex((float)x, (float)y, (float)z)); P2 = Buf.ToArray(); x = data[0].X + 2 * ax / 3; y = data[0].Y + 2 * ay / 3; z = data[0].Z + 2 * az / 3; Buf = new List <PrecisedVertex>(P1); Buf.Insert(0, new PrecisedVertex((float)x, (float)y, (float)z)); P1 = Buf.ToArray(); x = data[0].X + ax; y = data[0].Y + ay; z = data[0].Z + az; Buf = new List <PrecisedVertex>(data); Buf.Insert(0, new PrecisedVertex(x, y, z)); data = Buf.ToArray(); return(new PrecisedVertex(x, y, z)); } else { int N = data.Length - 2; l = Math.Sqrt((data[N + 1].X - P2[N].X) * (data[N + 1].X - P2[N].X) + (data[N + 1].Y - P2[N].Y) * (data[N + 1].Y - P2[N].Y) + (data[N + 1].Z - P2[N].Z) * (data[N + 1].Z - P2[N].Z)); ax = (data[N + 1].X - P2[N].X) * Inc / l; ay = (data[N + 1].Y - P2[N].Y) * Inc / l; az = (data[N + 1].Z - P2[N].Z) * Inc / l; x = data[N + 1].X + ax / 3; y = data[N + 1].Y + ay / 3; z = data[N + 1].Z + az / 3; Array.Resize(ref P1, P1.Length + 1); P1[N + 1] = new PrecisedVertex((float)x, (float)y, (float)z); x = data[N + 1].X + 2 * ax / 3; y = data[N + 1].Y + 2 * ay / 3; z = data[N + 1].Z + 2 * az / 3; Array.Resize(ref P2, P2.Length + 1); P2[N + 1] = new PrecisedVertex((float)x, (float)y, (float)z); x = data[N + 1].X + ax; y = data[N + 1].Y + ay; z = data[N + 1].Z + az; Array.Resize(ref data, data.Length + 1); data[N + 2] = new PrecisedVertex(x, y, z); return(new PrecisedVertex(x, y, z)); } }
PrecisedVertex[] GetMid() { PrecisedVertex[] mid = new PrecisedVertex[Count]; int iter = 0; foreach (var item in Items) { mid[iter++] = item.Center(); } return(mid); }
PrecisedVertex[] GetBot() { PrecisedVertex[] bot = new PrecisedVertex[Count]; int iter = 0; foreach (var item in Items) { bot[iter++] = item[item.Count - 1]; } return(bot); }
PrecisedVertex[] GetTop() { PrecisedVertex[] top = new PrecisedVertex[Count]; int iter = 0; foreach (var item in Items) { top[iter++] = item[0]; } return(top); }
public override void SetVertex(IList <PrecisedVertex> vertices, PrecisedVertex newVertex, int index) { if (index == 0) { if (newVertex.Z < vertices[2].Z) { vertices[0] = newVertex; } } else if (index == 1) { if (newVertex.Z > vertices[0].Z && newVertex.Z < vertices[4].Z) { vertices[2] = newVertex; } } else { if (newVertex.Z > vertices[2].Z) { vertices[4] = newVertex; } } PrecisedVertex[] p1, p2; List <PrecisedVertex> buf = new List <PrecisedVertex>(this.GetVertices(vertices)); if ((buf.Count - 1) <= 0) { return; } TimeZYX.Model.Utils.MathFunctions.GetControlPoints(buf.ToArray(), out p1, out p2); //tmp[0] = buf[0]; //tmp[4] = buf[buf.Count - 1]; //for (int k = 1; k < 4; k++) //{ double t = 0.25 * 1; int p = (int)(t * (buf.Count - 1)); t = (t - p * 1.0 / (buf.Count - 1)); vertices[1] = TimeZYX.Model.Utils.MathFunctions.BezierCurve(buf[p], p1[p], p2[p], buf[p + 1], t); t = 0.25 * 3; p = (int)(t * (buf.Count - 1)); t = (t - p * 1.0 / (buf.Count - 1)); vertices[3] = TimeZYX.Model.Utils.MathFunctions.BezierCurve(buf[p], p1[p], p2[p], buf[p + 1], t); //} }
public override void ConvertPillar(IList <PrecisedVertex> vertices) { double len = vertices[0].DistanceTo(vertices[vertices.Count - 1]); double step = len / vertices.Count; double vx = (vertices[vertices.Count - 1].X - vertices[0].X) / (vertices.Count - 1); double vy = (vertices[vertices.Count - 1].Y - vertices[0].Y) / (vertices.Count - 1); double vz = (vertices[vertices.Count - 1].Z - vertices[0].Z) / (vertices.Count - 1); PrecisedVertex vec = new PrecisedVertex(vx, vy, vz); for (int i = 1; i < vertices.Count - 1; i++) { vertices[i] = vertices[i - 1] + vec; } //buf = new PrecisedVertex[2]; //vertices[0] = items[0]; //vertices[vertices.Count-1] = items[items.Count - 1]; }
public override void ConvertPillar(IList <PrecisedVertex> vertices) { PrecisedVertex center = GetCenter(vertices); vertices[0] = new PrecisedVertex(center.X, center.Y, vertices[0].Z); vertices[vertices.Count - 1] = new PrecisedVertex(center.X, center.Y, vertices[vertices.Count - 1].Z); double len = vertices[0].DistanceTo(vertices[vertices.Count - 1]); double step = len / vertices.Count; double vx = (vertices[vertices.Count - 1].X - vertices[0].X) / (vertices.Count - 1); double vy = (vertices[vertices.Count - 1].Y - vertices[0].Y) / (vertices.Count - 1); double vz = (vertices[vertices.Count - 1].Z - vertices[0].Z) / (vertices.Count - 1); PrecisedVertex vec = new PrecisedVertex(vx, vy, vz); for (int i = 1; i < vertices.Count - 1; i++) { vertices[i] = vertices[i - 1] + vec; } }
static void AddNewPillarBetween(double Inc, int index, ref PrecisedVertex[] data, ref PrecisedVertex[] P1, ref PrecisedVertex[] P2) { double derX = 0.125 * (-data[index].X - P1[index].X + P2[index].X + data[index + 1].X); double derY = 0.125 * (-data[index].Y - P1[index].Y + P2[index].Y + data[index + 1].Y); double derZ = 0.125 * (-data[index].Z - P1[index].Z + P2[index].Z + data[index + 1].Z); PrecisedVertex V = MathFunctions.BezierCurve(data[index], P1[index], P2[index], data[index + 1], 0.5); List <PrecisedVertex> Buf = new List <PrecisedVertex>(data); Buf.Insert(index + 1, V); data = Buf.ToArray(); Buf = new List <PrecisedVertex>(P1); Buf.Insert(index + 1, new PrecisedVertex()); P1 = Buf.ToArray(); Buf = new List <PrecisedVertex>(P2); Buf.Insert(index + 1, new PrecisedVertex()); P2 = Buf.ToArray(); P2[index + 1] = new PrecisedVertex(P2[index].X, P2[index].Y, P2[index].Z); //P1[index + 1].X = (float)(data[index + 1].X + derX); //P1[index + 1].Y = (float)(data[index + 1].Y + derY); //P1[index + 1].Z = (float)(data[index + 1].Z + derZ); P1[index + 1] = P1[index + 1].Move((data[index + 1].X + derX), (data[index + 1].Y + derY), (data[index + 1].Z + derZ)); //P2[index].X = (float)(data[index + 1].X - derX); //P2[index].Y = (float)(data[index + 1].Y - derY); //P2[index].Z = (float)(data[index + 1].Z - derZ); P2[index] = P2[index].Move((data[index + 1].X - derX), (data[index + 1].Y - derY), (data[index + 1].Z - derZ)); //P2[index + 1].X = data[index + 2].X + (P2[index + 1].X - data[index + 2].X) / 2; //P2[index + 1].Y = data[index + 2].Y + (P2[index + 1].Y - data[index + 2].Y) / 2; //P2[index + 1].Z = data[index + 2].Z + (P2[index + 1].Z - data[index + 2].Z) / 2; P2[index + 1] = P2[index + 1].Move(data[index + 2].X + (P2[index + 1].X - data[index + 2].X) / 2, data[index + 2].Y + (P2[index + 1].Y - data[index + 2].Y) / 2, data[index + 2].Z + (P2[index + 1].Z - data[index + 2].Z) / 2); //P1[index].X = data[index].X + (P1[index].X - data[index].X) / 2; //P1[index].Y = data[index].Y + (P1[index].Y - data[index].Y) / 2; //P1[index].Z = data[index].Z + (P1[index].Z - data[index].Z) / 2; P1[index] = P1[index].Move(data[index].X + (P1[index].X - data[index].X) / 2, data[index].Y + (P1[index].Y - data[index].Y) / 2, data[index].Z + (P1[index].Z - data[index].Z) / 2); }
public override void SetVertexes(IList <PrecisedVertex> vertices, PrecisedVertex[] newVertexes) { if (newVertexes.Length != 5) { return; } if (newVertexes[1].Z > vertices[2].Z) { vertices[1] = new PrecisedVertex(newVertexes[1].X, newVertexes[1].Y, vertices[2].Z); } else { vertices[1] = newVertexes[1]; } if (newVertexes[3].Z < vertices[2].Z) { vertices[3] = new PrecisedVertex(newVertexes[3].X, newVertexes[3].Y, vertices[2].Z); } else { vertices[3] = newVertexes[3]; } if (newVertexes[0].Z > vertices[1].Z) { vertices[0] = new PrecisedVertex(newVertexes[0].X, newVertexes[0].Y, vertices[1].Z); } else { vertices[0] = newVertexes[0]; } if (newVertexes[4].Z < vertices[3].Z) { vertices[4] = new PrecisedVertex(newVertexes[4].X, newVertexes[4].Y, vertices[3].Z); } else { vertices[4] = newVertexes[4]; } }
public override void SetVertex(IList <PrecisedVertex> vertices, PrecisedVertex newVertex, int index) { if (index == 0) { if (newVertex.Z < vertices[1].Z) { vertices[index] = newVertex; } } else if (index == 1) { if (newVertex.Z > vertices[0].Z && newVertex.Z < vertices[2].Z) { vertices[index] = newVertex; } } else if (index == 2) { if (newVertex.Z > vertices[1].Z && newVertex.Z < vertices[3].Z) { vertices[index] = newVertex; } } else if (index == 3) { if (newVertex.Z > vertices[2].Z && newVertex.Z < vertices[4].Z) { vertices[index] = newVertex; } } else { if (newVertex.Z > vertices[3].Z) { vertices[index] = newVertex; } } }
public Pillar AddPillarBetween(List <int> ids, FaultSettings fsettings) { if (ids.Count < 2) { return(null); } ids.Sort(); if (ids[1] != ids[0] + 1) { return(null); } PrecisedVertex top = (Items[ids[0]][0] + Items[ids[1]][0]) / 2.0; PrecisedVertex bot = (Items[ids[0]][Items[ids[0]].Count - 1] + Items[ids[1]][Items[ids[1]].Count - 1]) / 2.0; double len = top.DistanceTo(bot); double step = len / 5; double vx = (bot.X - top.X) / 4; double vy = (bot.Y - top.Y) / 4; double vz = (bot.Z - top.Z) / 4; PrecisedVertex vec = new PrecisedVertex(vx, vy, vz); PrecisedVertex nv = top; List <PrecisedVertex> nlist = new List <PrecisedVertex>(5); nlist.Add(top); for (int i = 0; i < 3; i++) { nv = nv + vec; nlist.Add(nv); } nlist.Add(bot); Pillar pillar = new Pillar(Project, "Adding", nlist, fsettings.Impl); if (pillar != null) { Insert(ids[1], pillar); } return(pillar); //return null; }
private void RecalcMinMax() { double xmin = double.MaxValue, ymin = double.MaxValue, zmin = double.MaxValue; double xmax = double.MinValue, ymax = double.MinValue, zmax = double.MinValue; foreach (Pillar item in items) { if (xmin > item.Min.X) { xmin = item.Min.X; } if (ymin > item.Min.Y) { ymin = item.Min.Y; } if (zmin > item.Min.Z) { zmin = item.Min.Z; } if (xmax < item.Max.X) { xmax = item.Max.X; } if (ymax < item.Max.Y) { ymax = item.Max.Y; } if (zmax < item.Max.Z) { zmax = item.Max.Z; } } currentMin = new PrecisedVertex(xmin, ymin, zmin); currentMax = new PrecisedVertex(xmax, ymax, zmax); }
public abstract void SetVertex(IList <PrecisedVertex> vertices, PrecisedVertex newVertex, int index);
public Pillar AddPillarToEnd(List <int> ids, FaultSettings fsettings, double distance) { if (ids.Count == 0) { return(null); } bool isFirst = false; ids.Sort(); if (ids[0] == 0) { isFirst = true; } else { if (ids[ids.Count - 1] != Count - 1) { return(null); } } List <PrecisedVertex> v = new List <PrecisedVertex>(); foreach (var item in Items) { v.Add(item[0]); } //foreach (var id in ids) //{ // v.Add(Items[id][0]); //} PrecisedVertex[] data; PrecisedVertex[] P1 = new PrecisedVertex[v.Count]; PrecisedVertex[] P2 = new PrecisedVertex[v.Count]; data = v.ToArray(); try { MathFunctions.GetControlPoints(v.ToArray(), out P1, out P2); PrecisedVertex top = AddNewPillarToEnd(distance, isFirst, ref data, ref P1, ref P2); v.Clear(); //foreach (var id in ids) //{ // v.Add(Items[id][Items[id].Count - 1]); //} foreach (var item in Items) { v.Add(item[item.Count - 1]); } data = v.ToArray(); MathFunctions.GetControlPoints(v.ToArray(), out P1, out P2); PrecisedVertex bot = AddNewPillarToEnd(distance, isFirst, ref data, ref P1, ref P2); double len = top.DistanceTo(bot); double step = len / 5; double vx = (bot.X - top.X) / 4; double vy = (bot.Y - top.Y) / 4; double vz = (bot.Z - top.Z) / 4; PrecisedVertex vec = new PrecisedVertex(vx, vy, vz); PrecisedVertex nv = top; List <PrecisedVertex> nlist = new List <PrecisedVertex>(5); nlist.Add(top); for (int i = 0; i < 3; i++) { nv = nv + vec; nlist.Add(nv); } nlist.Add(bot); Pillar pillar = new Pillar(Project, "Adding", nlist, fsettings.Impl); if (isFirst) { Insert(0, pillar); } else { Add(pillar); } //Insert(isFirst ? 0 : Count - 1, pillar); return(pillar); } catch { return(null); } }