Hi, I'm trying to calculate the Euler Characteristic of my mesh. I need to figure the Genus of my mesh, to check if it is a torus or disk.
To to this I just need to count the number of vertexs (points), faces (primitives) and edges..
Points and prims are easy, but how can I count the number of edges?
https://en.wikipedia.org/wiki/Euler_characteristic [en.wikipedia.org]
Count number of edges
6593 6 2- aeaeaeae
- Member
- 126 posts
- Joined: Aug. 2010
- Offline
- animatrix_
- Member
- 4523 posts
- Joined: Feb. 2012
- Offline
len(hou.Geometry.globEdges("*"))
but it will be slow for high res models.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
- blackpixel
- Member
- 182 posts
- Joined: April 2009
- Offline
Python is indeed very slow when you have to deal with millions of polygons.
But there is another way using vex
You run an attrib wrangle over primitives and for each primitive you look at its half edges.
hedge_equivcount() will give you the number of half edges that are equivalent to your current half edge.
If it has only one equivalent, then it's an unshared edge.
If it has more, then you know it's a shared edge and it contributes by ( 1 / hedge_equivcount ) to the total count.
An edge between two primitives thus equals 1, because each prim's half edge contributes 0.5.
Last but not least you promote the count to a detail attribute to get the total sum.
This might sound more complicated, but it is faster because most of it is running multithreaded in the wrangle sop.
But there is another way using vex
You run an attrib wrangle over primitives and for each primitive you look at its half edges.
hedge_equivcount() will give you the number of half edges that are equivalent to your current half edge.
If it has only one equivalent, then it's an unshared edge.
If it has more, then you know it's a shared edge and it contributes by ( 1 / hedge_equivcount ) to the total count.
An edge between two primitives thus equals 1, because each prim's half edge contributes 0.5.
Last but not least you promote the count to a detail attribute to get the total sum.
This might sound more complicated, but it is faster because most of it is running multithreaded in the wrangle sop.
Edited by blackpixel - June 24, 2016 17:11:32
- Konstantin Magnus
- Member
- 670 posts
- Joined: Sept. 2013
- Offline
Not very elegant, but you could set carve node to
U = 0 and V = 1
Breakpoints -> Cut Breakpoints
and count prims.
U = 0 and V = 1
Breakpoints -> Cut Breakpoints
and count prims.
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
- blackpixel
- Member
- 182 posts
- Joined: April 2009
- Offline
- friedasparagus
- Member
- 402 posts
- Joined: June 2014
- Offline
There's also a hedge_isprimary() vex function which only returns true for one in every set of shared half edges, you can make a wrangle to “Run Over: Detail” and iterate over the half edges testing for primary:
EDIT: although I think there's more magic to @blackpixel's solution
int numedges = 0;
int i = 0;
while(hedge_isvalid(0, i)){
if(hedge_isprimary(geoself(), i))
numedges++;
i++;
}
i@count = numedges;
EDIT: although I think there's more magic to @blackpixel's solution
Edited by friedasparagus - June 27, 2016 13:06:36
Henry Dean
- blackpixel
- Member
- 182 posts
- Joined: April 2009
- Offline
-
- Quick Links