Beispiel #1
0
def plot_grid_3d(g, ax, **kwargs):
    faces_cells, cells, _ = sps.find(g.cell_faces)
    nodes_faces, faces, _ = sps.find(g.face_nodes)

    cell_value = np.zeros(g.num_cells)
    rgb = kwargs.get('rgb', [1, 0, 0])
    alpha = kwargs.get('alpha', 1)

    def color_face(value):
        return np.r_[rgb, alpha]

    for c in np.arange(g.num_cells):
        loc_c = slice(g.cell_faces.indptr[c], g.cell_faces.indptr[c + 1])
        fs = faces_cells[loc_c]
        for f in fs:
            loc_f = slice(g.face_nodes.indptr[f], g.face_nodes.indptr[f + 1])
            ptsId = nodes_faces[loc_f]
            mask = sort_points.sort_point_plane( g.nodes[:, ptsId], \
                                                 g.face_centers[:, f], \
                                                 g.face_normals[:, f] )
            pts = g.nodes[:, ptsId[mask]]
            linewidth = kwargs.get('linewidth', 1)
            poly = Poly3DCollection([pts.T], linewidth=linewidth)
            poly.set_edgecolor('k')
            poly.set_facecolors(color_face(cell_value[c]))
            ax.add_collection3d(poly)
Beispiel #2
0
 def test_points_to_be_rotated(self):
     p = np.array([[0, 1, 0, 1], [0, 0, 1, 1], [0, 1, 0, 1]])
     center = np.array([[0.5], [0.5], [0]])
     sp = sort_points.sort_point_plane(p, center)
     known_ordering = np.array([0, 1, 3, 2])
     self.assertTrue(test_utils.compare_arrays(sp, known_ordering))