diff --git a/cpp/open3d/t/geometry/TriangleMesh.h b/cpp/open3d/t/geometry/TriangleMesh.h index 6dd228aab3e..2b324751004 100644 --- a/cpp/open3d/t/geometry/TriangleMesh.h +++ b/cpp/open3d/t/geometry/TriangleMesh.h @@ -598,7 +598,7 @@ class TriangleMesh : public Geometry, public DrawableGeometry { const core::Device &device = core::Device("CPU:0")); /// Create a mesh from a 3D scalar field (volume) by computing the - /// isosurface. This method uses the Flying Edges dual contouring method + /// isosurface. This method uses the Flying Edges dual contouring method /// that computes the isosurface similar to Marching Cubes. The center of /// the first voxel of the volume is at the origin (0,0,0). The center of /// the voxel at index [z,y,x] will be at (x,y,z). diff --git a/cpp/pybind/t/geometry/trianglemesh.cpp b/cpp/pybind/t/geometry/trianglemesh.cpp index e0c108f04a0..b6a27b0a102 100644 --- a/cpp/pybind/t/geometry/trianglemesh.cpp +++ b/cpp/pybind/t/geometry/trianglemesh.cpp @@ -586,11 +586,30 @@ This example shows how to create a sphere from a volume:: import open3d as o3d import numpy as np - coords = np.stack(np.meshgrid(*3*[np.linspace(-1,1,num=64)], indexing='ij'), axis=-1) - vol = np.linalg.norm(coords, axis=-1) - 0.5 + grid_coords = np.stack(np.meshgrid(*3*[np.linspace(-1,1,num=64)], indexing='ij'), axis=-1) + vol = 0.5 - np.linalg.norm(grid_coords, axis=-1) mesh = o3d.t.geometry.TriangleMesh.create_isosurfaces(vol) o3d.visualization.draw(mesh) + +This example shows how to convert a mesh to a signed distance field (SDF) and back to a mesh:: + + import open3d as o3d + import numpy as np + + mesh1 = o3d.t.geometry.TriangleMesh.create_torus() + grid_coords = np.stack(np.meshgrid(*3*[np.linspace(-2,2,num=64, dtype=np.float32)], indexing='ij'), axis=-1) + + scene = o3d.t.geometry.RaycastingScene() + scene.add_triangles(mesh1) + sdf = scene.compute_signed_distance(grid_coords) + mesh2 = o3d.t.geometry.TriangleMesh.create_isosurfaces(sdf) + + # Flip the triangle orientation for SDFs with negative values as "inside" and positive values as "outside" + mesh2.triangle.indices = mesh2.triangle.indices[:,[2,1,0]] + + o3d.visualization.draw(mesh2) + )"); triangle_mesh.def(