예제 #1
0
    def test_outside(self):
        mesh = self.load_mesh("tet.msh");
        x = np.linspace(-1.0, 1.0, 10);
        y = np.linspace(-1.0, 1.0, 10);
        z = np.linspace(-1.0, 1.0, 10);
        x_coord, y_coord, z_coord = np.meshgrid(x, y, z);
        points = np.array([x_coord.ravel(), y_coord.ravel(), z_coord.ravel()]).T;

        p_locator = PyMeshUtils.PointLocator(mesh);
        self.assertRaises(RuntimeError, p_locator.locate, points);
예제 #2
0
    def test_2D(self):
        mesh = self.load_mesh("square_2D.obj");
        x = np.linspace(-1.0, 1.0, 10);
        y = np.linspace(-1.0, 1.0, 10);
        x_coord, y_coord = np.meshgrid(x, y);
        points = np.array([x_coord.ravel(), y_coord.ravel()]).T;

        p_locator = PyMeshUtils.PointLocator(mesh);
        p_locator.locate(points);

        elem_indices = p_locator.get_enclosing_voxels().ravel();
        barycentric_coords = p_locator.get_barycentric_coords();

        self.assert_barycentric_coords_are_valid(mesh, elem_indices,
                barycentric_coords, points);