public DisplacementPoint(Displacement parent, int x, int y) { Parent = parent; XIndex = x; YIndex = y; CurrentPosition = new Vertex(Coordinate.Zero, parent); InitialPosition = Coordinate.Zero; Displacement = new Vector(Coordinate.UnitZ, 0); OffsetDisplacement = new Vector(Coordinate.UnitZ, 0); Alpha = 0; }
/// <summary> /// Whether or not this displacement is sewable with the provided displacement. /// </summary> /// <param name="disp">The displcement to test</param> /// <returns>True if these displacements are sewable.</returns> public bool IsSewableTo(Displacement disp) { var otherEdges = disp.GetEdges(); return GetEdges().Any(x => otherEdges.Any(y => x.EquivalentTo(y))); }
private static GenericStructure WriteDisplacement(Displacement disp) { throw new NotImplementedException(); }
private static Displacement ReadDisplacement(long id, GenericStructure dispinfo) { var disp = new Displacement(id); // power, startposition, flags, elevation, subdiv, normals{}, distances{}, // offsets{}, offset_normals{}, alphas{}, triangle_tags{}, allowed_verts{} disp.SetPower(dispinfo.PropertyInteger("power", 3)); disp.StartPosition = dispinfo.PropertyCoordinate("startposition"); disp.Elevation = dispinfo.PropertyDecimal("elevation"); disp.SubDiv = dispinfo.PropertyInteger("subdiv") > 0; var size = disp.Resolution + 1; var normals = dispinfo.GetChildren("normals").FirstOrDefault(); var distances = dispinfo.GetChildren("distances").FirstOrDefault(); var offsets = dispinfo.GetChildren("offsets").FirstOrDefault(); var offsetNormals = dispinfo.GetChildren("offset_normals").FirstOrDefault(); var alphas = dispinfo.GetChildren("alphas").FirstOrDefault(); //var triangleTags = dispinfo.GetChildren("triangle_tags").First(); //var allowedVerts = dispinfo.GetChildren("allowed_verts").First(); for (var i = 0; i < size; i++) { var row = "row" + i; var norm = normals != null ? normals.PropertyCoordinateArray(row, size) : Enumerable.Range(0, size).Select(x => Coordinate.Zero).ToArray(); var dist = distances != null ? distances.PropertyDecimalArray(row, size) : Enumerable.Range(0, size).Select(x => 0m).ToArray(); var offn = offsetNormals != null ? offsetNormals.PropertyCoordinateArray(row, size) : Enumerable.Range(0, size).Select(x => Coordinate.Zero).ToArray(); var offs = offsets != null ? offsets.PropertyDecimalArray(row, size) : Enumerable.Range(0, size).Select(x => 0m).ToArray(); var alph = alphas != null ? alphas.PropertyDecimalArray(row, size) : Enumerable.Range(0, size).Select(x => 0m).ToArray(); for (var j = 0; j < size; j++) { disp.Points[i, j].Displacement = new Vector(norm[j], dist[j]); disp.Points[i, j].OffsetDisplacement = new Vector(offn[j], offs[j]); disp.Points[i, j].Alpha = alph[j]; } } return disp; }
private void CollectJoinedDisplacements(List<Displacement> collection, Displacement startingPoint, List<Displacement> searchList) { if (collection.Contains(startingPoint)) return; collection.Add(startingPoint); searchList.Remove(startingPoint); var sewable = startingPoint.GetSewableDisplacements(searchList).ToList(); sewable.ForEach(x => CollectJoinedDisplacements(collection, x, searchList)); }
/// <summary> /// Whether or not this displacement is sewable with the provided displacement. /// </summary> /// <param name="disp">The displcement to test</param> /// <returns>True if these displacements are sewable.</returns> public bool IsSewableTo(Displacement disp) { var otherEdges = disp.GetEdges(); return(GetEdges().Any(x => otherEdges.Any(y => x.EquivalentTo(y)))); }