Esempio n. 1
0
    def display(self):
        polygons = []
        for fkey in self.mesh.faces():
            points = self.mesh.face_coordinates(fkey)
            color_front = self.mesh.get_face_attribute(fkey, 'color',
                                                       (0.8, 0.8, 0.8, 1.0))
            color_back = (0.2, 0.2, 0.2, 1.0)
            polygons.append({
                'points': points,
                'color.front': color_front,
                'color.back': color_back
            })

        lines = []
        for u, v in self.mesh.edges():
            lines.append({
                'start': self.mesh.vertex_coordinates(u),
                'end': self.mesh.vertex_coordinates(v),
                'color': (0.1, 0.1, 0.1),
                'width': 1.
            })

        points = []
        for key in self.mesh.vertices():
            points.append({
                'pos': self.mesh.vertex_coordinates(key),
                'color': (0.4, 0.4, 0.4),
                'size': 5.0
            })

        xdraw_polygons(polygons)
        xdraw_lines(lines)
        xdraw_points(points)
Esempio n. 2
0
    def display(self):
        xyz = {
            key: self.mesh.vertex_coordinates(key)
            for key in self.mesh.vertices()
        }

        lines = []
        for u, v in self.mesh.wireframe():
            lines.append({
                'start': xyz[u],
                'end': xyz[v],
                'color': (0.1, 0.1, 0.1),
                'width': 1.
            })

        points = []
        for key in self.mesh.vertices():
            points.append({
                'pos': xyz[key],
                'color': (0.0, 1.0, 0.0),
                'size': 10.0
            })

        xdraw_lines(lines)
        xdraw_points(points)

        if self.subd:
            xyz = {
                key: self.subd.vertex_coordinates(key)
                for key in self.subd.vertices()
            }
            front = (0.7, 0.7, 0.7, 1.0)
            back = (0.2, 0.2, 0.2, 1.0)

            poly = []
            for fkey in self.subd.faces():
                poly.append({
                    'points': self.subd.face_coordinates(fkey),
                    'color.front': front,
                    'color.back': back
                })

            lines = []
            for u, v in self.subd.wireframe():
                lines.append({
                    'start': xyz[u],
                    'end': xyz[v],
                    'color': (0.1, 0.1, 0.1),
                    'width': 1.
                })

            xdraw_polygons(poly)
            xdraw_lines(lines)
 def display(self):
     points = []
     vcolor = self.network.attributes['color.vertex']
     vcolor = vcolor or self.default_vertexcolor
     vcolor = color_to_rgb(vcolor, True)
     for key, attr in self.network.vertices(True):
         points.append({
             'pos': (attr['x'], attr['y'], attr['z']),
             'size': 6.0,
             'color': vcolor,
         })
     lines = []
     ecolor = self.network.attributes['color.vertex']
     ecolor = ecolor or self.default_edgecolor
     ecolor = color_to_rgb(ecolor, True)
     for u, v in self.network.edges():
         lines.append({
             'start': self.network.vertex_coordinates(u),
             'end': self.network.vertex_coordinates(v),
             'color': ecolor,
             'width': 1.0
         })
     # loads = []
     # for key, attr in self.network.vertices(True):
     #     if attr['is_fixed']:
     #         continue
     #     if 'p' in attr:
     #         p = attr['p']
     #         l = sqrt(p[0] ** 2 + p[1] ** 2 + p[2] ** 2)
     #         if l:
     #             start = self.network.vertex_coordinates(key)
     #             end   = [start[i] + p[i] for i in range(3)]
     #             loads.append({
     #                 'start': start,
     #                 'end'  : end,
     #                 'color': (0, 1.0, 0),
     #                 'width': 3.0
     #             })
     xdraw_points(points)
     xdraw_lines(lines)
Esempio n. 4
0
 def display(self):
     points = []
     vcolor = self.network.attributes['color.vertex']
     vcolor = vcolor or self.default_vertexcolor
     vcolor = color_to_rgb(vcolor, True)
     for key, attr in self.network.vertices(True):
         points.append({
             'pos': (attr['x'], attr['y'], attr['z']),
             'size': 6.,
             'color': vcolor,
         })
     lines = []
     ecolor = self.network.attributes['color.vertex']
     ecolor = ecolor or self.default_edgecolor
     ecolor = color_to_rgb(ecolor, True)
     for u, v in self.network.edges():
         lines.append({
             'start': self.network.vertex_coordinates(u),
             'end': self.network.vertex_coordinates(v),
             'color': ecolor,
             'width': 1.
         })
     xdraw_points(points)
     xdraw_lines(lines)
Esempio n. 5
0
 def draw_plane():
     xdraw_points(points)
     xdraw_lines(lines)