Exemple #1
0
def main():
  """a simple example of a "component" tiling of a mesh surface.  
  given a mesh with only quad faces, we will generate a simple pyramid-like 
  component to take the place of each mesh face.
  """
  outie = fp.make_out(fp.outies.Rhino, "component")
  outie.set_color(Color.RGB(0.75,0.5,1.0))
  
  # get user input
  innie = fp.make_in(fp.innies.Rhino)
  mymesh = innie.get_mesh()
  pathPrefix = "solarIncidence/"
  path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
  epwdata = epwData(path)
  
  # go through each mesh face, and calcuate the average surface irradiance
  # and store value in irrArr
  irrArr = []
  for i in range(len(mymesh.faces)):
    facePlane = Ray(mymesh.face_centroid(i),mymesh.face_normal(i))
    irrArr.append(avgIrradinaceForYear(facePlane,epwdata))
  
  # go through each mesh face, and construct a component for each face
  for i in range(len(mymesh.faces)):
    height = irrArr[i] / 30
    if height < 1.0 : height = 1.0
    outie.put(pyramidComponent(mymesh,i,height))
  
  outie.draw()
def main():
  """a simple example of calculating solar incident radiation.  
  given a user-defined plane to evaluate, a hard-coded position, 
  and a EPW file that associates date/time with radiation level, 
  calculates the amount of radition striking the plane
  and produces a simple visualization.
  """
  outie = fp.make_out(fp.outies.Rhino, "solar incidence")
  outie.set_color(Color(0.75))
  
  # getting user input
  pathPrefix = ""
  path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
  epwdata = epwData(path)
  plane = Ray(Point(0,0,2), Vec(5,2,1)) #user-defined plane
  
  # Calculates the Yearly Average or Yearly Maximum Incident Radiation
  irrArr = []
  for h in range(8760): irrArr.append(srfIrradiance(plane,h,epwdata))
  maxIrr = max(irrArr) #Calculates Yearly Maximum Radiation
  avgIrr = (sum(irrArr))/(len(irrArr)) #Calculates Yearly Average Radiation
  print '{} Yearly Maximum Radiation w/m2'.format(maxIrr)
  print '{} Yearly Average Radiation w/m2'.format(avgIrr)
  
  #visualize results
  normalizedVal = maxIrr/1000 #sets a range of 0w/m2 -> 1000w/m2
  colorA = Color.HSB(0.75) #saturation and brightness of HSB colors default to 1.0
  colorB = Color.HSB(0.0) #saturation and brightness of HSB colors default to 1.0
  color = Color.interpolate(colorA,colorB,normalizedVal)
  plane.set_color(color)
  plane.vec.length = normalizedVal * 10
  
  outie.put([plane])
  outie.draw()
Exemple #3
0
def main():
 outie = fp.make_out(fp.outies.Rhino, "wayout")
 
 epw = fake_epw_data()
 print epw
 
 outie.draw()
Exemple #4
0
def main():
    outie = fp.make_out(fp.outies.Rhino, "wayout")

    epw = fake_epw_data()
    print epw

    outie.draw()
def main():
    """a simple example of a "component" tiling of a mesh surface.  
  given a mesh with only quad faces, we will generate a simple pyramid-like 
  component to take the place of each mesh face.
  """
    outie = fp.make_out(fp.outies.Rhino, "component")
    outie.set_color(Color.RGB(0.75, 0.5, 1.0))

    # get user input
    innie = fp.make_in(fp.innies.Rhino)
    mymesh = innie.get_mesh()
    pathPrefix = "solarIncidence/"
    path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
    epwdata = epwData(path)

    # go through each mesh face, and calcuate the average surface irradiance
    # and store value in irrArr
    irrArr = []
    for i in range(len(mymesh.faces)):
        facePlane = Ray(mymesh.face_centroid(i), mymesh.face_normal(i))
        irrArr.append(avgIrradinaceForYear(facePlane, epwdata))

    # go through each mesh face, and construct a component for each face
    for i in range(len(mymesh.faces)):
        height = irrArr[i] / 30
        if height < 1.0: height = 1.0
        outie.put(pyramidComponent(mymesh, i, height))

    outie.draw()
