Exemple #1
0
    def from_lines(cls, lines, delete_boundary_face=True, precision=None):
        """Construct a FormDiagram from a list of lines described by start and end point coordinates.

        Parameters
        ----------
        lines : list
            A list of pairs of point coordinates.
        precision: str, optional
            The precision of the geometric map that is used to connect the lines.

        Returns
        -------
        FormDiagram
            A Formdiagram object.

        Examples
        --------
        .. code-block:: python

            from compas_tna.diagrams import FormDiagram

            form = FormDiagram.from_lines(lines)

        """
        from compas.topology import network_find_faces
        from compas.datastructures import Network
        network = Network.from_lines(lines, precision=precision)
        mesh = cls()
        for key, attr in network.vertices(True):
            mesh.add_vertex(key, x=attr['x'], y=attr['y'], z=0.0)
        mesh.halfedge = network.halfedge
        network_find_faces(mesh)
        if delete_boundary_face:
            mesh.delete_face(0)
        return mesh
Exemple #2
0
# ==============================================================================
# Main
# ==============================================================================

if __name__ == '__main__':

    import compas

    from compas.datastructures import FaceNetwork
    from compas.topology import network_find_faces
    from compas.plotters import FaceNetworkPlotter

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

    network_find_faces(network, breakpoints=network.leaves())

    plotter = FaceNetworkPlotter(network, figsize=(10, 7))

    plotter.defaults['vertex.fontsize'] = 8.0

    plotter.draw_vertices(
        facecolor={key: '#ff0000' for key in network.leaves()},
        radius=0.2,
        text={key: key for key in network.vertices()}
    )

    plotter.draw_faces(text={key: str(key) for key in network.faces()}, facecolor='#eeeeee', edgecolor='#eeeeee')
    plotter.draw_edges(color={uv: '#ff0000' for uv in network.edges_on_boundary()})

    plotter.show()