Surface Subdivision

Surface Component Definition

 

Create a surface panelization of a surface defined by 4 corner points.

import rhinoscriptsyntax as rss

import Rhino.Geometry as rg

 

#everything that I want my component to recognize OUTSIDE THE DEFINITIONS (functions)

#point list to store points on surface

#empty list

pointsSrf = []

baseSrfs = []

ptsNorm = []

tabSrfs = []

compPolys = []

 

def calcNormalWithSize(srf,uParam,vParam,tabSize,ptBase):

    ptNorm = rss.SurfaceNormal(srf,(uParam,vParam))

    ptNorm = rss.VectorScale(ptNorm,tabSize)

    ptNorm = rss.VectorAdd(ptNorm,ptBase)

    return ptNorm

 

def panelize():

    #populate the surface with points

    #-surface domain

    domU = rss.SurfaceDomain(srf,0)

    domV = rss.SurfaceDomain(srf,1)

 

    print (domU)

    print (domV)

 

    #enter variables that contain surface domain

    #max will be the second value, therefore [1]

    domUMax = domU[1]

    domUMin = domU[0]

    domVMax = domV[1]

    domVMin = domV[0]

 

    #calculate the stepSize

    stepU = (domUMax-domUMin)/divU

    stepV = (domVMax-domVMin)/divV

    

    for i in range(divU+1):

        for j in range(divV+1):

            if((i>0)and(j>0)):

                #-evaluate surface

                uParam = i*stepU

                vParam = j*stepV

                pt1Coord = rss.EvaluateSurface(srf,uParam,vParam)

                pt2Coord = rss.EvaluateSurface(srf,uParam-stepU,vParam)

                pt3Coord = rss.EvaluateSurface(srf,uParam-stepU,vParam-stepV)

                pt4Coord = rss.EvaluateSurface(srf,uParam,vParam-stepV)

            

                #obtain middle points

                ptMid12Coord = rss.EvaluateSurface(srf,uParam-stepU/2,vParam)

                ptMid23Coord = rss.EvaluateSurface(srf,uParam-stepU,vParam-stepV/2)

                ptMid34Coord = rss.EvaluateSurface(srf,uParam-stepU/2,vParam-stepV)

                ptMid41Coord = rss.EvaluateSurface(srf,uParam,vParam-stepV/2)

            

                ptListTemp = (pt1Coord,pt2Coord,pt3Coord,pt4Coord)

                pointsSrf.extend(ptListTemp)

                

                #use the rg for these WEIRD cases

                #basePts = (pt1Coord,pt2Coord,pt3Coord,pt4Coord)

                baseSrf = rg.NurbsSurface.CreateFromCorners(pt1Coord,pt2Coord,pt3Coord,pt4Coord)

                baseSrfs.append(baseSrf)

                

                #calculate normals

                pt1NCoord = calcNormalWithSize(srf,uParam,vParam,tabSize,pt1Coord)

                ptMidN12Coord = calcNormalWithSize(srf,uParam-stepU/2,vParam,tabSize,ptMid12Coord)

                ptMidN23Coord = calcNormalWithSize(srf,uParam-stepU,vParam-stepV/2,tabSize,ptMid23Coord)

                ptMidN34Coord = calcNormalWithSize(srf,uParam-stepU/2,vParam-stepV,tabSize,ptMid34Coord)

                ptMidN41Coord = calcNormalWithSize(srf,uParam,vParam-stepV/2,tabSize,ptMid41Coord)

                

                #turn the normals into actual points

                pt1N = rg.Point3d(pt1NCoord)

                ptMidN12 = rg.Point3d(ptMidN12Coord)

                ptMidN23 = rg.Point3d(ptMidN23Coord)

                ptMidN34= rg.Point3d(ptMidN34Coord)

                ptMidN41 = rg.Point3d(ptMidN41Coord)

                ptsNorm.extend((ptMidN12,ptMidN23,ptMidN34,ptMidN41))

                

                #create tabs - > use rg because we had problems

                tab1Srf = rg.NurbsSurface.CreateFromCorners(pt1Coord,pt2Coord,ptMidN12)

                tab2Srf = rg.NurbsSurface.CreateFromCorners(pt2Coord,pt3Coord,ptMidN23)

                tab3Srf = rg.NurbsSurface.CreateFromCorners(pt3Coord,pt4Coord,ptMidN34)

                tab4Srf = rg.NurbsSurface.CreateFromCorners(pt4Coord,pt1Coord,ptMidN41)

                tabSrfs.extend((tab1Srf,tab2Srf,tab3Srf,tab4Srf))

                

                #create polysurfaces

                tab1Tmp = rg.Brep.CreateFromSurface(tab1Srf)

                tab2Tmp = rg.Brep.CreateFromSurface(tab2Srf)

                tab3Tmp = rg.Brep.CreateFromSurface(tab3Srf)

                tab4Tmp = rg.Brep.CreateFromSurface(tab4Srf)

                baseTmp = rg.Brep.CreateFromSurface(baseSrf)

                

                tabSrfsTmp = (tab1Tmp,tab2Tmp,tab3Tmp,tab4Tmp,baseTmp)

                #rss.JoinSurfaces(tabSrfsTmp,False)

                #JoinBreps returns an array (list) with a single object inside

                #we obtain it by adding [0] which refers to the first object in the list

                #this way we store a single object inside polyTmp

                polyTmp = rg.Brep.JoinBreps(tabSrfsTmp,0.001)[0]

                compPolys.append(polyTmp)

                

#call function to be executed

if (calculate==True):

    if(flip==True):

        tabSize = -tabSize

    print ("Calling panelize")

    panelize()

 

if (calculate==False):

 

    print ("I will do nothing")

Search Site




archi·o·logics survey

I am interested in: