Exemplo n.º 1
0
def test_init_open():
    """Test the initialization of a room with open geometry."""
    pts_1 = [
        Point3D(0, 0, 0),
        Point3D(0, 10, 0),
        Point3D(10, 10, 0),
        Point3D(10, 0, 0)
    ]
    pts_2 = [
        Point3D(0, 0, 0),
        Point3D(0, 0, 3),
        Point3D(0, 10, 3),
        Point3D(0, 10, 0)
    ]
    pts_3 = [
        Point3D(0, 0, 0),
        Point3D(10, 0, 0),
        Point3D(10, 0, 3),
        Point3D(0, 0, 3)
    ]
    pts_4 = [
        Point3D(10, 10, 0),
        Point3D(0, 10, 0),
        Point3D(0, 10, 3),
        Point3D(10, 10, 3)
    ]
    pts_5 = [
        Point3D(10, 10, 0),
        Point3D(10, 0, 0),
        Point3D(10, 0, 3),
        Point3D(10, 10, 3)
    ]
    pts_6 = [
        Point3D(10, 0, 3),
        Point3D(10, 2.5, 3),
        Point3D(0, 2.5, 3),
        Point3D(0, 0, 3)
    ]
    pts_7 = [
        Point3D(10, 2.5, 3),
        Point3D(10, 5, 3),
        Point3D(0, 5, 3),
        Point3D(0, 2.5, 3)
    ]
    face_1 = Face('Face 1', Face3D(pts_1))
    face_2 = Face('Face 2', Face3D(pts_2))
    face_3 = Face('Face 3', Face3D(pts_3))
    face_4 = Face('Face 4', Face3D(pts_4))
    face_5 = Face('Face 5', Face3D(pts_5))
    face_6 = Face('Face 6', Face3D(pts_6))
    face_7 = Face('Face 7', Face3D(pts_7))
    room = Room('Zone: SHOE_BOX [920980]',
                [face_1, face_2, face_3, face_4, face_5, face_6, face_7], 0.01,
                1)

    assert not room.check_solid(0.01, 1, False)
    with pytest.raises(ValueError):
        room.check_solid(0.01, 1, True)
Exemplo n.º 2
0
def test_init():
    """Test the initialization of a room and basic properties."""
    pts_1 = [Point3D(0, 0, 0), Point3D(0, 10, 0), Point3D(10, 10, 0), Point3D(10, 0, 0)]
    pts_2 = [Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(0, 10, 3), Point3D(0, 10, 0)]
    pts_3 = [Point3D(0, 0, 0), Point3D(10, 0, 0), Point3D(10, 0, 3), Point3D(0, 0, 3)]
    pts_4 = [Point3D(10, 10, 0), Point3D(0, 10, 0), Point3D(0, 10, 3), Point3D(10, 10, 3)]
    pts_5 = [Point3D(10, 10, 0), Point3D(10, 0, 0), Point3D(10, 0, 3), Point3D(10, 10, 3)]
    pts_6 = [Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3), Point3D(0, 0, 3)]
    face_1 = Face('Face1', Face3D(pts_1))
    face_2 = Face('Face2', Face3D(pts_2))
    face_3 = Face('Face3', Face3D(pts_3))
    face_4 = Face('Face4', Face3D(pts_4))
    face_5 = Face('Face5', Face3D(pts_5))
    face_6 = Face('Face6', Face3D(pts_6))
    room = Room('ZoneSHOE_BOX920980',
                [face_1, face_2, face_3, face_4, face_5, face_6], 0.01, 1)

    str(room)  # test the string representation of the room
    assert room.identifier == 'ZoneSHOE_BOX920980'
    assert room.display_name == 'ZoneSHOE_BOX920980'
    assert room.multiplier == 1
    assert room.story is None
    assert isinstance(room.geometry, Polyface3D)
    assert len(room.geometry.vertices) == 8
    assert len(room) == 6
    assert room.center == Point3D(5, 5, 1.5)
    assert room.volume == 300
    assert room.floor_area == 100
    assert room.exposed_area == 220
    assert room.exterior_wall_area == 120
    assert room.exterior_aperture_area == 0
    assert room.average_floor_height == 0
    assert not room.has_parent
    assert room.check_solid(0.01, 1) == ''

    assert room[0].normal == Vector3D(0, 0, -1)
    assert room[1].normal == Vector3D(-1, 0, 0)
    assert room[2].normal == Vector3D(0, -1, 0)
    assert room[3].normal == Vector3D(0, 1, 0)
    assert room[4].normal == Vector3D(1, 0, 0)
    assert room[5].normal == Vector3D(0, 0, 1)
