Exemplo n.º 1
0
def CalcRevealDims(_phpp_window_obj, RevealShaderObjs_input, SideIntersectionSurface, Side_OriginPt, Side_Direction):
    #Test shading objects for their edge points
    Side_IntersectionCurve = []
    Side_IntersectionPoints = []
    for i in range(len(RevealShaderObjs_input)): #This is the list of shading objects to filter
        if ghc.BrepXBrep(RevealShaderObjs_input[i], SideIntersectionSurface).curves != None:
            Side_IntersectionCurve.append(ghc.BrepXBrep(RevealShaderObjs_input[i], SideIntersectionSurface).curves)
    for i in range(len(Side_IntersectionCurve)):
        for k in range(len(ghc.ControlPoints(Side_IntersectionCurve[i]).points)):
            Side_IntersectionPoints.append(ghc.ControlPoints(Side_IntersectionCurve[i]).points[k])
    
    #Find the top/closets point for each of the objects that could possibly shade
    Side_KeyPoints = []
    Side_Rays = []
    Side_Angles = []
    for i in range(len(Side_IntersectionPoints)):
        if Side_OriginPt != Side_IntersectionPoints[i]:
            Ray = ghc.Vector2Pt(Side_OriginPt, Side_IntersectionPoints[i], False).vector
            Angle = math.degrees(ghc.Angle(_phpp_window_obj.surface_normal, Ray).angle)
            if  Angle < 89.9:
                Side_Rays.append(Ray)
                Side_Angles.append(float(Angle))
                Side_KeyPoints.append(Side_IntersectionPoints[i])
    Side_KeyPoint = Side_KeyPoints[Side_Angles.index(min(Side_Angles))]
    Side_KeyRay = Side_Rays[Side_Angles.index(min(Side_Angles))]
    
    #use the Key point found to calculte the Distances for the PHPP Shading Calculator
    Side_Hypot = ghc.Length(ghc.Line(Side_OriginPt, Side_KeyPoint))
    Deg = (ghc.Angle(Side_Direction, Side_KeyRay).angle) #note this is in Radians
    Side_o_reveal =  math.sin(Deg) * Side_Hypot
    Side_d_reveal = math.sqrt(Side_Hypot**2 - Side_o_reveal**2)
    Side_CheckLine = ghc.Line(Side_OriginPt, Side_KeyPoint)
    
    return [Side_o_reveal, Side_d_reveal, Side_CheckLine]
Exemplo n.º 2
0
def findNeighbors(_srfcList):
    """ Takes in a list of surfaces. tests against others in the

    set to see if they are touching. Adds a 'Neighbor' marker if so"""

    for i, srfc in enumerate(_srfcList):

        for k in range(0, len(_srfcList)):

            #print 'Surface: {} looking at Surface: {}...'.format(i, k)

            vertsI = ghc.DeconstructBrep(_srfcList[i].Surface).vertices

            vertsK = ghc.DeconstructBrep(_srfcList[k].Surface).vertices

            if ghc.BrepXBrep(_srfcList[i].Surface,
                             _srfcList[k].Surface).curves:

                if _srfcList[i].Neighbors != None:

                    matchSetID = _srfcList[i].Neighbors

                elif _srfcList[k].Neighbors != None:

                    matchSetID = _srfcList[k].Neighbors

                else:

                    matchSetID = i

                _srfcList[i].addNeighbor(matchSetID)  #branch[k].ID)

                _srfcList[k].addNeighbor(matchSetID)  #branch[i].ID)

    return _srfcList
Exemplo n.º 3
0
def isZoneHost(_winSrfc, _HBzones):

    # Performs a BrepXBrep collision to see if the Windw

    # is 'on' any of the HB Zone Surfaces or not?

    for zone in _HBzones:

        if 'surfaces' not in dir(zone):

            warning = "Double check the input into _HBZones? It looks like perhaps you are\n"\

            "passing in just the HB Surfaces? Be sure to pass those surfaces to an HB 'createHBZones'\n"\

            "before this in order to create a 'Zone' before passing in here."

            ghenv.Component.AddRuntimeMessage(
                ghK.GH_RuntimeMessageLevel.Warning, warning)

            return None

        for srfc in zone.surfaces:

            if ghc.BrepXBrep(srfc.geometry, _winSrfc).curves != None:

                hostZone = zone.name

                return hostZone

    return None
Exemplo n.º 4
0
def find_neighbors(_dict_of_TFA_objs):
    for tfa_a in _dict_of_TFA_objs.values():
        for tfa_b in _dict_of_TFA_objs.values():
            if ghc.BrepXBrep(tfa_a.surface, tfa_b.surface).curves:
                tfa_a.set_neighbors(tfa_b.neighbors)
                tfa_b.set_neighbors(tfa_a.neighbors)

    return None
