示例#1
0
def test_difference_3D_polys_multi():
    # type: () -> None
    """Test for difference_3D_polys with two overlapping regions
    
    This has two shapes in the horizontal plane which overlap in two places.
    Fails if the overlapping shapes are not returned as a new polygons.

    """    
    # surface is already a flat plane with z == 0
    s1 = Polygon3D([(0,0,0), (5,0,0), (5,2,0), (0,2,0)])  # counterclockwise
    s2 = Polygon3D([(1,1,0), (2,1,0), (2,2,0), (3,2,0),
                     (3,1,0), (4,1,0), (4,3,0), (1,3,0)])  # counterclockwise
    
    ex_s1 = [Polygon3D([(0,0,0), (5,0,0), (5,2,0), (4,2,0), (4,1,0), (3,1,0), 
                        (3,2,0), (2,2,0), (2,1,0), (1,1,0), (1,2,0), (0,2,0)])]
    ex_s2 = [Polygon3D([(1,2,0), (4,2,0), (4,3,0), (1,3,0)])]

    expected = [ex_s1, ex_s2]
    result = [s1.difference(s2), s2.difference(s1)]
    
    for res, exp in zip(result, expected):
        assert len(res) == len(exp)
        for r, e  in zip(res, exp):
            assert r == e
            
    assert s1.difference(s2) == ex_s1
    assert s2.difference(s1) == ex_s2
示例#2
0
def test_surface_is_clockwise():
    # type: () -> None
    """Test if a surface is clockwise as seen from a given point.
    """
    poly = Polygon3D(
        reversed(
            [
                Vector3D(0.0, 0.0, 0.0),
                Vector3D(1.0, 0.0, 0.0),
                Vector3D(1.0, 1.0, 0.0),
                Vector3D(0.0, 1.0, 0.0),
            ]
        )
    )
    poly_inv = Polygon3D(
        [
            Vector3D(0.0, 0.0, 0.0),
            Vector3D(1.0, 0.0, 0.0),
            Vector3D(1.0, 1.0, 0.0),
            Vector3D(0.0, 1.0, 0.0),
        ]
    )

    pt = Vector3D(0.5, 0.5, 1.0)  # point above the plane

    assert poly.is_clockwise(pt)
    assert not poly_inv.is_clockwise(pt)
示例#3
0
def test_surface_normal():
    # type: () -> None
    poly = Polygon3D([Vector3D(0.0, 0.0, 0.0),
                      Vector3D(1.0, 0.0, 0.0),
                      Vector3D(1.0, 1.0, 0.0),
                      Vector3D(0.0, 1.0, 0.0)])
    assert list(poly.normal_vector) == [0.0, 0.0, 1.0]  # for a horizontal surface

    poly = Polygon3D(reversed([Vector3D(0.0, 0.0, 0.0),
                      Vector3D(1.0, 0.0, 0.0),
                      Vector3D(1.0, 1.0, 0.0),
                      Vector3D(0.0, 1.0, 0.0)]))
    assert list(poly.normal_vector) == [0.0, 0.0, -1.0]  # for a horizontal surface

    poly = Polygon3D([Vector3D(0.0, 0.0, 0.0),
                      Vector3D(2.0, 1.0, 0.0),
                      Vector3D(4.0, 0.0, 0.0),
                      Vector3D(4.0, 3.0, 0.0),
                      Vector3D(2.0, 2.0, 0.0),
                      Vector3D(0.0, 3.0, 0.0)])
    assert list(poly.normal_vector) == [0.0, 0.0, 1.0]  # for a horizontal surface

    poly = Polygon3D(reversed([Vector3D(0.0, 0.0, 0.0),
                      Vector3D(2.0, 1.0, 0.0),
                      Vector3D(4.0, 0.0, 0.0),
                      Vector3D(4.0, 3.0, 0.0),
                      Vector3D(2.0, 2.0, 0.0),
                      Vector3D(0.0, 3.0, 0.0)]))
    assert list(poly.normal_vector) == [0.0, 0.0, -1.0]  # for a horizontal surface
    
    poly = Polygon3D([[ 1.,  1.1,  0.5],
                      [ 1.,  1.1,  0.],
                      [ 1.,  2.1,  0.],
                      [ 1.,  2.1,  0.5]])
    assert list(poly.normal_vector) == [1.0, 0.0, 0.0]  # for a horizontal surface
