lithop 0.1.0 → 0.3.0

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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/Cargo.lock +284 -0
  4. data/Cargo.toml +6 -0
  5. data/README.md +31 -7
  6. data/RELEASING.md +24 -6
  7. data/docs/README.md +4 -1
  8. data/docs/artifacts.md +26 -2
  9. data/docs/bambu-studio.md +7 -1
  10. data/docs/color-model.md +2 -0
  11. data/docs/command.md +48 -7
  12. data/docs/config.md +31 -4
  13. data/docs/getting-started.md +10 -5
  14. data/docs/images/cmyw-lithophane-preview.png +0 -0
  15. data/docs/local-ui.md +114 -0
  16. data/docs/tiling.md +134 -0
  17. data/docs/troubleshooting.md +22 -0
  18. data/ext/lithop_native/Cargo.toml +17 -0
  19. data/ext/lithop_native/build.rs +4 -0
  20. data/ext/lithop_native/extconf.rb +6 -0
  21. data/ext/lithop_native/src/column_mesh.rs +388 -0
  22. data/ext/lithop_native/src/lib.rs +37 -0
  23. data/ext/lithop_native/src/mesh.rs +187 -0
  24. data/ext/lithop_native/src/palette.rs +67 -0
  25. data/ext/lithop_native/src/xml.rs +134 -0
  26. data/lib/lithop/calibration/export.rb +21 -8
  27. data/lib/lithop/cli/calibration.rb +3 -1
  28. data/lib/lithop/cli/image_options.rb +41 -2
  29. data/lib/lithop/cli/options.rb +13 -0
  30. data/lib/lithop/cli.rb +36 -1
  31. data/lib/lithop/export/color_metadata.rb +55 -0
  32. data/lib/lithop/export/generation.rb +131 -21
  33. data/lib/lithop/export/job.rb +30 -16
  34. data/lib/lithop/export/metadata.rb +54 -4
  35. data/lib/lithop/export/planning.rb +97 -0
  36. data/lib/lithop/export/previews.rb +25 -1
  37. data/lib/lithop/export/print_readme.rb +22 -4
  38. data/lib/lithop/export/result.rb +26 -4
  39. data/lib/lithop/formats/three_mf/bambu_metadata.rb +111 -24
  40. data/lib/lithop/formats/three_mf/mesh.rb +72 -3
  41. data/lib/lithop/formats/three_mf/model_writer.rb +249 -24
  42. data/lib/lithop/formats/three_mf/part_writer.rb +51 -6
  43. data/lib/lithop/formats/three_mf.rb +9 -6
  44. data/lib/lithop/image/pipeline.rb +66 -10
  45. data/lib/lithop/image/svg_loader.rb +5 -5
  46. data/lib/lithop/job_directory.rb +41 -0
  47. data/lib/lithop/job_execution.rb +378 -0
  48. data/lib/lithop/layer_structure.rb +11 -0
  49. data/lib/lithop/mesh/box_geometry.rb +41 -0
  50. data/lib/lithop/mesh/column_geometry.rb +10 -2
  51. data/lib/lithop/mesh/column_topology.rb +2 -0
  52. data/lib/lithop/mesh/geometry.rb +21 -13
  53. data/lib/lithop/model/layer_region_model.rb +24 -0
  54. data/lib/lithop/model/material_model.rb +17 -5
  55. data/lib/lithop/model/palette.rb +21 -3
  56. data/lib/lithop/native.rb +39 -0
  57. data/lib/lithop/reference_three_mf.rb +17 -1
  58. data/lib/lithop/settings.rb +116 -1
  59. data/lib/lithop/settings_file.rb +10 -4
  60. data/lib/lithop/tiling.rb +127 -0
  61. data/lib/lithop/version.rb +1 -1
  62. data/lib/lithop/web/app.rb +513 -0
  63. data/lib/lithop/web/bambu_studio_launcher.rb +82 -0
  64. data/lib/lithop/web/job_launcher.rb +214 -0
  65. data/lib/lithop/web/job_store.rb +390 -0
  66. data/lib/lithop/web/preview_store.rb +182 -0
  67. data/lib/lithop/web/public/app.css +319 -0
  68. data/lib/lithop/web/public/app.js +1847 -0
  69. data/lib/lithop/web/server.rb +21 -0
  70. data/lib/lithop/web/settings_form.rb +64 -0
  71. data/lib/lithop/web/settings_library.rb +154 -0
  72. data/lib/lithop/web/views/index.erb +364 -0
  73. data/lib/lithop/web/worker.rb +27 -0
  74. data/lib/lithop.rb +5 -0
  75. data/sig/lithop.rbs +102 -2
  76. metadata +89 -2
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "lithop"
5
+
6
+ module Lithop
7
+ module Web
8
+ # Runs one UI conversion in a separate Ruby process.
9
+ module Worker
10
+ module_function
11
+
12
+ def run(arguments, out: $stdout, err: $stderr)
13
+ job_id, input_path, settings_path, project_dir = arguments
14
+ raise Error, "invalid web worker arguments" unless arguments.length == 4
15
+
16
+ loaded = SettingsFile.load(settings_path, required: true)
17
+ settings = Settings.new(**loaded.values)
18
+ result = Export.new(settings:, project_dir:, job_id:).call(input_path)
19
+ out.puts "Generated #{result.three_mf_triangle_count} CMYW 3MF triangles in #{result.path}"
20
+ 0
21
+ rescue Error, SystemCallError, JSON::ParserError => e
22
+ err.puts "lithop: #{e.message}"
23
+ 1
24
+ end
25
+ end
26
+ end
27
+ end
data/lib/lithop.rb CHANGED
@@ -8,22 +8,27 @@ module Lithop
8
8
  class InputError < Error; end