Exemplo n.º 5
0
xkeepList = []  # xキープリスト:残すと判断されたブリッジ(x方向)を格納
xdelList = []  # x削除リスト:削除すると判断されたブリッジ(x方向)
ykeepList = []  # yキープリスト:残すと判断されたブリッジ(y方向)を格納
ydelList = []  # y削除リスト:削除すると判断されたブリッジ(y方向)を格納

# x方向に架かるブリッジの選択
for i in range(0, len(bridge_x)):
    for ii in range(0, len(bridge_x)):
        if i != ii:
            # ブリッジiがx削除リストにない場合実行
            if bridge_x[i] not in xdelList:
                # ブリッジiiがxキープリスト,x削除リストにない場合,ブリッジiとブリッジiiに重なりがあるかないか判定
                if bridge_x[ii] not in xkeepList and bridge_x[
                        ii] not in xdelList:
                    check = gh.BrepXBrep(bridge_x[i], bridge_x[ii]).curves
# 重なりがある場合ブリッジiはxキープリストへ格納,ブリッジiiは削除リストへ格納
                if check != None:
                    xkeepList.append(bridge_x[i])
                    xdelList.append(bridge_x[ii])

# y方向にå架かるブリッジの選択
for i in range(0, len(bridge_y)):
    for ii in range(0, len(bridge_y)):
        if i != ii:
            # ブリッジiがy削除リストにない場合実行
            if bridge_y[i] not in ydelList:
                # ブリッジiiがyキープリスト,y削除リストにない場合,ブリッジiとブリッジiiに重なりがあるかないか判定
                if bridge_y[ii] not in ykeepList and bridge_y[
                        ii] not in ydelList:
                    check = gh.BrepXBrep(bridge_y[i], bridge_y[ii]).curves
Exemplo n.º 6
0
def find_overhang_shading(_phpp_window_obj, _shadingGeom, _extents=99):
    # Figure out the glass surface (inset a bit) and then
    # find the origin point for all the subsequent shading calcs (top, middle)
    glzgCenter = ghc.Area(_phpp_window_obj.glazing_surface).centroid
    glazingEdges = _phpp_window_obj._get_edges_in_order( _phpp_window_obj.glazing_surface )
    glazingTopEdge = from_linesegment3d(glazingEdges.Top)
    ShadingOrigin = ghc.CurveMiddle(glazingTopEdge)
    
    # In order to also work for windows which are not vertical, find the 
    # 'direction' from the glazing origin and the top/middle ege point
    UpVector = ghc.Vector2Pt(glzgCenter, ShadingOrigin, True).vector
    
    #-----------------------------------------------------------------------
    # First, need to filter the scene to find the objects that are 'above'
    # the window. Create a 'test plane' that is _extents (99m) tall and 0.5m past the wall surface, test if
    # any objects intersect that plane. If so, add them to the set of things
    # test in the next step
    depth = float(_phpp_window_obj.install_depth) + 0.5
    edge1 = ghc.LineSDL(ShadingOrigin, UpVector, _extents)
    edge2 = ghc.LineSDL(ShadingOrigin, _phpp_window_obj.surface_normal, depth)
    intersectionTestPlane = ghc.SumSurface(edge1, edge2)
    
    OverhangShadingObjs = (x for x in _shadingGeom 
                    if ghc.BrepXBrep(intersectionTestPlane, x).curves != None)
    
    #-----------------------------------------------------------------------
    # Using the filtered set of shading objects, find the 'edges' of shading 
    # geom and then decide where the maximums shading point is
    # Create a new 'test' plane coming off the origin (99m in both directions this time).
    # Test to find any intersection shading objs and all their crvs/points with this plane
    HorizontalLine = ghc.LineSDL(ShadingOrigin, _phpp_window_obj.surface_normal, _extents)
    VerticalLine = ghc.LineSDL(ShadingOrigin, UpVector, _extents)
    
    IntersectionSurface = ghc.SumSurface(HorizontalLine, VerticalLine)
    IntersectionCurves = (ghc.BrepXBrep(obj, IntersectionSurface).curves 
                            for obj in OverhangShadingObjs
                            if ghc.BrepXBrep(obj, IntersectionSurface).curves != None)
    IntersectionPointsList = (ghc.ControlPoints(crv).points for crv in IntersectionCurves)
    IntersectionPoints = (pt for list_of_pts in IntersectionPointsList for pt in list_of_pts)
    
    #-----------------------------------------------------------------------
    # If there are any intersection Points found, choose the right one to use to calc shading....
    # Find the top/closets point for each of the objects that could possibly shade
    smallest_angle_found = 2 * math.pi
    key_point = None
    
    for pt in IntersectionPoints:
        if pt == None:        
            continue
        
        # Protect against Zero-Length error
        ray = ghc.Vector2Pt(ShadingOrigin, pt, False).vector
        if ray.Length < 0.001:
            continue
        
        this_ray_angle = ghc.Angle(_phpp_window_obj.surface_normal , ray).angle
        if this_ray_angle < 0.001:
            continue
        
        if this_ray_angle <= smallest_angle_found:
            smallest_angle_found = this_ray_angle
            key_point = pt
    
    #-----------------------------------------------------------------------
    # Use the 'key point' found to deliver the Height and Distance for the PHPP Shading Calculator
    if not key_point:
        d_over = None
        o_over = None
        CheckLine = VerticalLine
    else:
        d_over = key_point.Z - ShadingOrigin.Z                              # Vertical distance
        Hypot = ghc.Length(ghc.Line(ShadingOrigin, key_point))              # Hypot
        o_over = math.sqrt(Hypot**2 - d_over**2)                            # Horizontal distance
        CheckLine = ghc.Line(ShadingOrigin, key_point)
    
    return d_over, o_over, CheckLine
