Esempio n. 1
0
def test_planar(k5_network):
    if compas.IPY:
        return

    from compas.datastructures import network_is_planar

    k5_network.delete_edge('a', 'b')  # Delete (a, b) edge to make K5 planar
    assert network_is_planar(k5_network) is True
Esempio n. 2
0
def test_non_planar(k5_network):
    try:
        import planarity  # noqa: F401
    except ImportError:
        return

    from compas.datastructures import network_is_planar
    assert network_is_planar(k5_network) is not True
Esempio n. 3
0
def test_planar(k5_network):
    try:
        import planarity  # noqa: F401
    except ImportError:
        return

    from compas.datastructures import network_is_planar

    k5_network.delete_edge('a', 'b')  # Delete (a, b) edge to make K5 planar
    assert network_is_planar(k5_network) is True
Esempio n. 4
0
def network_is_planar_embedding(network):
    """Verify that a network is embedded in the plane without crossing edges.

    Parameters
    ----------
    network : Network
        A network object.

    Returns
    -------
    bool
        True if the network is embedded in the plane without crossing edges.
        Fase otherwise.

    """
    return (network_is_planar(network) and network_is_xy(network)
            and not network_is_crossed(network))
Esempio n. 5
0
def test_planar(k5_network):
    k5_network.delete_edge('a', 'b')  # Delete (a, b) edge to make K5 planar
    assert network_is_planar(k5_network) is True
Esempio n. 6
0
def test_non_planar(k5_network):
    assert network_is_planar(k5_network) is not True
Esempio n. 7
0
 def is_planar(self, data):
     network = Network.from_data(data)
     return network_is_planar(network)
Esempio n. 8
0
def test_non_planar(k5_network):
    if compas.IPY:
        return

    from compas.datastructures import network_is_planar
    assert network_is_planar(k5_network) is not True
Esempio n. 9
0
# ==============================================================================

if __name__ == '__main__':

    import compas

    from compas.datastructures import Network
    from compas.datastructures import network_is_planar
    from compas.datastructures import network_find_crossings
    from compas.plotters import NetworkPlotter

    network = Network.from_obj(compas.get('lines.obj'))

    network.add_edge(6, 15)

    if not network_is_planar(network):
        crossings = network_find_crossings(network)
    else:
        crossings = []

    print(crossings)

    plotter = NetworkPlotter(network)

    plotter.draw_vertices(radius=0.15,
                          text={key: key
                                for key in network.vertices()})
    plotter.draw_edges(
        color={edge: '#ff0000'
               for edges in crossings for edge in edges})