def add_face(face, geo):
    """Add Face geometry to a geo list."""
    geo.extend(from_face3d_to_wireframe(face.geometry))
    for ap in face.apertures:
        add_aperture(ap, geo)
    for dr in face.doors:
        add_door(dr, geo)
    for shd in face.shades:
        geo.extend(from_face3d_to_wireframe(shd.geometry))
예제 #2
0
def label_face(face, _attribute_, _font_, label_text, base_pts, labels, wire_frame):
    """Generate labels for a face or sub-face and add it to a list."""
    face_prop = get_attr_nested(face, _attribute_)

    # get a base plane and text height for the text label
    cent_pt = face.geometry.center  # base point for the text
    base_plane = Plane(face.normal, cent_pt)
    if base_plane.y.z < 0:  # base plane pointing downwards; rotate it
        base_plane = base_plane.rotate(base_plane.n, math.pi, base_plane.o)
    if _txt_height_ is None:  # auto-calculate default text height
        txt_len = len(face_prop) if len(face_prop) > 10 else 10
        largest_dim = max((face.geometry.max.x - face.geometry.min.x),
                           (face.geometry.max.y - face.geometry.min.y))
        txt_h = largest_dim / (txt_len * 2)
    else:
        txt_h = _txt_height_

    # move base plane origin a little to avoid overlaps of adjacent labels
    if base_plane.n.x != 0:
        m_vec = base_plane.y if base_plane.n.x < 0 else -base_plane.y
    else:
        m_vec = base_plane.y if base_plane.n.z < 0 else -base_plane.y
    base_plane = base_plane.move(m_vec * txt_h)

    # create the text label
    label = text_objects(face_prop, base_plane, txt_h, font=_font_,
                         horizontal_alignment=1, vertical_alignment=3)

    # append everything to the lists
    label_text.append(face_prop)
    base_pts.append(from_plane(base_plane))
    labels.append(label)
    wire_frame.extend(from_face3d_to_wireframe(face.geometry))
def context_shade_geometry(context_shades):
    """Get Rhino geometry curves from a list of ContextShades."""

    faces = [face for shd_geo in context_shades for face in shd_geo.geometry]
    return [
        curve for face in faces for curve in from_face3d_to_wireframe(face)
    ]
def add_model(model, geo):
    """Add Model geometry to a geo list."""
    for room in model.rooms:
        add_room(room, geo)
    for face in model.orphaned_faces:
        add_face(face, geo)
    for ap in model.orphaned_apertures:
        add_aperture(ap, geo)
    for dr in model.orphaned_doors:
        add_door(dr, geo)
    for shd in model.orphaned_shades:
        geo.extend(from_face3d_to_wireframe(shd.geometry))
예제 #5
0

if all_required_inputs(ghenv.Component):
    # extract any faces from input Rooms or Models
    faces = []
    for hb_obj in _hb_objs:
        if isinstance(hb_obj, Model):
            for room in hb_obj.rooms:
                faces.extend(room.faces)
                faces.extend(room.shades)
            faces.extend(hb_obj.orphaned_faces)
            faces.extend(hb_obj.orphaned_apertures)
            faces.extend(hb_obj.orphaned_doors)
            faces.extend(hb_obj.orphaned_shades)
        elif isinstance(hb_obj, Room):
            faces.extend(hb_obj.faces)
            faces.extend(hb_obj.shades)
        else:
            faces.append(hb_obj)

    # create the ColorFace visualization object and output geometry
    color_obj = ColorFace(faces, _attribute, legend_par_)
    graphic = color_obj.graphic_container
    mesh = [from_face3ds_to_colored_mesh([fc], col) for fc, col in
            zip(color_obj.flat_geometry, graphic.value_colors)]
    wire_frame = []
    for face in color_obj.flat_faces:
        wire_frame.extend(from_face3d_to_wireframe(face.geometry))
    legend = legend_objects(graphic.legend)
    values = color_obj.attributes
    colors = [color_to_color(col) for col in graphic.value_colors]
예제 #6
0
    from ladybug_rhino.color import color_to_color
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