def DanzerAxiom():
  outie = fp.make_out(fp.outies.Rhino, "axiom")
  outie.iconscale = 0.1
  ta = DzTileA(xf=Xform.translation(Vec(1,0,0)),rlvl=1)
  tb = DzTileB(xf=Xform.translation(Vec(2,0,0)),rlvl=1)
  tc = DzTileC(xf=Xform.translation(Vec(3,0,0)),rlvl=1)
  tk = DzTileK(xf=Xform.translation(Vec(4,0,0)),rlvl=1)
  
  for t in [ta,tb,tc,tk] : outie.put(t.draw())
  outie.draw()
def DanzerAxiom():
  outie = fp.make_out(fp.outies.Rhino, "axiom")
  outie.iconscale = 0.1
  ta = DzTileA(xf=Xform.translation(Vec(1,0,0)),rlvl=1)
  tb = DzTileB(xf=Xform.translation(Vec(2,0,0)),rlvl=1)
  tc = DzTileC(xf=Xform.translation(Vec(3,0,0)),rlvl=1)
  tk = DzTileK(xf=Xform.translation(Vec(4,0,0)),rlvl=1)
  
  for t in [ta,tb,tc,tk] : outie.put(t.draw())
  outie.draw()
Exemple #8
0
def simpleTiling():
  outie = fp.make_out(fp.outies.Rhino, "tiles")
  
  maxRecursion = 3
  def recurse(tiles,rlvl=0):
    if rlvl >= maxRecursion : return [tile.draw() for tile in tiles]
    return [recurse(tile.inflate(),rlvl+1) for tile in tiles]
  
  cs = CS(Point(1,1),Vec(1,-1))
  outie.put( recurse([pt.PwTile(xf=cs.xform)]) ) 
  outie.draw()
Exemple #9
0
def main():
    """a simple example of calculating solar incident radiation.  
  given a user-defined plane to evaluate, a hard-coded position, 
  and a EPW file that associates date/time with radiation level, 
  calculates the amount of radition striking the plane
  and produces a simple visualization.
  """
    outie = fp.make_out(fp.outies.Rhino, "solar incidence")
    outie.set_color(Color(0.75))

    # getting user input
    pathPrefix = ""
    path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
    epwdata = epwData(path)
    plane = Ray(Point(0, 0, 0), Vec(1, -5, 2))  #user-defined plane

    # Calculates the Yearly Average or Yearly Maximum Incident Radiation
    #irrArr = []
    #for h in range(8760): irrArr.append(srfIrradiance(plane,h,epwdata))
    #maxIrr = max(irrArr) #Calculates Yearly Maximum Radiation
    #avgIrr = (sum(irrArr))/(len(irrArr)) #Calculates Yearly Average Radiation
    #print '{} Yearly Maximum Radiation w/m2'.format(maxIrr)
    #print '{} Yearly Average Radiation w/m2'.format(avgIrr)

    dateStart = "1/1"
    dateEnd = "12/31"
    dayStart = sg.calc_dayOfYear(dateStart)
    dayEnd = sg.calc_dayOfYear(dateEnd)
    startTime = 9
    endTime = 18

    envelope = sunEnvelope(plane, epwdata, dayStart, dayEnd, startTime,
                           endTime)
    print "size of envelope = " + str(len(envelope))

    #visualize results
    #normalizedVal = maxIrr/1000 #sets a range of 0w/m2 -> 1000w/m2
    normalizedVal = 0.5
    colorA = Color.HSB(
        0.75)  #saturation and brightness of HSB colors default to 1.0
    colorB = Color.HSB(
        0.0)  #saturation and brightness of HSB colors default to 1.0
    color = Color.interpolate(colorA, colorB, normalizedVal)
    plane.set_color(color)
    plane.vec.length = normalizedVal * 10

    outie.put([plane])
    outie.put(envelope)
    outie.draw()