示例#4
0
def test_difference_3D_polys_single():
    # type: () -> None
    """Simplest test for difference_3D_polys
    
    This has two squares in the horizontal plane which overlap in one place.
    Fails if the two original polygons do not have the intersection removed.
    
    """
    # surface is already a flat plane with z == 0
    s1 = Polygon3D([(0, 2, 0), (2, 2, 0), (2, 0, 0), (0, 0, 0)])  # clockwise
    s2 = Polygon3D([(1, 3, 0), (3, 3, 0), (3, 1, 0), (1, 1, 0)])  # clockwise

    # clockwise
    ex_s1 = [
        Polygon3D([(0, 2, 0), (1, 2, 0), (1, 1, 0), (2, 1, 0), (2, 0, 0),
                   (0, 0, 0)])
    ]
    ex_s2 = [
        Polygon3D([(1, 3, 0), (3, 3, 0), (3, 1, 0), (2, 1, 0), (2, 2, 0),
                   (1, 2, 0)])
    ]
    expected = [ex_s1, ex_s2]

    result = [s1.difference(s2), s2.difference(s1)]
    assert result[0] == expected[0]
    assert result[1] == expected[1]
示例#5
0
def test_order_points():
    # type: () -> None
    polygon = Polygon3D([(0, 0, 0), (0, 1, 1), (1, 1, 1), (1, 0, 0)])
    starting_position = "upperleftcorner"
    expected = Polygon3D([(1, 1, 1), (1, 0, 0), (0, 0, 0), (0, 1, 1)])
    result = polygon.order_points(starting_position)
    assert result == expected
    assert result[0] == expected[0]

    starting_position = "lowerleftcorner"
    expected = Polygon3D([(1, 0, 0), (0, 0, 0), (0, 1, 1), (1, 1, 1)])
    result = polygon.order_points(starting_position)
    assert result == expected
    assert result[0] == expected[0]

    starting_position = "lowerrightcorner"
    expected = Polygon3D([(0, 0, 0), (0, 1, 1), (1, 1, 1), (1, 0, 0)])
    result = polygon.order_points(starting_position)
    assert result == expected
    assert result[0] == expected[0]

    starting_position = "upperrightcorner"
    expected = Polygon3D([(0, 1, 1), (1, 1, 1), (1, 0, 0), (0, 0, 0)])
    result = polygon.order_points(starting_position)
    assert result == expected
    assert result[0] == expected[0]
示例#6
0
def test_union_3D_polys_single():
    # type: () -> None
    """Simplest test for union_3D_polys
    
    This has two squares in the horizontal plane which overlap in one place.
    Fails if the expected union shape is not returned.
    
    """
    # surface is already a flat plane with z == 0
    s1 = Polygon3D([(0, 2, 0), (2, 2, 0), (2, 0, 0), (0, 0, 0)])  # clockwise
    s2 = Polygon3D([(1, 3, 0), (3, 3, 0), (3, 1, 0), (1, 1, 0)])  # clockwise
    expected = [
        Polygon3D([
            (0, 0, 0),
            (0, 2, 0),
            (1, 2, 0),
            (1, 3, 0),
            (3, 3, 0),
            (3, 1, 0),
            (2, 1, 0),
            (2, 0, 0),
        ])
    ]  # clockwise

    result = s1.union(s2)
    for res, exp in zip(result, expected):
        assert res == exp

    result = s2.union(s1)
    for res, exp in zip(result, expected):
        assert res == exp
