Ejemplo n.º 1
0
def volmesh_draw_edges(volmesh,
                       keys=None,
                       color=None,
                       layer=None,
                       clear_layer=False,
                       redraw=True):
    """Draw the edges of a volmesh.

    Parameters
    ----------
    volmesh : compas.datastructures.VolMesh
        A volmesh object.
    keys : list (None)
        A list of edge keys identifying which edges to draw.
        Default is to draw all edges.
    color : str, tuple, dict (None)
        The color specififcation for the edges.
        Colors should be specified in the form of a string (hex colors) or as a tuple of RGB components.
        To apply the same color to all edges, provide a single color specification.
        Individual colors can be assigned using a dictionary of key-color pairs.
        Missing keys will be assigned the default vertex color (``self.defaults['vertex.color']``).
        Default is use the color of the parent layer.
    layer : str (None)
        The layer in which the edges are drawn.
        Default is to draw in the current layer.
    clear_layer : bool (False)
        Clear the drawing layer.
    redraw : bool (True)
        Redraw the view after adding the edges.

    Examples
    --------
    >>> volmesh_draw_edges(volmesh)
    >>> volmesh_draw_edges(volmesh, keys=volmesh.edges_on_boundary())
    >>> volmesh_draw_edges(volmesh, color='#00ff00')
    >>> color = {key: (('#ff0000') if volmesh.vertex_is_on_boundary(key) else ('#00ff00')) for key in volmesh.edges()}
    >>> volmesh_draw_edges(volmesh, color=color)

    See Also
    --------
    * compas_rhino.helpers.VolMeshArtist

    """
    artist = VolMeshArtist(volmesh)
    artist.layer = layer
    if clear_layer:
        artist.clear_layer()
    artist.clear_edges()
    artist.draw_edges(color=color)
    if redraw:
        artist.redraw()
Ejemplo n.º 2
0
def volmesh_draw(volmesh,
                 layer=None,
                 clear_layer=False,
                 vertexcolor=None,
                 edgecolor=None,
                 facecolor=None):
    """Draw a volmesh.

    Parameters
    ----------
    volmesh : compas.datastructures.VolMesh
        A volmesh object.
    layer : str (None)
        The layer to draw in.
        Default is to draw in the current layer.
    clear_layer : bool (False)
        Clear the current layer.
    vertexcolor : str, tuple, list, dict (None)
        The vertex color specification.
        Default is to use the color of the parent layer.
    edgecolor : str, tuple, list, dict (None)
        The edge color specification.
        Default is to use the color of the parent layer.
    facecolor : str, tuple, list, dict (None)
        The face color specification.
        Default is to use the color of the parent layer.

    Examples
    --------
    >>> volmesh_draw(volmesh)
    >>> volmesh_draw(volmesh, layer='SomeLayer')
    >>> volmesh_draw(volmesh, clear_layer=True)
    >>> volmesh_draw(volmesh, vertexcolor='#ff0000')
    >>> volmesh_draw(volmesh, edgecolor=(0, 255, 0))
    >>> volmesh_draw(volmesh, facecolor={key: (0.0, 0.0, 0.5) for key in volmesh.faces()})

    See Also
    --------
    * compas_rhino.helpers.VolMeshArtist

    """
    artist = VolMeshArtist(volmesh)
    artist.layer = layer
    if clear_layer:
        artist.clear_layer()
    artist.clear()
    artist.draw_vertices(color=vertexcolor)
    artist.draw_edges(color=edgecolor)
    artist.draw_faces(color=facecolor)
    artist.redraw()
Ejemplo n.º 3
0
if __name__ == "__main__":

    import compas

    from compas.datastructures import VolMesh
    from compas_rhino.helpers.artists.volmeshartist import VolMeshArtist

    volmesh = VolMesh.from_obj(compas.get('boxes.obj'))

    artist = VolMeshArtist(volmesh, layer='VolMeshArtist')

    artist.clear_layer()

    artist.draw_vertices()
    artist.redraw(0.0)

    artist.draw_vertexlabels()
    artist.redraw(1.0)

    artist.draw_faces()
    artist.redraw(1.0)

    artist.draw_facelabels()
    artist.redraw(1.0)

    artist.draw_edges()
    artist.redraw(1.0)

    artist.draw_edgelabels()
    artist.redraw(1.0)