kni8_2k Posted November 8, 2012 Share Posted November 8, 2012 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 Quote Link to comment Share on other sites More sharing options...
kni8_2k Posted November 8, 2012 Author Share Posted November 8, 2012 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 ? curves_withSpheres_cut_InsideCuts.hip Quote Link to comment Share on other sites More sharing options...
kni8_2k Posted November 9, 2012 Author Share Posted November 9, 2012 I don't know if this is taboo but I've cross posted this with sidefx forum and will share results. http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=27190 Quote Link to comment Share on other sites More sharing options...
kni8_2k Posted November 9, 2012 Author Share Posted November 9, 2012 Soo, I think I found a solution. but its really dirty and I feel horrible about it. Check it out and please let me know if there is a cleaner way. I can't sleep thinking there is no other way that is simpler. curves_withSpheres_dirty.hip Quote Link to comment Share on other sites More sharing options...
stabby Posted November 16, 2012 Share Posted November 16, 2012 ...sorry if it's too late... curves_withSpheres_dirty.hip Quote Link to comment Share on other sites More sharing options...
kni8_2k Posted January 16, 2013 Author Share Posted January 16, 2013 Thank you, your solution is pretty cleve, how ever it does not account for the intersection between point 8 and edge 11-12 Cheers for the effort.. Quote Link to comment Share on other sites More sharing options...
bloomendale Posted January 16, 2013 Share Posted January 16, 2013 Here is my solution. 3ak_curves_withSpheres_cut.hipnc Quote Link to comment Share on other sites More sharing options...
ben Posted January 17, 2013 Share Posted January 17, 2013 Nice one. But I think it can works with even fewer nodes 3ak_curves_withSpheres_cut.hipnc Quote Link to comment Share on other sites More sharing options...
bloomendale Posted January 17, 2013 Share Posted January 17, 2013 (edited) 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 January 17, 2013 by bloomendale Quote Link to comment Share on other sites More sharing options...
kni8_2k Posted January 22, 2013 Author Share Posted January 22, 2013 You are all Awesome. :-) when I get back to this file I will try implementing the final solution. Thanks again. Quote Link to comment Share on other sites More sharing options...
c0y Posted June 7, 2016 Share Posted June 7, 2016 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 ! Quote Link to comment Share on other sites More sharing options...
f1480187 Posted June 7, 2016 Share Posted June 7, 2016 (edited) @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 June 7, 2016 by f1480187 1 Quote Link to comment Share on other sites More sharing options...
c0y Posted June 8, 2016 Share Posted June 8, 2016 thank you very much for this "decryption" I didn't notice that chs ifs stamps were strings versions ! it's clearer now, tkx ! 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.