Jump to content

Boolean subtract geometry from curves?


Recommended Posts

this is very good thread. i did test all approaches and im getting best results from satoru's setup (testing on 58k curves - cad drawings, where im making bridges for router).

But that being said, i found scenario where even his method fails. And thats when curve goes through two cutting objects where curve points are outside. See sample image (as input i have curve with two poins)

 

01.PNG

  • Like 1
Link to comment
Share on other sites

it comes back to selecting points inside an object....there's no point inside to be found coz they are ON the surface...and NO....that's not having a dig at other contributors to this thread...they're all good...I learnt plenty from them.

Link to comment
Share on other sites

Here's a compromise solution. I was having trouble getting this to work with Intersection Stitch, but that might just be my misunderstanding it. It was adding inline points but not in any order that I could use to actually split the path into individual prims. PolySplit seemed to work better for that.

To fix the problem of points existing on the surface, I just uniqued each segmented prim's points and moved them very slightly towards their neighbor. Seems to work on both busy curved lines and the straight line through a torus example posted above.

curve_bool_2.hip

edit: forgot to fuse afterwards. this one re-attaches the segments afterwards.

curve_bool_3.hip

Edited by toadstorm
  • Like 1
Link to comment
Share on other sites

2 minutes ago, Noobini said:

shhhh...don't tell the architect guys you moved the points slightly....you never know they might demand their 5th decimal point accuracy back.

they get moved back after testing! 

but really though, biasing things like raycasts and such is a pretty normal thing to do when dealing with imperfect things like polygon meshes; I'm not worried about those kinds of cheats. there's acceptable margins of error for any scene.

Link to comment
Share on other sites

3 minutes ago, toadstorm said:

they get moved back after testing! 

but really though, biasing things like raycasts and such is a pretty normal thing to do when dealing with imperfect things like polygon meshes; I'm not worried about those kinds of cheats. there's acceptable margins of error for any scene.

oh yeah...i'm blind, sorry about that...

(your wrangle is still abit too advanced for me tho...it'll take awhile to sink in)

Edited by Noobini
Link to comment
Share on other sites

3 hours ago, martinkindl83 said:

this is very good thread. i did test all approaches and im getting best results from satoru's setup (testing on 58k curves - cad drawings, where im making bridges for router).

But that being said, i found scenario where even his method fails. And thats when curve goes through two cutting objects where curve points are outside. See sample image (as input i have curve with two poins)

 

01.PNG

@martinkindl83

Thank you Martin for verifying this!

It is a problem that arises when I use a newly added cut-point as an inner point.

The problem was avoided by checking the inner line again.

DissolveInside_sy_fixnestedline.hipnc

@toadstorm

I also like your way. 

Edited by satoru
  • Like 1
Link to comment
Share on other sites

8 minutes ago, satoru said:

@martinkindl83

Thank you Martin for verifying this!

It is a problem that arises when I use a newly added cut-point as an inner point.

The problem was avoided by checking the inner line again.

 

Good update. i had fix that was working for mine specific case, but your solution is way better.

Funny how you can use Houdini for preparing CNC data :)

 

Link to comment
Share on other sites

Had to give this a go. This is a one wrangle solution, the issue i have come into is that it wont cut several curves. Putting it inside a for-each loop fixes this, but its not optimal. The code should work without it, but i cant manage to find where the problem lies.

Features that it doesnt support atm is intersecting meshes, surfaces and meshes that covers the ends (want to solve the multicurve issue first).

 

Heres the code:

int primpts[] = primpoints(0,@primnum);
vector newpos[] = {},intlist[] = {},uvlist[] = {};
int posinfo[] = {}, primlist[] = {};
int newprim = addprim(0,"polyline");
int toggle = 1; 
int removenext = 0;
 
foreach(int i;primpts)
    {
    vector p01 = point(0,"P",primpts[i]);
    push(newpos,p01);
    push(posinfo,1);
    if(i != primpts[len(primpts)-1]){
                  
        vector p02 = point(0,"P",primpts[i+1]);
        vector ray = p02-p01;                
        intersect_all(1,p01,ray,intlist,primlist,uvlist,chf("tol"),chf("mergetol"));
        
        foreach(vector j;intlist)
            {
            push(newpos,j);
            push(posinfo,0);
            }
        }
    }    
    

foreach(int index;vector k;newpos)
    {
        if(removenext == 0 || posinfo[index]==0){
           int newpoint = addpoint(0,k);
           setpointattrib(0,"origprim",newpoint,@origprim,"set");
           setpointattrib(0,"cut",newpoint,posinfo[index],"set");
           addvertex(0,newprim,newpoint);
           }
        if(posinfo[index]==0){
            if(removenext == 1){               
                removenext = 0;
                }
            else{
                removenext = 1;
                newprim = addprim(0,"polyline");
                }
            }
        
    }
removeprim(0,@primnum,1);
    

 

 

Boolean_Curve_01.hiplc

RND_Boolean_Boolean_Curve_01.png

Link to comment
Share on other sites

  • 2 years later...
On 02/02/2018 at 9:55 PM, petz said:

here's another one.
it's a simple vex solution which works basically by counting the number of intersections along the curve and the fact that an uneven number means it`s inside an object ...

hth.
petz

curve-boolean.hipnc

I never stop learning every single time I see one of your example scenes... what a joy to see this elegant solution. Thank you.

  • Like 2
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...