Esempio n. 1
0
    def draw_vertices(self, vertices=None, color=None):
        """Draw a selection of vertices.

        Parameters
        ----------
        vertices : list[int], optional
            A selection of vertices to draw.
            Default is None, in which case all vertices are drawn.
        color : tuple[int, int, int] or dict[int, tuple[int, int, int]], optional
            The color specification for the vertices.
            The default is the value of :attr:`MeshArtist.default_vertexcolor`.

        Returns
        -------
        list[:rhino:`Rhino.Geometry.Point3d`]

        """
        self.vertex_color = color
        vertices = vertices or list(self.mesh.vertices())
        vertex_xyz = self.vertex_xyz
        points = []
        for vertex in vertices:
            points.append({
                'pos':
                vertex_xyz[vertex],
                'name':
                "{}.vertex.{}".format(self.mesh.name, vertex),
                'color':
                self.vertex_color.get(vertex, self.default_vertexcolor)
            })
        return compas_ghpython.draw_points(points)
Esempio n. 2
0
    def draw_origin(self):
        """Draw the frame's origin.

        Returns
        -------
        :class:`Rhino.Geometry.Point`
        """
        point, _ = self._get_args(self.primitive, self.scale,
                                  self.color_origin, self.color_xaxis,
                                  self.color_yaxis, self.color_zaxis)
        return compas_ghpython.draw_points([point])[0]
Esempio n. 3
0
    def draw(self, point=None, show_point=False):
        """Draw the vector.

        Parameters
        ----------
        point : [float, float, float] or :class:`compas.geometry.Point`, optional
            Point of application of the vector.
            Default is ``Point(0, 0, 0)``.
        show_point : bool, optional
            If True, draw the point of application of the vector.

        Returns
        -------
        list[:rhino:`Rhino.Geometry.Point3d`, :rhino:`Rhino.Geometry.Line`]
            The Rhino line and endpoints, if requested.

        """
        if not point:
            point = [0, 0, 0]
        start = Point(*point)
        end = start + self.primitive
        start = list(start)
        end = list(end)
        result = []
        if show_point:
            points = [{
                'pos': start,
                'color': self.color,
                'name': self.primitive.name
            }]
            result += compas_ghpython.draw_points(points)
        lines = [{
            'start': start,
            'end': end,
            'arrow': 'end',
            'color': self.color,
            'name': self.primitive.name
        }]
        result += compas_ghpython.draw_lines(lines)
        return result