fastest way to convert point to edges in python

   4679   16   2
User Avatar
Member
280 posts
Joined:
Offline
what is the fastest way to convert point to edges in python?
the current implementation to convert it is by checking all the prims if it has the same point component
but this is very slow… on a large mesh

thanx before
Patar
User Avatar
Member
8 posts
Joined: Aug. 2017
Offline
Just curious, is python the program language Houdini users use? I am a noobie so I don't have a answer for your question.
User Avatar
Member
280 posts
Joined:
Offline
vex is alot faster… but for my purpose is not suitable as i need to define functions so i went to python route..
also theres always hdk but its harder to use
Edited by patar - Aug. 30, 2017 22:55:13
User Avatar
Member
323 posts
Joined: Jan. 2015
Online
Hi Patar,
you can define functions in vex:
see:

http://www.sidefx.com/docs/houdini/vex/cookbook [www.sidefx.com]

Olaf
User Avatar
Member
280 posts
Joined:
Offline
hmmm thanx… i rarely see function in vex so i assume it only support linear way of programming kinda like expression
so thanks for this!!

but do you have the answer to the main question?
it turn out to manipulate edge in vex is a little harder in vex..

best regards
Patar
Edited by patar - Aug. 31, 2017 06:35:48
User Avatar
Member
323 posts
Joined: Jan. 2015
Online
Hi Patar,
i dont fully get the main question…
What do you want to do exactly? Maybe an image/scene that shows before and after…

kind regards
Olaf
User Avatar
Member
280 posts
Joined:
Offline
actually what im looking for is a faster way to do Procedural Edge Loops

like what Luiz Kruel does in :
https://sidefx.com/tutorials/houdini-game-dev-tools-procedural-edge-loopsgroup-expandcontract/ [sidefx.com]

i found that this asset is very slow im trying to find a faster way
thats the main goal

but before that i have to know how to convert points to edges, and contained edges, prims, and contained prims…
its like group promote sops but in python…

best regards
Patar
User Avatar
Member
323 posts
Joined: Jan. 2015
Online
Hi Patar,
maybe have a look at the tool from Luiz.
It is actually written in Python!

I think a vex version of it might and should be faster.

And it is actualy not a trivial task.

The tool Luiz wrote seems only to work on quad meshes with loops presnt, if you feed it a trimesh it does not realy work…

You may want to have a look at
https://github.com/qLab/qLib [github.com]

there is -group edge loop ql" does what i was expecting and is fast… I have not looked how they implemented it.


kind regards

Olaf
User Avatar
Member
323 posts
Joined: Jan. 2015
Online
Hi Patar,
i just looked into group_edge_loop_ql_SOP.otl

and it is also done in python.

I had a look at the code (my python is rusty) but it seems quite advanced…
It makes use of itertools and is at least a bit documented…

check it out!

kind regards

Olaf
User Avatar
Member
280 posts
Joined:
Offline
Ahh man thank you for this …..

Best regards
Patar
User Avatar
Member
8575 posts
Joined: July 2007
Offline
if you want to stay in Python, there is
hou.Geometry.edgeLoop() for getting loops
as well as hou.Selection class, where you can convert/grow/shrink/… your components
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
280 posts
Joined:
Offline
Thanx tomas,
I can not find the “hou.Geometry.edgeLoop()” in the documentation
also can you give a snippet how to use the selection class to convert components?
im also with olaf ….my python is also rusty hehehe…

thanx again
i love this community!!! its one of the best i've seen anywhere… so helpfull
thanx guys

best regards
Patar
User Avatar
Member
8575 posts
Joined: July 2007
Offline
patar

I can not find the “hou.Geometry.edgeLoop()” in the documentation

right here
http://sidefx.com/docs/houdini/hom/hou/Geometry#loops [sidefx.com]
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
8575 posts
Joined: July 2007
Offline
patar

also can you give a snippet how to use the selection class to convert components?…

quick example of Python SOP to convert point group or pattern to edge group and contained edge group
node = hou.pwd()
geo = node.geometry()

# specify point group pattern
ptgrp = "0 1"

# create selection object from ptgrp
sel = hou.Selection(geo, hou.geometryType.Points, ptgrp)

# convert to edge selection
sel.convert(geo, hou.geometryType.Edges)

# get edges from selection
edges = sel.edges(geo)

# keep only contained edges
cedges = []
pts = geo.globPoints(ptgrp)
for edge in edges:
    if set(edge.points()).issubset(pts):
        cedges.append(edge)
        
# create groups if needed    
grp = geo.createEdgeGroup("neighborEdges")
grp.add(edges)
grp = geo.createEdgeGroup("containedEdges")
grp.add(cedges)
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
280 posts
Joined:
Offline
Again Thank you Tomas!!
User Avatar
Member
1694 posts
Joined: March 2020
Offline
Olaf Finkbeiner
Hi Patar,
i just looked into group_edge_loop_ql_SOP.otl

and it is also done in python.

I had a look at the code (my python is rusty) but it seems quite advanced…
It makes use of itertools and is at least a bit documented…


Yeah, I wrote that code before there was any edge loop functionality in the python API. It's quite old, though (although it still might have some relevance, I'm not familiar how extensive the python api functionality is).

The reason why the code looks a bit complicated because I started replacing houdini geometry structures with an own data representation to make it faster (I mention the improvements in the code comments).

cheers,
Imre
Imre Tuske
FX Supervisor | Senior FXTD @ Weta FX

qLib -- Houdini asset library
http://qlab.github.io/qLib/ [qlab.github.io]
https://www.facebook.com/qLibHoudini [www.facebook.com]
User Avatar
Member
323 posts
Joined: Jan. 2015
Online
Hi Imre,
i have learned a lot from qLib! Very usefull tools etc.
Thanks for your contributions to the Houdini community.

kind regards

Olaf
  • Quick Links