contrek 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07f6097c256b6d44373aa941b969b12dd68630e168c72b29d1ae478bb5f48186
4
- data.tar.gz: 7ec31b1ef4413e679e31a123f367d0a86ed332160455c8024ea185ca67c27020
3
+ metadata.gz: 0df584b1fe92f70cb27f479a6d7705545f662b8758a4843bf966fe92d90c4c9d
4
+ data.tar.gz: 2dfe6f8b0cc96298858f5055158ba439644d24a9921166c572e91cd5df17780b
5
5
  SHA512:
6
- metadata.gz: c03213b7499e5741bf3c90044251a5ba6fc606905f3c72ff93462a62ffc116ebae7ce211fb2a201862d874ae865df048e45cf85beed094bc60967d2b4dd6fc34
7
- data.tar.gz: ae891e55d9d9ef5503f654d79c7187713579c6fa1c699736d446d6b19497ddb9d30723a26e98a77261481f364466b7d891962e9937433a65e6e341f240129faa
6
+ metadata.gz: d97742b1bc4f3688a8d083d25873da8db709b69c42c8068d02cfe6fe3569acac159f3d1a37c31128a7809b0e9851ba5e9da15c801f18c514189e53f4bc39440a
7
+ data.tar.gz: ee34393dc9713f62de0560b5d6538e7e9ffd6ff38358429f14f7ab7efb3cde201f2461d4ec209ed906a0a0e1e6aa0eb013040dddf290856400f632131e4c3622
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- contrek (1.2.3)
4
+ contrek (1.2.4)
5
5
  chunky_png (~> 1.4)
6
6
  concurrent-ruby (~> 1.3.5)
7
7
  rice (= 4.5.0)