def main():
    """a simple example of calculating solar incident radiation.  
  given a user-defined plane to evaluate, a hard-coded position, 
  and a EPW file that associates date/time with radiation level, 
  calculates the amount of radition striking the plane
  and produces a simple visualization.
  """
    outie = fp.make_out(fp.outies.Rhino, "solar incidence")
    outie.set_color(Color(0.75))

    # getting user input #
    pathPrefix = ""
    path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
    epwdata = epwData(path)
    innie = fp.make_in(fp.innies.Rhino)
    mymesh = innie.get_mesh()

    # find the normals for each mesh face
    normals = [
        Ray(mymesh.face_centroid(i), mymesh.face_normal(i))
        for i in range(len(mymesh.faces))
    ]

    # setup our visualization
    colorA = Color.HSB(
        0.75)  #saturation and brightness of HSB colors default to 1.0
    colorB = Color.HSB(
        0.0)  #saturation and brightness of HSB colors default to 1.0

    # Calculate the Yearly Average or Yearly Maximum Incident Radiation
    # and Visualize Results
    for normal in normals:
        irrArr = []
        for h in range(8760):
            irrArr.append(srfIrradiance(normal, h, epwdata))
        avgIrr = (sum(irrArr)) / (len(irrArr)
                                  )  #Calculates Yearly Average Radiation
        maxIrr = max(irrArr)  #Calculates Yearly Maximum Radiation
        #print '{} Yearly Average Radiation w/m2'.format(avgIrr)

        #visualize results
        normalizedVal = maxIrr / 1000  #sets a range of 0w/m2 -> 1000w/m2
        color = Color.interpolate(colorA, colorB, normalizedVal)
        normal.set_color(color)
        normal.vec.length = normalizedVal * 10

    outie.put([normals])
    outie.draw()
Exemple #11
0
def main():
    """a simple example of a "component" tiling of a mesh surface.  
  given a mesh with only quad faces, we will generate a simple pyramid-like 
  component to take the place of each mesh face.
  """
    outie = fp.make_out(fp.outies.Rhino, "component")
    outie.set_color(Color.RGB(0.75, 0.5, 1.0))

    # get user input
    innie = fp.make_in(fp.innies.Rhino)
    mymesh = innie.get_mesh()

    # go through each mesh face, and construct a component for each face
    for i in range(len(mymesh.faces)):
        outie.put(pyramidComponent(mymesh, i, 2))

    outie.draw()
Exemple #12
0
def main():
  """a simple example of a "component" tiling of a mesh surface.  
  given a mesh with only quad faces, we will generate a simple pyramid-like 
  component to take the place of each mesh face.
  """
  outie = fp.make_out(fp.outies.Rhino, "component")
  outie.set_color(Color.RGB(0.75,0.5,1.0))
  
  # get user input
  innie = fp.make_in(fp.innies.Rhino)
  mymesh = innie.get_mesh()
  
  # go through each mesh face, and construct a component for each face
  for i in range(len(mymesh.faces)):
    outie.put(pyramidComponent(mymesh,i,2))
  
  outie.draw()
Exemple #13
0
def main():
    """a simple example of calculating solar incident radiation.  
  given a user-defined plane to evaluate, a hard-coded position, 
  and a EPW file that associates date/time with radiation level, 
  calculates the amount of radition striking the plane
  and produces a simple visualization.
  """
    outie = fp.make_out(fp.outies.Rhino, "solar incidence")
    outie.set_color(Color(0.75))

    # getting user input
    epwdata = epwData("USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw")
    plane = Ray(Point(0, 0, 2), Vec(5, 2, 1))  #user-defined plane
    day = sg.calc_dayOfYear(
        "01/03")  #day of the year to calculate solar incidence
    hour = (24 * (day - 1)) + int(sg.calc_hourDecimal(
        "14:00"))  #hour of the day to calculate solar incidence

    #Yearly Average
    srfIrr = 0
    for h in range(hour, hour + 1):
        srfIrr = (srfIrradiance(plane, h, epwdata))  #/24
        print srfIrr
        #print srfIrr
        #srfIrr = 0
        #for irrVal in srfIrr:
        #  irrVal += srfIrr
    #   print irrVal
    #for srfIrr in range(24):
    #srfIrr += (srfIrradiance(plane,h,epwdata))/8760
    print '{} total w/m2 for first 48 hours'.format(srfIrr)

    #visualize results
    colorA = Color.HSB(
        0.0)  #saturation and brightness of HSB colors default to 1.0
    colorB = Color.HSB(
        0.75)  #saturation and brightness of HSB colors default to 1.0
    color = Color.interpolate(colorA, colorB, srfIrr * .001)
    plane.set_color(color)
    plane.vec.length = srfIrr / 10

    outie.put([plane])
    outie.draw()
