# Path: geomeppy/geom/surfaces.py
# def get_adjacencies(surfaces):
#     # type: (Idf_MSequence) -> defaultdict
#     """Create a dictionary mapping surfaces to their adjacent surfaces.
# 
#     :param surfaces: A mutable list of surfaces.
#     :returns: Mapping of surfaces to adjacent surfaces.
#     """
#     adjacencies = defaultdict(list)  # type: defaultdict
#     # find all adjacent surfaces
#     for s1, s2 in combinations(surfaces, 2):
#         adjacencies = populate_adjacencies(adjacencies, s1, s2)
#     for adjacency, polys in adjacencies.items():
#         adjacencies[adjacency] = minimal_set(polys)
#     return adjacencies
# 
# Path: geomeppy/geom/surfaces.py
# def set_coords(
#     surface,  # type: EpBunch
#     coords,
#     # type: Union[List[Vector3D], List[Tuple[float, float, float]], Polygon3D]
#     ggr,  # type: Union[List, None, Idf_MSequence]
# ):
#     # type: (...) -> None
#     """Update the coordinates of a surface.
# 
#     :param surface: The surface to modify.
#     :param coords: The new coordinates as lists of [x,y,z] lists.
#     :param ggr: Global geometry rules.
#     """
#     coords = list(coords)
#     deduped = [c for i, c in enumerate(coords) if c != coords[(i + 1) % len(coords)]]
#     poly = Polygon3D(deduped)
#     poly = poly.normalize_coords(ggr)
#     coords = [i for vertex in poly for i in vertex]
#     if len(coords) > 120:
#         warnings.warn(
#             "To create surfaces with >120 vertices, ensure you have customised your IDD before running EnergyPlus. "
#             "https://unmethours.com/question/9343/energy-idf-parsing-error/?answer=9344#post-id-9344"
#         )
#     # find the vertex fields
#     n_vertices_index = surface.objls.index("Number_of_Vertices")
#     first_x = n_vertices_index + 1  # X of first coordinate
#     surface.obj = surface.obj[:first_x]
#     # set the vertex field values
#     surface.fieldvalues.extend(coords)


import pytest
from geomeppy.geom.surfaces import get_adjacencies
from geomeppy.geom.surfaces import set_coords
        },
        {
            "name": "PN1001_Bld1003 Zone4",
            "coordinates": [
                (-83616.24896021019, -100960.96199999936),
                (-83619.72295787116, -100976.95590000041),
                (-83636.55229433342, -100976.95590000041),
                (-83636.50970000029, -100976.35019999929),
                (-83635.42752116646, -100960.96199999936),
                (-83616.24896021019, -100960.96199999936),
            ],
            "height": 3.0,
            "num_stories": 1,
        },
    ]
    return {"zones": zones, "shadows": shadow_blocks}


def _test_adjacencies(new_idf, shadow_intersecting):
    """Test in a single plane, but angled."""
    try:
        ggr = new_idf.idfobjects["GLOBALGEOMETRYRULES"][0]
    except IndexError:
        ggr = None
    for block in shadow_intersecting["shadows"]:
        new_idf.add_shading_block(**block)
    for block in shadow_intersecting["zones"]:
        new_idf.add_block(**block)
    new_idf.translate_to_origin()
    # new_idf.view_model()

# Path: geomeppy/geom/surfaces.py
# def get_adjacencies(surfaces):
#     # type: (Idf_MSequence) -> defaultdict
#     """Create a dictionary mapping surfaces to their adjacent surfaces.
# 
#     :param surfaces: A mutable list of surfaces.
#     :returns: Mapping of surfaces to adjacent surfaces.
#     """
#     adjacencies = defaultdict(list)  # type: defaultdict
#     # find all adjacent surfaces
#     for s1, s2 in combinations(surfaces, 2):
#         adjacencies = populate_adjacencies(adjacencies, s1, s2)
#     for adjacency, polys in adjacencies.items():
#         adjacencies[adjacency] = minimal_set(polys)
#     return adjacencies
# 
# Path: geomeppy/geom/surfaces.py
# def set_coords(
#     surface,  # type: EpBunch
#     coords,
#     # type: Union[List[Vector3D], List[Tuple[float, float, float]], Polygon3D]
#     ggr,  # type: Union[List, None, Idf_MSequence]
# ):
#     # type: (...) -> None
#     """Update the coordinates of a surface.
# 
#     :param surface: The surface to modify.
#     :param coords: The new coordinates as lists of [x,y,z] lists.
#     :param ggr: Global geometry rules.
#     """
#     coords = list(coords)
#     deduped = [c for i, c in enumerate(coords) if c != coords[(i + 1) % len(coords)]]
#     poly = Polygon3D(deduped)
#     poly = poly.normalize_coords(ggr)
#     coords = [i for vertex in poly for i in vertex]
#     if len(coords) > 120:
#         warnings.warn(
#             "To create surfaces with >120 vertices, ensure you have customised your IDD before running EnergyPlus. "
#             "https://unmethours.com/question/9343/energy-idf-parsing-error/?answer=9344#post-id-9344"
#         )
#     # find the vertex fields
#     n_vertices_index = surface.objls.index("Number_of_Vertices")
#     first_x = n_vertices_index + 1  # X of first coordinate
#     surface.obj = surface.obj[:first_x]
#     # set the vertex field values
#     surface.fieldvalues.extend(coords)


# Path: tests/test_adjacencies.py
import pytest
from geomeppy.geom.surfaces import get_adjacencies
from geomeppy.geom.surfaces import set_coords

        },
        {
            "name": "PN1001_Bld1003 Zone4",
            "coordinates": [
                (-83616.24896021019, -100960.96199999936),
                (-83619.72295787116, -100976.95590000041),
                (-83636.55229433342, -100976.95590000041),
                (-83636.50970000029, -100976.35019999929),
                (-83635.42752116646, -100960.96199999936),
                (-83616.24896021019, -100960.96199999936),
            ],
            "height": 3.0,
            "num_stories": 1,
        },
    ]
    return {"zones": zones, "shadows": shadow_blocks}


def _test_adjacencies(new_idf, shadow_intersecting):
    """Test in a single plane, but angled."""
    try:
        ggr = new_idf.idfobjects["GLOBALGEOMETRYRULES"][0]
    except IndexError:
        ggr = None
    for block in shadow_intersecting["shadows"]:
        new_idf.add_shading_block(**block)
    for block in shadow_intersecting["zones"]:
        new_idf.add_block(**block)
    new_idf.translate_to_origin()
    # new_idf.view_model()

    adjacencies = get_adjacencies(new_idf.getsurfaces() + new_idf.getshadingsurfaces())