示例#7
0
        def avg(zone: eppy.bunch_subclass.EpBunch):
            """calculate the zone centroid coordinates"""
            x_, y_, z_, dem = 0, 0, 0, 0
            from geomeppy.geom.polygons import Polygon3D, Vector3D
            from geomeppy.recipes import translate_coords

            ggr = zone.theidf.idfobjects["GLOBALGEOMETRYRULES"][0]

            for surface in zone.zonesurfaces:
                if surface.key.upper() in ["INTERNALMASS", "WINDOWSHADINGCONTROL"]:
                    pass
                else:
                    dem += 1  # Counter for average calc at return
                    if ggr.Coordinate_System.lower() == "relative":
                        # add zone origin to surface coordinates and create
                        # Polygon3D from updated coords.
                        zone = zone.theidf.getobject("ZONE", surface.Zone_Name)
                        poly3d = Polygon3D(surface.coords)
                        origin = (zone.X_Origin, zone.Y_Origin, zone.Z_Origin)
                        coords = translate_coords(poly3d, Vector3D(*origin))
                        poly3d = Polygon3D(coords)
                    else:
                        # Polygon3D from surface coords
                        poly3d = Polygon3D(surface.coords)
                    x, y, z = poly3d.centroid
                    x_ += x
                    y_ += y
                    z_ += z
            return x_ / dem, y_ / dem, z_ / dem
示例#8
0
def populate_adjacencies(adjacencies, s1, s2):
    # type: (defaultdict, EpBunch, EpBunch) -> defaultdict
    """Update the adjacencies dict with any intersections between two surfaces.

    :param adjacencies: Dict to contain lists of adjacent surfaces.
    :param s1: Object representing an EnergyPlus surface.
    :param s2: Object representing an EnergyPlus surface.
    :returns: An updated dict of adjacencies.
    """
    poly1 = Polygon3D(s1.coords)
    poly2 = Polygon3D(s2.coords)
    if not almostequal(abs(poly1.distance), abs(poly2.distance), 4):
        return adjacencies
    if not almostequal(poly1.normal_vector, poly2.normal_vector, 4):
        if not almostequal(poly1.normal_vector, -poly2.normal_vector, 4):
            return adjacencies

    intersection = poly1.intersect(poly2)
    if intersection:
        new_surfaces = intersect(poly1, poly2)
        new_s1 = [
            s for s in new_surfaces
            if almostequal(s.normal_vector, poly1.normal_vector, 4)
        ]
        new_s2 = [
            s for s in new_surfaces
            if almostequal(s.normal_vector, poly2.normal_vector, 4)
        ]
        adjacencies[(s1.key, s1.Name)] += new_s1
        adjacencies[(s2.key, s2.Name)] += new_s2
    return adjacencies
示例#9
0
def test_intersect_no_overlap():
    # type: () -> None
    # surfaces don't overlap
    s1 = Polygon3D([(0, 2, 0), (2, 2, 0), (2, 0, 0), (0, 0, 0)])  # clockwise
    s2 = Polygon3D([(2, 3, 0), (3, 3, 0), (3, 1, 0), (2, 1, 0)])  # clockwise
    expected = []  # clockwise
    result = s1.intersect(s2)
    assert result == expected
示例#10
0
def populate_adjacencies(s1, s2):
    poly1 = Polygon3D(s1.coords)
    poly2 = Polygon3D(s2.coords)
    if almostequal(abs(poly1.distance), abs(poly2.distance), 3):
        if almostequal(poly1.normal_vector,
                       poly2.normal_vector, 3) or almostequal(
                           poly1.normal_vector, -poly2.normal_vector, 3):
            return True
