Skip to content

offset_surface

offset_surface(V, F, iso, grid_size=100)

Compute the surface obtained from dilating a given mesh

Given a triangle mesh, paste signed distances onto a grid, then use Marching Cubes to obtain a new surface at a given isolevel

Parameters:

Name Type Description Default
V (n,d) numpy array

vertex list of a triangle mesh

required
F (m,3) numpy int array

face index list of a triangle mesh

required
iso double

Matrix of vertex coordinates of the second mesh

required
grid_size int, optional (default 100)

Size of the grid used to compute signed distances

100

Returns:

Name Type Description
U numpy double array

Matrix of output vertex coordinates

G numpy int array

Matrix of output triangle indices

See Also

lazy_cage.

Examples:

from gpytoolbox import read_mesh, normalize_points, offset_surface
# Read a mesh
v,f = read_mesh("test/unit_tests_data/armadillo.obj")
# Normalize the mesh
v = normalize_points(v)
u1,g1 = offset_surface(v,f,iso=0.05,grid_size=100)
Source code in src/gpytoolbox/offset_surface.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def offset_surface(V,F,iso,grid_size=100):
    """Compute the surface obtained from dilating a given mesh

    Given a triangle mesh, paste signed distances onto a grid, then use Marching Cubes to obtain a new surface at a given isolevel

    Parameters
    ----------
    V : (n,d) numpy array
        vertex list of a triangle mesh
    F : (m,3) numpy int array
        face index list of a triangle mesh
    iso : double
        Matrix of vertex coordinates of the second mesh
    grid_size : int, optional (default 100)
        Size of the grid used to compute signed distances

    Returns
    -------
    U : numpy double array
        Matrix of output vertex coordinates
    G : numpy int array
        Matrix of output triangle indices

    See Also
    --------
    lazy_cage.

    Examples
    --------
    ```python
    from gpytoolbox import read_mesh, normalize_points, offset_surface
    # Read a mesh
    v,f = read_mesh("test/unit_tests_data/armadillo.obj")
    # Normalize the mesh
    v = normalize_points(v)
    u1,g1 = offset_surface(v,f,iso=0.05,grid_size=100)
    ```
    """


    try:
        from gpytoolbox_bindings import _offset_surface_cpp_impl
    except:
        raise ImportError("Gpytoolbox cannot import its C++ binding.")

    v, f = _offset_surface_cpp_impl(V.astype(np.float64),F.astype(np.int32),iso,grid_size)

    return v,f