9
9
  end
10
10
 
11
+ require_relative "lithop/native"
11
12
  require_relative "lithop/sampling_grid"
12
13
  require_relative "lithop/layer_structure"
13
14
  require_relative "lithop/settings"
14
15
  require_relative "lithop/settings_file"
15
16
  require_relative "lithop/job_directory"
17
+ require_relative "lithop/job_execution"
16
18
  require_relative "lithop/instrumentation"
17
19
  require_relative "lithop/model/thickness"
18
20
  require_relative "lithop/model/palette"
19
21
  require_relative "lithop/model/material_display_map"
20
22
  require_relative "lithop/model/filament_profile"
21
23
  require_relative "lithop/model/material_model"
24
+ require_relative "lithop/model/layer_region_model"
25
+ require_relative "lithop/tiling"
22
26
  require_relative "lithop/image/placement"
23
27
  require_relative "lithop/image/svg_loader"
24
28
  require_relative "lithop/image/pipeline"
25
29
  require_relative "lithop/image/preview"
26
30
  require_relative "lithop/mesh/geometry"
31
+ require_relative "lithop/mesh/box_geometry"
27
32
  require_relative "lithop/mesh/voxel_topology"
28
33
  require_relative "lithop/mesh/voxel_geometry"
29
34
  require_relative "lithop/mesh/column_topology"
data/sig/lithop.rbs CHANGED
@@ -1,6 +1,30 @@
1
1
  module Lithop
2
2
  VERSION: String
3
3
 
4
+ module Native
5
+ class MeshBuilder
6
+ def self.new: () -> MeshBuilder
7
+ def add_batch: (Array[Float] coordinates, Array[Integer] topology_keys) -> Integer
8
+ def vertex_count: () -> Integer
9
+ def triangle_count: () -> Integer
10
+ def center: () -> Array[Float]
11
+ def vertex_xml: (Integer offset, Integer count, Array[Float] origin) -> String
12
+ def triangle_xml: (Integer offset, Integer count) -> String
13
+ def memory_bytes: () -> Integer
14
+ end
15
+
16
+ def self.available?: () -> bool
17
+ def self.enabled?: () -> bool
18
+ def self.backend: () -> (:rust | :ruby)
19
+ def self.extension_version: () -> String
20
+ def self.loaded_extension_version: () -> String?
21
+ def self.diagnostics: () -> Hash[Symbol, untyped]
22
+ def self.palette_indices: (Array[Float] cmys, Array[Float] coverages) -> Array[Integer]
23
+ def self.vertex_xml: (Array[Float] vertices, Array[Float] origin) -> String
24
+ def self.triangle_xml: (Array[Integer] indices) -> String
25
+ def self.column_mesh: (Integer columns, Integer rows, Array[Float] x_boundaries, Array[Float] y_boundaries, Array[Float] z_boundaries, Array[Integer] intervals, Array[Integer] group_ids, Integer group_count) -> MeshBuilder
26
+ end
27
+
4
28
  class Error < StandardError
5
29
  end
6
30
 
@@ -22,12 +46,21 @@ module Lithop
22
46
  attr_reader crop_position_x: Numeric
23
47
  attr_reader crop_position_y: Numeric
24
48
  attr_reader crop_scale: Numeric
49
+ attr_reader brightness: Numeric
50
+ attr_reader contrast: Numeric
51
+ attr_reader saturation: Numeric
25
52
  attr_reader minimum_thickness: Numeric
26
53
  attr_reader maximum_thickness: Numeric
27
54
  attr_reader pixel_size: Numeric
28
55
  attr_reader color_pixel_size: Numeric?
29
56
  attr_reader grid_columns: Integer?
30
57
  attr_reader grid_rows: Integer?
58
+ attr_reader tile_count: Integer
59
+ attr_reader tile_layout: String
60
+ attr_reader tile_rows: Integer?
61
+ attr_reader tile_columns: Integer?
62
+ attr_reader separate_z_parts: bool
63
+ attr_reader color_region_parts: Integer
31
64
  attr_reader first_layer_height: Numeric