if all_required_inputs(ghenv.Component):
    # extract any rooms from input Models
    rooms = []
    for df_obj in _df_obj:
        if isinstance(df_obj, Model):
            for bldg in df_obj.buildings:
                rooms.extend(bldg.all_room_2ds())
        elif isinstance(df_obj, Building):
            rooms.extend(df_obj.all_room_2ds())
        elif isinstance(df_obj, Story):
            rooms.extend(df_obj.room_2ds)
        elif isinstance(df_obj, Room2D):
            rooms.extend([df_obj])

    # create the ColorRoom visualization object and output geometry
    color_obj = ColorRoom2D(rooms, _attribute, legend_par_)
    graphic = color_obj.graphic_container
    mesh = [from_face3ds_to_colored_mesh([flrs], col) for flrs, col in
            zip(color_obj.floor_faces, graphic.value_colors)]
    wire_frame = []
    for room in rooms:
        wire_frame.extend(from_face3d_to_wireframe(room.floor_geometry))
    legend = legend_objects(graphic.legend)
    values = color_obj.attributes
    colors = [color_to_color(col) for col in graphic.value_colors]
def add_room(room, geo):
    """Add Room geometry to a geo list."""
    for face in room.faces:
        add_face(face, geo)
    for shd in room.shades:
        geo.extend(from_face3d_to_wireframe(shd.geometry))
def add_aperture(aperture, geo):
    """Add Aperture geometry to a geo list."""
    geo.extend(from_face3d_to_wireframe(aperture.geometry))
    for shd in aperture.shades:
        geo.extend(from_face3d_to_wireframe(shd.geometry))
def add_door(door, geo):
    """Add Door geometry to a geo list."""
    geo.extend(from_face3d_to_wireframe(door.geometry))
    for shd in door.shades:
        geo.extend(from_face3d_to_wireframe(shd.geometry))
    for face in model.orphaned_faces:
        add_face(face, geo)
    for ap in model.orphaned_apertures:
        add_aperture(ap, geo)
    for dr in model.orphaned_doors:
        add_door(dr, geo)
    for shd in model.orphaned_shades:
        geo.extend(from_face3d_to_wireframe(shd.geometry))


if all_required_inputs(ghenv.Component):
    # list of rhino geometry to be filled with content
    geo = []

    # loop through all objects and add them
    for hb_obj in _hb_objs:
        if isinstance(hb_obj, Room):
            add_room(hb_obj, geo)
        elif isinstance(hb_obj, Face):
            add_face(hb_obj, geo)
        elif isinstance(hb_obj, Aperture):
            add_aperture(hb_obj, geo)
        elif isinstance(hb_obj, Door):
            add_door(hb_obj, geo)
        elif isinstance(hb_obj, Shade):
            geo.extend(from_face3d_to_wireframe(hb_obj.geometry))
        elif isinstance(hb_obj, Model):
            add_model(hb_obj, geo)
        else:
            raise TypeError('Unrecognized honeybee object type: {}'.format(
                type(hb_obj)))
        if len(_interior_walls) != 0 else None
    roofs = from_face3ds_to_colored_mesh(_roofs, palette[3]) \
        if len(_roofs) != 0 else None
    ceilings = from_face3ds_to_colored_mesh(_ceilings, palette[4]) \
        if len(_ceilings) != 0 else None
    exterior_floors = from_face3ds_to_colored_mesh(_exterior_floors, palette[6]) \
        if len(_exterior_floors) != 0 else None
    interior_floors = from_face3ds_to_colored_mesh(_interior_floors, palette[7]) \
        if len(_interior_floors) != 0 else None
    air_walls = from_face3ds_to_colored_mesh(_air_walls, palette[12]) \
        if len(_air_walls) != 0 else None
    apertures = from_face3ds_to_colored_mesh(_apertures, palette[9]) \
        if len(_apertures) != 0 else None
    interior_apertures = from_face3ds_to_colored_mesh(_interior_apertures, palette[9]) \
        if len(_interior_apertures) != 0 else None
    doors = from_face3ds_to_colored_mesh(_doors, palette[10]) \
        if len(_doors) != 0 else None
    interior_doors = from_face3ds_to_colored_mesh(_interior_doors, palette[10]) \
        if len(_interior_doors) != 0 else None
    outdoor_shades = from_face3ds_to_colored_mesh(_outdoor_shades, palette[11]) \
        if len(_outdoor_shades) != 0 else None
    indoor_shades = from_face3ds_to_colored_mesh(_indoor_shades, palette[11]) \
        if len(_indoor_shades) != 0 else None

    # create the wire frame
    all_geo = _walls + _interior_walls + _roofs + _ceilings + _exterior_floors + \
        _interior_floors + _air_walls + _apertures + _interior_apertures + _doors + \
        _interior_doors + _outdoor_shades + _indoor_shades
    wire_frame = [
        curve for face in all_geo for curve in from_face3d_to_wireframe(face)
    ]
def room_2d_geometry(room_2ds):
    """Get Rhino geometry curves from a list of Room2Ds."""
    return [
        curve for room in room_2ds
        for curve in from_face3d_to_wireframe(room.floor_geometry)
    ]