Esempio n. 1
0
def mesh_draw_vertices(mesh,
                       keys=None,
                       color=None):
    """Draw a selection of vertices of the mesh.

    Parameters
    ----------
    mesh : :class:`compas.datastructures.Mesh`
        A mesh object.
    keys : list (None)
        A list of vertex keys identifying which vertices to draw.
        Default is to draw all vertices.
    color : str, tuple, dict (None)
        The color specififcation for the vertices.
        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 vertices, 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.

    Notes
    -----
    The vertices are named using the following template: ``"{mesh.name}.vertex.{id}"``.
    This name can be used afterwards to identify vertices of the mesh in the Rhino model.

    Examples
    --------
    >>>

    """
    artist = MeshArtist(mesh)
    return artist.draw_vertices(keys, color)
Esempio n. 2
0
from compas.datastructures import Mesh
from compas.datastructures import mesh_subdivide

from compas_ghpython.artists import MeshArtist

# make a control mesh
mesh = Mesh.from_polyhedron(6)

# set default vertex attributes
mesh.update_default_vertex_attributes({'is_fixed': False})

# make an artist for drawing
artist = MeshArtist(mesh)

# draw the control mesh into outputs P, L
P = artist.draw_vertices()
L = artist.draw_edges()

# keep some of the vertices fixed and make a subd mesh (using catmullclark)
for key, value in zip(range(len(is_fixed)), is_fixed):
    mesh.set_vertex_attribute(key, 'is_fixed', value)

fixed = mesh.vertices_where({'is_fixed': True})
subd = mesh_subdivide(mesh, scheme='catmullclark', k=k, fixed=fixed)

# pass the new mesh to the artist
artist.mesh = subd

# draw the result into output M
M = artist.draw_mesh()