# Mini-challenge. Get ordered poly edge loops

 05 May 2017 aaandres Matrix3 fighter   portfolio Andres Fernandez Cruz Proin3D CEO Proin3D Madrid, España Originally Posted by denisT: hmm... it changes the rule of the original challenge... the original task was to find all loops in ANY edge selection... definitely you can organize your algorithm the way to process 'isolated loops' first. but it's just a step of the solution I see ... I did not quite understand your requirements. But my routine seems to work fine and fast for its purpose! __________________ Andrés FC. P3D_PathScripts Proin3D YouTube Channel share quote
 05 May 2017 aaandres Matrix3 fighter   portfolio Andres Fernandez Cruz Proin3D CEO Proin3D Madrid, España I really still don't understand what do you need... How many loops should you get in this schema? http://matap.dmae.upm.es/cursofract...o2/square-g.gif - 2 closed unconnected loops? (then 2 valid solutions and 4 edges not used) - 4 closed loops sharing 1 edge? (then using 4 edges twice in different loops) And in this other one? https://upload.wikimedia.org/wikipe...Example.svg.png You will need to leave unused edges or share them in different loops. __________________ Andrés FC. P3D_PathScripts Proin3D YouTube Channel share quote
05 May 2017
for picture #1 there two loops minimum....

the algorithm mostly has to solve these loops:

There are two loops on my picture
Attached Images
 Capture2.PNG (6.5 KB, 0 views)

 05 May 2017 PolyTools3D Expert   portfolio Jorge Rodríguez Argentina Originally Posted by denisT: for picture #1 there two loops minimum.... the algorithm mostly has to solve these loops: There are two loops on my picture The algorithm I proposed does solve these cases perfectly. It even gives you the two possible solutions, bridged and unbridged paths And, if the code is optimized, it is very fast. I get these results using a modified (fixed) version of the code I posted earlier: Bridged Paths #(60, 62, 63, 49, 61, 74, 75, 77, 79, 81, 82, 69, 55, 67, 68, 70) #(36, 38, 40, 41, 28, 11, 26, 39, 52) Unbridged Paths #(60, 61, 49, 63, 62, 74, 75, 77, 79, 81, 82, 68, 67, 55, 69, 70) #(36, 38, 39, 26, 11, 28, 41, 40, 52) __________________ Jorge Rodríguez PolyTools3D Last edited by PolyTools3D : 05 May 2017 at 06:48 PM. share quote
 05 May 2017 PolyTools3D Expert   portfolio Jorge Rodríguez Argentina Here is one of the many "hard cases" to solve. It can be solved, but I can't figure out a logic for a 1 or 2 passes solution for it. The challenging part is to pick the correct edge to start.``````( delete objects obj = converttopoly (plane pos:[0,0,1] length:100 width:100 lengthsegs:6 widthsegs:6 wirecolor:yellow isselected:on) obj.selectededges = #{8, 11, 23..25, 27..29, 35..37, 39, 41..43, 51..53, 63..64, 66..67} max modify mode subobjectlevel = 2 )`````` If you pick the correct edge to start, then the algorithm I proposed will work it out just perfectly. __________________ Jorge Rodríguez PolyTools3D share quote
 05 May 2017 aaandres Matrix3 fighter   portfolio Andres Fernandez Cruz Proin3D CEO Proin3D Madrid, España Originally Posted by PolyTools3D: Here is one of the many "hard cases" to solve. It can be solved, but I can't figure out a logic for a 1 or 2 passes solution for it. The challenging part is to pick the correct edge to start. If you pick the correct edge to start, then the algorithm I proposed will work it out just perfectly. I'm not sure, but: - If I'm not wrong, you do the calculation of 'neigthbors edges' for each edge. Perhaps you can do it once at the beginning for all the edges and store the result in an array (you can use some sort of dictionnary, as I've done in my routine). - In your 'FindHeadTail' routine, if there aren't pure 'tail edges', chose those with 2 neigthbors in one side. - Start with one of them, in the opposite direction of this intersection. - Add a final function for 'gluing' loops in these intersection points if needed. __________________ Andrés FC. P3D_PathScripts Proin3D YouTube Channel share quote
 05 May 2017 PolyTools3D Expert   portfolio Jorge Rodríguez Argentina Originally Posted by aaandres: I'm not sure, but: - If I'm not wrong, you do the calculation of 'neigthbors edges' for each edge. Perhaps you can do it once at the beginning for all the edges and store the result in an array (you can use some sort of dictionnary, as I've done in my routine). The code I posted is much worse than that, trust me It is just a sketch as proof of concept. But the algorithm does work. So, the code has many bugs, is redundant, and of course not optimized. Even the algorithm misses a few things, which I've found later when working with different scenes. But I think I've solved them. Originally Posted by aaandres: - In your 'FindHeadTail' routine, if there aren't pure 'tail edges', chose those with 2 neigthbors in one side. - Start with one of them, in the opposite direction of this intersection. - Add a final function for 'gluing' loops in these intersection points if needed. The problem I face is not how to solve it, but how to do it quickly. For example, if the loop is as one of the torus test, we can pick any random edge and that will be fine. But maybe it can't be done the way I would like and it needs to be analyzed differently. Sometime things are just like that. I haven't put too much work on it, so I am still not sure whether there is a better/simple approach. __________________ Jorge Rodríguez PolyTools3D share quote
 05 May 2017 aaandres Matrix3 fighter   portfolio Andres Fernandez Cruz Proin3D CEO Proin3D Madrid, España Hi Jorge. No, the first item wasn't an improvement of your code (I'm not able to do that), it's just a way to pre-store neigthbors so you can search for edges that have just 2 connections in one side. __________________ Andrés FC. P3D_PathScripts Proin3D YouTube Channel share quote
 05 May 2017 PolyTools3D Expert   portfolio Jorge Rodríguez Argentina Originally Posted by aaandres: Hi Jorge. No, the first item wasn't an improvement of your code (I'm not able to do that), it's just a way to pre-store neigthbors so you can search for edges that have just 2 connections in one side. Ah, I misunderstood the comment. Yes, for figuring out if there are intersections, I just go thru all the edges and if a vertex appears more than twice we have an intersection. __________________ Jorge Rodríguez PolyTools3D share quote

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.