pak Posted November 12, 2017 Share Posted November 12, 2017 What's the best method to put a point into the center of each primitive group in a geo? I was wondering if scatter can [somehow] do it? Quote Link to comment Share on other sites More sharing options...
jon3de Posted November 14, 2017 Share Posted November 14, 2017 You can do this with an assemble sop. Just use it on all groups and transfer the groups also. Create packed geo and delete the points which are not grouped. I think there are also slicker methods but this one was the first I came up with. pointsOnPrimitiveGroups.hip Quote Link to comment Share on other sites More sharing options...
acey195 Posted November 14, 2017 Share Posted November 14, 2017 there is an actual vex function for this http://www.sidefx.com/docs/houdini16.0/vex/functions/getbbox_center you can give it a group as input. running the following code in a wrangle (Run Over: Detail (only once)) string grps[] = detailintrinsic(0, "primitivegroups"); foreach(string grp; grps) { int groupCenterPt = addpoint(0,getbbox_center(0, grp)); } should do the trick for you 3 Quote Link to comment Share on other sites More sharing options...
Noobini Posted November 14, 2017 Share Posted November 14, 2017 (edited) problem i see with bbox is it is flawed that it's not always truely 'centre'....ie. for a 'quad'...the centre is same as bbox centre...easy...but say you are dealing with the 2 tris making up that quad...the centre of each tri is somewhere inside the tri...not at the centre of its bbox. here's the illustration....group shape resembles a triangle...its centre should be inside that triangle...not on its hypotenuse/bbox centre bboxflaw.hipnc Edited November 14, 2017 by Noobini Quote Link to comment Share on other sites More sharing options...
pak Posted November 14, 2017 Author Share Posted November 14, 2017 (edited) Thank you for the answers, @acey195 very nice use of bbox centers, indeed! @jon3de I've checked your file however after the packed geo assemble, blast and delete has nothing in them, 0 prims, points, vertices, etc. Edited November 14, 2017 by pak Quote Link to comment Share on other sites More sharing options...
jon3de Posted November 14, 2017 Share Posted November 14, 2017 file is ok here. Check if you have some primitve groups for the assemble sop. Also make sure that you transfer your groups if you create the packed geo in the assemble sop. Than it should work. Quote Link to comment Share on other sites More sharing options...
pak Posted November 14, 2017 Author Share Posted November 14, 2017 there is no "transfer_groups" parameter for the assemble obj here, that may be the reason. I'm not connecting your file to my content, opening it up directly gives me the above error/popup. H16 here Quote Link to comment Share on other sites More sharing options...
violalyu Posted November 14, 2017 Share Posted November 14, 2017 One way I've used before is scale it to 0 on a per primitive basis and then fuse all the points, so that you get the center point of each one. Hope it helps :-) Quote Link to comment Share on other sites More sharing options...
moneitor Posted November 14, 2017 Share Posted November 14, 2017 (edited) Is it something like this?, I am doing it inside a for each, maybe is not what you are looking for, but have a look. pointsOnPrimitiveGroups.hip Edited November 14, 2017 by moneitor redaction Quote Link to comment Share on other sites More sharing options...
moneitor Posted November 14, 2017 Share Posted November 14, 2017 No I misunderstood the question, I am gonna prepare something else. Sorry about that. Quote Link to comment Share on other sites More sharing options...
moneitor Posted November 14, 2017 Share Posted November 14, 2017 This is probably more like that. pointsOnPrimitiveGroups.hip Quote Link to comment Share on other sites More sharing options...
pak Posted November 14, 2017 Author Share Posted November 14, 2017 3 hours ago, violalyu said: One way I've used before is scale it to 0 on a per primitive basis and then fuse all the points, so that you get the center point of each one. Hope it helps :-) That would solve for "primitives" - but I'm looking for "prim group centers" ~ I believe this method wouldn't work in that case? Quote Link to comment Share on other sites More sharing options...
violalyu Posted November 14, 2017 Share Posted November 14, 2017 @pak yes sorry I wasn't reading the title carefully! I went from @jon3de 's file and added a (very roundabout) way to get the group name as an attribute on the newly created centroid points, I'm sure there are better ways, but I'll just post it here in case this could be of any inspiration :-) pointsOnPrimitiveGroups_viola.hipnc Quote Link to comment Share on other sites More sharing options...
pak Posted November 15, 2017 Author Share Posted November 15, 2017 @violalyuthank you for this nice addition, there are some good vex solutions to this problem indeed, one of the things I'm wondering is - how to solve this without vex for me, the file @jon3de provided does not work (as described above) Quote Link to comment Share on other sites More sharing options...
violalyu Posted November 15, 2017 Share Posted November 15, 2017 Hi @pak, I didn't have the error message, but it is basically the same for me, it might be Houdini version difference? I'm using Houdini16.0.633, something might changed from 15.5 to 16? Also it seems you need the group attribute on the points for some later operation? Maybe there are other ways to directly achieve that, like instead of using group name as the "marker", there might be other attributes that could be used? Quote Link to comment Share on other sites More sharing options...
Noobini Posted November 15, 2017 Share Posted November 15, 2017 (edited) mmm...still wrong to me...because everyone's using BBox logic...if my prim groups are 'triangles' like these in the corners...their prim group center....well...they don't look very centered do they ? However if all your prim groups are 'rectangular'...well ignore me...all's fine and dandy... Edited November 15, 2017 by Noobini Quote Link to comment Share on other sites More sharing options...
Noobini Posted November 15, 2017 Share Posted November 15, 2017 (edited) here's my take on things...look at the classic case in the top left corner, a piece that is a triangular shape, imagine if BBox logic was applied to get the 'center'...it would have been ON the hypotenuse (right angle triangle, basic trig)....WRONG !!! But with my simple CoM logic (I won't claim it's foolproof, I'm wondering how it works on an L shape)..it's on the inside of the tri itself... vu_CoM.hipnc Edited November 15, 2017 by Noobini 3 Quote Link to comment Share on other sites More sharing options...
Noobini Posted November 15, 2017 Share Posted November 15, 2017 FYI, if you load the sample file CentroidPoints, you'll get this Detail Wrangle: int nprims = nprimitives(1); for(int i = 0; i < nprims; ++i) { int nvtx = primintrinsic(1, "vertexcount", i); vector pos = { 0, 0, 0 }; if(nvtx > 0) { for(int j = 0; j < nvtx; ++j) { int ptidx = vertexpoint(1, vertexindex(1, i, j)); pos += point(1, "P", ptidx); } pos /= nvtx; } int pt = addpoint(geoself(), pos); } which was my initial idea to solve this problem...while it would work fine if your prim verts were 'evenly' distributed...it falls down when the verts distribution is skewed. so if your prim (or prim group) has this vert distribution, using the wrangle above you'd get the center incorrectly pulled to the highest vert concentration...so I decided to use scatter to even out my sample size so I don't care how 'dodgy' the orig geometry is... Quote Link to comment Share on other sites More sharing options...
pak Posted November 16, 2017 Author Share Posted November 16, 2017 (edited) That's such a clever way to work @Noobini, thank you for this detailed step by step share! @violalyu I am on 16.0.705 - maybe it's a version difference.. However, I don't have the option "transfer groups" anywhere in that node. Here, check out this brand new assemble node I've placed. Edit: Just checked help for the node through right click menu, indeed in H16, there is no "transfer groups" option in assemble node. Maybe that's why. Edited November 16, 2017 by pak Quote Link to comment Share on other sites More sharing options...
violalyu Posted November 17, 2017 Share Posted November 17, 2017 Hi @pak thanks for the update! Good to know Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.