def main():
  """a simple example of calculating solar incident radiation.  
  given a user-defined plane to evaluate, a hard-coded position, 
  and a EPW file that associates date/time with radiation level, 
  calculates the amount of radition striking the plane
  and produces a simple visualization.
  """
  outie = fp.make_out(fp.outies.Rhino, "solar incidence")
  outie.set_color(Color(0.75))
  
  # getting user input #
  pathPrefix = ""
  path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
  epwdata = epwData(path)
  innie = fp.make_in(fp.innies.Rhino)
  mymesh = innie.get_mesh()
  
  # find the normals for each mesh face
  normals = [Ray(mymesh.face_centroid(i),mymesh.face_normal(i)) for i in range(len(mymesh.faces))]
  
  # setup our visualization
  colorA = Color.HSB(0.75) #saturation and brightness of HSB colors default to 1.0
  colorB = Color.HSB(0.0) #saturation and brightness of HSB colors default to 1.0
  
  # Calculate the Yearly Average or Yearly Maximum Incident Radiation
  # and Visualize Results
  for normal in normals:
    irrArr = []
    for h in range(8760): irrArr.append(srfIrradiance(normal,h,epwdata))
    avgIrr = (sum(irrArr))/(len(irrArr)) #Calculates Yearly Average Radiation
    maxIrr = max(irrArr) #Calculates Yearly Maximum Radiation
    #print '{} Yearly Average Radiation w/m2'.format(avgIrr)

    #visualize results
    normalizedVal = maxIrr/1000 #sets a range of 0w/m2 -> 1000w/m2
    color = Color.interpolate(colorA,colorB,normalizedVal)
    normal.set_color(color)
    normal.vec.length = normalizedVal * 10
    
  outie.put([normals])
  outie.draw()
Exemple #15
0
def attractorTiling():
  outie = fp.make_out(fp.outies.Rhino, "tiles")
  attPt = Point(0.666,0.333)
  
  maxRecursion = 6
  baseDist = 0.9 # totally arbitrary
  falloff = 1.2 # also totally arbitrary
  def recurse(tiles,rlvl=0):
    if rlvl >= maxRecursion : return tiles
    moreTiles = []
    for tile in tiles :
      if attPt.distance(tile.centroid()) < baseDist/math.pow((rlvl+1),falloff) : 
        for t in recurse(tile.inflate(),rlvl+1) : moreTiles.append(t)
      else : moreTiles.append(tile)
    return moreTiles

  tiles = recurse([pt.PwTile()])
  print tiles
  for tile in tiles : 
    if attPt.distance(tile.centroid()) < baseDist/2 : outie.put(tile.draw()) 
  outie.draw()
def main():
  """a simple example of calculating solar incident radiation.  
  given a user-defined plane to evaluate, a hard-coded position, 
  and a EPW file that associates date/time with radiation level, 
  calculates the amount of radition striking the plane
  and produces a simple visualization.
  """
  outie = fp.make_out(fp.outies.Rhino, "solar incidence")
  outie.set_color(Color(0.75))
  
  # getting user input
  epwdata = epwData("USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw")
  plane = Ray(Point(0,0,2), Vec(5,2,1)) #user-defined plane
  day = sg.calc_dayOfYear("01/03") #day of the year to calculate solar incidence 
  hour = (24*(day-1))+int(sg.calc_hourDecimal("14:00")) #hour of the day to calculate solar incidence
  
  #Yearly Average
  srfIrr = 0
  for h in range(hour, hour+1):
    srfIrr = (srfIrradiance(plane,h,epwdata))#/24
    print srfIrr
    #print srfIrr
    #srfIrr = 0 
    #for irrVal in srfIrr:
    #  irrVal += srfIrr
   #   print irrVal
    #for srfIrr in range(24):
    #srfIrr += (srfIrradiance(plane,h,epwdata))/8760
  print '{} total w/m2 for first 48 hours'.format(srfIrr)
  
  #visualize results
  colorA = Color.HSB(0.0) #saturation and brightness of HSB colors default to 1.0
  colorB = Color.HSB(0.75) #saturation and brightness of HSB colors default to 1.0
  color = Color.interpolate(colorA,colorB,srfIrr*.001)
  plane.set_color(color)
  plane.vec.length = srfIrr/10
  
  outie.put([plane])
  outie.draw()
