Class: Contrek::Cpp::CPPResult
- Inherits:
-
Object
- Object
- Contrek::Cpp::CPPResult
- Defined in:
- lib/contrek/cpp/cpp_result.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.to_numpy(polygons_data) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/contrek/cpp/cpp_result.rb', line 33 def self.to_numpy(polygons_data) polygons_data.map do |poly| {outer: poly[:outer].flat_map { |p| [p[:x], p[:y]] }, inner: (poly[:inner] || []).map { |hole| hole.flat_map { |p| [p[:x], p[:y]] } }, bounds: poly[:bounds]} end end |
.to_points(flat_polygon) ⇒ Object
29 30 31 |
# File 'lib/contrek/cpp/cpp_result.rb', line 29 def self.to_points(flat_polygon) flat_polygon.each_slice(2).map { |x, y| {x: x, y: y} } end |
Instance Method Details
#metadata=(map) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/contrek/cpp/cpp_result.rb', line 8 def (map) @metadata_storage = { width: 0, height: 0, benchmarks: {}, treemap: [] }.merge(map) end |
#points ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/contrek/cpp/cpp_result.rb', line 17 def points raw_list = polygons.to_a @to_points ||= raw_list.map do |polygon| {outer: self.class.to_points(polygon[:outer]), inner: polygon[:inner].map { |s| self.class.to_points(s) }} end end |
#polygons=(list) ⇒ Object
4 5 6 |
# File 'lib/contrek/cpp/cpp_result.rb', line 4 def polygons=(list) @polygons_storage = list end |
#total_time ⇒ Object
25 26 27 |
# File 'lib/contrek/cpp/cpp_result.rb', line 25 def total_time [:benchmarks].values.sum end |