Jump to content

Number of points / vertices in primitive?


Recommended Posts

Hi guys,

I need a method that returns the number of points or vertices in primitive (precisely GEO_Primitive) and also a way to get a reference to any point / vertex in a prim.

I'm stuck somewhere between those Doxy HDK pages trying to figure out this stuff :(

Thanks.

Edited by hoknamahn
Link to comment
Share on other sites

Culled from one of my sops ...

	  const GEO_Primitive *prim;
	  FOR_ALL_PRIMITIVES(gdp_in,prim)
		{
		  if (prim->getPrimitiveId()==GEOPRIMPOLY)
			{
			  if (prim->getVertexCount() >= 3)

I generally just browse the include files, quicker than loading web pages.

-Drew

Hi guys,

I need a method that returns the number of points or vertices in primitive (precisely GEO_Primitive) and also a way to get a reference to any point / vertex in a prim.

I'm stuck somewhere between those Doxy HDK pages trying to figure out this stuff :(

Thanks.

Edited by eloop
Link to comment
Share on other sites

Culled from one of my sops ...

	  const GEO_Primitive *prim;
	  FOR_ALL_PRIMITIVES(gdp_in,prim)
		{
		  if (prim->getPrimitiveId()==GEOPRIMPOLY)
			{
			  if (prim->getVertexCount() >= 3)

I generally just browse the include files, quicker than loading web pages.

-Drew

Thanks Drew!

Looks like the best way is digging of someones code :D

Link to comment
Share on other sites

  • 7 months later...

Thread resurrection!

Instead of opening one I'm just gonna bump this, but I''m trying to do the same business, except I want the total number of points, since I'm not working with vertices, and I cannot seem to be able to find a way.

I tried something like this but ended up getting this crazy value.

    FOR_ALL_GPOINTS(gdp, pt)
    {
        numpoints += pt->getNum();
    }

Been searching all over the docs, but can't seem to find anything that works.

Link to comment
Share on other sites

pt->getNum() in the above code gives you the point number (ie. $PT) so you don't want to be adding those up. It would simpler if you just added 1 in your loop to numpoints to get the total number of points that the FOR_ALL_GPOINTS() loop iterated over. However, since you're looping through ALL points, you can just do

numpoints = gdp->points().entries()

(without looping)

Link to comment
Share on other sites

pt->getNum() in the above code gives you the point number (ie. $PT) so you don't want to be adding those up. It would simpler if you just added 1 in your loop to numpoints to get the total number of points that the FOR_ALL_GPOINTS() loop iterated over. However, since you're looping through ALL points, you can just do

numpoints = gdp->points().entries()

(without looping)

Ack, I knew I shouldn't have been coding so late. Thanks edward!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...