extract_curves 0.0.1-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/bin/ec_rect2polar.rb +22 -0
  2. data/bin/ec_rev_lines.rb +5 -0
  3. data/bin/ec_sph_area.rb +30 -0
  4. data/bin/extract_curves.rb +2145 -0
  5. data/ruby_ext/pav/extconf.rb +22 -0
  6. data/ruby_ext/pav/pav.dll +0 -0
  7. data/ruby_libs/pav/attr_cache.rb +211 -0
  8. data/ruby_libs/pav/attr_cache.t1.rb +32 -0
  9. data/ruby_libs/pav/cache.rb +31 -0
  10. data/ruby_libs/pav/dbg_log.rb +458 -0
  11. data/ruby_libs/pav/floatsio.rb +53 -0
  12. data/ruby_libs/pav/generator_cache.rb +165 -0
  13. data/ruby_libs/pav/gtk/button.rb +130 -0
  14. data/ruby_libs/pav/gtk/icons.rb +87 -0
  15. data/ruby_libs/pav/gtk/toolbar.rb +192 -0
  16. data/ruby_libs/pav/heap.rb +54 -0
  17. data/ruby_libs/pav/icons/alt_handle.xpm +3832 -0
  18. data/ruby_libs/pav/icons/alt_handle_hover.xpm +3368 -0
  19. data/ruby_libs/pav/icons/alt_handle_pressed.xpm +3828 -0
  20. data/ruby_libs/pav/icons/extract_curves/extract_curves-icon-rgb.ppm +14 -0
  21. data/ruby_libs/pav/icons/extract_curves/extract_curves-logo-rgb.gif +0 -0
  22. data/ruby_libs/pav/icons/extract_curves/trace_mark.xpm +38 -0
  23. data/ruby_libs/pav/icons/handle.xpm +213 -0
  24. data/ruby_libs/pav/icons/next.xpm +29 -0
  25. data/ruby_libs/pav/icons/next_hover.xpm +315 -0
  26. data/ruby_libs/pav/icons/next_pressed.xpm +144 -0
  27. data/ruby_libs/pav/icons/prev.xpm +29 -0
  28. data/ruby_libs/pav/icons/prev_hover.xpm +315 -0
  29. data/ruby_libs/pav/icons/prev_pressed.xpm +144 -0
  30. data/ruby_libs/pav/icons/vnext.xpm +29 -0
  31. data/ruby_libs/pav/icons/vprev.xpm +29 -0
  32. data/ruby_libs/pav/numeric/ext.rb +13 -0
  33. data/ruby_libs/pav/pav_find.rb +90 -0
  34. data/ruby_libs/pav/pix/aapix.rb +378 -0
  35. data/ruby_libs/pav/pix/blob.rb +543 -0
  36. data/ruby_libs/pav/pix/circle.rb +73 -0
  37. data/ruby_libs/pav/pix/contour/calc_situations.rb +9 -0
  38. data/ruby_libs/pav/pix/contour/carp_calc.rb +212 -0
  39. data/ruby_libs/pav/pix/contour/situations.dmp +0 -0
  40. data/ruby_libs/pav/pix/contour/situations.rb +21 -0
  41. data/ruby_libs/pav/pix/contour.rb +644 -0
  42. data/ruby_libs/pav/pix/curve.rb +1508 -0
  43. data/ruby_libs/pav/pix/img_obj.rb +751 -0
  44. data/ruby_libs/pav/pix/node.rb +712 -0
  45. data/ruby_libs/pav/pix/node_grp.rb +853 -0
  46. data/ruby_libs/pav/pix/shaved_core.rb +534 -0
  47. data/ruby_libs/pav/pix/subpix.rb +212 -0
  48. data/ruby_libs/pav/pix.rb +402 -0
  49. data/ruby_libs/pav/rand_accessible.rb +16 -0
  50. data/ruby_libs/pav/rangeset.rb +63 -0
  51. data/ruby_libs/pav/search.rb +210 -0
  52. data/ruby_libs/pav/set.rb +20 -0
  53. data/ruby_libs/pav/string/bits.rb +523 -0
  54. data/ruby_libs/pav/string/ext.rb +58 -0
  55. data/ruby_libs/pav/string/observable.rb +155 -0
  56. data/ruby_libs/pav/string/text.rb +79 -0
  57. data/ruby_libs/pav/string/words.rb +42 -0
  58. data/ruby_libs/pav/sub_arr.rb +55 -0
  59. data/ruby_libs/pav/traced_obj.rb +79 -0
  60. metadata +112 -0