示例#11
0
 def test_scale_idf(self, base_idf):
     # type: (IDF) -> None
     idf1 = base_idf
     idf2 = IDF()
     idf2.initreadtxt(idf1.idfstr())
     idf1.scale(10)
     idf1.scale(0.1)
     floor1 = Polygon3D(idf1.getsurfaces("floor")[0].coords).normalize_coords(None)
     floor2 = Polygon3D(idf2.getsurfaces("floor")[0].coords).normalize_coords(None)
     assert almostequal(floor1, floor2)
示例#12
0
def test_intersect():
    # type: () -> None
    poly1 = Polygon3D([(1.0, 2.1, 0.5), (1.0, 2.1, 0.0), (2.0, 2.0, 0.0),
                       (2.0, 2.0, 0.5)])
    poly2 = Polygon3D([(2.5, 1.95, 0.5), (2.5, 1.95, 0.0), (1.5, 2.05, 0.0),
                       (1.5, 2.05, 0.5)])
    intersection = poly1.intersect(poly2)[0]
    #    view_polygons({'blue': [poly1, poly2], 'red': [intersect]})
    assert not is_hole(poly1, intersection)
    assert not is_hole(poly2, intersection)
示例#13
0
def test_intersect_3D_polys_angled():
    # type: () -> None
    s1 = Polygon3D([(2.5,1.95,0.5), (2.5,1.95,0), (1.5,2.05,0), (1.5,2.05,0.5)])  # clockwise
    s2 = Polygon3D([(1,2.1,0.5), (1,2.1,0), (2,2,0), (2,2,0.5)])  # clockwise
    expected = [Polygon3D([(2.0, 2.0, 0.0), (1.5, 2.05, 0.0),
                           (1.5, 2.05, 0.5),(2.0, 2.0, 0.5)])]

    result = s1.intersect(s2)

    assert result == expected
    def test_three_overlapping(self):
        # type: () -> None
        """
         __ ___ __ __
        | 1| 1 | 3| 3|  
        |__|_2_|_2|__| 

         __ ___ __ __
        | 1| 2 | 4| 6|  
        |__|_3_|_5|__| 
        
        """
        poly1 = Polygon3D([(0, 1, 0), (0, 0, 0), (2, 0, 0), (2, 1, 0)])
        poly2 = Polygon3D([(3, 1, 0), (3, 0, 0), (1, 0, 0), (1, 1, 0)])
        poly3 = Polygon3D([(2, 1, 0), (2, 0, 0), (4, 0, 0), (4, 1, 0)])
        adjacencies = [(poly1, poly2), (poly2, poly3)]
        poly1 = Polygon3D([(0, 1, 0), (0, 0, 0), (1, 0, 0), (1, 1, 0)])
        poly2 = Polygon3D([(2, 1, 0), (2, 0, 0), (1, 0, 0), (1, 1, 0)])
        poly3 = Polygon3D([(1, 1, 0), (1, 0, 0), (2, 0, 0), (2, 1, 0)])
        poly4 = Polygon3D([(2, 1, 0), (2, 0, 0), (3, 0, 0), (3, 1, 0)])
        poly5 = Polygon3D([(3, 1, 0), (3, 0, 0), (2, 0, 0), (2, 1, 0)])
        poly6 = Polygon3D([(3, 1, 0), (3, 0, 0), (4, 0, 0), (4, 1, 0)])
        expected = [poly1, poly2, poly3, poly4, poly5, poly6]

        result = intersect(*adjacencies[0])
        result.extend(intersect(*adjacencies[1]))

        assert len(minimal_set(result)) == len(minimal_set(expected))
        for poly in expected:
            assert poly in result
    def test_align_face_transformations_trapezoid_floor(self):
        # type: () -> None
        tol = 12  # places

        testVertices = Polygon3D([(27.69, 0, 0), (0, 0, 0), (5, 5, 0),
                                  (22.69, 5, 0)])
        t = Transformation()._align_face(testVertices)
        tempVertices = t._inverse() * testVertices
        expectedVertices = Polygon3D([(0, 0, 0), (27.69, 0, 0), (22.69, 5, 0),
                                      (5, 5, 0)])
        assert almostequal(tempVertices, expectedVertices, tol)
