[Rock-dev] weired typelib related error

Sylvain Joyeux sylvain.joyeux at dfki.de
Mon Jun 4 10:53:14 CEST 2012


On 06/01/2012 01:28 PM, Janosch Machowinski wrote:
> Hey,
> I get an error in case I try to access an uninitialized map of
> Base::Spline from ruby:
> /home/scotch/rock1.9/base/types_ruby/lib/base/typelib_plugin.rb:50:in
> `initialize': dimension must be strictly positive (RuntimeError)
>           from
> /home/scotch/rock1.9/base/types_ruby/lib/base/typelib_plugin.rb:50:in `new'
>           from
> /home/scotch/rock1.9/base/types_ruby/lib/base/typelib_plugin.rb:50:in
> `block in<top (required)>'
>           from
> /home/scotch/rock1.9/install/lib/ruby/1.9.1/typelib.rb:2589:in `to_ruby'
>           from
> /home/scotch/rock1.9/install/lib/ruby/1.9.1/typelib.rb:1388:in `block in
> each'
>           from
> /home/scotch/rock1.9/install/lib/ruby/1.9.1/typelib.rb:1379:in `block in
> raw_each'
>           from
> /home/scotch/rock1.9/install/lib/ruby/1.9.1/typelib.rb:1378:in `times'
>           from
> /home/scotch/rock1.9/install/lib/ruby/1.9.1/typelib.rb:1378:in `raw_each'
>           from
> /home/scotch/rock1.9/install/lib/ruby/1.9.1/typelib.rb:1387:in `each'
>           from
> /home/scotch/rock1.9/install/lib/ruby/1.9.1/typelib.rb:1421:in `map'
>           from
> /home/scotch/rock1.9/install/lib/ruby/1.9.1/typelib.rb:1421:in `block in
> extend_for_custom_convertions'
>           from
> /home/scotch/rock1.9/install/lib/ruby/1.9.1/typelib.rb:2589:in `to_ruby'
>           from
> /home/scotch/rock1.9/install/lib/ruby/1.9.1/typelib.rb:1228:in `get_field'
>           from
> /home/scotch/rock1.9/install/lib/ruby/1.9.1/typelib.rb:1039:in `block (3
> levels) in custom_convertion_module'
>           from
> /home/scotch/rock1.9/install/share/typelib/ruby/corridor_plan.rb:105:in
> `block in split'
>           from
> /home/scotch/rock1.9/install/share/typelib/ruby/corridor_plan.rb:97:in
> `times'
>           from
> /home/scotch/rock1.9/install/share/typelib/ruby/corridor_plan.rb:97:in
> `split'
>           from
> /home/scotch/rock1.9/install/share/typelib/ruby/corridor_plan.rb:136:in
> `block in split_annotation_segments'
>           from
> /home/scotch/rock1.9/install/lib/ruby/1.9.1/typelib.rb:1727:in `block in
> each'
>           from
> /home/scotch/rock1.9/install/lib/ruby/1.9.1/typelib.rb:1726:in `do_each'
>           from
> /home/scotch/rock1.9/install/lib/ruby/1.9.1/typelib.rb:1726:in `each'
>           from
> /home/scotch/rock1.9/install/share/typelib/ruby/corridor_plan.rb:127:in
> `split_annotation_segments'
>           from ./filter_plan:213:in `filter_plan'
>           from ./filter_plan:256:in `<main>'
>
> The error message actually comes from the constructor of base::SplineBase.
> The give 'value' parameter to
> /home/scotch/rock1.9/base/types_ruby/lib/base/typelib_plugin.rb:50
> is :
> {
>     geometric_resolution=0.0,
>     dimension=0,
>     curve_order=0,
>     kind=:DEGENERATE,
>     knots=[
>
>     ],
>     vertices=[
>
>     ]}
>
> The problem is that dimension is zero. My problem now is that I have no idea
> who generates the 'value' and why it is non valid.
> As a workaround I just force dimension to one in typelib_plugin.rb which
> works,
> but is obviously the wrong fix.
> Any ideas ?

You are trying to access, from Ruby, a typelib value that never got 
properly initialized. Since typelib values are simply storing data, they 
have no validation. However, once you try to access it from ruby, it 
gets converted to the Spline / Spline3 class which does validate (and in 
your case fails).

If you want to create a new spline in Ruby, just use 
Base::Geometry::Spline.new and/or Base::Geometry::Spline3.new.

The fact that one cannot define an initializer for typelib values is a 
missing feature ...

Sylvain


More information about the Rock-dev mailing list