Exemplo n.º 1
0
def test_door_init():
    """Test the initialization of Door objects."""
    pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(1, 0, 3), Point3D(1, 0, 0))
    unique_id = str(py_uuid.uuid4())
    door = Door(unique_id, Face3D(pts))
    door.display_name = 'Test Door'
    str(door)  # test the string representation

    assert door.identifier == unique_id
    assert door.display_name == 'Test Door'
    assert isinstance(door.geometry, Face3D)
    assert len(door.vertices) == 4
    assert door.upper_left_vertices[0] == Point3D(1, 0, 3)
    assert len(door.triangulated_mesh3d.faces) == 2
    assert door.normal == Vector3D(0, 1, 0)
    assert door.center == Point3D(0.5, 0, 1.5)
    assert door.area == 3
    assert door.perimeter == 8
    assert isinstance(door.boundary_condition, Outdoors)
    assert not door.has_parent
if all_required_inputs(ghenv.Component):
    doors = []  # list of doors that will be returned
    for j, geo in enumerate(_geo):
        if len(_name_) == 0:  # make a default Door name
            name = display_name = clean_and_id_string('Door')
        else:
            display_name = '{}_{}'.format(longest_list(_name_, j), j + 1) \
                if len(_name_) != len(_geo) else longest_list(_name_, j)
            name = clean_and_id_string(display_name)
        glass = longest_list(glass_, j) if len(glass_) != 0 else False

        lb_faces = to_face3d(geo)
        for i, lb_face in enumerate(lb_faces):
            dr_name = '{}_{}'.format(name, i) if len(lb_faces) > 1 else name
            hb_dr = Door(dr_name, lb_face, is_glass=glass)
            hb_dr.display_name = display_name

            # try to assign the energyplus construction
            if len(ep_constr_) != 0:
                ep_constr = longest_list(ep_constr_, j)
                if isinstance(ep_constr, str):
                    ep_constr = opaque_construction_by_identifier(ep_constr) if not \
                        hb_dr.is_glass else window_construction_by_identifier(ep_constr)
                hb_dr.properties.energy.construction = ep_constr

            # try to assign the radiance modifier
            if len(rad_mod_) != 0:
                rad_mod = longest_list(rad_mod_, j)
                if isinstance(rad_mod, str):
                    rad_mod = modifier_by_identifier(rad_mod)
                hb_dr.properties.radiance.modifier = rad_mod