POV-Ray : Newsgroups : povray.beta-test : Dictionary 'reassign' Server Time: 11 Dec 2018 15:25:42 GMT
  Dictionary 'reassign' (Message 1 to 8 of 8)  
From: ingo
Subject: Dictionary 'reassign'
Date: 4 Dec 2018 15:59:01
Message: <XnsA9AEACC41A9B2seed7@news.povray.org>
Don't know the proper word for what I do, but the code below fails. Should 
it? Can it be made not to fail?

#declare T = dictionary {
  ["Index"] : array[2]{"Base1", "Base2"},
  ["Base1"] : <1,2,3>,
  ["Base2"] : <0,1,2>
};

#declare Chain = T["Index"][0];
#declare Vec = T.Chain;

Parse Error: Cannot pass uninitialized identifier to non-optional LValue.

ingo


Post a reply to this message

From: jr
Subject: Re: Dictionary 'reassign'
Date: 4 Dec 2018 19:20:01
Message: <web.5c06d2c1a98f76e2e43b71790@news.povray.org>
hi,

ingo <ing### [at] tagpovrayorg> wrote:
> Don't know the proper word for what I do, but the code below fails. Should
> it? Can it be made not to fail?
>
> #declare T = dictionary {
>   ["Index"] : array[2]{"Base1", "Base2"},
>   ["Base1"] : <1,2,3>,
>   ["Base2"] : <0,1,2>
> };
>
> #declare Chain = T["Index"][0];
> #declare Vec = T.Chain;
>
> Parse Error: Cannot pass uninitialized identifier to non-optional LValue.


I don't suppose "the other way round" is any good to you?  eg:

#version 3.8;

global_settings {assumed_gamma 1}

#declare T = dictionary {
  .base0 : 0,
  .base1 : 1,
  .base2 : 2,
  .vecs : array {<1,2,3>,<0,1,2>,<4,5,6>}
};

#debug concat("2)  <",vstr(3,T.vecs[T.base2],",",0,0),">.\n")


regards, jr.


Post a reply to this message

From: ingo
Subject: Re: Dictionary 'reassign'
Date: 4 Dec 2018 20:16:01
Message: <XnsA9AED85707CE3seed7@news.povray.org>
in news:web.5c06d2c1a98f76e2e43b71790@news.povray.org jr wrote:

> I don't suppose "the other way round" is any good to you?  eg:
> 
> #declare T = dictionary {
>   .base0 : 0,
>   .base1 : 1,
>   .base2 : 2,
>   .vecs : array {<1,2,3>,<0,1,2>,<4,5,6>}
> };

I'll have to reorient my brain for that, but I'll have a try. It may 
work for a few things but probably not for the the more complex 
structures I have.

#declare Fabrik = dictionary{
    // Processing order
    ["Proc"]  : array[4]{"Left", "Right", "LRB" ,"Base"},
    //Chain named 'Base'
    ["Base"]  : dictionary{
        ["Type"]      : "BaseSubbase",
        ["Joint"]     : array[4]{<0,0,0>, < 0,1,0>, < 0,2,0>, < 0,3,0>},
        ["Constraint"]: array[4]{false, object{}, false, false},
        ["Centroid"]  : array[1]{"LRB"}
    },
    ["Left"]  : dictionary{
        ["Type"]      : "SubbaseEnd"
        ["Joint"]     : array[4]{<0,3,0>, <-1,4,0>, <-2,5,0>, <-3,6,0>},
        ["Centroid"]  : array[1]{"LRB"}
    },
    ["Right"] : dictionary{
        ["Type"]      : "SubbaseEnd"
        ["Joint"]     : array[4]{<0,3,0>, < 1,4,0>, < 2,5,0>, < 3,6,0>},
        ["Constraint"]: array[4]{false, object{}, false, false},
        ["Centroid"]  : array[1]{"LRB"}
    },
    ["LRB"]   : dictionary{
        ["Type"]      : "Centroid"
        ["Index"]     : array[3]{"Left", "Right", "Base"},
        ["Centroid"]  : dictionary{
            ["Left"]      : 0, 
            ["Right"]     : 0, 
            ["Base"]      : 3
        }
    }
};

Thanks,

ingo


Post a reply to this message

From: jr
Subject: Re: Dictionary 'reassign'
Date: 4 Dec 2018 21:55:00
Message: <web.5c06f675a98f76e2e43b71790@news.povray.org>
hi,

ingo <ing### [at] tagpovrayorg> wrote:
> in news:web.5c06d2c1a98f76e2e43b71790@news.povray.org jr wrote:
> > I don't suppose "the other way round" is any good to you?  eg:
>
> I'll have to reorient my brain for that, but I'll have a try. It may
> work for a few things but probably not for the the more complex
> structures I have.
>
> #declare Fabrik = dictionary{
  ...
> };