def main():
  """a simple example of calculating solar incident radiation.  
  given a user-defined plane to evaluate, and hard-coded position, date/time and radiation level, 
  calculates the amount of radition striking the plane
  and produces a simple visualization.
  """
  outie = fp.make_out(fp.outies.Rhino, "solar incidence")
  outie.set_color(Color(0.75))
  
  # getting user input
  lat,long,tmz = 40.75,-73.5,-5.0 #global position
  plane = Ray(Point(0,0,0), Vec(5,2,1)) #user-defined plane
  date,hour = "05/16", "12:00" #hard-coded date/time
  radiation = 1000 #user-defined solar intensity (direct normal)
  
  #calculate the solar vector
  day = sg.calc_dayOfYear(date)
  hour = sg.calc_hourDecimal(hour)
  sunvec = sg.calc_sunVector(lat, long, tmz, day, hour)
  
  #find the angle between our plane and the sun direction
  incidenceAngle = sunvec.angle(plane.vec)
  if incidenceAngle > math.pi/2 or radiation == 0:
    #if the sun is behind our plane then no radiation is possible
    print "Solar Incidence on the Surface = 0" 
    return
  else :
    #calculate the amout of radition striking our surface
    srfIrr = radiation * math.cos(incidenceAngle)
  print "srfIrr = {}".format(srfIrr)
  
  #visualize results
  colorA = Color.HSB(0.75) #saturation and brightness of HSB colors default to 1.0
  colorB = Color.HSB(0.0) #saturation and brightness of HSB colors default to 1.0
  color = Color.interpolate(colorA,colorB,srfIrr/100)
  plane.set_color(color) #assign HSB color to user-defined plane
  plane.vec.length = srfIrr/10 #scale the vector to a length proportional to the surface irradiance
  outie.put([plane,sunvec])
  outie.draw()
Exemple #18
0
import fieldpack as fp
from fieldpack import *
import math
TOL = 1e-9

outie = fp.make_out(fp.outies.Rhino, "delaunay2Dtest")

    
class Triangle():
    def __init__(self, v, f):
        self._vert = v
        self._face = f # ordered in a counterclockwise manner

    def vert(self): return self._vert	
    def face(self): return self._face

    def circumcenter(self):
        x1 = self._vert[0].x
        y1 = self._vert[0].y
        x2 = self._vert[1].x
        y2 = self._vert[1].y
        x3 = self._vert[2].x
        y3 = self._vert[2].y
    
        if math.fabs(y2-y1) < TOL:
            m2 = -(x3 - x2) / (y3 - y2)
            mx2 = (x2 + x3) / 2
            my2 = (y2 + y3) / 2
            xc = (x2 + x1) / 2
            yc = m2 * (xc - mx2) + my2
        elif math.fabs(y3-y2) < TOL:
Exemple #19
0
import fieldpack as fp
from fieldpack import *
import fieldpack.extensions.danzerTile as dt


maxRecursion = 5
def recurse(tiles,rlvl=0):
  if rlvl < maxRecursion : 
    return [recurse(tile.inflate(),rlvl+1) for tile in tiles]
  else :
    #for tile in tiles : outie.put(tile.draw()) 
    return [tile.draw() for tile in tiles]

outie = fp.make_out(fp.outies.Rhino, "tiles")
outie.put( recurse([dt.DzTileK()]) ) 
outie.draw()


