CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
reply share thread « Previous Thread | Next Thread »
 
Thread Tools Search this Thread Display Modes
Old 05-20-2017, 07:45 PM   #31
aaandres
Matrix3 fighter
 
aaandres's Avatar
portfolio
Andres Fernandez Cruz
Proin3D CEO
Proin3D
Madrid, España
 
Join Date: Jun 2015
Posts: 477
Quote:
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
 
Old 05-21-2017, 07:54 AM   #32
aaandres
Matrix3 fighter
 
aaandres's Avatar
portfolio
Andres Fernandez Cruz
Proin3D CEO
Proin3D
Madrid, España
 
Join Date: Jun 2015
Posts: 477
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
 
Old 05-21-2017, 03:17 PM   #33
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,865
Send a message via ICQ to denisT
for picture #1 there two loops minimum....

the algorithm mostly has to solve these loops:

There are two loops on my picture
Attached Images
File Type: png Capture2.PNG (6.5 KB, 0 views)
 
Old 05-21-2017, 06:44 PM   #34
PolyTools3D
Expert
 
PolyTools3D's Avatar
portfolio
Jorge Rodríguez
Argentina
 
Join Date: Jun 2013
Posts: 1,250
Quote:
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-21-2017 at 06:48 PM.
 
Old 05-21-2017, 08:28 PM   #35
PolyTools3D
Expert
 
PolyTools3D's Avatar
portfolio
Jorge Rodríguez
Argentina
 
Join Date: Jun 2013
Posts: 1,250
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.
Code:
( 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
 
Old 05-22-2017, 08:13 AM   #36
aaandres
Matrix3 fighter
 
aaandres's Avatar
portfolio
Andres Fernandez Cruz
Proin3D CEO
Proin3D
Madrid, España
 
Join Date: Jun 2015
Posts: 477
Quote:
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
 
Old 05-22-2017, 10:21 AM   #37
PolyTools3D
Expert
 
PolyTools3D's Avatar
portfolio
Jorge Rodríguez
Argentina
 
Join Date: Jun 2013
Posts: 1,250
Quote:
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.

Quote:
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
 
Old 05-22-2017, 10:28 AM   #38
aaandres
Matrix3 fighter
 
aaandres's Avatar
portfolio
Andres Fernandez Cruz
Proin3D CEO
Proin3D
Madrid, España
 
Join Date: Jun 2015
Posts: 477
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
 
Old 05-22-2017, 10:38 AM   #39
PolyTools3D
Expert
 
PolyTools3D's Avatar
portfolio
Jorge Rodríguez
Argentina
 
Join Date: Jun 2013
Posts: 1,250
Quote:
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
 
reply share thread



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 vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:05 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.