Jump to content

Cutting Curves with Spheres


kni8_2k

Recommended Posts

I am trying to cut a few curves with nurbs spheres that are placed at the CV Points. giving me more curves. to do this I am using a for loop and the curvesect sop to get all the intersections.

The result "looks" correct but on further inspection There are way too many polygons.

I've tried multiple copy stamp loops and trying to set groups by bounding box to get inside points... with out success.

I was wondering if anyone has tackled this before and can suggest something.

I have attached a hip.

Thank you in advance

curves_withSpheres_cut.hip

Link to comment
Share on other sites

so I have managed to get a version where I actually get the intersection geometry :

This is done through using an expression in the switch which is getting the smallest arc length (inside object) if the geometry is returning a point in the extraction curvesect :

if(npoints(opinputpath(".",3)) == 0,2, arclen(opinputpath(".",0),0,0,1)>arclen(opinputpath(".",1),0,0,1))

But I still can't get the inverse of this. The lines in between these lines.

thoughts ?

post-522-0-28245400-1352418685_thumb.jpg

post-522-0-37170600-1352418757_thumb.jpg

post-522-0-24841900-1352418763_thumb.jpg

curves_withSpheres_cut_InsideCuts.hip

Link to comment
Share on other sites

  • 1 month later...

Nice one.

But I think it can works with even fewer nodes :)

Oh, yes, clever)

first i made just all in one big expression in delete after foreach, but then divided in several nodes to better show what's going on.

Anyway i like doing it in foreach more, like in your example)

Edited by bloomendale
Link to comment
Share on other sites

  • 3 years later...

Hi, and thanks for the example file , but can someone explain the each node related with the foreach ?

I mean : we have the feeback checked, and

cull group :

ifs(!(!strcmp(chs("../fortype"), "group") || !strcmp(chs("../fortype"), "prim")), "", stamps("..", chs("../forstamp"), ""))

Cull Attribute :

ifs(!!strcmp(chs("../fortype"), "attrib"), "", chs("../attrib"))

Value :

stamp("..", chs("../forstamp") + "1", 0)
stamp("..", chs("../forstamp") + "2", 0)
stamp("..", chs("../forstamp") + "3", 0)

it's hard to understand, and it could be very interesting.

I read that strcmp(s1,s2) is a compare function that returns -1 if s1 comes before s2, 1 if s1 come after s2 and 0 if s1=s2 but the "ifs", "!", "!!" give me headacke :)

thks !

Link to comment
Share on other sites

@c0y.

if(condition, true, false)

if(@P.x > 0, 1, -1)         # Float version.
ifs(@P.x > 0, "foo", "bar") # String version.

It's like Two-Way Switch VOP. If condition is true, first argument will be returned, and if false, second. Note that unlike VEX, it seems that HScript has no function signatures, so, when you need to return strings, you must be aware and use string versions of many functions: chs, ifs, stamps, etc. Otherwise returned floats will be replaced with something default, like empty strings, and you will get a headache trying to debug what's going on.

"if (!thing)" stuff basically means "if thing equals to zero" (read as "if not thing"). And opposite "if (thing)" often means: "if thing not equals to zero" , "if thing converted to integer not equals to zero". HScript seems to be the first case, while VEX is the second: values of -1 or 0.12345 is true in HScript. !(1) equals to 0, !(0.1) equals to 0, !(0) equals to 1. And "!!" will simply convert any condition value to 0 or 1 numbers explicitly: -1, 0, 0.1, 1, 12345 will became 1, 0, 1, 1, 1. I don't think it is necessary, and nothing should happen if you simply delete "!!". Otherwise, I'm wrong. It is cleaner to explicitly compare: "if (thing == 0)" or "if (thing != 1)", imho.

Cull group expression means: "if For-Each in Group mode (strcmp returned 0 which mean "equal strings"), use stamp expression returning current group name, otherwise leave string empty". Cull attrubute expression is same logic: "if For-Each in Attribute mode, use attribute name, otherwise leave string empty". You see that if-function logic is reversed there, because of strcmp return values, as you noticed already. Positive result (equal strings) return zero (false), that's why stamp call typed at second (false clause) argument place. Value expression simply fetches FORVALUE1, FORVALUE2, FORVALUE3 variables from foreach node for current iteration, it is better to understand stamp function by using Copy node and manually creating such variables.

Also take a look at new loop stuff introduced in H15. For-Each Subnetwork is what we used before it. They are not identical, but in most cases give you same result.

Edited by f1480187
  • 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...