@@ -0,0 +1,212 @@
1
+ require 'pav/pix'
2
+ require 'pav/pix/subpix'
3
+
4
+ module PPix
5
+
6
+ class ContourCarpetCalc
7
+ def self.subpix_situ8_unpack(situ)
8
+ res = Array.new(8, 0)
9
+ pos = 0
10
+ while situ > 0
11
+ res[pos] = situ % 3
12
+ pos += 1
13
+ situ /= 3
14
+ end
15
+ res
16
+ end
17
+
18
+ def self.subpix_situ8p_unpack(situ)
19
+ res = Array.new(9, 0)
20
+ res[-1] = 1
21
+ pos = 0
22
+ while situ > 0
23
+ res[pos] = situ % 3
24
+ pos += 1
25
+ situ /= 3
26
+ end
27
+ res
28
+ end
29
+
30
+ def self.subpix_situ8_pack(situ_arr)
31
+ #$PDbgLog.sig_call(self)
32
+ res = 0; order = 1
33
+ for ngb_id in situ_arr
34
+ res += order * ngb_id
35
+ order *= 3
36
+ end
37
+ #$PDbgLog.sig_return(situ_arr.inspect + ": 0x%x" % res)
38
+ res
39
+ end
40
+
41
+ def self.situ_subpix_goable_to(situ, sub_n, subpix_class, border_id)
42
+ situ_arr = self.subpix_situ8p_unpack(situ)
43
+ subpix_class::SUB_N_BORDER[sub_n].detect { |bordn_spec|
44
+ situ_arr[Xy::ADJ8_ID2SPEC[PixbufPix.adj8_xy_id(
45
+ bordn_spec.x, bordn_spec.y)][1]] == border_id
46
+ }
47
+ end
48
+
49
+ def self.subpix_situ_neighbs(situ, sub_n, subpix_class, border_id)
50
+ #$PDbgLog.sig_call(self)
51
+ situ_arr = self.subpix_situ8p_unpack(situ)
52
+ #$PDbgLog.print_msg("situ=#{"0x%x" % situ}, sub_n=#{sub_n
53
+ # }, subpix_class=#{subpix_class.name}, border_id=#{border_id
54
+ # }; situ_arr=#{situ_arr.inspect}: ")
55
+ res = []
56
+ subpix_class::SUB_N_NEIGHBS[sub_n].each_with_index {|ngb_spec,i|
57
+ if situ_arr[Xy::ADJ8_ID2SPEC[PixbufPix.adj8_xy_id(
58
+ x=ngb_spec.x, y=ngb_spec.y)][1]] == 1 &&
59
+ subpix_class::SUB_N_BORDER[ngb_spec.sub_n].detect{|bordn_spec|
60
+ situ_arr[Xy::ADJ8_ID2SPEC[PixbufPix.adj8_xy_id(
61
+ x+bordn_spec.x, y+bordn_spec.y)][1]]==border_id
62
+ }
63
+ res[i/2] = ngb_spec
64
+ end
65
+ }
66
+ #$PDbgLog.sig_return(res.inspect)
67
+ res
68
+ end
69
+
70
+ def self.subpix_situ_path(situ, sub_n_0, subpix_class, external)
71
+ #$PDbgLog.sig_call(self)
72
+ # $PDbgLog.print_msg "situ=%x, sub_n_0=#{sub_n_0}, subpix_class=#{
73
+ # subpix_class.name}, external=#{external}: " % situ
74
+ border_id = external ? 2 : 0
75
+ if sub_n_0 >= subpix_class::SUB_N_NEIGHBS.length-1
76
+ ngbs = self.subpix_situ_neighbs(situ, sub_n_0,
77
+ subpix_class, border_id)
78
+ unless (n = ngbs.detect {|ngb| ngb})
79
+ #$PDbgLog.sig_return('Empty.')
80
+ return []
81
+ end
82
+ else
83
+ unless self.situ_subpix_goable_to(situ, sub_n_0,
84
+ subpix_class, border_id)
85
+ #$PDbgLog.sig_return('[]')
86
+ return []
87
+ end
88
+ n = SubXy.new(0, 0, sub_n_0)
89
+ end
90
+ res = [prev_n = n]
91
+ ngbs0 = self.subpix_situ_neighbs(situ, n.sub_n, subpix_class,
92
+ border_id)
93
+ n = ngbs0[0]
94
+ while n
95
+ res.unshift(n)
96
+ break if n.y != 0 || n.x != 0
97
+ ngbs = self.subpix_situ_neighbs(situ, n.sub_n,
98
+ subpix_class, border_id)
99
+ tmp = n
100
+ n = ngbs.first == prev_n ? ngbs.last : ngbs.first
101
+ if res.include?(n)
102
+ #$PDbgLog.sig_return(res.inspect)
103
+ return res
104
+ end
105
+ prev_n = tmp
106
+ end
107
+ prev_n = res.last
108
+ n = ngbs0[1]
109
+ #$PDbgLog.puts_msg "half1: " + res.inspect + ": "
110
+ #$PDbgLog.puts_msg "prev_n=#{prev_n}, n=#{n}: "
111
+ #$PDbgLog.puts_msg "res.include?(n): #{res.include?(n)}"
112
+ while n && !res.include?(n)
113
+ res << n
114
+ break if n.y != 0 || n.x != 0
115
+ ngbs = self.subpix_situ_neighbs(situ, n.sub_n,
116
+ subpix_class, border_id)
117
+ #$PDbgLog.puts_msg "ngbs: #{ngbs.inspect}"
118
+ tmp = n
119
+ n = ngbs.first == prev_n ? ngbs.last : ngbs.first
120
+ prev_n = tmp
121
+ end
122
+ #$PDbgLog.sig_return(res.inspect)
123
+ res
124
+ end
125
+
126
+ def self.subpix_path_border_dirs8_id(path, subpix_class)
127
+ res = 0
128
+ for ngb_spec in path
129
+ subpix_class::SUB_N_BORDER[ngb_spec.sub_n].each { |n|
130
+ res |= Xy::ADJ8_ID2SPEC.at(PixbufPix.
131
+ adj8_xy_id(n.x, n.y)).at(2) if n.y != 0 || n.x != 0
132
+ }
133
+ end
134
+ res
135
+ end
136
+
137
+ def self.subpix_pix_path_normalize(path, subpix_class)
138
+ res = path.collect { |spec| spec.sub_n }
139
+ cyc = subpix_class::SUB_N_NEIGHBS.length-1
140
+ if res.length > 1 && res.first == (res.last + 1) % cyc
141
+ i_min = min_sub_n = 1.0/0.0
142
+ res.each_with_index { |sub_n, i|
143
+ if sub_n < min_sub_n
144
+ min_sub_n = sub_n; i_min = i
145
+ end
146
+ }
147
+ tmp = []
148
+ res.each_index {|i| tmp << res[(i+i_min) % res.length] }
149
+ res = tmp
150
+ end
151
+ res
152
+ end
153
+
154
+ ContourPathLm = Struct.new("ContourPathLm", #:sub_n_path,
155
+ :entry, :exit, :border_dirs8_id, :path_horiz_cnt,
156
+ :path_vert_cnt)
157
+
158
+ def self.get_id2lm(subpix_class, external, c_path_lms={})
159
+ $PDbgLog.sig_call(self)
160
+ $PDbgLog.new_progr
161
+ $PDbgLog.progr.show_as = "/ situations"
162
+ $PDbgLog.progr.total_progr_units = 3**8
163
+ res =
164
+ (0...3**8).collect { |situ8|
165
+ $PDbgLog.progr.progr_units = situ8
166
+ sub_n_lms = Array.new(subpix_class::SUB_N_NEIGHBS.length, nil)
167
+ (0...subpix_class::SUB_N_NEIGHBS.length).each { |sub_n_0|
168
+ path = self.subpix_situ_path(situ8, sub_n_0, subpix_class,
169
+ external)
170
+ if path[0] && (path[0].y != 0 || path[0].x != 0)
171
+ p_entry = path.shift
172
+ else
173
+ p_entry = nil
174
+ end
175
+ if path.last && (path.last.y != 0 || path.last.x != 0)
176
+ p_exit = path.pop
177
+ else
178
+ p_exit = nil
179
+ end
180
+ path_lm = ContourPathLm.new(
181
+ #self.subpix_pix_path_normalize(path, subpix_class),
182
+ p_entry, p_exit,
183
+ self.subpix_path_border_dirs8_id(path, subpix_class),
184
+ path.find_all{|spec| subpix_class.horizontal?(spec.sub_n)}.
185
+ length,
186
+ path.find_all{|spec| subpix_class.vertical?(spec.sub_n)}.
187
+ length)
188
+ path_lm = c_path_lms.include?(path_lm) ? c_path_lms[path_lm] :
189
+ (c_path_lms[path_lm] = path_lm)
190
+ path.each { |spec| sub_n = spec.sub_n
191
+ if sub_n_lms[sub_n]
192
+ if sub_n_lms[sub_n] != path_lm
193
+ raise "Conflicting path elements for #{subpix_class.name
194
+ }, #{external ? 'ex' : 'in'}ternal, situ8=#{
195
+ situ8}, sub_n=#{sub_n} from sub_n_0=#{sub_n_0
196
+ }: #{sub_n_lms[sub_n]} vs. #{path_lm}!"
197
+ end
198
+ else
199
+ sub_n_lms[sub_n] = path_lm
200
+ end
201
+ }
202
+ sub_n_lms[sub_n_0] = path_lm
203
+ }
204
+ sub_n_lms
205
+ }
206
+ $PDbgLog.progr.progr_units += 1
207
+ $PDbgLog.sig_return(' done.')
208
+ res
209
+ end
210
+ end
211
+
212
+ end
@@ -0,0 +1,21 @@
1
+ require 'pav/pav_find'
2
+ require 'pav/string/ext'
3
+ require 'pav/pix/contour/carp_calc'
4
+
5
+ module PPix
6
+
7
+ class ContourCarpetCalc
8
+ PavFind.pfind($:) { |path|
9
+ if path.ends_with('pav/pix/contour/situations.dmp')
10
+ open(path, 'r') { |file|
11
+ CONTOUR_PATH_EXTERNAL_SITU8_ID2LM,
12
+ CONTOUR_PATH_INTERNAL_SITU8_ID2LM,
13
+ CONTOUR_PATH_EXTERNAL_SITU4_ID2LM,
14
+ CONTOUR_PATH_INTERNAL_SITU4_ID2LM = *Marshal.load(file)
15
+ }
16
+ break
17
+ end
18
+ }
19
+ end
20
+
21
+ end