Grasshopper

algorithmic modeling for Rhino

I am trying to flatten a polysurface to UV space so that surfaces with adjacency lie next to each other. Ive written a script to find shared edges of surfaces and outputs the index of each shared surface. What I am trying to do is then take these indexes and arrange them to fit a grid - so that all shared edges meet up. e.g. Surface 0 shares edges with surfaces 7 and 8, surface 7 shares edges with 19,4, 3, surface 3 shares and edge with 8 etc. What I need to do is graphically represent this in a grid, so that I can map out the uvs and effectively solve the problem of surface seams. Does anyone have a clue how to do this kind of 2d shuffling?

Views: 774

Replies to This Discussion

Are you looking for unfolding algorithms a la Pepakura?

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David,

As I was planning on simply mapping out UV coords to 1*1 squares in a grid, I was hoping it would be a little simpler than pepakura style mapping algorithms. I have attached a little diagram to explain my goal, I re-read my post and realise I did a sloppy job of explaining what I am trying to achieve.

Please take a squiz
Attachments:
A further update on how I am struggling to approach this problem. I have a function that reproduces the tree structure of my list of surface adjacencies. I then take an arbitrary surface, take two of its neighbouring surfaces and try to find the surface in between to begin orienting the data in a grid. The polysurface I am using is such that all surfaces will only ever have a maximum of 4 neighbouring surfaces. My code so far is:

Dim intTree As New DataTree (Of Integer)
intTree = convertTree(y, z, x)

'create a tree for storing common adjacencies
Dim commonAdj As New dataTree (Of Integer)

'need a loop to run through in appropriate order. for now just use very first value

'get list of all adjacencies for first surface
Dim branch As New GH_Path(0)
Dim srfListA As New list(Of Integer)
srfListA = intTree.Branch(branch)

'get first adjacency, again, eventually will need a loop
Dim tempInt As Integer = srfListA(0)

'get the list of first surfaces adjacencies
Dim branch1 As New GH_Path(tempInt)
Dim srfListB As New list(Of Integer)
srfListB = intTree.Branch(branch1)

'find shared adjacencies, first find out how many to check, START FROM 1 BECAUSE I AM USING 0 FOR TEST
For i As Integer = 1 To srfListA.count() - 1

'Get a list Of Each adjacency
Dim branch2 As New GH_Path(srfListA(i))
Dim srfListC As New list(Of Integer)
srfListC = intTree.Branch(branch2)

'loop through each new srf List
For j As Integer = 0 To srfListC.count() - 1


For k As Integer = 0 To srfListB.count() - 1
If (srfListB(k) = srfListC(j)) Then
'we have a shared point, need to store indexes i and k?
'need to make sure we place surfaces in correct orientation?


End If
Next
Next
Next

a = commonAdj



Any suggestions for where to go from here? I think I am getting bogged down in the complexity.

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service