def test_intersect():
    # type: () -> None
    poly1 = Polygon3D(
        [(1.0, 2.1, 0.5), (1.0, 2.1, 0.0), (2.0, 2.0, 0.0), (2.0, 2.0, 0.5)]
    )
    poly2 = Polygon3D(
        [(2.5, 1.95, 0.5), (2.5, 1.95, 0.0), (1.5, 2.05, 0.0), (1.5, 2.05, 0.5)]
    )
    intersection = poly1.intersect(poly2)[0]
    assert not is_hole(poly1, intersection)
    assert not is_hole(poly2, intersection)
示例#17
0
def test_unique():
    # type: () -> None
    poly1 = Polygon3D([(0, 1, 0), (0, 0, 0), (1, 0, 0), (1, 1, 0)])
    poly2 = Polygon3D([(1, 1, 0), (1, 0, 0), (0, 0, 0), (0, 1, 0)])
    poly3 = Polygon3D([(0, 1, 0), (1, 1, 0), (1, 0, 0), (0, 0, 0)])
    assert poly1 != poly2
    assert poly2 == poly3
    polys = [poly1, poly2, poly3]
    unique_polys = unique(polys)
    assert len(unique_polys) == 2
    for poly in polys:
        assert poly in unique_polys
示例#18
0
 def test_rotate_idf_360(self, base_idf):
     # type: (IDF) -> None
     idf1 = base_idf
     idf2 = IDF()
     idf2.initreadtxt(idf1.idfstr())
     idf1.rotate(360)
     floor1 = Polygon3D(idf1.getsurfaces("floor")[0].coords).normalize_coords(None)
     floor2 = Polygon3D(idf2.getsurfaces("floor")[0].coords).normalize_coords(None)
     assert almostequal(floor1, floor2)
     shade1 = Polygon3D(idf1.getshadingsurfaces()[0].coords).normalize_coords(None)
     shade2 = Polygon3D(idf1.getshadingsurfaces()[0].coords).normalize_coords(None)
     assert almostequal(shade1, shade2)
示例#19
0
def test_break_polygons():
    # type: () -> None
    poly = Polygon3D([(0,4,0),(0,0,0),(4,0,0),(4,4,0)])
    hole = Polygon3D([(1,3,0),(1.5,2,0),(1,1,0),(3,1,0),(3,3,0)])
    expected = [
        Polygon3D([(0,4,0),(0,0,0),(1,1,0),(1.5,2,0),(1,3,0)]),
        Polygon3D([(4,4,0),(0,4,0),(1,3,0),(3,3,0),(3,1,0),(1,1,0),(0,0,0),(4,0,0)])
        ]

    result = break_polygons(poly, hole)
    
    assert result[0] == expected[0]
    assert result[1] == expected[1]
示例#20
0
    def test_double_overlap(self):
        # type: () -> None
        """
         __________
        |__1_______| 
        | 1 | 2 |1 |
        |_2_|   |2_|
        |__________|
        
         __________
        |__1________| 
        | 2 | 4 | 5 |
        |_3_|   |_6_|
        |___________|
        
        """
        poly1 = Polygon3D([(0, 2, 0), (0, 0, 0), (3, 0, 0), (3, 2, 0)])
        poly2 = Polygon3D([(3, 3, 0), (3, 1, 0), (2, 1, 0), (2, 2, 0),
                           (1, 2, 0), (1, 1, 0), (0, 1, 0), (0, 3, 0)])
        adjacencies = [(poly1, poly2)]

        poly1 = Polygon3D([(3, 3, 0), (3, 2, 0), (0, 2, 0), (0, 3, 0)])
        poly2 = Polygon3D([(0, 2, 0), (0, 1, 0), (1, 1, 0), (1, 2, 0)])
        poly3 = Polygon3D([(1, 2, 0), (1, 1, 0), (0, 1, 0), (0, 2, 0)])
        poly4 = Polygon3D([(1, 2, 0), (1, 1, 0), (0, 1, 0), (0, 0, 0),
                           (3, 0, 0), (3, 1, 0), (2, 1, 0), (2, 2, 0)])
        poly5 = Polygon3D([(2, 2, 0), (2, 1, 0), (3, 1, 0), (3, 2, 0)])
        poly6 = Polygon3D([(3, 2, 0), (3, 1, 0), (2, 1, 0), (2, 2, 0)])

        result = intersect(*adjacencies[0])
        expected = [poly1, poly2, poly3, poly4, poly5, poly6]
        assert len(result) == len(expected)
        assert len(result) == len(expected)
        for poly in expected:
            assert poly in result