Exemplo n.º 3
0
def test_init_coplanar():
    """Test the initialization of a room with coplanar faces."""
    pts_1 = [Point3D(0, 0, 0), Point3D(0, 10, 0), Point3D(10, 10, 0), Point3D(10, 0, 0)]
    pts_2 = [Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(0, 10, 3), Point3D(0, 10, 0)]
    pts_3 = [Point3D(0, 0, 0), Point3D(10, 0, 0), Point3D(10, 0, 3), Point3D(0, 0, 3)]
    pts_4 = [Point3D(10, 10, 0), Point3D(0, 10, 0), Point3D(0, 10, 3), Point3D(10, 10, 3)]
    pts_5 = [Point3D(10, 10, 0), Point3D(10, 0, 0), Point3D(10, 0, 3), Point3D(10, 10, 3)]
    pts_6 = [Point3D(10, 0, 3), Point3D(10, 2.5, 3), Point3D(0, 2.5, 3), Point3D(0, 0, 3)]
    pts_7 = [Point3D(10, 2.5, 3), Point3D(10, 5, 3), Point3D(0, 5, 3), Point3D(0, 2.5, 3)]
    pts_8 = [Point3D(10, 5, 3), Point3D(10, 10, 3), Point3D(0, 10, 3), Point3D(0, 5, 3)]
    face_1 = Face('Face 1', Face3D(pts_1))
    face_2 = Face('Face 2', Face3D(pts_2))
    face_3 = Face('Face 3', Face3D(pts_3))
    face_4 = Face('Face 4', Face3D(pts_4))
    face_5 = Face('Face 5', Face3D(pts_5))
    face_6 = Face('Face 6', Face3D(pts_6))
    face_7 = Face('Face 7', Face3D(pts_7))
    face_8 = Face('Face 8', Face3D(pts_8))
    room = Room('Zone: SHOE_BOX [920980]',
                [face_1, face_2, face_3, face_4, face_5, face_6, face_7, face_8],
                0.01, 1)

    str(room)  # test the string representation of the room
    assert room.name == 'ZoneSHOE_BOX920980'
    assert room.display_name == 'Zone: SHOE_BOX [920980]'
    assert isinstance(room.geometry, Polyface3D)
    assert len(room.geometry.vertices) == 12
    assert len(room) == 8
    assert room.center == Point3D(5, 5, 1.5)
    assert room.volume == 300
    assert room.floor_area == 100
    assert room.exposed_area == 220
    assert room.exterior_wall_area == 120
    assert room.exterior_aperture_area == 0
    assert room.average_floor_height == 0
    assert not room.has_parent
    assert room.check_solid(0.01, 1)
    # duplicate the input objects to avoid editing them
    faces = (face.duplicate() for face in _faces)

    # generate a default name
    if _name_ is None:  # create a default Room name
        display_name = 'Room_{}'.format(document_counter('room_count'))
    else:
        display_name = _name_
    name = clean_and_id_string(display_name)

    # create the Room
    room = Room(name, faces, tolerance, angle_tolerance)
    room.display_name = display_name

    # check that the Room geometry is closed.
    if room.check_solid(tolerance, angle_tolerance, False) != '':
        give_warning(
            ghenv.Component, 'Input _faces do not form a closed volume.\n'
            'Room volume must be closed to access most honeybee features.\n'
            'Preview the output Room to see the holes in your model.')

    # try to assign the modifier set
    if _mod_set_ is not None:
        if isinstance(_mod_set_, str):
            _mod_set_ = modifier_set_by_identifier(_mod_set_)
        room.properties.radiance.modifier_set = _mod_set_

    # try to assign the construction set
    if _constr_set_ is not None:
        if isinstance(_constr_set_, str):
            _constr_set_ = construction_set_by_identifier(_constr_set_)