public void AddSample(ITopoArray <Tile> sample, TileRotation tileRotation = null) { foreach (var s in OverlappingAnalysis.GetRotatedSamples(sample, tileRotation)) { AddSample(s); } }
public void AddSample(ITopoArray <Tile> sample, int rotationalSymmetry, bool reflectionalSymmetry, TileRotation tileRotation = null) { foreach (var s in OverlappingAnalysis.GetRotatedSamples(sample, rotationalSymmetry, reflectionalSymmetry, tileRotation)) { AddSample(s); } }
private void Build() { if (propagator != null) { return; } // Update the model based on the collected data var directions = sampleTopologyDirections; // Collect all the pattern edges var patternIndicesByEdge = new Dictionary <Direction, Dictionary <PatternArray, int[]> >(); var edgesByPatternIndex = new Dictionary <(Direction, int), PatternArray>(); for (var d = 0; d < directions.Count; d++) { var dx = directions.DX[d]; var dy = directions.DY[d]; var dz = directions.DZ[d]; var edges = new Dictionary <PatternArray, HashSet <int> >(new PatternArrayComparer()); for (var p = 0; p < patternArrays.Count; p++) { var edge = OverlappingAnalysis.PatternEdge(patternArrays[p], dx, dy, dz); if (!edges.TryGetValue(edge, out var l)) { l = edges[edge] = new HashSet <int>(); } l.Add(p); edgesByPatternIndex[((Direction)d, p)] = edge;
public void AddSample(ITopoArray <Tile> sample, TileRotation tileRotation = null) { if (sample.Topology.Depth == 1) { nz = 1; } var topology = sample.Topology.AsGridTopology(); var periodicX = topology.PeriodicX; var periodicY = topology.PeriodicY; var periodicZ = topology.PeriodicZ; foreach (var s in OverlappingAnalysis.GetRotatedSamples(sample, tileRotation)) { OverlappingAnalysis.GetPatterns(s, nx, ny, nz, periodicX, periodicY, periodicZ, patternIndices, patternArrays, frequencies); } // Update the model based on the collected data var directions = topology.Directions; // TODO: Don't regenerate this from scratch every time propagator = new List <HashSet <int>[]>(patternArrays.Count); for (var p = 0; p < patternArrays.Count; p++) { propagator.Add(new HashSet <int> [directions.Count]); for (var d = 0; d < directions.Count; d++) { var l = new HashSet <int>(); for (var p2 = 0; p2 < patternArrays.Count; p2++) { var dx = directions.DX[d]; var dy = directions.DY[d]; var dz = directions.DZ[d]; if (Aggrees(patternArrays[p], patternArrays[p2], dx, dy, dz)) { l.Add(p2); } } propagator[p][d] = l; } } patternsToTiles = patternArrays .Select((x, i) => new KeyValuePair <int, Tile>(i, x.Values[0, 0, 0])) .ToDictionary(x => x.Key, x => x.Value); tilesToPatterns = patternsToTiles.ToLookup(x => x.Value, x => x.Key); }
public void AddSample(ITopoArray <Tile> sample, TileRotation tileRotation = null) { if (sample.Topology.Depth == 1) { nz = 1; } var topology = sample.Topology.AsGridTopology(); var periodicX = topology.PeriodicX; var periodicY = topology.PeriodicY; var periodicZ = topology.PeriodicZ; foreach (var s in OverlappingAnalysis.GetRotatedSamples(sample, tileRotation)) { OverlappingAnalysis.GetPatterns(s, nx, ny, nz, periodicX, periodicY, periodicZ, patternIndices, patternArrays, frequencies); } sampleTopologyDirections = topology.Directions; propagator = null;// Mark as dirty }