I kept this onscreen for a while -- pretty awe-inspiring.  :-)

I also had a (very) cursory look at the pdf documenting the FABRIK algorithm.

given all that I'm thinking -- were I in your shoes -- I'd like to get a level
of abstraction between self and the details.  so, perhaps a "tree.inc", a set of
macros which implement the exact needed subset of
en.wikipedia.org/wiki/Tree_(data_structure)#Common_operations.  if nothing else,
it would reduce the amount of implementation detail I'd need to deal with.

anyway, if you want someone to test some code etc, feel free to write.

regards, jr.


Post a reply to this message

From: jr
Subject: Re: Dictionary 'reassign'
Date: 4 Dec 2018 22:45:00
Message: <web.5c07026fa98f76e2e43b71790@news.povray.org>
hi,

ingo <ing### [at] tagpovrayorg> wrote:
> Don't know the proper word for what I do, but the code below fails. Should
> it? Can it be made not to fail?
> #declare T = dictionary {
>   ["Index"] : array[2]{"Base1", "Base2"},
>   ["Base1"] : <1,2,3>,
>   ["Base2"] : <0,1,2>
> };
> #declare Chain = T["Index"][0];
> #declare Vec = T.Chain;
> Parse Error: Cannot pass uninitialized identifier to non-optional LValue.

heh, turns out there is a way (thanks to the Kenneth + clipka exchange :-))

#version 3.8;

global_settings {assumed_gamma 1}

#include "strings.inc"

#declare T = dictionary {
  ["Index"] : array[2]{"Base1", "Base2"},
  ["Base1"] : <1,2,3>,
  ["Base2"] : <0,1,2>
};

#declare Chain = T["Index"][1];
#declare Vec = Parse_String(concat("T.",Chain));

#debug concat("Vec: <",vstr(3,Vec,",",0,0),">\n")


:-)


regards, jr.


Post a reply to this message

From: clipka
Subject: Re: Dictionary 'reassign'
Date: 5 Dec 2018 04:14:57
Message: <5c0750c1$1@news.povray.org>
Am 04.12.2018 um 16:59 schrieb ingo:
> Don't know the proper word for what I do, but the code below fails. Should
> it? Can it be made not to fail?
> 
> #declare T = dictionary {
>    ["Index"] : array[2]{"Base1", "Base2"},
>    ["Base1"] : <1,2,3>,
>    ["Base2"] : <0,1,2>
> };
> 
> #declare Chain = T["Index"][0];
> #declare Vec = T.Chain;
> 
> Parse Error: Cannot pass uninitialized identifier to non-optional LValue.

`T.Chain` is shorthand for `T["Chain"]`. You don't have a key "Chain" in 
your dictionary.

What you want is

    #declare Vec = T[Chain];

Notice the use of square brackets without quotes. This tells POV-Ray 
that the key to use is the content of the variable `Chain`.


Post a reply to this message

From: ingo
Subject: Re: Dictionary 'reassign'
Date: 5 Dec 2018 06:40:51
Message: <XnsA9AF4E22035EBseed7@news.povray.org>
in news:5c0750c1$1@news.povray.org clipka wrote:

> Am 04.12.2018 um 16:59 schrieb ingo:
>> Don't know the proper word for what I do, but the code below fails.
>> Should it? Can it be made not to fail?
>> 
>> #declare T = dictionary {
>>    ["Index"] : array[2]{"Base1", "Base2"},
>>    ["Base1"] : <1,2,3>,
>>    ["Base2"] : <0,1,2>
>> };
>> 
>> #declare Chain = T["Index"][0];
>> #declare Vec = T.Chain;
>> 
>> Parse Error: Cannot pass uninitialized identifier to non-optional
>> LValue. 
> 
> `T.Chain` is shorthand for `T["Chain"]`. You don't have a key "Chain"
> in your dictionary.
> 
> What you want is
> 
>     #declare Vec = T[Chain];
> 
> Notice the use of square brackets without quotes. This tells POV-Ray 
> that the key to use is the content of the variable `Chain`.

Ah, the result of T["Index"][0] is a string, so why quote it again. 
Being a bit blind sometimes.

Thanks,

ingo


Post a reply to this message

From: ingo
Subject: Re: Dictionary 'reassign'
Date: 5 Dec 2018 06:47:04
Message: <XnsA9AF4F30EB662seed7@news.povray.org>
in news:web.5c06f675a98f76e2e43b71790@news.povray.org jr wrote:

> en.wikipedia.org/wiki/Tree_(data_structure)#Common_operations

Thanks for the link, I'll look into it.

The Farbrik algorithem is not that complex, but setting the whole thing up 
in a general way makes it a bit complicated. With the use of nested dicts 
and a bit of OOPishness it's doable I think.

ingo


Post a reply to this message

Copyright 2003-2008 Persistence of Vision Raytracer Pty. Ltd.