public static BoundaryLine[] ToLines(Vector[] polygon) { BoundaryLine[] lines = new BoundaryLine[polygon.Length]; BoundaryLine line; for (int i = 0; i < polygon.Length - 1; ++i) { line = new BoundaryLine { Start = new Vertex() { Position = polygon[i] }, End = new Vertex() { Position = polygon[i + 1] }, }; lines[i] = line; } line = new BoundaryLine { Start = new Vertex(), End = new Vertex() }; line.Start.Position = polygon[polygon.Length - 1]; line.End.Position = polygon[0]; lines[lines.Length - 1] = line; return(lines); }
static IDictionary <int, Transformation> CreatePeriodicTransformationsFrom( Vector[] boundary, IDictionary <int, int> periodicBoundaryMap) { BoundaryLine[] boundaryLines = BoundaryLine.ToLines(boundary); return(CreatePeriodicTransformationsFrom(boundaryLines, periodicBoundaryMap)); }
public MeshGenerator(MeshingAlgorithm.State settings) { cutter = new Cutter <T>(); boundingBox = settings.BoundingBox; boundaryLines = BoundaryLine.ToLines(settings.Boundary); boundaryHandler = new PeriodicBoundaryHandler <T>(settings.PeriodicMap); }
public static BoundaryLine[] Copy(BoundaryLine[] source) { BoundaryLine[] copy = new BoundaryLine[source.Length]; for (int i = 0; i < copy.Length; ++i) { copy[i] = source[i].Copy(); } return(copy); }
public static BoundaryLine GetReverse(BoundaryLine line) { BoundaryLine reverse = new BoundaryLine { Start = line.End, End = line.Start }; return(reverse); }
public BoundaryTransformation(BoundaryLine source, BoundaryLine target) : base(2) { if (source.Length() != target.Length()) { throw new Exception("There is something rotten in the state of the boundary lengths"); } Matrix = GetRotationMatrixFrom( source.End.Position - source.Start.Position, target.End.Position - target.Start.Position); AffineTransformation = (-1) * (Matrix * source.Start.Position) + source.Start.Position + (target.Start.Position - source.Start.Position); }
public BoundaryLine Copy() { var copy = new BoundaryLine(); copy.Start = new Vertex { Position = new Vector(Start.Position) }; copy.End = new Vertex { Position = new Vector(End.Position) }; return(copy); }
static IDictionary <int, Transformation> CreatePeriodicTransformationsFrom( BoundaryLine[] boundary, IDictionary <int, int> periodicBoundaryMap) { IDictionary <int, Transformation> periodicTrafoMap = new LinkedListDictionary <int, Transformation>(); foreach (var boundaryPair in periodicBoundaryMap) { BoundaryLine source = boundary[boundaryPair.Key]; BoundaryLine target = BoundaryLine.GetReverse(boundary[boundaryPair.Value]); Transformation transformation = new BoundaryTransformation(source, target); periodicTrafoMap.Add(boundaryPair.Key, transformation); } return(periodicTrafoMap); }