def test_is_hole():
    # type: () -> None
    """Test if a surface represents a hole in one of the surfaces.
    """
    # opposite faces (all touching edges)
    poly1 = Polygon3D([(0, 4, 0), (0, 0, 0), (4, 0, 0), (4, 4, 0)])
    poly2 = Polygon3D(reversed([(0, 4, 0), (0, 0, 0), (4, 0, 0), (4, 4, 0)]))
    intersection = poly1.intersect(poly2)[0]
    assert not is_hole(poly1, intersection)
    assert not is_hole(poly2, intersection)

    # poly2 is within poly1 and reversed (no touching edges)
    poly1 = Polygon3D([(0, 4, 0), (0, 0, 0), (4, 0, 0), (4, 4, 0)])
    poly2 = Polygon3D(reversed([(1, 3, 0), (1, 1, 0), (3, 1, 0), (3, 3, 0)]))
    intersection = poly1.intersect(poly2)[0]
    assert is_hole(poly1, intersection)
    assert not is_hole(poly2, intersection)

    # poly2 is within poly1 and reversed (touches at x=0)
    poly1 = Polygon3D([(0, 4, 0), (0, 0, 0), (4, 0, 0), (4, 4, 0)])
    poly2 = Polygon3D(reversed([(0, 3, 0), (0, 1, 0), (3, 1, 0), (3, 3, 0)]))
    intersection = poly1.intersect(poly2)[0]
    assert not is_hole(poly1, intersection)
    assert not is_hole(poly2, intersection)

    # poly2 overlaps poly1
    poly1 = Polygon3D([(1, 4, 0), (1, 0, 0), (5, 0, 0), (5, 4, 0)])
    poly2 = Polygon3D(reversed([(0, 3, 0), (0, 1, 0), (3, 1, 0), (3, 3, 0)]))
    intersection = poly1.intersect(poly2)[0]
    assert not is_hole(poly1, intersection)
    assert not is_hole(poly2, intersection)
示例#22
0
    def test_translate_to_origin(self, base_idf):
        # type: () -> None
        idf = base_idf
        surfaces = getidfsurfaces(idf)
        translate(surfaces, (50000, 10000))  # move to x + 50, y + 100
        result = Polygon3D(surfaces[0].coords).xs
        expected = [50002.0, 50002.0, 50001.0, 50001.0]
        assert result == expected

        translate_to_origin(idf)
        surfaces = getidfsurfaces(idf)
        min_x = min(min(Polygon3D(s.coords).xs) for s in surfaces)
        min_y = min(min(Polygon3D(s.coords).ys) for s in surfaces)
        assert min_x == 0
        assert min_y == 0
