Wednesday, April 25, 2012

DIFFERENT TYPES OF SURFACE TESSELLATIONS

QUAD  - DIAMOND - TRIANGULAR - HEXAGONAL












QUAD

import rhinoscriptsyntax as rs

points=[]

def samplesurface(strSrf, intUdivisions,intVdivisions):

listUdomain = rs.SurfaceDomain(strSrf,0) # list of 2 elements - starting and ending point of domain

listVdomain = rs.SurfaceDomain(strSrf,1)







floatUstep
= (listUdomain[1]-listUdomain[0])/intUdivisions

floatVstep = (listVdomain[1]-listVdomain[0])/intVdivisions



listofrows = []



for i in rs.frange(listUdomain[0],listUdomain[1]+floatUstep,floatUstep):

columnlist = []

for j in rs.frange(listVdomain[0],listVdomain[1]+floatVstep,floatVstep):

columnlist.append(rs.EvaluateSurface(strSrf,i,j))

listofrows.append(columnlist)

return listofrows #rs.AddPoints(listofrows[10][0]) take 10th element of list, which is a list - second number:take first element of this list in the list

strSrf = rs.GetObject("surface",8)

 

intUdivisions =
10

intVdivisions = 10

listofpoints = samplesurface(strSrf,intUdivisions,intVdivisions)

for i in range (0,len(listofpoints)-1):

for j in range (0,len(listofpoints[i])-1):

rs.AddSrfPt([listofpoints[i][j],listofpoints[i][j+1],listofpoints[i+1][j+1],listofpoints[i+1][j]])

DIAMOND

import rhinoscriptsyntax as rs

points=[]

def samplesurface(strSrf, intUdivisions,intVdivisions):

listUdomain = rs.SurfaceDomain(strSrf,0) # list of 2 elements - starting and ending point of domain

listVdomain = rs.SurfaceDomain(strSrf,1)







floatUstep
= (listUdomain[1]-listUdomain[0])/intUdivisions

floatVstep = (listVdomain[1]-listVdomain[0])/intVdivisions



listofrows = []



for i in rs.frange(listUdomain[0],listUdomain[1]+floatUstep,floatUstep):

columnlist = []

for j in rs.frange(listVdomain[0],listVdomain[1]+floatVstep,floatVstep):

columnlist.append(rs.EvaluateSurface(strSrf,i,j))

listofrows.append(columnlist)

return listofrows #rs.AddPoints(listofrows[10][0]) take 10th element of list, which is a list - second number:take first element of this list in the list

strSrf = rs.GetObject("surface",8)

 

intUdivisions =
10

intVdivisions = 10

listofpoints = samplesurface(strSrf,intUdivisions,intVdivisions)

for i in range (0,len(listofpoints)-2,2):

for j in range (0,len(listofpoints[i])-2,2):

rs.AddSrfPt([listofpoints[i+1][j],listofpoints[i+2][j+1],listofpoints[i+1][j+2],listofpoints[i][j+1]])

for i in range (1,len(listofpoints)-2,2):

for j in range (1,len(listofpoints[i])-2,2):

rs.AddSrfPt([listofpoints[i+1][j],listofpoints[i+2][j+1],listofpoints[i+1][j+2],listofpoints[i][j+1]])

TRIANGULAR

import rhinoscriptsyntax as rs

pointlist=[]

def samplesurface(strSrf, intUdivisions,intVdivisions):

listUdomain = rs.SurfaceDomain(strSrf,0) # list of 2 elements - starting and ending point of domain

listVdomain = rs.SurfaceDomain(strSrf,1)







floatUstep
= (listUdomain[1]-listUdomain[0])/intUdivisions

floatVstep = (listVdomain[1]-listVdomain[0])/intVdivisions



listofrows = []



for i in rs.frange(listUdomain[0],listUdomain[1]+floatUstep,floatUstep):

columnlist = []

for j in rs.frange(listVdomain[0],listVdomain[1]+floatVstep,floatVstep):

columnlist.append(rs.EvaluateSurface(strSrf,i,j))

listofrows.append(columnlist)

return listofrows #rs.AddPoints(listofrows[10][0]) take 10th element of list, which is a list - second number:take first element of this list in the list

strSrf = rs.GetObject("surface",8)

 

intUdivisions =
20

intVdivisions = 20

listofpoints = samplesurface(strSrf,intUdivisions,intVdivisions)

for i in range (0,len(listofpoints)-2,2):

for j in range (0,len(listofpoints[i])-2,2):

pointlist=[listofpoints[i+1][j],listofpoints[i+2][j+1],listofpoints[i+1][j+2],listofpoints[i][j+1]]

rs.AddSrfPt([pointlist[0],pointlist[1],pointlist[2]])

rs.AddSrfPt([pointlist[0],pointlist[2],pointlist[3]])

for i in range (1,len(listofpoints)-2,2):

for j in range (1,len(listofpoints[i])-2,2):

pointlist=[listofpoints[i+1][j],listofpoints[i+2][j+1],listofpoints[i+1][j+2],listofpoints[i][j+1]]

rs.AddSrfPt([pointlist[0],pointlist[1],pointlist[2]])

rs.AddSrfPt([pointlist[0],pointlist[2],pointlist[3]])

HEXAGONAL

import rhinoscriptsyntax as rs

points=[]

def samplesurface(strSrf, intUdivisions,intVdivisions):

listUdomain = rs.SurfaceDomain(strSrf,0) # list of 2 elements - starting and ending point of domain

listVdomain = rs.SurfaceDomain(strSrf,1)







floatUstep
= (listUdomain[1]-listUdomain[0])/intUdivisions

floatVstep = (listVdomain[1]-listVdomain[0])/intVdivisions



listofrows = []



for i in rs.frange(listUdomain[0],listUdomain[1]+floatUstep,floatUstep):

columnlist = []

for j in rs.frange(listVdomain[0],listVdomain[1]+floatVstep,floatVstep):

columnlist.append(rs.EvaluateSurface(strSrf,i,j))

listofrows.append(columnlist)

return listofrows #rs.AddPoints(listofrows[10][0]) take 10th element of list, which is a list - second number:take first element of this list in the list

strSrf = rs.GetObject("surface",8)

 

intUdivisions =
20

intVdivisions = 10

listofpoints = samplesurface(strSrf,intUdivisions,intVdivisions)

 

listofnormals=[]

for i in range (0,len(listofpoints)-2,2):

for j in range (0,len(listofpoints[i])-3,4):

hexpoints =[listofpoints[i+1][j],listofpoints[i+2][j+1],listofpoints[i+2][j+2],listofpoints[i+1][j+3],listofpoints[i][j+2],listofpoints[i][j+1],listofpoints[i+1][j]]

rs.AddCurve(hexpoints,1) #change starting point to make them fit into each other

rs.AddSrfPt([hexpoints[0],hexpoints[1],hexpoints[2],hexpoints[3]])

rs.AddSrfPt([hexpoints[0],hexpoints[3],hexpoints[4],hexpoints[5]])

for i in range (1,len(listofpoints)-2,2):

for j in range (2,len(listofpoints[i])-3,4):

hexpoints =[listofpoints[i+1][j],listofpoints[i+2][j+1],listofpoints[i+2][j+2],listofpoints[i+1][j+3],listofpoints[i][j+2],listofpoints[i][j+1],listofpoints[i+1][j]]

rs.AddCurve(hexpoints,1)

rs.AddSrfPt([hexpoints[0],hexpoints[1],hexpoints[2],hexpoints[3]])

rs.AddSrfPt([hexpoints[0],hexpoints[3],hexpoints[4],hexpoints[5]])


No comments:

Post a Comment