Fairing a noisy open surface by minimizing area (degree 1) or curvature (degree 2).
Overview
This tutorial demonstrates implicit mesh fairing with SurfaceMeshFairing. The input is a noisy hemisphere — an open surface patch whose circular boundary is kept fixed. Two fairing modes are available: minimizing surface area (degree 1) and minimizing surface curvature (degree 2). Gaussian noise is added first so the smoothing effect is visible. Fairing is the constrained cousin of smoothing: instead of denoising a closed mesh everywhere, it reconstructs a smooth patch that interpolates prescribed boundary conditions, which is exactly what hole filling and surface reconstruction need.
The technique
Fairing solves a k-harmonic equation L^k x = 0 on the interior vertices, where L is the (cotangent) Laplace-Beltrami operator and the boundary vertices are held fixed as constraints. The degree k selects which energy is minimized: k = 1 minimizes surface area (a membrane / mean-curvature flow, producing a minimal-area patch), while k = 2 minimizes the integral of squared curvature (a thin-plate / biharmonic energy, producing a smoother, curvature-continuous patch). Because the system is solved implicitly in one sparse linear solve, it is stable and the result depends only on the boundary constraints, not on a timestep. This is the implicit fairing framework of Desbrun et al., "Implicit
fairing of irregular meshes using diffusion and curvature flow" (SIGGRAPH 1999). With no vertex selection, the whole interior of the mesh is faired; locked/selected vertices act as constraints.
Easy3D API
- SurfaceMeshFairing: minimize_area() fairs with degree 1; minimize_curvature() fairs with degree 2 (both forward to fair(k)). Boundary vertices are automatically treated as fixed constraints.
- GaussianNoise::apply(mesh, sigma, true): adds noise while preserving the boundary, so the patch still meets its (fixed) rim after perturbation.
- Renderer::update(): re-extracts the rendering buffers after the vertex positions change.
- Viewer::bind_shortcut() / set_usage(): register the Ctrl shortcuts and the help text.
Running it
The hemisphere starts noisy. Press Ctrl+a to minimize surface area (degree 1), Ctrl+c to minimize surface curvature (degree 2), and Ctrl+n to add Gaussian noise again for another comparison.
27#include <easy3d/viewer/viewer.h>
28#include <easy3d/core/surface_mesh.h>
29#include <easy3d/renderer/camera.h>
30#include <easy3d/renderer/renderer.h>
31#include <easy3d/algo/surface_mesh_fairing.h>
32#include <easy3d/algo/gaussian_noise.h>
33#include <easy3d/util/resource.h>
34#include <easy3d/util/initializer.h>
90 const float sigma = mesh->bounding_box().diagonal_length() * 0.005f;
91 GaussianNoise::apply(mesh, sigma,
true);
100 mesh->renderer()->update();
112 mesh->renderer()->update();
118 bool fair_curvature(
Viewer *viewer,
Model *model) {
124 mesh->renderer()->update();
131int main(
int argc,
char **argv) {
137 const std::string file = resource::directory() +
"/data/hemisphere.ply";
140 Viewer viewer(EXAMPLE_TITLE);
141 auto mesh =
dynamic_cast<SurfaceMesh *
>(viewer.add_model(file,
true));
143 std::cerr <<
"failed to load model. Please make sure the file exists and format is correct" << std::endl;
148 viewer.camera()->set_view_direction(
vec3(0, 1, 0));
152 mesh->renderer()->update();
155 viewer.bind_shortcut([](
Viewer *v,
Model *m) {
return fair_area(v, m); }, mesh, Viewer::KEY_A, Viewer::MODIF_CTRL);
156 viewer.bind_shortcut([](
Viewer *v,
Model *m) {
return fair_curvature(v, m); }, mesh, Viewer::KEY_C, Viewer::MODIF_CTRL);
157 viewer.bind_shortcut([](
Viewer *v,
Model *m) {
return noise(v, m); }, mesh, Viewer::KEY_N, Viewer::MODIF_CTRL);
160 "Ctrl + a: minimize surface area (fairing degree 1)\n" "Ctrl + c: minimize surface curvature (fairing degree 2)\n" "Ctrl + n: add Gaussian noise again");
Base class for spatial models with optional rendering and manipulation state.
Definition model.h:53
A class for implicitly fairing a surface mesh.
Definition surface_mesh_fairing.h:26
void minimize_curvature()
Minimize surface curvature.
Definition surface_mesh_fairing.h:49
void minimize_area()
Minimize surface area.
Definition surface_mesh_fairing.h:43
A halfedge data structure for polygonal meshes of 2-manifold topology.
Definition surface_mesh.h:51
The default viewer implementation for both OpenGL and Vulkan backends.
Definition viewer.h:143
Definition collider.cpp:182
- See also
- SurfaceMeshFairing, GaussianNoise, SurfaceMesh, Tutorial_802_Mesh_Smoothing, Tutorial_804_Mesh_HoleFilling