Exemplo n.º 7
0
def find_horizon_shading(_phpp_window_obj, _shadingGeom, _extents=99):
    """
    Arguments:
        _phpp_winddow_obj: The PHPP_Window object to calcualte the values for
        _shadingGeom: (list) A list of possible shading objects to test against
        _extents: (float) A number (m) to limit the shading search to. Default = 99m
    Returns:
        h_hori: Distance (m) out from the glazing surface of any horizontal shading objects found
        d_hori: Distance (m) up from the base of the window to the top of any horizontal shading objects found
    """
    surface_normal = _phpp_window_obj.surface_normal

    #-----------------------------------------------------------------------
    # Find Starting Point
    glazingEdges = _phpp_window_obj._get_edges_in_order( _phpp_window_obj.glazing_surface )
    glazingBottomEdge = glazingEdges.Bottom
    ShadingOrigin = ghc.CurveMiddle( from_linesegment3d(glazingBottomEdge) )
    UpVector = ghc.VectorXYZ(0,0,1).vector
    
    #-----------------------------------------------------------------------
    # Find if there are any shading objects and if so put them in a list
    HorizonShading = []
    
    HorizontalLine = ghc.LineSDL(ShadingOrigin, surface_normal, _extents)
    VerticalLine = ghc.LineSDL(ShadingOrigin, UpVector, _extents)
    for shadingObj in _shadingGeom:
        if ghc.BrepXCurve(shadingObj, HorizontalLine).points != None:
            HorizonShading.append( shadingObj )
    
    #-----------------------------------------------------------------------
    # Find any intersection Curves with the shading objects
    IntersectionSurface = ghc.SumSurface(HorizontalLine, VerticalLine)
    IntersectionCurve = []
    IntersectionPoints = []
    
    for shadingObj in HorizonShading:
        if ghc.BrepXBrep(shadingObj, IntersectionSurface).curves != None:
            IntersectionCurve.append(ghc.BrepXBrep(shadingObj, IntersectionSurface))
    for pnt in IntersectionCurve:
        IntersectionPoints.append(ghc.ControlPoints(pnt).points)
    
    #-----------------------------------------------------------------------
    # Run the "Top-Corner-Finder" if there are any intersecting objects...
    if len(IntersectionPoints) != 0:
        # Find the top/closets point for each of the objects that could possibly shade
        KeyPoints = []
        for pnt in IntersectionPoints:
            Rays = []
            Angles = []
            if pnt:
                for k in range(len(pnt)):
                    Rays.append(ghc.Vector2Pt(ShadingOrigin,pnt[k], False).vector)
                    Angles.append(ghc.Angle(surface_normal , Rays[k]).angle)
                KeyPoints.append(pnt[Angles.index(max(Angles))])
    
        # Find the relevant highest / closest point
        Rays = []
        Angles = []
        for i in range(len(KeyPoints)):
            Rays.append(ghc.Vector2Pt(surface_normal, KeyPoints[i], False).vector)
            Angles.append(ghc.Angle(surface_normal, Rays[i]).angle)
        KeyPoint = KeyPoints[Angles.index(max(Angles))]
    
        # Use the point it finds to deliver the Height and Distance for the PHPP Shading Calculator
        h_hori = KeyPoint.Z - ShadingOrigin.Z #Vertical distance
        Hypot = ghc.Length(ghc.Line(ShadingOrigin, KeyPoint))
        d_hori = math.sqrt(Hypot**2 - h_hori**2)
        CheckLine = ghc.Line(ShadingOrigin, KeyPoint)
    else:
        h_hori = None
        d_hori = None
        CheckLine = HorizontalLine
    
    return h_hori, d_hori, CheckLine