32
65
  attr_reader layer_height: Numeric
33
66
  attr_reader base_white_layers: Integer
@@ -52,6 +85,9 @@ module Lithop
52
85
  def fitted_grid?: () -> bool
53
86
  def pixel_size_x: () -> Float
54
87
  def pixel_size_y: () -> Float
88
+ def resolved_tile_shape: () -> [Integer, Integer]
89
+ def resolved_tile_rows: () -> Integer
90
+ def resolved_tile_columns: () -> Integer
55
91
  def estimated_triangles: () -> Integer
56
92
  def triangle_limit_message: (String label, Integer triangle_count) -> String
57
93
  def x_boundaries: () -> Array[Numeric]
@@ -61,6 +97,33 @@ module Lithop
61
97
  def to_h: () -> Hash[Symbol, untyped]
62
98
  end
63
99
 
100
+ class TileLayout
101
+ class Tile < Data
102
+ attr_reader id: String
103
+ attr_reader row: Integer
104
+ attr_reader column: Integer
105
+ attr_reader row_start: Integer
106
+ attr_reader row_end: Integer
107
+ attr_reader column_start: Integer
108
+ attr_reader column_end: Integer
109
+ attr_reader x_min: Numeric
110
+ attr_reader x_max: Numeric
111
+ attr_reader y_min: Numeric
112
+ attr_reader y_max: Numeric
113
+
114
+ def width: () -> Numeric
115
+ def height: () -> Numeric
116
+ def offset: () -> Hash[Symbol, Numeric]
117
+ def bounds: () -> Hash[Symbol, Numeric]
118
+ end
119
+
120
+ attr_reader rows: Integer
121
+ attr_reader columns: Integer
122
+ attr_reader tiles: Array[Tile]
123
+
124
+ def initialize: (Settings settings) -> void
125
+ end
126
+
64
127
  class Palette
65
128
  class Recipe < Data
66
129
  attr_reader cyan: Integer
@@ -82,6 +145,7 @@ module Lithop
82
145
 
83
146
  def initialize: (?layer_count: Integer, ?pigment_order: Array[Symbol]) -> void
84
147
  def nearest: (Array[Numeric] cmy) -> Recipe
148
+ def nearest_many: (Array[Array[Numeric]] cmys) -> Array[Recipe]
85
149
  def display_color: (Recipe recipe) -> String
86
150
  end
87
151
 
@@ -186,7 +250,14 @@ module Lithop
186
250
  attr_reader patch_count: Integer
187
251
  end
188
252
 
189
- def initialize: (settings: Settings, project_dir: String, ?clock: untyped, ?random: untyped) -> void
253
+ def initialize: (
254
+ settings: Settings,
255
+ project_dir: String,
256
+ ?job_progress: untyped,
257
+ ?clock: untyped,
258
+ ?random: untyped,
259
+ ?job_id: String?
260
+ ) -> void
190
261
  def call: () -> Result
191
262
  end
192
263
  end
@@ -243,6 +314,11 @@ module Lithop
243
314
  class Part < Data
244
315
  attr_reader material: Symbol
245
316
  attr_reader triangles: Enumerable[untyped]
317
+ attr_reader name: String?
318
+ attr_reader region: String?
319
+ attr_reader build_z_offset: Numeric
320
+
321
+ def initialize: (material: Symbol, triangles: Enumerable[untyped], ?name: String?, ?region: String?, ?build_z_offset: Numeric) -> void
246
322
  end
247
323
 
248
324
  class Result < Data
@@ -266,6 +342,28 @@ module Lithop
266
342
  attr_reader object_count: Integer
267
343
  end
268
344
 
345
+ class JobCancelled < Error
346
+ end
347
+
348
+ class JobExecution
349
+ class Progress < Data
350
+ attr_reader job_id: String
351
+ attr_reader state: String
352
+ attr_reader phase: String
353
+ attr_reader percent: Float
354
+ attr_reader message: String
355
+ attr_reader updated_at: String
356
+ end
357
+
358
+ attr_reader job_id: String
359
+ attr_reader status_path: String
360
+
361
+ def initialize: (project_dir: String, job_id: String, ?progress: untyped, ?clock: untyped) -> void
362
+ def call: [A] () { (JobExecution) -> A } -> A
363
+ def progress: (phase: String | Symbol, percent: Numeric, message: String) -> void
364
+ def self.request_cancel: (project_dir: String, job_id: String, ?clock: untyped) -> String
365
+ end
366
+
269
367
  class Export
270
368
  class CalibrationInput < Data
271
369
  attr_reader profile: Calibration::Profile
@@ -278,9 +376,11 @@ module Lithop
278
376
  ?input_settings_path: String?,