@@ -86,9 +86,8 @@ void Cursor::traverse_outer(Part* act_part,
86
86
  auto& q_set = new_position->end_point()->queues();
87
87
  auto it = std::find_if(q_set.begin(), q_set.end(), [&](Queueable<Point>* q) {
88
88
  Part* p = static_cast<Part*>(q);
89
- return p->versus() == -versus && p->polyline()->tile != act_part->polyline()->tile;
89
+ return (p->mirror || act_part->mirror || p->versus() == -versus) && p->polyline()->tile != act_part->polyline()->tile;
90
90
  });
91
-
92
91
  Part* part = nullptr;
93
92
  if (it != q_set.end()) {
94
93
  part = static_cast<Part*>(*it);
@@ -97,24 +96,26 @@ void Cursor::traverse_outer(Part* act_part,
97
96
  const auto n = all_parts.size();
98
97
  Part *last_last_part = n >= 2 ? all_parts[n - 2] : nullptr;
99
98
  if (last_last_part != part) {
99
+ bool all_seam = false;
100
100
  if (n >= 2) {
101
- bool all_seam = true;
101
+ all_seam = true;
102
102
  for (std::size_t i = all_parts.size() - 2; i < all_parts.size(); ++i) {
103
103
  if (all_parts[i]->type != Part::SEAM) {
104
104
  all_seam = false;
105
105
  break;
106
106
  }
107
107
  }
108
- if (all_seam) break;
109
108
  }
110
- if (shapes_sequence_lookup.insert(part->polyline()->shape).second) {
111
- shapes_sequence.push_back(part->polyline()->shape);
109
+ if (!all_seam) {
110
+ if (shapes_sequence_lookup.insert(part->polyline()->shape).second) {
111
+ shapes_sequence.push_back(part->polyline()->shape);
112
+ }
113
+ part->next_position(new_position);
114
+ part->dead_end = true;
115
+ act_part = part;
116
+ jumped_to_new_part = true;
117
+ break;
112
118
  }
113
- part->next_position(new_position);
114
- part->dead_end = true;
115
- act_part = part;
116
- jumped_to_new_part = true;
117
- break;
118
119
  }
119
120
  }
120
121
  if (!jumped_to_new_part) {
@@ -65,7 +65,13 @@ void Part::orient()
65
65
  { if (this->size <= 1 || (this->size == 2 && this->inverts)) {
66
66
  this->versus_ = 0;
67
67
  } else {
68
- this->versus_ = (this->tail->payload->y - this->head->payload->y) > 0 ? 1 : -1;
68
+ int diff = this->tail->payload->y - this->head->payload->y;
69
+ if (diff == 0) {
70
+ this->mirror = true;
71
+ this->versus_ = 0;
72
+ } else {
73
+ this->versus_ = diff > 0 ? 1 : -1;
74
+ }
69
75
  }
70
76
  }
71
77
 
@@ -78,6 +84,7 @@ std::string Part::inspect() {
78
84
  std::stringstream ss;
79
85
  ss << "part " << part_index
80
86
  << " (versus=" << this->versus_
87
+ << " mirror=" << this->mirror
81
88
  << " inv=" << this->inverts
82
89
  << " trm=" << this->trasmuted
83
90
  << " touched=" << this->touched_
@@ -33,6 +33,7 @@ class Part : public Queueable<Point> {
33
33
  bool inverts = false;
34
34
  bool trasmuted = false;
35
35
  bool dead_end = false;
36
+ bool mirror = false;
36
37
  Part* next = nullptr;
37
38
  Part* prev = nullptr;
38
39
  Part* circular_next = nullptr;
@@ -87,10 +87,16 @@ void Partitionable::trasmute_parts()
87
87
  }
88
88
  return false;
89
89
  });
90
- if (count == inside->size && count < inside_compare->size) {
91
- inside->type = Part::EXCLUSIVE;
92
- inside->trasmuted = true;
93
- break;
90
+ if (count == inside->size) {
91
+ if (count < inside_compare->size) {
92
+ inside->type = Part::EXCLUSIVE;
93
+ inside->trasmuted = true;
94
+ break;
95
+ } else if ( count == inside_compare->size &&
96
+ inside->next == nullptr &&
97
+ inside_compare->prev == nullptr) {
98
+ inside->mirror = true;
99
+ }
94
100
  }
95
101
  }
96
102
  }
@@ -115,7 +115,7 @@ module Contrek
115
115
  new_position.end_point.tracked_outer = true
116
116
  versus = act_part.versus
117
117
  part = new_position.end_point.queues.find do |p|
118
- p.versus == -versus && p.polyline.tile != act_part.polyline.tile
118
+ (p.mirror || act_part.mirror || p.versus == -versus) && p.polyline.tile != act_part.polyline.tile
119
119
  end
120
120
  if part
121
121
  if all_parts[-2] != part
@@ -8,7 +8,7 @@ module Contrek
8
8
  ADDED = 2
9
9
 
10
10
  attr_reader :polyline, :touched
11
- attr_accessor :next, :circular_next, :prev, :type, :dead_end, :inverts, :trasmuted, :versus
11
+ attr_accessor :next, :circular_next, :prev, :type, :dead_end, :inverts, :trasmuted, :versus, :mirror
12
12
  def initialize(type, polyline)
13
13
  @type = type
14
14
  @polyline = polyline
@@ -20,6 +20,7 @@ module Contrek
20
20
  @inverts = false
21
21
  @trasmuted = false
22
22
  @versus = 0
23
+ @mirror = false
23
24
  end
24
25
 
25
26
  def is?(type)
@@ -56,7 +57,7 @@ module Contrek
56
57
  end
57
58
 
58
59
  def inspect
59
- "part #{polyline.parts.index(self)} (versus=#{@versus} inv=#{@inverts} trm=#{@trasmuted} touched=#{@touched} dead_end =#{@dead_end}, #{size}x) of #{polyline.info} (#{name}) (#{to_a.map { |e| "[#{e[:x]},#{e[:y]}]" }.join})"
60
+ "part #{polyline.parts.index(self)} (mir=#{@mirror} versus=#{@versus} inv=#{@inverts} trm=#{@trasmuted} touched=#{@touched} dead_end =#{@dead_end}, #{size}x) of #{polyline.named} (#{name}) (#{to_a.map { |e| "[#{e[:x]},#{e[:y]}]" }.join})"
60
61
  end
61
62
 
62
63
  def innerable?
@@ -67,7 +68,13 @@ module Contrek
67
68
  @versus = if size <= 1 || (size == 2 && @inverts)
68
69
  0
69
70
  else
70
- (tail.payload[:y] - head.payload[:y]).positive? ? 1 : -1
71
+ diff = tail.payload[:y] - head.payload[:y]
72
+ if diff == 0
73
+ @mirror = true
74
+ 0
75
+ else
76
+ diff.positive? ? 1 : -1
77
+ end
71
78
  end
72
79
  end
73
80
 
@@ -73,6 +73,10 @@ module Contrek
73
73
  inside.trasmuted = true
74
74
  break
75
75
  end
76
+ if count == inside.size && count == inside_compare.size &&
77
+ inside.next.nil? && inside_compare.prev.nil?
78
+ inside.mirror = true
79
+ end
76
80
  end
77
81
  end
78
82
  end
@@ -1,3 +1,3 @@
1
1
  module Contrek
2
- VERSION = "1.2.3"
2
+ VERSION = "1.2.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contrek
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emanuele Cesaroni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-23 00:00:00.000000000 Z
11
+ date: 2026-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec