tracksperanto 2.6.1 → 2.6.2

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.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 2.6.2 / 2011-30-07
2
+
3
+ * Fix missing progress percentages in the Flame import module
4
+
1
5
  === 2.6.1 / 2011-22-07
2
6
 
3
7
  * Fix errors that occurred when empty disabled trackers were present in Flame setups
data/Manifest.txt CHANGED
@@ -94,6 +94,7 @@ test/export/test_pftrack5_export.rb
94
94
  test/export/test_pftrack_export.rb
95
95
  test/export/test_shake_export.rb
96
96
  test/export/test_syntheyes_export.rb
97
+ test/fixtures/processing_log.txt
97
98
  test/helper.rb
98
99
  test/import/samples/3de_v3/3de_export_v3.txt
99
100
  test/import/samples/3de_v4/3de_export_cube.txt
data/bin/tracksperanto CHANGED
@@ -94,6 +94,7 @@ op.on("--version", "Show the version and exit") do |v|
94
94
  UpdateHints.version_check("tracksperanto", Tracksperanto::VERSION, STDOUT)
95
95
  exit(0)
96
96
  end
97
+ op.on("--trace", "Output LOTS of info during conversion") { $debug = true }
97
98
 
98
99
  begin
99
100
  op.parse!
@@ -114,7 +115,14 @@ unless File.exist?(input_file)
114
115
  end
115
116
 
116
117
  pbar = ProgressBar.new("Converting", 100, $stdout)
117
- progress = lambda{|percent,message| pbar.set(percent) }
118
+ progress = lambda do |percent,message|
119
+ pbar.set(percent)
120
+ if $debug
121
+ STDOUT.puts("[%d -> %s]" % [percent, message])
122
+ STDOUT.flush
123
+ end
124
+ end
125
+
118
126
  begin
119
127
  pipe = Tracksperanto::Pipeline::Base.new(:progress_block => progress, :middleware_tuples => $middlewares)
120
128
  pipe.exporters = [Tracksperanto.get_exporter(writer_class_name)] if writer_class_name
@@ -23,8 +23,6 @@ class Tracksperanto::Import::FlameStabilizer < Tracksperanto::Import::Base
23
23
 
24
24
  report_progress("Assembling tracker curves from channels")
25
25
  scavenge_trackers_from_channels(channels, names) {|t| yield(t) }
26
- ensure
27
- channels.clear
28
26
  end
29
27
 
30
28
  private
@@ -46,28 +44,31 @@ class Tracksperanto::Import::FlameStabilizer < Tracksperanto::Import::Base
46
44
  end
47
45
 
48
46
  end
49
-
50
- def extract_channels_from_stream(io)
51
- channels = FlameChannelParser.parse(io)
52
- [channels, channels.map{|c| c.path }]
53
- end
54
47
 
55
- USEFUL_CHANNELS = %w( /shift/x /shift/y /ref/x /ref/y ).map(&Regexp.method(:new))
56
-
57
- # This method tells the importer whether a channel that has been found in the source
58
- # setup is needed. If that method returns ++false++ the channel will be discarded and not
59
- # kept in memory. Should you need to write a module that scavenges other Flame animation channels
60
- # inherit from this class and rewrite this method to either return +true+ always (then all the channels
61
- # will be recovered) or to return +true+ only for channels that you actually need.
62
- def channel_is_useful?(channel_name)
63
- USEFUL_CHANNELS.any?{|e| channel_name =~ e }
48
+ # We subclass the standard parser for a couple of reasons - we want to only parse the needed channels
49
+ # AND we want to provide progress reports
50
+ class StabilizerParser < FlameChannelParser::Parser
51
+ USEFUL_CHANNELS = %w( /shift/x /shift/y /ref/x /ref/y ).map(&Regexp.method(:new))
52
+
53
+ # This method tells the importer whether a channel that has been found in the source
54
+ # setup is needed. If that method returns ++false++ the channel will be discarded and not
55
+ # kept in memory. Should you need to write a module that scavenges other Flame animation channels
56
+ # inherit from this class and rewrite this method to either return +true+ always (then all the channels
57
+ # will be recovered) or to return +true+ only for channels that you actually need.
58
+ def channel_is_useful?(channel_name)
59
+ USEFUL_CHANNELS.any?{|e| channel_name =~ e }
60
+ end
64
61
  end
65
62
 
66
- REF_CHANNEL = "ref" # or "track" - sometimes works sometimes don't
63
+ def extract_channels_from_stream(io)
64
+ parser = StabilizerParser.new(&method(:report_progress))
65
+ channels = parser.parse(io)
66
+ [channels, channels.map{|c| c.path }]
67
+ end
67
68
 
68
69
  def scavenge_trackers_from_channels(channels, names)
69
70
  channels.each do |c|
70
- next unless c.name =~ /\/#{REF_CHANNEL}\/x/
71
+ next unless c.name =~ /\/ref\/x/
71
72
 
72
73
  report_progress("Detected reference channel #{c.name}")
73
74
 
@@ -87,7 +88,7 @@ class Tracksperanto::Import::FlameStabilizer < Tracksperanto::Import::Base
87
88
 
88
89
  # This takes a LONG time when we have alot of channels, we need a precache of
89
90
  # some sort to do this
90
- ref_idx = names.index("#{t.name}/#{REF_CHANNEL}/y")
91
+ ref_idx = names.index("#{t.name}/ref/y")
91
92
  shift_x_idx = names.index("#{t.name}/shift/x")
92
93
  shift_y_idx = names.index("#{t.name}/shift/y")
93
94
 
@@ -1,5 +1,5 @@
1
1
  module Tracksperanto::ShakeGrammar
2
- class WrongInput < RuntimeError; end
2
+ class WrongInputError < RuntimeError; end
3
3
 
4
4
  # Since Shake uses a C-like language for it's scripts we rig up a very sloppy
5
5
  # but concise C-like lexer to cope
@@ -41,11 +41,11 @@ module Tracksperanto::ShakeGrammar
41
41
  c = @io.read(1)
42
42
 
43
43
  if @buf.length > MAX_BUFFER_SIZE # Wrong format and the buffer is filled up, bail
44
- raise WrongInput, "Atom buffer overflow at #{MAX_BUFFER_SIZE} bytes, this is definitely not a Shake script"
44
+ raise WrongInputError, "Atom buffer overflow at #{MAX_BUFFER_SIZE} bytes, this is definitely not a Shake script"
45
45
  end
46
46
 
47
47
  if @stack_depth > MAX_STACK_DEPTH # Wrong format - parentheses overload
48
- raise WrongInput, "Stack overflow at level #{MAX_STACK_DEPTH}, this is probably a LISP program uploaded by accident"
48
+ raise WrongInputError, "Stack overflow at level #{MAX_STACK_DEPTH}, this is probably a LISP program uploaded by accident"
49
49
  end
50
50
 
51
51
  if c == '/' && (@buf[-1].chr rescue nil) == '/' # Comment start
data/lib/pipeline/base.rb CHANGED
@@ -132,21 +132,33 @@ module Tracksperanto::Pipeline
132
132
  # status message that you can pass back to the UI
133
133
  def run_export(tracker_data_io, importer, exporter)
134
134
  points, keyframes, percent_complete = 0, 0, 0.0
135
+ last_reported_percentage = 0.0
135
136
 
136
137
  report_progress(percent_complete, "Starting the parser")
138
+ progress_lambda = lambda do | m |
139
+ last_reported_percentage = percent_complete
140
+ report_progress(percent_complete, m)
141
+ end
137
142
 
138
143
  # Report progress from the parser
139
- importer.progress_block = lambda { | m | report_progress(percent_complete, m) }
144
+ importer.progress_block = progress_lambda
140
145
 
141
146
  # Wrap the input in a progressive IO, setup a lambda that will spy on the reader and
142
147
  # update the percentage. We will only broadcast messages that come from the parser
143
148
  # though (complementing it with a percentage)
144
149
  io_with_progress = Tracksperanto::ProgressiveIO.new(tracker_data_io) do | offset, of_total |
145
150
  percent_complete = (50.0 / of_total) * offset
151
+
152
+ # Some importers do not signal where they are and do not send nice reports. The way we can help that in the interim
153
+ # would be just to indicate where we are in the input, but outside of the exporter. We do not want to flood
154
+ # the logs though so what we WILL do instead is report some progress going on every 2-3 percent
155
+ progress_lambda.call("Parsing the file") if (percent_complete - last_reported_percentage) > 3
146
156
  end
157
+
147
158
  @ios.push(io_with_progress)
148
159
 
149
160
  @accumulator = Tracksperanto::Accumulator.new
161
+
150
162
  begin
151
163
 
152
164
  # OBSOLETE - for this version we are going to permit it.
data/lib/tracksperanto.rb CHANGED
@@ -5,7 +5,7 @@ require 'flame_channel_parser'
5
5
 
6
6
  module Tracksperanto
7
7
  PATH = File.expand_path(File.dirname(__FILE__))
8
- VERSION = '2.6.1'
8
+ VERSION = '2.6.2'
9
9
 
10
10
  module Import; end
11
11
  module Export; end
@@ -0,0 +1,50 @@
1
+ 0 -> Starting the parser
2
+ 0 -> Extracting setup size
3
+ 0 -> Extracting all animation channels
4
+ 3 -> Parsing the file
5
+ 6 -> Parsing the file
6
+ 9 -> Parsing the file
7
+ 13 -> Parsing the file
8
+ 16 -> Parsing the file
9
+ 19 -> Parsing the file
10
+ 22 -> Parsing the file
11
+ 25 -> Parsing the file
12
+ 28 -> Parsing the file
13
+ 31 -> Parsing the file
14
+ 34 -> Parsing the file
15
+ 37 -> Parsing the file
16
+ 40 -> Parsing the file
17
+ 43 -> Parsing the file
18
+ 46 -> Parsing the file
19
+ 49 -> Parsing the file
20
+ 50 -> Assembling tracker curves from channels
21
+ 50 -> Detected reference channel tracker1/ref/x
22
+ 50 -> Extracting tracker tracker1
23
+ 50 -> Detecting base value
24
+ 50 -> Extracting keyframe 2 of tracker1
25
+ 50 -> Extracting keyframe 3 of tracker1
26
+ 50 -> Extracting keyframe 4 of tracker1
27
+ 50 -> Detected reference channel tracker2/ref/x
28
+ 50 -> Extracting tracker tracker2
29
+ 50 -> Detecting base value
30
+ 50 -> Extracting keyframe 2 of tracker2
31
+ 50 -> Extracting keyframe 3 of tracker2
32
+ 50 -> Extracting keyframe 4 of tracker2
33
+ 50 -> Detected reference channel tracker3/ref/x
34
+ 50 -> Extracting tracker tracker3
35
+ 50 -> Detecting base value
36
+ 50 -> Extracting keyframe 2 of tracker3
37
+ 50 -> Extracting keyframe 3 of tracker3
38
+ 50 -> Extracting keyframe 4 of tracker3
39
+ 50 -> Validating 3 imported trackers
40
+ 50 -> Starting export
41
+ 55 -> Writing keyframe 1 of "tracker1", 3 trackers to go
42
+ 61 -> Writing keyframe 2 of "tracker1", 3 trackers to go
43
+ 66 -> Writing keyframe 3 of "tracker1", 3 trackers to go
44
+ 72 -> Writing keyframe 1 of "tracker2", 2 trackers to go
45
+ 77 -> Writing keyframe 2 of "tracker2", 2 trackers to go
46
+ 83 -> Writing keyframe 3 of "tracker2", 2 trackers to go
47
+ 88 -> Writing keyframe 1 of "tracker3", 1 trackers to go
48
+ 94 -> Writing keyframe 2 of "tracker3", 1 trackers to go
49
+ 100 -> Writing keyframe 3 of "tracker3", 1 trackers to go
50
+ 100 -> Wrote 3 points and 9 keyframes
@@ -87,7 +87,7 @@ class FlameImportTest < Test::Unit::TestCase
87
87
  end
88
88
 
89
89
  # a failing setup from flame 2012
90
- def test_from_flame2012
90
+ def test_from_flame2012_with_empty_trackers
91
91
  fixture = File.open(File.dirname(__FILE__) + '/samples/flame_stabilizer/flame_2012_another.stabilizer')
92
92
  trackers = Tracksperanto::Import::FlameStabilizer.new(:io => fixture).to_a
93
93
  assert_equal 1, trackers.length
