Skip to content

Commit

Permalink
fix problem with outermost edges on boundary polygons not being gener…
Browse files Browse the repository at this point in the history
…ated
  • Loading branch information
jamis committed Feb 17, 2011
1 parent c154e1e commit cb0b113
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/kaleidoscope/pattern.rb
Expand Up @@ -51,6 +51,7 @@ def build_at(seed, increment, &validator)

validator ||= proc { |pt| true }
seeds = []
valid_edges_generated = false

@tile.phase_count.times do |n|
data = @tile.phase(n)
Expand Down Expand Up @@ -81,11 +82,13 @@ def build_at(seed, increment, &validator)
poly = (@poly_map[@dict.canonical(trans.apply(center))] ||= Polygon.new)
poly.outside! unless inside
valid_edges.each { |edge, neighbor| poly.edges[edge] = neighbor }
valid_edges_generated = true
end
end

neighbor = @dict.canonical(trans.apply(data[:neighbor]))
seeds << neighbor if validator[neighbor]
if valid_edges_generated
seeds << @dict.canonical(trans.apply(data[:neighbor]))
end
end

return seeds
Expand Down
2 changes: 1 addition & 1 deletion test/pattern_test.rb
Expand Up @@ -73,6 +73,6 @@ def test_generate_should_mark_edges_as_outside_when_they_are_not_fully_inside_th
def test_generate_should_cover_all_seed_sites_within_the_bounds
p = Pattern.new(6, 3)
p.generate! { |pt| pt.x.between?(-1.01, 3.01) && pt.y.between?(-1.01, 3.01) }
assert_equal 49, p.polygons.length
assert_equal 50, p.polygons.length
end
end

0 comments on commit cb0b113

Please sign in to comment.