Exemple #20
0
    tk = DzTileK(xf=xform, rlvl=0)
    out_0.put(tk.draw())

    inflt1 = tk.inflate()
    for tile in inflt1:
        out_1.put(tile.draw())
        inflt2 = tile.inflate()
        for tile in inflt2:
            out_2.put(tile.draw())


# Here we check to see if this file is being executed as the "main" python
# script instead of being used as a module by some other python script
# This allows us to use the module which ever way we want.
if __name__ == '__main__':
    out_0 = fp.make_out(fp.outies.Rhino, "0")
    out_0.set_color(0, 0, 0)
    out_0.iconscale = 0.2

    out_1 = fp.make_out(fp.outies.Rhino, "1")
    out_1.set_color(0.5, 0.5, 1.0)
    out_1.iconscale = 0.1

    out_2 = fp.make_out(fp.outies.Rhino, "2")
    out_2.set_color(1.0, 0.5, 1.0)
    out_2.iconscale = 0.05

    #DanzerAxiom()
    inflationB(out_0, out_1, out_2)
    #inflationK(out_0,out_1,out_2)
Exemple #21
0
import fieldpack as fp
from fieldpack import *
import math
import sys
import getopt
TOLERANCE = 1e-9
BIG_FLOAT = 1e38

outie = fp.make_out(fp.outies.Rhino, "delaunay-fortune")

#------------------------------------------------------------------
class Context( object ):
    def __init__(self):
        self.doPrint = 0
        self.debug   = 0
        self.plot    = 0
        self.triangulate = False
        self.vertices  = []    # list of vertex 2-tuples: (x,y)
        self.lines     = []    # equation of line 3-tuple (a b c), for the equation of the line a*x+b*y = c  
        self.edges     = []    # edge 3-tuple: (line index, vertex 1 index, vertex 2 index)   if either vertex index is -1, the edge extends to infiinity
        self.triangles = []    # 3-tuple of vertex indices
#        self.extra_edges = []  # list of additional vertex 2-tubles (x,y) based on bounded voronoi tesselation
#        self.set_bounds(None)
#        self.use_bound = False
        self.xmin = self.ymin = self.xmax = self.ymax = None

    def circle(self,x,y,rad):
        pass

    def clip_line(self,edge,lid,rid):
        pass
