guache Posted October 21, 2020 Share Posted October 21, 2020 (edited) Sometimes, after some complex modeling, I get invisible, unnecessarily doubled lines: that is, line segments that occupy the same space as some other line (pic 1). If I sort prims by X and raise each one a bit in Y based on its ID (pic 2), I can see them. Is there an easy way to get rid of such doubled lines (pic 3)? I don't care if the result is a single primitive with many points, or several 2-point line segments. The "Fuse" SOP will merge points, but it won't get rid of doubled lines. Note: in the pic, the colors / width are just for illustration purposes. In Houdini, it's all one wireframe, you can't see the doublings. Also, the pic is just a simple example: in this case, I could remove all prims, keep the points, fuse them, then rebuild a single primitive. In real cases, the lines may be part of a grid, connect to other lines in specific ways etc, so rebuilding prims from just points would be very hard. Edited October 21, 2020 by guache Quote Link to comment Share on other sites More sharing options...
Librarian Posted October 21, 2020 Share Posted October 21, 2020 (edited) Maybe this Helps ..you have endless ways to do this depending of Your File and Case that we don't see Here @guache 9 hours ago, guache said: I don't care if the result is a single primitive with many points //Prim int prim_points[] = primpoints( geoself(), @primnum ); vector pos_accum = 0; for ( int i = 0; i < len(prim_points); i++ ) { pos_accum += attrib( 0, "point", "P", prim_points[i] ); } pos_accum /= len(prim_points); int xyz_prim; vector xyz_uv; float xyz_dist = xyzdist( 0, pos_accum, xyz_prim, xyz_uv); if ( xyz_prim > @primnum && xyz_dist < 0.001 ) removeprim(geoself(), @primnum, 1); else if ( xyz_prim < @primnum && xyz_dist < 0.001 ) removeprim(geoself(), xyz_prim, 1); Primi.hiplc Prim2.hiplc Edited October 21, 2020 by Librarian Quote Link to comment Share on other sites More sharing options...
guache Posted October 21, 2020 Author Share Posted October 21, 2020 14 hours ago, Librarian said: Prim2.hiplc Thanks for looking into this. It doesn't quite work with my test case with overlapping T-junctions, meeting at odd angles etc. In the end, I created a network of ~30 or so SOPs (!) that works for me. I exported it with opscript / old school (to avoid issues with many dependencies in my setup). duplicate_removal.cmd Quote Link to comment Share on other sites More sharing options...
Aizatulin Posted October 22, 2020 Share Posted October 22, 2020 (edited) Hi, here is another approach (if you have not straight lines). I'm not sure if this works in every situation. rebuild all primitives to polylines (for xyzdist()) for every primitive (the first one, which you are looping over) get all other primitives as list, where the first point is close enough (create a list of these primitives) for these candidates check the distance for all points of the primitive itself (all distances should be small) take the uv_i.x value of the first point and last point (of the first primitive) from the ith candidate (from xyzdist()) check all points of each primitive i, if they are close enough to the first primitive (and between uv_i.x(0) and uv_i.x(n-1)) This method will not work for overlapping primitives (if the primitive is part pf two or more other primitives). Here is a example file remove_redundant_prims.hipnc or brutal way: resample/subdivide your primitive measure distance to rest geometry if distance is small for every point -> delete advantage (it is working for closed and open prims, also working for overlapping parts) disadvantage (depends on subdivisions -> bad performance, not elegant) remove_redundant_primsA.hipnc Edited October 22, 2020 by Aizatulin 1 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.