Exemplo n.º 1
0
    def display(self):
        for i in range(len(self.meshes)):
            mesh = self.meshes[i]

            polygons = []
            for fkey in mesh.faces():
                color_front = self.colors[i]
                color_back = (0.2, 0.2, 0.2, 1.0)
                polygons.append({
                    'points': mesh.face_coordinates(fkey),
                    'color.front': color_front,
                    'color.back': color_back
                })

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

            xdraw_polygons(polygons)
            xdraw_lines(lines)
Exemplo n.º 2
0
 def display(self):
     polygons = []
     for ckey in self.volmesh.cells():
         for fkey in self.volmesh.cell_halffaces(ckey):
             vkeys = self.volmesh.halfface_vertices(fkey, ordered=True)
             points = [
                 self.volmesh.vertex_coordinates(vkey) for vkey in vkeys
             ]
             color_front = (0.7, 0.7, 0.7, 1.0)
             color_back = (0.0, 0.0, 0.0, 1.0)
             polygons.append({
                 'points': points,
                 'color.front': color_front,
                 'color.back': color_back
             })
     lines = []
     for u, v in self.volmesh.edges():
         lines.append({
             'start': self.volmesh.vertex_coordinates(u),
             'end': self.volmesh.vertex_coordinates(v),
             'color': (0.1, 0.1, 0.1),
             'width': 3.
         })
     points = []
     for u in self.volmesh.vertices():
         points.append({
             'pos': self.volmesh.vertex_coordinates(u),
             'size': 10.,
             'color': (0.0, 1.0, 0.0),
         })
     xdraw_polygons(polygons)
     xdraw_lines(lines)
     xdraw_points(points)
Exemplo n.º 3
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)
Exemplo n.º 4
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
            })

        # normals = []
        # for fkey in self.mesh.faces():
        #     n  = self.mesh.face_normal(fkey, unitized=True)
        #     sp = self.mesh.face_centroid(fkey)
        #     ep = [sp[axis] + n[axis] for axis in (0, 1, 2)]
        #     normals.append({
        #         'start' : sp,
        #         'end'   : ep,
        #         'color' : (0.0, 1.0, 0.0),
        #         'width' : 2.0
        #     })

        xdraw_polygons(polygons)
        xdraw_lines(lines)
        xdraw_points(points)
Exemplo n.º 5
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.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)