Exemple #22
0
def main():
    """a simple example of calculating solar incident radiation.  
  given a user-defined plane to evaluate, a hard-coded position, 
  and a EPW file that associates date/time with radiation level, 
  calculates the amount of radition striking the plane
  and produces a simple visualization.
  """
    outie = fp.make_out(fp.outies.Rhino, "solar incidence")
    outie.set_color(Color(0.75))

    # getting user input
    pathPrefix = ""
    path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
    epwdata = epwData(path)
    innie = fp.make_in(fp.innies.Rhino)
    mymesh = innie.get_mesh()

    # find the normals for each mesh face
    normals = [Ray(mymesh.face_centroid(i), mymesh.face_normal(i)) for i in range(len(mymesh.faces))]
    meshNormal = [(mymesh.face_normal(i)) for i in range(len(mymesh.faces))]
    meshCentroid = [(mymesh.face_centroid(i)) for i in range(len(mymesh.faces))]
    # meshVerts = [(mymesh.face_verts(i)) for i in range(len(mymesh.faces))]
    # print meshVerts

    for normal in meshNormal:
        # midPt = []
        for centroid in meshCentroid:
            # midPt.append(centroid + normal)
            p0 = centroid + normal
    print p0

    # for i in range(len(mymesh.faces)):
    # meshCentroid = mymesh.face_centroid(i)
    # for i in range(len(mymesh.faces)):
    # meshNormal = mymesh.face_normal(i)
    # p0 = meshCentroid + meshNormal

    for i in range(len(mymesh.faces)):
        meshVerts = mymesh.face_verts(i)
    meshPts = meshVerts[:]
    # print meshPts
    meshPts[0:0] = [p0]
    # print meshPts

    m1 = [meshPts[0], meshPts[1], meshPts[2]]
    m2 = [meshPts[0], meshPts[2], meshPts[3]]
    m3 = [meshPts[0], meshPts[3], meshPts[4]]
    m4 = [meshPts[0], meshPts[1], meshPts[4]]

    meshModule = [(Mesh(m1, (0, 1, 2))), (Mesh(m2, (0, 2, 3))), (Mesh(m3, (0, 3, 4))), (Mesh(m4, (0, 1, 4)))]
    print meshModule

    # for n in meshCentroid:
    # print n
    # for i in range(len(mymesh.faces)):
    # meshVerts = mymesh.face_verts(i)
    # for vert in meshVerts:
    # pLine = Line(vert, n)
    # print vert
    # pirLine = Line(vert, n)
    # print pLine
    # p1 = Point(normals)
    # print p1

    #####Rhinoscript
    # mesh = rs.GetObject('Select Mesh')
    # verts, norms, centroid = rs.MeshVertices(mesh), rs.MeshFaceNormals(mesh), rs.MeshFaceCenters(mesh)
    # print norms
    # for norm in norms:
    # for v in verts:
    # for c in norms:
    # rs.AddLine(v, c)

    # setup our visualization
    colorA = Color.HSB(0.75)  # saturation and brightness of HSB colors default to 1.0
    colorB = Color.HSB(0.0)  # saturation and brightness of HSB colors default to 1.0

    # Calculate the Yearly Average or Yearly Maximum Incident Radiation
    # and Visualize Results
    for normal in normals:
        irrArr = []
        for h in range(48):
            irrArr.append(srfIrradiance(normal, h, epwdata))
        avgIrr = (sum(irrArr)) / (len(irrArr))  # Calculates Yearly Average Radiation
        print "{} Yearly Average Radiation w/m2".format(avgIrr)

        # visualize results
        normalizedVal = avgIrr / 1000  # sets a range of 0w/m2 -> 1000w/m2
        color = Color.interpolate(colorA, colorB, normalizedVal)
        normal.set_color(color)
        normal.vec.length = normalizedVal * 10

    outie.put([normals, p0])
    outie.draw()
  xform = Xform.rotation(center=Point(0,1), angle=math.pi/2, axis=Vec(0,0,1))
  tk = DzTileK(xf=xform,rlvl=0)
  out_0.put(tk.draw())

  inflt1 = tk.inflate()
  for tile in inflt1 : 
    out_1.put(tile.draw())
    inflt2 = tile.inflate()
    for tile in inflt2 : out_2.put(tile.draw())


# Here we check to see if this file is being executed as the "main" python
# script instead of being used as a module by some other python script
# This allows us to use the module which ever way we want.
if __name__ == '__main__' :
    out_0 = fp.make_out(fp.outies.Rhino, "0")
    out_0.set_color(0,0,0)
    out_0.iconscale = 0.2
    
    out_1 = fp.make_out(fp.outies.Rhino, "1")
    out_1.set_color(0.5,0.5,1.0)
    out_1.iconscale = 0.1
  
    out_2 = fp.make_out(fp.outies.Rhino, "2")
    out_2.set_color(1.0,0.5,1.0)
    out_2.iconscale = 0.05  
    
    #DanzerAxiom()
    inflationB(out_0,out_1,out_2)
    #inflationK(out_0,out_1,out_2)
    
