Jump to content

Remove doubled lines


guache

Recommended Posts

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.

Doublings.png

Edited by guache
Link to comment
Share on other sites

Maybe this Helps ..you have endless ways to do this depending of Your File and Case that we don't see Here :P
@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

02444.jpg

Prim2.hiplc

Edited by Librarian
Link to comment
Share on other sites

14 hours ago, Librarian said:

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).

overlaps.png

duplicate_removal.cmd

Link to comment
Share on other sites

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 by Aizatulin
  • Like 1
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...