@@ -7,14 +7,14 @@ class ShakeLexerTest < Test::Unit::TestCase
7
7
  WRONG = File.dirname(__FILE__) + "/samples/flame_stabilizer/hugeFlameSetup.stabilizer"
8
8
 
9
9
  def test_raises_wrong_input_when_buffer_gets_too_large
10
- assert_raise(Tracksperanto::ShakeGrammar::WrongInput) do
10
+ assert_raise(Tracksperanto::ShakeGrammar::WrongInputError) do
11
11
  parse(File.open(WRONG), L)
12
12
  end
13
13
  end
14
14
 
15
15
  def test_raises_wrong_input_on_stack_size
16
16
  huge_stack = "(" * 345
17
- assert_raise(Tracksperanto::ShakeGrammar::WrongInput) do
17
+ assert_raise(Tracksperanto::ShakeGrammar::WrongInputError) do
18
18
  parse(StringIO.new(huge_stack), L)
19
19
  end
20
20
  end
data/test/test_cli.rb CHANGED
@@ -65,6 +65,12 @@ class CliTest < Test::Unit::TestCase
65
65
  assert_same_set fs, Dir.entries(TEMP_DIR)
66
66
  end
67
67
 
68
+ # TODO: This currently hangs in testing
69
+ # def test_cli_with_trace_option
70
+ # FileUtils.cp(File.dirname(__FILE__) + "/import/samples/flame_stabilizer/fromCombustion_fromMidClip_wSnap.stabilizer", TEMP_DIR + "/flm.stabilizer")
71
+ # status, o, e = cli("#{BIN_P} --trace #{TEMP_DIR}/flm.stabilizer")
72
+ # end
73
+
68
74
  def test_cli_reformat
69
75
  FileUtils.cp(File.dirname(__FILE__) + "/import/samples/flame_stabilizer/fromCombustion_fromMidClip_wSnap.stabilizer", TEMP_DIR + "/flm.stabilizer")
70
76
  cli("--reformat-x 1204 --reformat-y 340 --only flamestabilizer #{TEMP_DIR}/flm.stabilizer")
@@ -35,7 +35,7 @@ class PipelineTest < Test::Unit::TestCase
35
35
  assert_equal [:a, :b], pipeline.middleware_tuples
36
36
  end
37
37
 
38
- def test_run_with_autodetected_importer_and_size
38
+ def test_run_with_autodetected_importer_and_size_without_progress_block
39
39
  create_stabilizer_file
40
40
  pipeline = Tracksperanto::Pipeline::Base.new
41
41
  assert_nothing_raised { pipeline.run(@stabilizer) }
@@ -43,6 +43,19 @@ class PipelineTest < Test::Unit::TestCase
43
43
  assert_equal 9, pipeline.converted_keyframes, "Should report conversion of 9 keyframes"
44
44
  end
45
45
 
46
+ def test_run_with_autodetected_importer_and_size_with_progress_block
47
+ create_stabilizer_file
48
+ processing_log = ""
49
+ accum = lambda do | percent, message |
50
+ processing_log << ("%d -> %s\n" % [percent, message])
51
+ end
52
+
53
+ pipeline = Tracksperanto::Pipeline::Base.new(:progress_block => accum)
54
+ assert_nothing_raised { pipeline.run(@stabilizer) }
55
+ reference = File.read(File.dirname(__FILE__) + "/fixtures/processing_log.txt")
56
+ assert_equal reference, processing_log, "The log output should be the same"
57
+ end
58
+
46
59
  def test_run_crashes_with_empty_file
47
60
  empty_file_path = "./input_empty.stabilizer"
48
61
  f = File.open(empty_file_path, "w"){|f| f.write('') }
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: tracksperanto
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.6.1
5
+ version: 2.6.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Julik Tarkhanov
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-22 00:00:00 Z
13
+ date: 2011-07-30 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: flame_channel_parser
@@ -188,6 +188,7 @@ files:
188
188
  - test/export/test_pftrack_export.rb
189
189
  - test/export/test_shake_export.rb
190
190
  - test/export/test_syntheyes_export.rb
191
+ - test/fixtures/processing_log.txt
191
192
  - test/helper.rb
192
193
  - test/import/samples/3de_v3/3de_export_v3.txt
193
194
  - test/import/samples/3de_v4/3de_export_cube.txt