279
377
  ?calibration: CalibrationInput?,
280
378
  ?progress: untyped,
379
+ ?job_progress: untyped,
281
380
  ?instrumentation: untyped,
282
381
  ?clock: untyped,
283
- ?random: untyped
382
+ ?random: untyped,
383
+ ?job_id: String?
284
384
  ) -> void
285
385
  def call: (String input_path) -> ExportResult
286
386
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lithop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ogom
@@ -9,6 +9,48 @@ bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: puma
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '7.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '7.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: rackup
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.2'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.2'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rb_sys
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.9.128
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.128
12
54
  - !ruby/object:Gem::Dependency
13
55
  name: rexml
14
56
  requirement: !ruby/object:Gem::Requirement
@@ -51,16 +93,33 @@ dependencies:
51
93
  - - "~>"
52
94
  - !ruby/object:Gem::Version
53
95
  version: '3.7'
96
+ - !ruby/object:Gem::Dependency
97
+ name: sinatra
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '4.2'
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '4.2'
54
110
  description: Lithop converts JPEG, PNG, and SVG images locally into STL and multipart
55
111
  CMYW 3MF models for backlit lithophane printing.
56
112
  email:
57
113
  - ogom@users.noreply.github.com
58
114
  executables:
59
115
  - lithop
60
- extensions: []
116
+ extensions:
117
+ - ext/lithop_native/extconf.rb
61
118
  extra_rdoc_files: []
62
119
  files:
63
120
  - CHANGELOG.md
121
+ - Cargo.lock
122
+ - Cargo.toml
64
123
  - LICENSE
65
124
  - README.md
66
125
  - RELEASING.md
@@ -73,7 +132,18 @@ files:
73
132
  - docs/command.md
74
133
  - docs/config.md
75
134
  - docs/getting-started.md
135
+ - docs/images/cmyw-lithophane-preview.png
136
+ - docs/local-ui.md
137
+ - docs/tiling.md
76
138
  - docs/troubleshooting.md
139
+ - ext/lithop_native/Cargo.toml
140
+ - ext/lithop_native/build.rs
141
+ - ext/lithop_native/extconf.rb
142
+ - ext/lithop_native/src/column_mesh.rs
143
+ - ext/lithop_native/src/lib.rs
144
+ - ext/lithop_native/src/mesh.rs
145
+ - ext/lithop_native/src/palette.rs
146
+ - ext/lithop_native/src/xml.rs
77
147
  - lib/lithop.rb
78
148
  - lib/lithop/calibration/export.rb
79
149
  - lib/lithop/calibration/profile.rb
@@ -108,7 +178,9 @@ files:
108
178
  - lib/lithop/image/svg_loader.rb
109
179
  - lib/lithop/instrumentation.rb
110
180
  - lib/lithop/job_directory.rb
181
+ - lib/lithop/job_execution.rb
111
182
  - lib/lithop/layer_structure.rb
183
+ - lib/lithop/mesh/box_geometry.rb
112
184
  - lib/lithop/mesh/column_geometry.rb
113
185
  - lib/lithop/mesh/column_topology.rb
114
186
  - lib/lithop/mesh/geometry.rb
@@ -116,15 +188,30 @@ files:
116
188
  - lib/lithop/mesh/voxel_geometry.rb
117
189
  - lib/lithop/mesh/voxel_topology.rb
118
190
  - lib/lithop/model/filament_profile.rb
191
+ - lib/lithop/model/layer_region_model.rb
119
192
  - lib/lithop/model/material_display_map.rb
120
193
  - lib/lithop/model/material_model.rb
121
194
  - lib/lithop/model/palette.rb
122
195
  - lib/lithop/model/thickness.rb
196
+ - lib/lithop/native.rb
123
197
  - lib/lithop/reference_three_mf.rb
124
198
  - lib/lithop/sampling_grid.rb
125
199
  - lib/lithop/settings.rb
126
200
  - lib/lithop/settings_file.rb
201
+ - lib/lithop/tiling.rb
127
202
  - lib/lithop/version.rb
203
+ - lib/lithop/web/app.rb
204
+ - lib/lithop/web/bambu_studio_launcher.rb
205
+ - lib/lithop/web/job_launcher.rb
206
+ - lib/lithop/web/job_store.rb
207
+ - lib/lithop/web/preview_store.rb
208
+ - lib/lithop/web/public/app.css
209
+ - lib/lithop/web/public/app.js
210
+ - lib/lithop/web/server.rb
211
+ - lib/lithop/web/settings_form.rb
212
+ - lib/lithop/web/settings_library.rb
213
+ - lib/lithop/web/views/index.erb
214
+ - lib/lithop/web/worker.rb
128
215
  - sig/lithop.rbs
129
216
  homepage: https://github.com/ogom/lithop
130
217
  licenses: