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

Mark Elendt mark at sidefx.com
Mon May 16 09:20:25 EDT 2011


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



More information about the Sidefx-houdini-list mailing list