[Sidefx-houdini-list] [HDK]: Attributes handles can't be nested in loops?

Szymon Kapeniak szymon.kapeniak at gmail.com
Tue May 17 05:50:43 EDT 2011


Thank you Mark!
Unfortunately I wasted your time, since this was one of those
embarrassing things. My code was "almost" ok, except... I accidently
put a semicolon before a body of a second loop.  Thanks to your post I
found it on sight.

Gosh, I was slowly getting crazy...



2011/5/16 Mark Elendt <mark at sidefx.com>:
> You'll have to provide a more complete example.  Could you change this
> code so that it fails?  Thanks.
>
> ------------------------------------------------------------------
> /*%hcustom -g -s %
>  */
>
> #include <GU/GU_Detail.h>
> #include <stdio.h>
>
> static void
> addIntegers(GU_Detail *gdp)
> {
>    GB_AttributeRef     h = gdp->addPointAttrib("ptnum", sizeof(int),
>                                GB_ATTRIB_INT, NULL);
>    GEO_Point           *ppt;
>    FOR_ALL_GPOINTS(gdp, ppt)
>        ppt->setValue<int>(h, ppt->getNum());
> }
>
> int
> main(int argc, char *argv[])
> {
>    GU_Detail           gdp;
>    GEO_AttributeHandle h1, h2;
>    GEO_Point           *p, *r;
>    int                 i, j;
>
>    gdp.load("defgeo.bgeo", NULL);
>    addIntegers(&gdp);
>
>    h1 = gdp.getPointAttribute("ptnum");
>    h2 = gdp.getPointAttribute("ptnum");
>
>    FOR_ALL_GPOINTS((&gdp),p)
>    {
>        h1.setElement(p);
>        i = h1.getI();
>        if (i != p->getNum())
>            fprintf(stderr, "iFail %d != %d\n", i, p->getNum());
>        FOR_ALL_GPOINTS((&gdp),r)
>        {
>            h2.setElement(r);
>            j = h2.getI();
>            if (j != r->getNum())
>                fprintf(stderr, "jFail %d != %d\n", j, r->getNum());
>        }
>    }
>
>    return 0;
> }
> ------------------------------------------------------------------
>
>
> On Saturday May 14 at 11:29, Szymon Kapeniak wrote:
>> Masters and Commanders,
>> ... two nested loop over points, on two different gdps, first handle
>> returns correct values while second one returns always 0 (but works
>> fine outside the loop). Does it mean to be like that? Replacing macros
>> with standard loops apparently doesn't help much.
>>
>> FOR_ALL_GPOINTS(gdp,p)
>>    handle.setElement(p); // handle initialized on gdp, handle2 on gdp2.
>>    i = handle.getI();  // works.
>>    FOR_ALL_GPOINTS(gdp2,r)
>>       handle2.setElement(r);
>>       j = handle2.getI(); // *does not* work.
>> (...)
>>
>> handle2.setElement(gdp2->points()[20]);
>> j = handle2.getI(); // this works again
>>
>> thanks for response!
>> --
>> skk.
>> _______________________________________________
>> Sidefx-houdini-list mailing list
>> Sidefx-houdini-list at sidefx.com
>> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>
> --
> Mark Elendt
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>



-- 
skk.



More information about the Sidefx-houdini-list mailing list