示例#23
0
def test_polygons_not_equal():
    # type: () -> None
    """Test the check for equality between polygons.
    """
    # different normal vector
    poly3d = Polygon3D([(0, 0, 0), (0, 1, 1), (1, 1, 1), (1, 0, 0)])
    poly3d_2 = Polygon3D([(0, 0, 2), (0, 1, 2), (1, 1, 2), (1, 0, 2)])
    assert poly3d.normal_vector != poly3d_2.normal_vector
    assert poly3d != poly3d_2
    # different distance
    poly3d = Polygon3D([(0, 0, 0), (0, 1, 1), (1, 1, 1), (1, 0, 0)])
    poly3d_2 = Polygon3D([(0, 1, 2), (0, 2, 3), (1, 2, 3), (1, 1, 2)])
    assert poly3d.normal_vector == poly3d_2.normal_vector
    assert poly3d.distance != poly3d_2.distance
    assert poly3d != poly3d_2
示例#24
0
def test_on_poly_edge():
    # type: () -> None
    poly = Polygon3D([(0, 4, 0), (0, 0, 0), (4, 0, 0), (4, 4, 0)])
    edge1 = Segment(Vector3D(0, 1, 0), Vector3D(0, 2, 0))
    edge2 = Segment(Vector3D(1, 1, 0), Vector3D(1, 2, 0))
    assert edge1._on_poly_edge(poly)
    assert not edge2._on_poly_edge(poly)
示例#25
0
def test_identify_inner_ring_polygons():
    # type: () -> None
    geom = [(
        u"POLYGON((528318.562 186087.89,528307.65 186095.1,528303.1 186088.15,528305.59 186086.5,528299.67 186077.17,"
        u"528300.85 186075.56,528295.35 186071.9,528294.401 186072.514,528292.8 186073.55,528285.8 186069.2,"
        u"528286 186066.5,528286.45 186065.85,528285.854 186065.438,528277.752 186059.839,528275.54 186058.31,"
        u"528273.93 186066.89,528273.76 186067.81,528273.45 186069.42,528269.73 186068.72,528267.91 186078.41,"
        u"528242.51 186073.65,528242.78 186072.209,528243.49 186068.42,528252.68 186058.13,528255.36 186043.87,"
        u"528261.22 186044.97,528266.75 186016.45,528269.25 186016.95,528271 186017.3,528271.2 186016.25,"
        u"528277.85 186017.5,528277.25 186020.4,528300.75 186024.85,528301 186023.65,528307.8 186024.95,"
        u"528307.7 186025.6,528311.5 186028.5,528310.85 186029.4,528316.7 186033.3,528320.15 186035.55,"
        u"528320.7 186034.95,528324.15 186037.25,528325 186036.95,528328.75 186042.7,528327.85 186043.3,"
        u"528340.6 186063.2,528342.65 186061.8,528347.25 186068.8,528347.3 186068.9,528318.562 186087.89),"
        u"(528306.281 186071.421,528312.36 186075.46,528314.06 186078.02,528314.7 186077.6,528315.98 186076.78,"
        u"528311.35 186069.56,528320.79 186063.52,528317.54 186058.45,528318.74 186057.68,528315.04 186051.9,"
        u"528318.42 186049.74,528317.5 186048.31,528319.21 186047.21,528317.9 186045.2,528316.6 186043.15,"
        u"528302.35 186063.6,528304.4 186065.05,528301.99 186068.57,528306.281 186071.421),"
        u"(528294.9 186046.92,528296.47 186044.6,528299.04 186040.78,528298.55 186040.45,528290.62 186038.77,"
        u"528289.3 186038.48,528288.33 186043.03,528289.65 186043.28,528287.66 186052.57,528285.16 186052.04,"
        u"528284.85 186053.5,528284.1 186054.8,528286.79 186056.63,528287.12 186056.86,528286.6 186057.65,"
        u"528287.3 186058.14,528289.45 186055,528291.3 186056.25,528296.85 186048.23,528294.9 186046.92),"
        u"(528274.89 186044.69,528277.99 186045.28,528276.9 186051.08,528276.98 186051.1,528278.3 186052,"
        u"528280.4 186053.44,528280.72 186052.98,528281.04 186051.33,528278.53 186050.86,528280.42 186041.51,"
        u"528282.23 186041.86,528283.17 186037.18,528276.65 186035.8,528274.89 186044.69))",
        7.7,
    )]

    for item in geom:
        poly = Polygon3D([]).from_wkt(item[0])