Exemple #24
0
def main():
    """a simple example of calculating solar incident radiation.  
  given a user-defined plane to evaluate, a hard-coded position, 
  and a EPW file that associates date/time with radiation level, 
  calculates the amount of radition striking the plane
  and produces a simple visualization.
  """
    outie = fp.make_out(fp.outies.Rhino, "solar incidence")
    outie.set_color(Color(0.75))

    # getting user input
    pathPrefix = ""
    path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
    epwdata = epwData(path)
    innie = fp.make_in(fp.innies.Rhino)
    mymesh = innie.get_mesh()

    # find the normals for each mesh face
    normals = [
        Ray(mymesh.face_centroid(i), mymesh.face_normal(i))
        for i in range(len(mymesh.faces))
    ]
    meshNormal = [(mymesh.face_normal(i)) for i in range(len(mymesh.faces))]
    meshCentroid = [(mymesh.face_centroid(i))
                    for i in range(len(mymesh.faces))]
    #meshVerts = [(mymesh.face_verts(i)) for i in range(len(mymesh.faces))]
    #print meshVerts

    for normal in meshNormal:
        #midPt = []
        for centroid in meshCentroid:
            #midPt.append(centroid + normal)
            p0 = centroid + normal
    print p0

    #for i in range(len(mymesh.faces)):
    #meshCentroid = mymesh.face_centroid(i)
    #for i in range(len(mymesh.faces)):
    #meshNormal = mymesh.face_normal(i)
    #p0 = meshCentroid + meshNormal

    for i in range(len(mymesh.faces)):
        meshVerts = mymesh.face_verts(i)
    meshPts = meshVerts[:]
    #print meshPts
    meshPts[0:0] = [p0]
    #print meshPts

    m1 = [meshPts[0], meshPts[1], meshPts[2]]
    m2 = [meshPts[0], meshPts[2], meshPts[3]]
    m3 = [meshPts[0], meshPts[3], meshPts[4]]
    m4 = [meshPts[0], meshPts[1], meshPts[4]]

    meshModule = [(Mesh(m1, (0, 1, 2))), (Mesh(m2, (0, 2, 3))),
                  (Mesh(m3, (0, 3, 4))), (Mesh(m4, (0, 1, 4)))]
    print meshModule

    #for n in meshCentroid:
    #print n
    #for i in range(len(mymesh.faces)):
    #meshVerts = mymesh.face_verts(i)
    #for vert in meshVerts:
    #pLine = Line(vert, n)
    #print vert
    #pirLine = Line(vert, n)
    #print pLine
    #p1 = Point(normals)
    #print p1

    #####Rhinoscript
    #mesh = rs.GetObject('Select Mesh')
    #verts, norms, centroid = rs.MeshVertices(mesh), rs.MeshFaceNormals(mesh), rs.MeshFaceCenters(mesh)
    #print norms
    #for norm in norms:
    #for v in verts:
    #for c in norms:
    #rs.AddLine(v, c)

    # setup our visualization
    colorA = Color.HSB(
        0.75)  #saturation and brightness of HSB colors default to 1.0
    colorB = Color.HSB(
        0.0)  #saturation and brightness of HSB colors default to 1.0

    # Calculate the Yearly Average or Yearly Maximum Incident Radiation
    # and Visualize Results
    for normal in normals:
        irrArr = []
        for h in range(48):
            irrArr.append(srfIrradiance(normal, h, epwdata))
        avgIrr = (sum(irrArr)) / (len(irrArr)
                                  )  #Calculates Yearly Average Radiation
        print '{} Yearly Average Radiation w/m2'.format(avgIrr)

        #visualize results
        normalizedVal = avgIrr / 1000  #sets a range of 0w/m2 -> 1000w/m2
        color = Color.interpolate(colorA, colorB, normalizedVal)
        normal.set_color(color)
        normal.vec.length = normalizedVal * 10

    outie.put([
        normals,
        p0,
    ])
    outie.draw()
Exemple #25
0
import fieldpack as fp
from fieldpack import *
import math
import sys
import getopt
TOLERANCE = 1e-9
BIG_FLOAT = 1e38

outie = fp.make_out(fp.outies.Rhino, "delaunay-fortune")


#------------------------------------------------------------------
class Context(object):
    def __init__(self):
        self.doPrint = 0
        self.debug = 0
        self.plot = 0
        self.triangulate = False
        self.vertices = []  # list of vertex 2-tuples: (x,y)
        self.lines = [
        ]  # equation of line 3-tuple (a b c), for the equation of the line a*x+b*y = c
        self.edges = [
        ]  # edge 3-tuple: (line index, vertex 1 index, vertex 2 index)   if either vertex index is -1, the edge extends to infiinity
        self.triangles = []  # 3-tuple of vertex indices
        #        self.extra_edges = []  # list of additional vertex 2-tubles (x,y) based on bounded voronoi tesselation
        #        self.set_bounds(None)
        #        self.use_bound = False
        self.xmin = self.ymin = self.xmax = self.ymax = None

    def circle(self, x, y, rad):
        pass