示例#26
0
 def test_set_coords(self):
     # type: () -> None
     idf = self.idf
     ggr = idf.idfobjects['GLOBALGEOMETRYRULES']
     wall = idf.idfobjects['BUILDINGSURFACE:DETAILED'][0]
     poly1 = Polygon3D([(0, 1, 0), (0, 0, 0), (1, 0, 0), (1, 1, 0)])
     wall.setcoords(poly1, ggr)
示例#27
0
def test_polygon_repr():
    # type: () -> None
    s2D = Polygon2D([(0, 0), (2, 0), (2, 0), (0, 0)])  # vertical
    assert eval(repr(s2D)) == s2D

    s3D = Polygon3D([(0, 0, 0), (2, 0, 0), (2, 2, 0), (0, 2, 0)])  # vertical
    assert eval(repr(s3D)) == s3D
 def test_set_coords(self, base_idf):
     # type: (IDF) -> None
     idf = base_idf
     ggr = idf.idfobjects["GLOBALGEOMETRYRULES"]
     wall = idf.idfobjects["BUILDINGSURFACE:DETAILED"][0]
     poly1 = Polygon3D([(0, 1, 0), (0, 0, 0), (1, 0, 0), (1, 1, 0)])
     wall.setcoords(poly1, ggr)
示例#29
0
def window_vertices_given_wall(wall, wwr):
    # type: (EpBunch, float) -> Polygon3D
    """Calculate window vertices given wall vertices and glazing ratio.
    :: For each axis:
        1) Translate the axis points so that they are centred around zero
        2) Either:
            a) Multiply the z dimension by the glazing ratio to shrink it vertically
            b) Multiply the x or y dimension by 0.995 to keep inside the surface
        3) Translate the axis points back to their original positions
    :param wall: The wall to add a window on. We expect each wall to have four vertices.
    :param wwr: Window to wall ratio.
    :returns: Window vertices bounding a vertical strip midway up the surface.
    """
    vertices = wall.coords
    average_x = sum([x for x, _y, _z in vertices]) / len(vertices)
    average_y = sum([y for _x, y, _z in vertices]) / len(vertices)
    average_z = sum([z for _x, _y, z in vertices]) / len(vertices)
    # move windows in 0.5% from the edges so they can be drawn in SketchUp
    window_points = [[
        ((x - average_x) * 0.999) + average_x,
        ((y - average_y) * 0.999) + average_y,
        ((z - average_z) * wwr) + average_z,
    ] for x, y, z in vertices]

    return Polygon3D(window_points)
示例#30
0
def test_basic_shadow_matching(new_idf):
    """
    Test with all x-axis at 0

    This should avoid any issues with rounding/almost_equals.

    """
    try:
        ggr = new_idf.idfobjects["GLOBALGEOMETRYRULES"][0]
    except IndexError:
        ggr = None
    wall = new_idf.newidfobject("BUILDINGSURFACE:DETAILED",
                                Name="A Wall",
                                Surface_Type="wall")

    set_coords(wall, [(0, 0, 0), (0, 1, 0), (0, 1, 1), (0, 0, 1)], ggr)
    shadow = new_idf.newidfobject("SHADING:SITE:DETAILED", Name="A Shadow")
    set_coords(shadow, [(0, 0, 2), (0, 2, 2), (0, 2, 0), (0, 0, 0)], ggr)
    new_idf.intersect_match()
    # new_idf.view_model()
    walls = [
        Polygon3D(w.coords) for w in new_idf.getsurfaces("wall")
        if w.Outside_Boundary_Condition == "adiabatic"
    ]
    expected_adiabatic = 1
    assert len(walls) == expected_adiabatic